diff options
21 files changed, 71 insertions, 509 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index dabbabb1e6..b903f98761 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -76,7 +76,7 @@ module ActionDispatch end def stderr_logger - @stderr_logger ||= Logger.new($stderr) + @stderr_logger ||= ActiveSupport::Logger.new($stderr) end end end diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb index 6ded9dbfed..1cb803ffb9 100644 --- a/actionpack/lib/action_dispatch/middleware/params_parser.rb +++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb @@ -69,7 +69,7 @@ module ActionDispatch end def logger(env) - env['action_dispatch.logger'] || Logger.new($stderr) + env['action_dispatch.logger'] || ActiveSupport::Logger.new($stderr) end end end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f40d663ae8..a60da65ae5 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -81,10 +81,6 @@ class LegacyRouteSetTests < Test::Unit::TestCase @rs = ::ActionDispatch::Routing::RouteSet.new end - def teardown - @rs.clear! - end - def test_class_and_lambda_constraints subdomain = Class.new { def matches? request diff --git a/actionpack/test/dispatch/request_id_test.rb b/actionpack/test/dispatch/request_id_test.rb index e2a38af233..4b98cd32f2 100644 --- a/actionpack/test/dispatch/request_id_test.rb +++ b/actionpack/test/dispatch/request_id_test.rb @@ -14,7 +14,7 @@ class RequestIdTest < ActiveSupport::TestCase end test "generating a request id when none is supplied" do - assert_match /\w+-\w+-\w+-\w+-\w+/, stub_request.uuid + assert_match(/\w+-\w+-\w+-\w+-\w+/, stub_request.uuid) end private diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 650fa3fc42..131ef09f57 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -16,7 +16,6 @@ module ActiveRecord include TimeZoneConversion include Dirty include Serialization - include DeprecatedUnderscoreRead # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example, # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). diff --git a/activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb b/activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb deleted file mode 100644 index 0eb0db65b1..0000000000 --- a/activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'active_support/concern' -require 'active_support/deprecation' - -module ActiveRecord - module AttributeMethods - module DeprecatedUnderscoreRead - extend ActiveSupport::Concern - - included do - attribute_method_prefix "_" - end - - module ClassMethods - protected - - def define_method__attribute(attr_name) - # Do nothing, let it hit method missing instead. - end - end - - protected - - def _attribute(attr_name) - ActiveSupport::Deprecation.warn( - "You have called '_#{attr_name}'. This is deprecated. Please use " \ - "either '#{attr_name}' or read_attribute('#{attr_name}')." - ) - read_attribute(attr_name) - end - end - end -end diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index 5d37088d98..a7785f8786 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -80,10 +80,6 @@ module ActiveRecord end end - def original_primary_key #:nodoc: - deprecated_original_property_getter :primary_key - end - # Sets the name of the primary key column. # # class Project < ActiveRecord::Base @@ -103,11 +99,6 @@ module ActiveRecord @primary_key = value && value.to_s @quoted_primary_key = nil end - - def set_primary_key(value = nil, &block) #:nodoc: - deprecated_property_setter :primary_key, value, block - @quoted_primary_key = nil - end end end end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 698da34d26..401398c56b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -162,34 +162,6 @@ module ActiveRecord end end - def columns - with_connection do |c| - c.schema_cache.columns - end - end - deprecate :columns - - def columns_hash - with_connection do |c| - c.schema_cache.columns_hash - end - end - deprecate :columns_hash - - def primary_keys - with_connection do |c| - c.schema_cache.primary_keys - end - end - deprecate :primary_keys - - def clear_cache! - with_connection do |c| - c.schema_cache.clear! - end - end - deprecate :clear_cache! - # Return any checked-out connections back to the pool by threads that # are no longer alive. def clear_stale_cached_connections! diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index ce0a165660..7815889b47 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -144,26 +144,18 @@ module ActiveRecord lock_optimistically && columns_hash[locking_column] end + # Set the column to use for optimistic locking. Defaults to +lock_version+. def locking_column=(value) @original_locking_column = @locking_column if defined?(@locking_column) @locking_column = value.to_s end - # Set the column to use for optimistic locking. Defaults to +lock_version+. - def set_locking_column(value = nil, &block) - deprecated_property_setter :locking_column, value, block - end - # The version column used for optimistic locking. Defaults to +lock_version+. def locking_column reset_locking_column unless defined?(@locking_column) @locking_column end - def original_locking_column #:nodoc: - deprecated_original_property_getter :locking_column - end - # Quote the column name used for optimistic locking. def quoted_locking_column connection.quote_column_name(locking_column) diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 36417d89f7..1de820b3a6 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -105,10 +105,6 @@ module ActiveRecord @table_name end - def original_table_name #:nodoc: - deprecated_original_property_getter :table_name - end - # Sets the table name explicitly. Example: # # class Project < ActiveRecord::Base @@ -125,13 +121,6 @@ module ActiveRecord @relation = Relation.new(self, arel_table) end - def set_table_name(value = nil, &block) #:nodoc: - deprecated_property_setter :table_name, value, block - @quoted_table_name = nil - @arel_table = nil - @relation = Relation.new(self, arel_table) - end - # Returns a quoted version of the table name, used to construct SQL statements. def quoted_table_name @quoted_table_name ||= connection.quote_table_name(table_name) @@ -161,20 +150,12 @@ module ActiveRecord end end - def original_inheritance_column #:nodoc: - deprecated_original_property_getter :inheritance_column - end - # Sets the value of inheritance_column def inheritance_column=(value) @original_inheritance_column = inheritance_column @inheritance_column = value.to_s end - def set_inheritance_column(value = nil, &block) #:nodoc: - deprecated_property_setter :inheritance_column, value, block - end - def sequence_name if base_class == self @sequence_name ||= reset_sequence_name @@ -183,10 +164,6 @@ module ActiveRecord end end - def original_sequence_name #:nodoc: - deprecated_original_property_getter :sequence_name - end - def reset_sequence_name #:nodoc: self.sequence_name = connection.default_sequence_name(table_name, primary_key) end @@ -210,10 +187,6 @@ module ActiveRecord @sequence_name = value.to_s end - def set_sequence_name(value = nil, &block) #:nodoc: - deprecated_property_setter :sequence_name, value, block - end - # Indicates whether the table associated with this class exists def table_exists? connection.schema_cache.table_exists?(table_name) @@ -329,34 +302,6 @@ module ActiveRecord base.table_name end end - - def deprecated_property_setter(property, value, block) - if block - ActiveSupport::Deprecation.warn( - "Calling set_#{property} is deprecated. If you need to lazily evaluate " \ - "the #{property}, define your own `self.#{property}` class method. You can use `super` " \ - "to get the default #{property} where you would have called `original_#{property}`." - ) - - define_attr_method property, value, false, &block - else - ActiveSupport::Deprecation.warn( - "Calling set_#{property} is deprecated. Please use `self.#{property} = 'the_name'` instead." - ) - - define_attr_method property, value, false - end - end - - def deprecated_original_property_getter(property) - ActiveSupport::Deprecation.warn("original_#{property} is deprecated. Define self.#{property} and call super instead.") - - if !instance_variable_defined?("@original_#{property}") && respond_to?("reset_#{property}") - send("reset_#{property}") - else - instance_variable_get("@original_#{property}") - end - end end end end diff --git a/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/activerecord/test/cases/associations/eager_load_nested_include_test.rb index 2cf9f89c3c..1e1958410c 100644 --- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb @@ -6,7 +6,6 @@ require 'models/comment' require 'models/category' require 'models/categorization' require 'models/tagging' -require 'active_support/core_ext/array/random_access' module Remembered extend ActiveSupport::Concern diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 5e9f8028e9..8e509a9792 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -102,7 +102,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase def test_respond_to? topic = Topic.find(1) assert_respond_to topic, "title" - assert_respond_to topic, "_title" assert_respond_to topic, "title?" assert_respond_to topic, "title=" assert_respond_to topic, :title @@ -114,19 +113,12 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert !topic.respond_to?(:nothingness) end - def test_deprecated_underscore_method - topic = Topic.find(1) - assert_equal topic.title, assert_deprecated { topic._title } - end - def test_respond_to_with_custom_primary_key keyboard = Keyboard.create assert_not_nil keyboard.key_number assert_equal keyboard.key_number, keyboard.id assert keyboard.respond_to?('key_number') - assert keyboard.respond_to?('_key_number') assert keyboard.respond_to?('id') - assert keyboard.respond_to?('_id') end # Syck calls respond_to? before actually calling initialize diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 2e2ab77f6e..f102634ef1 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1383,17 +1383,6 @@ class BasicsTest < ActiveRecord::TestCase assert_equal dev, dev.reload end - def test_set_table_name_with_value - k = Class.new( ActiveRecord::Base ) - k.table_name = "foo" - assert_equal "foo", k.table_name - - assert_deprecated do - k.set_table_name "bar" - end - assert_equal "bar", k.table_name - end - def test_switching_between_table_name assert_difference("GoodJoke.count") do Joke.table_name = "cold_jokes" @@ -1416,17 +1405,6 @@ class BasicsTest < ActiveRecord::TestCase assert_equal klass.connection.quote_table_name("bar"), klass.quoted_table_name end - def test_set_table_name_with_block - k = Class.new( ActiveRecord::Base ) - assert_deprecated do - k.set_table_name "foo" - k.set_table_name do - ActiveSupport::Deprecation.silence { original_table_name } + "ks" - end - end - assert_equal "fooks", k.table_name - end - def test_set_table_name_with_inheritance k = Class.new( ActiveRecord::Base ) def k.name; "Foo"; end @@ -1434,145 +1412,6 @@ class BasicsTest < ActiveRecord::TestCase assert_equal "foosks", k.table_name end - def test_original_table_name - k = Class.new(ActiveRecord::Base) - def k.name; "Foo"; end - k.table_name = "bar" - - assert_deprecated do - assert_equal "foos", k.original_table_name - end - - k = Class.new(ActiveRecord::Base) - k.table_name = "omg" - k.table_name = "wtf" - - assert_deprecated do - assert_equal "omg", k.original_table_name - end - end - - def test_set_primary_key_with_value - k = Class.new( ActiveRecord::Base ) - k.primary_key = "foo" - assert_equal "foo", k.primary_key - - assert_deprecated do - k.set_primary_key "bar" - end - assert_equal "bar", k.primary_key - end - - def test_set_primary_key_with_block - k = Class.new( ActiveRecord::Base ) - k.primary_key = 'id' - - assert_deprecated do - k.set_primary_key do - "sys_" + ActiveSupport::Deprecation.silence { original_primary_key } - end - end - assert_equal "sys_id", k.primary_key - end - - def test_original_primary_key - k = Class.new(ActiveRecord::Base) - def k.name; "Foo"; end - k.table_name = "posts" - k.primary_key = "bar" - - assert_deprecated do - assert_equal "id", k.original_primary_key - end - - k = Class.new(ActiveRecord::Base) - k.primary_key = "omg" - k.primary_key = "wtf" - - assert_deprecated do - assert_equal "omg", k.original_primary_key - end - end - - def test_set_inheritance_column_with_value - k = Class.new( ActiveRecord::Base ) - k.inheritance_column = "foo" - assert_equal "foo", k.inheritance_column - - assert_deprecated do - k.set_inheritance_column "bar" - end - assert_equal "bar", k.inheritance_column - end - - def test_set_inheritance_column_with_block - k = Class.new( ActiveRecord::Base ) - assert_deprecated do - k.set_inheritance_column do - ActiveSupport::Deprecation.silence { original_inheritance_column } + "_id" - end - end - assert_equal "type_id", k.inheritance_column - end - - def test_original_inheritance_column - k = Class.new(ActiveRecord::Base) - def k.name; "Foo"; end - k.inheritance_column = "omg" - - assert_deprecated do - assert_equal "type", k.original_inheritance_column - end - end - - def test_set_sequence_name_with_value - k = Class.new( ActiveRecord::Base ) - k.sequence_name = "foo" - assert_equal "foo", k.sequence_name - - assert_deprecated do - k.set_sequence_name "bar" - end - assert_equal "bar", k.sequence_name - end - - def test_set_sequence_name_with_block - k = Class.new( ActiveRecord::Base ) - k.table_name = "projects" - orig_name = k.sequence_name - return skip "sequences not supported by db" unless orig_name - - assert_deprecated do - k.set_sequence_name do - ActiveSupport::Deprecation.silence { original_sequence_name } + "_lol" - end - end - assert_equal orig_name + "_lol", k.sequence_name - end - - def test_original_sequence_name - k = Class.new(ActiveRecord::Base) - k.table_name = "projects" - orig_name = k.sequence_name - return skip "sequences not supported by db" unless orig_name - - k = Class.new(ActiveRecord::Base) - k.table_name = "projects" - k.sequence_name = "omg" - - assert_deprecated do - assert_equal orig_name, k.original_sequence_name - end - - k = Class.new(ActiveRecord::Base) - k.table_name = "projects" - k.sequence_name = "omg" - k.sequence_name = "wtf" - assert_deprecated do - assert_equal "omg", k.original_sequence_name - end - end - def test_sequence_name_with_abstract_class ak = Class.new(ActiveRecord::Base) ak.abstract_class = true diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 5978b244d4..f7ee83998d 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -226,48 +226,6 @@ class OptimisticLockingTest < ActiveRecord::TestCase end end -class SetLockingColumnTest < ActiveRecord::TestCase - def test_set_set_locking_column_with_value - k = Class.new( ActiveRecord::Base ) - k.locking_column = "foo" - assert_equal "foo", k.locking_column - - assert_deprecated do - k.set_locking_column "bar" - end - assert_equal "bar", k.locking_column - end - - def test_set_locking_column_with_block - k = Class.new( ActiveRecord::Base ) - k.locking_column = 'foo' - - assert_deprecated do - k.set_locking_column do - "lock_" + ActiveSupport::Deprecation.silence { original_locking_column } - end - end - assert_equal "lock_foo", k.locking_column - end - - def test_original_locking_column - k = Class.new(ActiveRecord::Base) - k.locking_column = "bar" - - assert_deprecated do - assert_equal ActiveRecord::Locking::Optimistic::ClassMethods::DEFAULT_LOCKING_COLUMN, k.original_locking_column - end - - k = Class.new(ActiveRecord::Base) - k.locking_column = "omg" - k.locking_column = "wtf" - - assert_deprecated do - assert_equal "omg", k.original_locking_column - end - end -end - class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase fixtures :people, :legacy_things, :references diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 0eb3d900bd..e17ba76437 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -1,5 +1,4 @@ require "cases/helper" -require 'active_support/core_ext/array/random_access' require 'models/post' require 'models/topic' require 'models/comment' diff --git a/activerecord/test/support/connection.rb b/activerecord/test/support/connection.rb index a39794fa39..56369da346 100644 --- a/activerecord/test/support/connection.rb +++ b/activerecord/test/support/connection.rb @@ -1,4 +1,4 @@ -require 'logger' +require 'active_support/logger' require_dependency 'models/course' module ARTest @@ -12,7 +12,7 @@ module ARTest def self.connect puts "Using #{connection_name} with Identity Map #{ActiveRecord::IdentityMap.enabled? ? 'on' : 'off'}" - ActiveRecord::Base.logger = Logger.new("debug.log") + ActiveRecord::Base.logger = ActiveSupport::Logger.new("debug.log") ActiveRecord::Base.configurations = connection_config ActiveRecord::Base.establish_connection 'arunit' Course.establish_connection 'arunit2' diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index c6d861d124..6cb2ea68b3 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -6,33 +6,21 @@ class ERB HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' } JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' } - # Detect whether 1.9 can transcode with XML escaping. - if '"><&""' == ('><&"'.encode('utf-8', :xml => :attr) rescue false) - # A utility method for escaping HTML tag characters. - # This method is also aliased as <tt>h</tt>. - # - # In your ERB templates, use this method to escape any unsafe content. For example: - # <%=h @person.name %> - # - # ==== Example: - # puts html_escape("is a > 0 & a < 10?") - # # => is a > 0 & a < 10? - def html_escape(s) - s = s.to_s - if s.html_safe? - s - else - s.encode(s.encoding, :xml => :attr)[1...-1].html_safe - end - end - else - def html_escape(s) #:nodoc: - s = s.to_s - if s.html_safe? - s - else - s.gsub(/[&"><]/n) { |special| HTML_ESCAPE[special] }.html_safe - end + # A utility method for escaping HTML tag characters. + # This method is also aliased as <tt>h</tt>. + # + # In your ERB templates, use this method to escape any unsafe content. For example: + # <%=h @person.name %> + # + # ==== Example: + # puts html_escape("is a > 0 & a < 10?") + # # => is a > 0 & a < 10? + def html_escape(s) + s = s.to_s + if s.html_safe? + s + else + s.encode(s.encoding, :xml => :attr)[1...-1].html_safe end end diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index ee4565fdfe..25d8f50a7b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1838,43 +1838,6 @@ NOTE: Defined in +active_support/core_ext/string/inflections.rb+. h4(#string-conversions). Conversions -h5. +ord+ - -Ruby 1.9 defines +ord+ to be the codepoint of the first character of the receiver. Active Support backports +ord+ for single-byte encodings like ASCII or ISO-8859-1 in Ruby 1.8: - -<ruby> -"a".ord # => 97 -"à".ord # => 224, in ISO-8859-1 -</ruby> - -In Ruby 1.8 +ord+ doesn't work in general in UTF8 strings, use the multibyte support in Active Support for that: - -<ruby> -"a".mb_chars.ord # => 97 -"à".mb_chars.ord # => 224, in UTF8 -</ruby> - -Note that the 224 is different in both examples. In ISO-8859-1 "à" is represented as a single byte, 224. Its single-character representation in UTF8 has two bytes, namely 195 and 160, but its Unicode codepoint is 224. If we call +ord+ on the UTF8 string "à" the return value will be 195 in Ruby 1.8. That is not an error, because UTF8 is unsupported, the call itself would be bogus. - -INFO: +ord+ is equivalent to +getbyte(0)+. - -NOTE: Defined in +active_support/core_ext/string/conversions.rb+. - -h5. +getbyte+ - -Active Support backports +getbyte+ from Ruby 1.9: - -<ruby> -"foo".getbyte(0) # => 102, same as "foo".ord -"foo".getbyte(1) # => 111 -"foo".getbyte(9) # => nil -"foo".getbyte(-1) # => 111 -</ruby> - -INFO: +getbyte+ is equivalent to +[]+. - -NOTE: Defined in +active_support/core_ext/string/conversions.rb+. - h5. +to_date+, +to_time+, +to_datetime+ The methods +to_date+, +to_time+, and +to_datetime+ are basically convenience wrappers around +Date._parse+: @@ -1967,20 +1930,6 @@ h3. Extensions to +BigDecimal+ h3. Extensions to +Enumerable+ -h4. +group_by+ - -Active Support redefines +group_by+ in Ruby 1.8.7 so that it returns an ordered hash as in 1.9: - -<ruby> -entries_by_surname_initial = address_book.group_by do |entry| - entry.surname.at(0).upcase -end -</ruby> - -Distinct block return values are added to the hash as they come, so that's the resulting order. - -NOTE: Defined in +active_support/core_ext/enumerable.rb+. - h4. +sum+ The method +sum+ adds the elements of an enumerable: @@ -2109,20 +2058,6 @@ The methods +second+, +third+, +fourth+, and +fifth+ return the corresponding el NOTE: Defined in +active_support/core_ext/array/access.rb+. -h4. Random Access - -Active Support backports +sample+ from Ruby 1.9: - -<ruby> -shape_type = [Circle, Square, Triangle].sample -# => Square, for example - -shape_types = [Circle, Square, Triangle].sample(2) -# => [Triangle, Circle], for example -</ruby> - -NOTE: Defined in +active_support/core_ext/array/random_access.rb+. - h4. Adding Elements h5. +prepend+ @@ -2875,14 +2810,6 @@ WARNING: The original +Range#include?+ is still the one aliased to +Range#===+. NOTE: Defined in +active_support/core_ext/range/include_range.rb+. -h4. +cover?+ - -Ruby 1.9 provides +cover?+, and Active Support defines it for previous versions as an alias for +include?+. - -The method +include?+ in Ruby 1.9 is different from the one in 1.8 for non-numeric ranges: instead of being based on comparisons between the value and the range's endpoints, it walks the range with +succ+ looking for value. This works better for ranges with holes, but it has different complexity and may not finish in some other cases. - -In Ruby 1.9 the old behavior is still available in the new +cover?+, which Active Support backports for forward compatibility. For example, Rails uses +cover?+ for ranges in +validates_inclusion_of+. - h4. +overlaps?+ The method +Range#overlaps?+ says whether any two given ranges have non-void intersection: diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 58855bc80b..fa783edc58 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -381,16 +381,16 @@ h4. +about+ <shell> $ rake about About your application's environment -Ruby version 1.8.7 (x86_64-linux) +Ruby version 1.9.3 (x86_64-linux) RubyGems version 1.3.6 Rack version 1.3 -Rails version 3.2.0.beta +Rails version 4.0.0.beta JavaScript Runtime Node.js (V8) -Active Record version 3.2.0.beta -Action Pack version 3.2.0.beta -Active Resource version 3.2.0.beta -Action Mailer version 3.2.0.beta -Active Support version 3.2.0.beta +Active Record version 4.0.0.beta +Action Pack version 4.0.0.beta +Active Resource version 4.0.0.beta +Action Mailer version 4.0.0.beta +Active Support version 4.0.0.beta Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport Application root /home/foobar/commandsapp Environment development diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index f38a487a4e..af743a9c51 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -128,13 +128,13 @@ module Rails # # ==== Boolean hooks # - # In some cases, you want to provide a boolean hook. For example, webrat + # In some cases, you may want to provide a boolean hook. For example, webrat # developers might want to have webrat available on controller generator. # This can be achieved as: # # Rails::Generators::ControllerGenerator.hook_for :webrat, :type => :boolean # - # Then, if you want, webrat to be invoked, just supply: + # Then, if you want webrat to be invoked, just supply: # # rails generate controller Account --webrat # @@ -146,7 +146,7 @@ module Rails # # You can also supply a block to hook_for to customize how the hook is # going to be invoked. The block receives two arguments, an instance - # of the current class and the klass to be invoked. + # of the current class and the class to be invoked. # # For example, in the resource generator, the controller should be invoked # with a pluralized class name. But by default it is invoked with the same diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 52d92cdd96..62c8de8d22 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -1,32 +1,40 @@ require 'rbconfig' require 'rake/testtask' -# Monkey-patch to silence the description from Rake::TestTask to cut down on rake -T noise -class TestTaskWithoutDescription < Rake::TestTask - # Create the tasks defined by this task lib. - def define - lib_path = @libs.join(File::PATH_SEPARATOR) - task @name do - run_code = '' - RakeFileUtils.verbose(@verbose) do - run_code = - case @loader - when :direct - "-e 'ARGV.each{|f| load f}'" - when :testrb - "-S testrb #{fix}" - when :rake - rake_loader +module Rails + # Don't abort when tests fail; move on the next test task. + # Silence the default description to cut down on `rake -T` noise. + class SubTestTask < Rake::TestTask + # Create the tasks defined by this task lib. + def define + lib_path = @libs.join(File::PATH_SEPARATOR) + task @name do + run_code = '' + RakeFileUtils.verbose(@verbose) do + run_code = + case @loader + when :direct + "-e 'ARGV.each{|f| load f}'" + when :testrb + "-S testrb #{fix}" + when :rake + rake_loader + end + @ruby_opts.unshift( "-I\"#{lib_path}\"" ) + @ruby_opts.unshift( "-w" ) if @warning + + begin + ruby @ruby_opts.join(" ") + + " \"#{run_code}\" " + + file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + + " #{option_list}" + rescue => error + warn "Error running #{@name}: #{error.inspect}" end - @ruby_opts.unshift( "-I\"#{lib_path}\"" ) - @ruby_opts.unshift( "-w" ) if @warning - ruby @ruby_opts.join(" ") + - " \"#{run_code}\" " + - file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + - " #{option_list}" + end end + self end - self end end @@ -76,20 +84,7 @@ task :default => :test desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)' task :test do - tests_to_run = ENV['TEST'] ? ["test:single"] : %w(test:units test:functionals test:integration) - errors = tests_to_run.collect do |task| - begin - Rake::Task[task].invoke - nil - rescue => e - { :task => task, :exception => e } - end - end.compact - - if errors.any? - puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n") - abort - end + Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke end namespace :test do @@ -97,6 +92,8 @@ namespace :test do # Placeholder task for other Railtie and plugins to enhance. See Active Record for an example. end + task :run => %w(test:units test:functionals test:integration) + Rake::TestTask.new(:recent => "test:prepare") do |t| since = TEST_CHANGES_SINCE touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + @@ -134,33 +131,33 @@ namespace :test do t.libs << "test" end - TestTaskWithoutDescription.new(:units => "test:prepare") do |t| + Rails::SubTestTask.new(:units => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/unit/**/*_test.rb' end - TestTaskWithoutDescription.new(:functionals => "test:prepare") do |t| + Rails::SubTestTask.new(:functionals => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/functional/**/*_test.rb' end - TestTaskWithoutDescription.new(:integration => "test:prepare") do |t| + Rails::SubTestTask.new(:integration => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/integration/**/*_test.rb' end - TestTaskWithoutDescription.new(:benchmark => 'test:prepare') do |t| + Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.options = '-- --benchmark' end - TestTaskWithoutDescription.new(:profile => 'test:prepare') do |t| + Rails::SubTestTask.new(:profile => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' end - TestTaskWithoutDescription.new(:plugins => :environment) do |t| + Rails::SubTestTask.new(:plugins => :environment) do |t| t.libs << "test" if ENV['PLUGIN'] |