Commit f29f96b2 by Jon Yurek

Running Rails 4 specs and features

parent 3b40121b
...@@ -12,3 +12,8 @@ appraise "3.2" do ...@@ -12,3 +12,8 @@ appraise "3.2" do
gem "rails", "~> 3.2.6" gem "rails", "~> 3.2.6"
gem "paperclip", :path => "../" gem "paperclip", :path => "../"
end end
appraise "4.0" do
gem "rails", "~> 4.0.0"
gem "paperclip", :path => "../"
end
source "https://rubygems.org" source "https://rubygems.org"
gemspec gemspec
gem "jruby-openssl", :platform => :jruby
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
gem "sqlite3", :platform => :ruby
...@@ -7,6 +7,7 @@ Feature: Rails integration ...@@ -7,6 +7,7 @@ Feature: Rails integration
And I run a migration And I run a migration
And I update my new user view to include the file upload field And I update my new user view to include the file upload field
And I update my user view to include the attachment And I update my user view to include the attachment
And I allow the attachment to be submitted
Scenario: Configure defaults for all attachments through Railtie Scenario: Configure defaults for all attachments through Railtie
Given I add this snippet to config/application.rb: Given I add this snippet to config/application.rb:
......
...@@ -16,6 +16,7 @@ Given /^I generate a new rails application$/ do ...@@ -16,6 +16,7 @@ Given /^I generate a new rails application$/ do
gem "aws-sdk" gem "aws-sdk"
""" """
And I remove turbolinks if it exists And I remove turbolinks if it exists
And I empty the application.js file if it exists
And I configure the application to use "paperclip" from this project And I configure the application to use "paperclip" from this project
And I reset Bundler environment variable And I reset Bundler environment variable
And I successfully run `bundle install --local` And I successfully run `bundle install --local`
...@@ -30,23 +31,30 @@ Given "I fix the application.rb for 3.0.12" do ...@@ -30,23 +31,30 @@ Given "I fix the application.rb for 3.0.12" do
end end
end end
def transform_file(filename) Given "I allow the attachment to be submitted" do
content = File.read(filename) in_current_dir do
File.open(filename, "w") do |f| transform_file("app/controllers/users_controller.rb") do |content|
content = yield(content) content.gsub("params.require(:user).permit(:name)",
f.write(content) "params.require(:user).permit!")
end
end end
end end
Given "I remove turbolinks if it exists" do Given "I remove turbolinks if it exists" do
if framework_major_version >= 4 in_current_dir do
in_current_dir do transform_file("app/assets/javascripts/application.js") do |content|
transform_file("app/assets/javascripts/application.js") do |content| content.gsub("//= require turbolinks", "")
content.gsub("//= require turbolinks", "") end
end transform_file("app/views/layouts/application.html.erb") do |content|
transform_file("app/views/layouts/application.html.erb") do |content| content.gsub(', "data-turbolinks-track" => true', "")
content.gsub(', "data-turbolinks-track" => true', "") end
end end
end
Given "I empty the application.js file if it exists" do
in_current_dir do
transform_file("app/assets/javascripts/application.js") do |content|
""
end end
end end
end end
...@@ -132,11 +140,11 @@ end ...@@ -132,11 +140,11 @@ end
Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path| Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
expected = IO.read(path) expected = IO.read(path)
actual = if web_file.match %r{^https?://} actual = if web_file.match %r{^https?://}
Net::HTTP.get(URI.parse(web_file)) Net::HTTP.get(URI.parse(web_file))
else else
visit(web_file) visit(web_file)
page.source page.source
end end
actual.force_encoding("UTF-8") if actual.respond_to?(:force_encoding) actual.force_encoding("UTF-8") if actual.respond_to?(:force_encoding)
actual.should == expected actual.should == expected
end end
...@@ -167,3 +175,13 @@ Given /^I am using Rails newer than ([\d\.]+)$/ do |version| ...@@ -167,3 +175,13 @@ Given /^I am using Rails newer than ([\d\.]+)$/ do |version|
pending "Not supported in Rails < #{version}" pending "Not supported in Rails < #{version}"
end end
end end
def transform_file(filename)
if File.exists?(filename)
content = File.read(filename)
File.open(filename, "w") do |f|
content = yield(content)
f.write(content)
end
end
end
# This file was generated by Appraisal
source "https://rubygems.org"
gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem "sqlite3", :platform=>:ruby
gem "rails", "~> 4.0.0"
gem "paperclip", :path=>"../"
gemspec :path=>"../"
\ No newline at end of file
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