Cucumber – Carrierwave – ImageUploader – Variable class

Problem
You would like to test the carrierwave imageuploader with a cucumber test, but you would also like to use a generic step that can be used with different classes and different image file column names.

Solution
Use the following and perhaps put it a file named features/common_steps.rb

Then /^the url for the column "([^"]*)" of model "([^"]*)" should be "([^"]*)"$/ do |col,mdl,url|
  # First get tne class name from the mdl argument by using the Kernel.const_get method
  m = Kernel.const_get(mdl).first
  # And then use the send with the column name (col) to call the model's field,
  # the url method of ImageUploader to get the full path
  # and basename to get only the file name
  File.basename(m.send(col).url).should == url
end

Changing local timezone in Debian server

Problem

You have developed your application in your local environment or you use it in an environment that has your local timezone, but your live deployment server is in a hosted server that has a different timezone. So a lot of the SQL queries, are not working correctly.

 

Solution

Login as root in your server and run:

dpkg-reconfigure tzdata

and then reload your database server.