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 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) diff --git a/spec/support/rails_template.rb b/spec/support/rails_template.rb index 0ce46b60161..952bc783d4b 100644 --- a/spec/support/rails_template.rb +++ b/spec/support/rails_template.rb @@ -11,6 +11,8 @@ # 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" +# 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" 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"