Commit 948ddfa5 by Prem Sichanugrist

Make sure that we're copy the rake task to Rails' folder on Rails 2.3.x

parent cd856aa0
......@@ -5,6 +5,7 @@ Feature: Rake tasks
And I run a rails generator to generate a "User" scaffold with "name:string"
And I run a paperclip generator to add a paperclip "attachment" to the "User" model
And I run a migration
And I prepare my old Rails application for rake task
And I add this snippet to the User model:
"""
has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
......
......@@ -22,9 +22,7 @@ When /^I modify my attachment definition to:$/ do |definition|
end
When /^I upload the fixture "([^"]*)"$/ do |filename|
in_current_dir do
run_simple %(bundle exec rails runner "User.create!(:attachment => File.open('#{fixture_path(filename)}'))")
end
run_simple %(bundle exec #{runner_command} "User.create!(:attachment => File.open('#{fixture_path(filename)}'))")
end
Then /^the attachment "([^"]*)" should have a dimension of (\d+x\d+)$/ do |filename, dimension|
......@@ -51,14 +49,14 @@ end
Then /^the attachment should have the same content type as the fixture "([^"]*)"$/ do |filename|
in_current_dir do
require 'mime/types'
attachment_content_type = `bundle exec rails runner "puts User.last.attachment_content_type"`.strip
attachment_content_type = `bundle exec #{runner_command} "puts User.last.attachment_content_type"`.strip
attachment_content_type.should == MIME::Types.type_for(filename).first.content_type
end
end
Then /^the attachment should have the same file size as the fixture "([^"]*)"$/ do |filename|
in_current_dir do
attachment_file_size = `bundle exec rails runner "puts User.last.attachment_file_size"`.strip
attachment_file_size = `bundle exec #{runner_command} "puts User.last.attachment_file_size"`.strip
attachment_file_size.should == File.size(fixture_path(filename)).to_s
end
end
......
......@@ -113,6 +113,16 @@ Given /^I update my application to use Bundler$/ do
end
end
Given /^I prepare my old Rails application for rake task$/ do
if framework_version?("2.3")
require 'fileutils'
source = File.expand_path('lib/tasks/paperclip.rake')
destination = in_current_dir { File.expand_path("lib/tasks") }
FileUtils.cp source, destination
append_to "Rakefile", "require 'paperclip'"
end
end
Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
expected = IO.read(path)
actual = if web_file.match %r{^https?://}
......
......@@ -38,5 +38,9 @@ module RailsCommandHelpers
def generator_command
framework_version?("3") ? "script/rails generate" : "script/generate"
end
def runner_command
framework_version?("3") ? "script/rails runner" : "script/runner"
end
end
World(RailsCommandHelpers)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment