diff options
-rw-r--r-- | .travis.yml | 12 | ||||
-rw-r--r-- | Gemfile | 6 | ||||
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 12 | ||||
-rw-r--r-- | activesupport/CHANGELOG | 3 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/blank.rb | 8 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 2 | ||||
-rwxr-xr-x | ci/travis.rb | 142 | ||||
-rw-r--r-- | load_paths.rb | 8 | ||||
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 4 |
12 files changed, 190 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..d33c6a3c86 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +script: 'ci/travis.rb' +notifications: + disabled: true +rvm: + - 1.8.7 + - 1.9.2 +env: + - "GEM=railties" + - "GEM=ap,am,amo,ares,as" + - "GEM=ar:mysql" + - "GEM=ar:mysql2" + - "GEM=ar:sqlite3"
\ No newline at end of file @@ -31,13 +31,13 @@ gem "memcache-client", ">= 1.8.5" platforms :mri_18 do gem "system_timer" - gem "ruby-debug", ">= 0.10.3" + gem "ruby-debug", ">= 0.10.3" unless ENV['TRAVIS'] gem "json" end platforms :mri_19 do # TODO: Remove the conditional when ruby-debug19 supports Ruby >= 1.9.3 - gem "ruby-debug19", :require => "ruby-debug" if RUBY_VERSION < "1.9.3" + gem "ruby-debug19", :require => "ruby-debug" unless RUBY_VERSION > "1.9.2" || ENV['TRAVIS'] end platforms :ruby do @@ -56,7 +56,7 @@ platforms :ruby do gem "sqlite3", "~> 1.3.3" group :db do - gem "pg", ">= 0.11.0" + gem "pg", ">= 0.11.0" unless ENV['TRAVIS'] # once pg is on travis this can be removed gem "mysql", ">= 2.8.1" gem "mysql2", ">= 0.3.6" end diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9d320ddb8d..9888be07a9 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -30,6 +30,8 @@ *Rails 3.1.0 (unreleased)* +* The submit form helper does not generate an id "object_name_id" anymore. [fbrusatti] + * Make sure respond_with with :js tries to render a template in all cases [José Valim] * json_escape will now return a SafeBuffer string if it receives SafeBuffer string [tenderlove] diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index c459846264..507f345ef5 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/module/delegation" +require "active_support/core_ext/class/attribute_accessors" require "active_support/core_ext/array/wrap" module ActiveRecord diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 283115a448..8cef4e5554 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -243,7 +243,7 @@ module ActiveRecord end def construct_limited_ids_condition(relation) - orders = relation.order_values + orders = relation.order_values.map { |val| val.presence }.compact values = @klass.connection.distinct("#{@klass.connection.quote_table_name table_name}.#{primary_key}", orders) relation = relation.dup diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index f1d061133c..c6e451fc57 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1048,4 +1048,16 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_not_equal 0, post.comments.to_a.count end end + + def test_join_eager_with_empty_order_should_generate_valid_sql + assert_nothing_raised(ActiveRecord::StatementInvalid) do + Post.includes(:comments).order("").where(:comments => {:body => "Thank you for the welcome"}).first + end + end + + def test_join_eager_with_nil_order_should_generate_valid_sql + assert_nothing_raised(ActiveRecord::StatementInvalid) do + Post.includes(:comments).order(nil).where(:comments => {:body => "Thank you for the welcome"}).first + end + end end diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 034d03533f..a25720adbf 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,8 @@ *Rails 3.2.0 (unreleased)* +* The definition of blank string for Ruby 1.9 has been extended to Unicode whitespace. +Also, in 1.8 the ideographic space U+3000 is considered to be whitespace. [Akira Matsuda, Damien Mathieu] + * The inflector understands acronyms. [dlee] * Deprecated ActiveSupport::Memoizable in favor of Ruby memoization pattern [José Valim] diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index d060ac04d8..fe27f45295 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +require 'active_support/core_ext/string/encoding' class Object # An object is blank if it's false, empty, or a whitespace string. @@ -99,7 +100,12 @@ class String # " something here ".blank? # => false # def blank? - self !~ NON_WHITESPACE_REGEXP + # 1.8 does not takes [:space:] properly + if encoding_aware? + self !~ /[^[:space:]]/ + else + self !~ NON_WHITESPACE_REGEXP + end end end diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 4000cc913a..18a86e08f5 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -158,7 +158,7 @@ class StringInflectionsTest < Test::Unit::TestCase assert_equal Time.local(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time(:local) assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local) - assert_equal Time.utc(2039, 2, 27, 23, 50), "2039-02-27 22:50 -0100".to_time + assert_equal Time.utc(2011, 2, 27, 23, 50), "2011-02-27 22:50 -0100".to_time assert_nil "".to_time end diff --git a/ci/travis.rb b/ci/travis.rb new file mode 100755 index 0000000000..8087c72f90 --- /dev/null +++ b/ci/travis.rb @@ -0,0 +1,142 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +commands = [ + 'mysql -e "create database activerecord_unittest;"', + 'mysql -e "create database activerecord_unittest2;"', + 'psql -c "create database activerecord_unittest;" -U postgres', + 'psql -c "create database activerecord_unittest2;" -U postgres' +] + +commands.each do |command| + system("#{command} > /dev/null 2>&1") +end + +class Build + MAP = { + 'railties' => 'railties', + 'ap' => 'actionpack', + 'am' => 'actionmailer', + 'amo' => 'activemodel', + 'ares' => 'activeresource', + 'as' => 'activesupport', + 'ar' => 'activerecord' + } + + attr_reader :component, :options + + def initialize(component, options = {}) + @component = component + @options = options + end + + def run!(options = {}) + self.options.update(options) + Dir.chdir(dir) do + announce(heading) + ENV['IM'] = identity_map?.inspect + rake(*tasks) + end + end + + def announce(heading) + puts "\n\e[1;33m[Travis CI] #{heading}\e[m\n" + end + + def heading + heading = [gem] + heading << "with #{adapter} IM #{identity_map? ? 'enabled' : 'disabled'}" if activerecord? + heading << "in isolation" if isolated? + heading.join(' ') + end + + def tasks + if activerecord? + ['mysql:rebuild_databases', "#{adapter}:#{'isolated_' if isolated?}test"] + else + ["test#{':isolated' if isolated?}"] + end + end + + def key + key = [gem] + key << adapter if activerecord? + key << 'IM' if identity_map? + key << 'isolated' if isolated? + key.join(':') + end + + def activerecord? + gem == 'activerecord' + end + + def identity_map? + options[:identity_map] + end + + def isolated? + options[:isolated] + end + + def gem + MAP[component.split(':').first] + end + alias :dir :gem + + def adapter + component.split(':').last + end + + def rake(*tasks) + tasks.each do |task| + cmd = "bundle exec rake #{task}" + puts "Running command: #{cmd}" + return false unless system(cmd) + end + true + end +end + +results = {} + +ENV['GEM'].split(',').each do |gem| + [false, true].each do |isolated| + next if gem == 'railties' && isolated + + build = Build.new(gem, :isolated => isolated) + results[build.key] = build.run! + + if build.activerecord? + build.options[:identity_map] = true + results[build.key] = build.run! + end + end +end + +# puts +# puts "Build environment:" +# puts " #{`cat /etc/issue`}" +# puts " #{`uname -a`}" +# puts " #{`ruby -v`}" +# puts " #{`mysql --version`}" +# # puts " #{`pg_config --version`}" +# puts " SQLite3: #{`sqlite3 -version`}" +# `gem env`.each_line {|line| print " #{line}"} +# puts " Bundled gems:" +# `bundle show`.each_line {|line| print " #{line}"} +# puts " Local gems:" +# `gem list`.each_line {|line| print " #{line}"} + +failures = results.select { |key, value| value == false } + +if failures.empty? + puts + puts "Rails build finished sucessfully" + exit(true) +else + puts + puts "Rails build FAILED" + puts "Failed components: #{failures.map { |component| component.first }.join(', ')}" + exit(false) +end diff --git a/load_paths.rb b/load_paths.rb index 590af69330..17f5ce180d 100644 --- a/load_paths.rb +++ b/load_paths.rb @@ -1,8 +1,4 @@ # bust gem prelude -if defined? Gem - gem 'bundler' -else - require 'rubygems' -end +require 'rubygems' unless defined? Gem require 'bundler' -Bundler.setup +Bundler.setup
\ No newline at end of file diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index a0ed85cf01..b35e04d7e1 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -78,12 +78,14 @@ The following values are considered to be blank in a Rails application: * +nil+ and +false+, -* strings composed only of whitespace, i.e. matching +/\A\s*\z/+, +* strings composed only of whitespace (see note below), * empty arrays and hashes, and * any other object that responds to +empty?+ and it is empty. +INFO: In Ruby 1.9 the predicate for strings uses the Unicode-aware character class <tt>[:space:]</tt>, so for example U+2029 (paragraph separator) is considered to be whitespace. In Ruby 1.8 whitespace is considered to be <tt>\s</tt> together with the ideographic space U+3000. + WARNING: Note that numbers are not mentioned, in particular 0 and 0.0 are *not* blank. For example, this method from +ActionDispatch::Session::AbstractStore+ uses +blank?+ for checking whether a session key is present: |