Commit 62c81300 by Tute Costa Committed by GitHub

Merge pull request #2331 from thoughtbot/tc-fix-ci

Fix Travis CI
parents 0188bbf6 3a359f61
...@@ -4,6 +4,10 @@ rvm: ...@@ -4,6 +4,10 @@ rvm:
script: "bundle exec rake clean spec cucumber" script: "bundle exec rake clean spec cucumber"
before_install:
- rvm @global do gem uninstall bundler -a -x
- rvm @global do gem install bundler -v 1.12.5
gemfile: gemfile:
- gemfiles/4.2.gemfile - gemfiles/4.2.gemfile
- gemfiles/5.0.gemfile - gemfiles/5.0.gemfile
......
...@@ -23,7 +23,7 @@ When /^I modify my attachment definition to:$/ do |definition| ...@@ -23,7 +23,7 @@ When /^I modify my attachment definition to:$/ do |definition|
end end
When /^I upload the fixture "([^"]*)"$/ do |filename| When /^I upload the fixture "([^"]*)"$/ do |filename|
run_simple %(bundle exec #{runner_command} "User.create!(:attachment => File.open('#{fixture_path(filename)}'))") run_simple %(bundle exec rails runner "User.create!(:attachment => File.open('#{fixture_path(filename)}'))")
end end
Then /^the attachment "([^"]*)" should have a dimension of (\d+x\d+)$/ do |filename, dimension| Then /^the attachment "([^"]*)" should have a dimension of (\d+x\d+)$/ do |filename, dimension|
...@@ -56,7 +56,7 @@ Then /^the attachment should have the same content type as the fixture "([^"]*)" ...@@ -56,7 +56,7 @@ Then /^the attachment should have the same content type as the fixture "([^"]*)"
require "mime/types" require "mime/types"
end end
attachment_content_type = `bundle exec #{runner_command} "puts User.last.attachment_content_type"`.strip attachment_content_type = `bundle exec rails runner "puts User.last.attachment_content_type"`.strip
expected = MIME::Types.type_for(filename).first.content_type expected = MIME::Types.type_for(filename).first.content_type
expect(attachment_content_type).to eq(expected) expect(attachment_content_type).to eq(expected)
end end
...@@ -64,14 +64,14 @@ end ...@@ -64,14 +64,14 @@ end
Then /^the attachment should have the same file name as the fixture "([^"]*)"$/ do |filename| Then /^the attachment should have the same file name as the fixture "([^"]*)"$/ do |filename|
cd(".") do cd(".") do
attachment_file_name = `bundle exec #{runner_command} "puts User.last.attachment_file_name"`.strip attachment_file_name = `bundle exec rails runner "puts User.last.attachment_file_name"`.strip
expect(attachment_file_name).to eq(File.name(fixture_path(filename)).to_s) expect(attachment_file_name).to eq(File.name(fixture_path(filename)).to_s)
end end
end end
Then /^the attachment should have the same file size as the fixture "([^"]*)"$/ do |filename| Then /^the attachment should have the same file size as the fixture "([^"]*)"$/ do |filename|
cd(".") do cd(".") do
attachment_file_size = `bundle exec #{runner_command} "puts User.last.attachment_file_size"`.strip attachment_file_size = `bundle exec rails runner "puts User.last.attachment_file_size"`.strip
expect(attachment_file_size).to eq(File.size(fixture_path(filename)).to_s) expect(attachment_file_size).to eq(File.size(fixture_path(filename)).to_s)
end end
end end
...@@ -84,7 +84,7 @@ end ...@@ -84,7 +84,7 @@ end
Then /^I should have attachment columns for "([^"]*)"$/ do |attachment_name| Then /^I should have attachment columns for "([^"]*)"$/ do |attachment_name|
cd(".") do cd(".") do
columns = eval(`bundle exec #{runner_command} "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip) columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip)
expect_columns = [ expect_columns = [
["#{attachment_name}_file_name", :string], ["#{attachment_name}_file_name", :string],
["#{attachment_name}_content_type", :string], ["#{attachment_name}_content_type", :string],
...@@ -97,7 +97,7 @@ end ...@@ -97,7 +97,7 @@ end
Then /^I should not have attachment columns for "([^"]*)"$/ do |attachment_name| Then /^I should not have attachment columns for "([^"]*)"$/ do |attachment_name|
cd(".") do cd(".") do
columns = eval(`bundle exec #{runner_command} "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip) columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip)
expect_columns = [ expect_columns = [
["#{attachment_name}_file_name", :string], ["#{attachment_name}_file_name", :string],
["#{attachment_name}_content_type", :string], ["#{attachment_name}_content_type", :string],
......
Given /^I generate a new rails application$/ do Given /^I generate a new rails application$/ do
steps %{ steps %{
When I run `bundle exec #{new_application_command} #{APP_NAME} --skip-bundle` When I run `rails new #{APP_NAME} --skip-bundle`
And I cd to "#{APP_NAME}" And I cd to "#{APP_NAME}"
}
FileUtils.chdir("tmp/aruba/testapp/")
steps %{
And I turn off class caching And I turn off class caching
And I fix the application.rb for 3.0.12 And I fix the application.rb for 3.0.12
And I write to "Gemfile" with: And I write to "Gemfile" with:
...@@ -21,6 +26,8 @@ Given /^I generate a new rails application$/ do ...@@ -21,6 +26,8 @@ Given /^I generate a new rails application$/ do
And I empty the application.js file And I empty the application.js file
And I configure the application to use "paperclip" from this project And I configure the application to use "paperclip" from this project
} }
FileUtils.chdir("../../..")
end end
Given "I fix the application.rb for 3.0.12" do Given "I fix the application.rb for 3.0.12" do
...@@ -60,11 +67,7 @@ Given /^I attach :attachment with:$/ do |definition| ...@@ -60,11 +67,7 @@ Given /^I attach :attachment with:$/ do |definition|
end end
def attach_attachment(name, definition = nil) def attach_attachment(name, definition = nil)
snippet = "" snippet = "has_attached_file :#{name}"
if using_protected_attributes?
snippet += "attr_accessible :name, :#{name}\n"
end
snippet += "has_attached_file :#{name}"
if definition if definition
snippet += ", \n" snippet += ", \n"
snippet += definition snippet += definition
...@@ -86,19 +89,19 @@ Given "I empty the application.js file" do ...@@ -86,19 +89,19 @@ Given "I empty the application.js file" do
end end
Given /^I run a rails generator to generate a "([^"]*)" scaffold with "([^"]*)"$/ do |model_name, attributes| Given /^I run a rails generator to generate a "([^"]*)" scaffold with "([^"]*)"$/ do |model_name, attributes|
step %[I successfully run `bundle exec #{generator_command} scaffold #{model_name} #{attributes}`] step %[I successfully run `rails generate scaffold #{model_name} #{attributes}`]
end end
Given /^I run a paperclip generator to add a paperclip "([^"]*)" to the "([^"]*)" model$/ do |attachment_name, model_name| Given /^I run a paperclip generator to add a paperclip "([^"]*)" to the "([^"]*)" model$/ do |attachment_name, model_name|
step %[I successfully run `bundle exec #{generator_command} paperclip #{model_name} #{attachment_name}`] step %[I successfully run `rails generate paperclip #{model_name} #{attachment_name}`]
end end
Given /^I run a migration$/ do Given /^I run a migration$/ do
step %[I successfully run `bundle exec rake db:migrate --trace`] step %[I successfully run `rake db:migrate --trace`]
end end
When /^I rollback a migration$/ do When /^I rollback a migration$/ do
step %[I successfully run `bundle exec rake db:rollback STEPS=1 --trace`] step %[I successfully run `rake db:rollback STEPS=1 --trace`]
end end
Given /^I update my new user view to include the file upload field$/ do Given /^I update my new user view to include the file upload field$/ do
......
...@@ -17,7 +17,7 @@ module NavigationHelpers ...@@ -17,7 +17,7 @@ module NavigationHelpers
page_name =~ /the (.*) page/ page_name =~ /the (.*) page/
path_components = $1.split(/\s+/) path_components = $1.split(/\s+/)
self.send(path_components.push('path').join('_').to_sym) self.send(path_components.push('path').join('_').to_sym)
rescue Object => e rescue Object
raise "Can't find mapping from \"#{page_name}\" to a path.\n" + raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
"Now, go and add a mapping in #{__FILE__}" "Now, go and add a mapping in #{__FILE__}"
end end
......
...@@ -35,29 +35,5 @@ module RailsCommandHelpers ...@@ -35,29 +35,5 @@ module RailsCommandHelpers
def framework_major_version def framework_major_version
framework_version.split(".").first.to_i framework_version.split(".").first.to_i
end end
def using_protected_attributes?
framework_major_version < 4
end
def new_application_command
"rails new"
end
def generator_command
if framework_major_version >= 4
"rails generate"
else
"script/rails generate"
end
end
def runner_command
if framework_major_version >= 4
"rails runner"
else
"script/rails runner"
end
end
end end
World(RailsCommandHelpers) World(RailsCommandHelpers)
...@@ -37,7 +37,7 @@ Gem::Specification.new do |s| ...@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('mocha') s.add_development_dependency('mocha')
s.add_development_dependency('aws-sdk', '>= 2.3.0', '< 3.0') s.add_development_dependency('aws-sdk', '>= 2.3.0', '< 3.0')
s.add_development_dependency('bourne') s.add_development_dependency('bourne')
s.add_development_dependency('cucumber', '~> 1.3.18') s.add_development_dependency('cucumber-rails')
s.add_development_dependency('aruba', '~> 0.9.0') s.add_development_dependency('aruba', '~> 0.9.0')
s.add_development_dependency('nokogiri') s.add_development_dependency('nokogiri')
s.add_development_dependency('capybara') s.add_development_dependency('capybara')
...@@ -48,7 +48,6 @@ Gem::Specification.new do |s| ...@@ -48,7 +48,6 @@ Gem::Specification.new do |s|
s.add_development_dependency('rake') s.add_development_dependency('rake')
s.add_development_dependency('fakeweb') s.add_development_dependency('fakeweb')
s.add_development_dependency('railties') s.add_development_dependency('railties')
s.add_development_dependency('actionmailer', '>= 4.2.0')
s.add_development_dependency('generator_spec') s.add_development_dependency('generator_spec')
s.add_development_dependency('timecop') s.add_development_dependency('timecop')
end end
...@@ -22,7 +22,8 @@ FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures") ...@@ -22,7 +22,8 @@ FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
ActiveRecord::Base.establish_connection(config['test']) ActiveRecord::Base.establish_connection(config['test'])
unless ActiveRecord::VERSION::STRING < "4.2" if ActiveRecord::VERSION::STRING >= "4.2" &&
ActiveRecord::VERSION::STRING < "5.0"
ActiveRecord::Base.raise_in_transactional_callbacks = true ActiveRecord::Base.raise_in_transactional_callbacks = true
end end
Paperclip.options[:logger] = ActiveRecord::Base.logger Paperclip.options[:logger] = ActiveRecord::Base.logger
......
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