From 46420a0d95387614bac239435959e440251a8e34 Mon Sep 17 00:00:00 2001 From: Philippe Creux Date: Thu, 3 May 2012 11:34:07 +0200 Subject: [PATCH 1/5] Update rails versions --- tasks/test.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/test.rake b/tasks/test.rake index 96d16845cd2..ff30d775952 100644 --- a/tasks/test.rake +++ b/tasks/test.rake @@ -29,7 +29,7 @@ namespace :test do desc "Run the full suite against the important versions of rails" task :major_supported_rails do - run_tests_against "3.0.11", "3.1.3", "3.2.0" + run_tests_against "3.0.12", "3.1.4", "3.2.3" end desc "Alias for major_supported_rails" From ea00502cc4846fe03e64081b805efdfc4e2a63f2 Mon Sep 17 00:00:00 2001 From: Philippe Creux Date: Thu, 3 May 2012 11:34:16 +0200 Subject: [PATCH 2/5] Travis tests against rails 3.0, 3.1, and 3.2 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4b2080a1e37..6edc2c533a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,11 @@ script: bundle exec rake rvm: - ree - 1.9.2 + - 1.9.3 before_install: - gem update --system - gem --version +env: + - RAILS=3.0.12 + - RAILS=3.1.4 + - RAILS=3.2.3 From 6c57947d21c05593bf9646b5357d91f0e8ec5bc5 Mon Sep 17 00:00:00 2001 From: Philippe Creux Date: Thu, 3 May 2012 11:56:20 +0200 Subject: [PATCH 3/5] Detect rails version takes into account RAILS env var --- spec/support/detect_rails_version.rb | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/spec/support/detect_rails_version.rb b/spec/support/detect_rails_version.rb index 5e894b95c9f..6146bb3129f 100644 --- a/spec/support/detect_rails_version.rb +++ b/spec/support/detect_rails_version.rb @@ -1,8 +1,6 @@ # Detects the current version of Rails that is being used # -# You can pass it in as an ENV variable or it will use -# the current Gemfile.lock to find it - +# unless defined?(RAILS_VERSION_FILE) RAILS_VERSION_FILE = File.expand_path("../../../.rails-version", __FILE__) end @@ -12,16 +10,24 @@ end def detect_rails_version - detected_version = if File.exists?(RAILS_VERSION_FILE) + version = version_from_file || version_from_env || DEFAULT_RAILS_VERSION + + puts "Detected Rails: #{version}" if ENV['DEBUG'] + + version +end + +def version_from_file + if File.exists?(RAILS_VERSION_FILE) version = File.read(RAILS_VERSION_FILE).chomp.strip - version != "" ? version : DEFAULT_RAILS_VERSION - else - DEFAULT_RAILS_VERSION - end + version = nil if version == "" - puts "Detected Rails: #{detected_version}" if ENV['DEBUG'] + version + end +end - detected_version +def version_from_env + ENV['RAILS'] end def write_rails_version(version) From e7274bc14572e6cff90da4937b17fae6d10eb412 Mon Sep 17 00:00:00 2001 From: Philippe Creux Date: Thu, 3 May 2012 15:23:44 +0200 Subject: [PATCH 4/5] Add attr_accessible :author for Rails 3.2.3 compatibility --- spec/support/rails_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index 0ce46b60161..9d7dec9d625 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -10,7 +10,7 @@ # Generate some test models generate :model, "post title:string body:text published_at:datetime author_id:integer category_id:integer" -inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n", :after => "class Post < ActiveRecord::Base\n" +inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n attr_accessible :author\n", :after => "class Post < ActiveRecord::Base\n" generate :model, "user type:string first_name:string last_name:string username:string age:integer" inject_into_file 'app/models/user.rb', " has_many :posts, :foreign_key => 'author_id'\n", :after => "class User < ActiveRecord::Base\n" generate :model, "publisher --migration=false --parent=User" From 05c2c4d26a4907c185178c34b2dbac5dd4b9287d Mon Sep 17 00:00:00 2001 From: Philippe Creux Date: Thu, 3 May 2012 15:46:22 +0200 Subject: [PATCH 5/5] Only add attr_accessible when using Rails >= 3.2.3 --- spec/support/rails_template.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index 9d7dec9d625..952bc783d4b 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -10,7 +10,9 @@ # Generate some test models generate :model, "post title:string body:text published_at:datetime author_id:integer category_id:integer" -inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n attr_accessible :author\n", :after => "class Post < ActiveRecord::Base\n" +inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n", :after => "class Post < ActiveRecord::Base\n" +# Rails 3.2.3 model generator declare attr_accessible +inject_into_file 'app/models/post.rb', " attr_accessible :author\n", :before => "end" if Rails::VERSION::STRING >= '3.2.3' generate :model, "user type:string first_name:string last_name:string username:string age:integer" inject_into_file 'app/models/user.rb', " has_many :posts, :foreign_key => 'author_id'\n", :after => "class User < ActiveRecord::Base\n" generate :model, "publisher --migration=false --parent=User"