Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 948ddfa555cca195ad22fbe505a39765192fc63e 1 parent cd856aa
@sikachu sikachu authored
View
1  features/rake_tasks.feature
@@ -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"
View
8 features/step_definitions/attachment_steps.rb
@@ -22,9 +22,7 @@ class User < ActiveRecord::Base
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 @@ class User < ActiveRecord::Base
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
View
10 features/step_definitions/rails_steps.rb
@@ -113,6 +113,16 @@
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?://}
View
4 features/support/rails.rb
@@ -38,5 +38,9 @@ def new_application_command
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)
Please sign in to comment.
Something went wrong with that request. Please try again.