Remove deprecated functionality from edge rails. Closes #9387 [lifofifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7402 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
f0dbd22c46
commit
6246fad19a
@ -6,7 +6,6 @@
|
||||
require 'active_record/associations/has_many_association'
|
||||
require 'active_record/associations/has_many_through_association'
|
||||
require 'active_record/associations/has_and_belongs_to_many_association'
|
||||
require 'active_record/deprecated_associations'
|
||||
|
||||
module ActiveRecord
|
||||
class HasManyThroughAssociationNotFoundError < ActiveRecordError #:nodoc:
|
||||
@ -625,13 +624,7 @@ module ClassMethods
|
||||
# alongside this object by calling their destroy method. If set to <tt>:delete_all</tt> all associated
|
||||
# objects are deleted *without* calling their destroy method. If set to <tt>:nullify</tt> all associated
|
||||
# objects' foreign keys are set to +NULL+ *without* calling their save callbacks.
|
||||
# NOTE: <tt>:dependent => true</tt> is deprecated and has been replaced with <tt>:dependent => :destroy</tt>.
|
||||
# May not be set if <tt>:exclusively_dependent</tt> is also set.
|
||||
# * <tt>:exclusively_dependent</tt> - Deprecated; equivalent to <tt>:dependent => :delete_all</tt>. If set to +true+ all
|
||||
# the associated objects are deleted in one SQL statement without having their
|
||||
# +before_destroy+ callback run. This should only be used on associations that depend solely on this class and don't need to do any
|
||||
# clean-up in +before_destroy+. The upside is that it's much faster, especially if there's a +counter_cache+ involved.
|
||||
# May not be set if <tt>:dependent</tt> is also set.
|
||||
# * <tt>:finder_sql</tt> - specify a complete SQL statement to fetch the association. This is a good way to go for complex
|
||||
# associations that depend on multiple tables. Note: When this option is used, +find_in_collection+ is _not_ added.
|
||||
# * <tt>:counter_sql</tt> - specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is
|
||||
@ -680,8 +673,6 @@ def has_many(association_id, options = {}, &extension)
|
||||
add_association_callbacks(reflection.name, reflection.options)
|
||||
collection_accessor_methods(reflection, HasManyAssociation)
|
||||
end
|
||||
|
||||
add_deprecated_api_for_has_many(reflection.name)
|
||||
end
|
||||
|
||||
# Adds the following methods for retrieval and query of a single associated object:
|
||||
@ -747,10 +738,6 @@ def has_one(association_id, options = {})
|
||||
association_constructor_method(:create, reflection, HasOneAssociation)
|
||||
|
||||
configure_dependency_for_has_one(reflection)
|
||||
|
||||
# deprecated api
|
||||
deprecated_has_association_method(reflection.name)
|
||||
deprecated_association_comparison_method(reflection.name, reflection.class_name)
|
||||
end
|
||||
|
||||
# Adds the following methods for retrieval and query for a single associated object for which this object holds an id:
|
||||
@ -838,10 +825,6 @@ def belongs_to(association_id, options = {})
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
# deprecated api
|
||||
deprecated_has_association_method(reflection.name)
|
||||
deprecated_association_comparison_method(reflection.name, reflection.class_name)
|
||||
end
|
||||
|
||||
# Create the callbacks to update counter cache
|
||||
@ -884,10 +867,6 @@ def belongs_to(association_id, options = {})
|
||||
# An empty array is returned if none are found.
|
||||
# * <tt>collection<<(object, ...)</tt> - adds one or more objects to the collection by creating associations in the join table
|
||||
# (<tt>collection.push</tt> and <tt>collection.concat</tt> are aliases to this method).
|
||||
# * <tt>collection.push_with_attributes(object, join_attributes)</tt> - adds one to the collection by creating an association in the join table that
|
||||
# also holds the attributes from <tt>join_attributes</tt> (should be a hash with the column names as keys). This can be used to have additional
|
||||
# attributes on the join, which will be injected into the associated objects when they are retrieved through the collection.
|
||||
# (<tt>collection.concat_with_attributes</tt> is an alias to this method). This method is now deprecated.
|
||||
# * <tt>collection.delete(object, ...)</tt> - removes one or more objects from the collection by removing their associations from the join table.
|
||||
# This does not destroy the objects.
|
||||
# * <tt>collection=objects</tt> - replaces the collection's content by deleting and adding objects as appropriate.
|
||||
@ -973,12 +952,6 @@ def destroy_without_callbacks
|
||||
end_eval
|
||||
|
||||
add_association_callbacks(reflection.name, options)
|
||||
|
||||
# deprecated api
|
||||
deprecated_collection_count_method(reflection.name)
|
||||
deprecated_add_association_relation(reflection.name)
|
||||
deprecated_remove_association_relation(reflection.name)
|
||||
deprecated_has_collection_method(reflection.name)
|
||||
end
|
||||
|
||||
private
|
||||
@ -1141,19 +1114,6 @@ def find_with_associations(options = {})
|
||||
end
|
||||
|
||||
def configure_dependency_for_has_many(reflection)
|
||||
if reflection.options[:dependent] == true
|
||||
::ActiveSupport::Deprecation.warn("The :dependent => true option is deprecated and will be removed from Rails 2.0. Please use :dependent => :destroy instead. See http://www.rubyonrails.org/deprecation for details.", caller)
|
||||
end
|
||||
|
||||
if reflection.options[:dependent] && reflection.options[:exclusively_dependent]
|
||||
raise ArgumentError, ':dependent and :exclusively_dependent are mutually exclusive options. You may specify one or the other.'
|
||||
end
|
||||
|
||||
if reflection.options[:exclusively_dependent]
|
||||
reflection.options[:dependent] = :delete_all
|
||||
::ActiveSupport::Deprecation.warn("The :exclusively_dependent option is deprecated and will be removed from Rails 2.0. Please use :dependent => :delete_all instead. See http://www.rubyonrails.org/deprecation for details.", caller)
|
||||
end
|
||||
|
||||
# See HasManyAssociation#delete_records. Dependent associations
|
||||
# delete children, otherwise foreign key is set to NULL.
|
||||
|
||||
@ -1165,13 +1125,13 @@ def configure_dependency_for_has_many(reflection)
|
||||
dependent_conditions = dependent_conditions.collect {|where| "(#{where})" }.join(" AND ")
|
||||
|
||||
case reflection.options[:dependent]
|
||||
when :destroy, true
|
||||
when :destroy
|
||||
module_eval "before_destroy '#{reflection.name}.each { |o| o.destroy }'"
|
||||
when :delete_all
|
||||
module_eval "before_destroy { |record| #{reflection.class_name}.delete_all(%(#{dependent_conditions})) }"
|
||||
when :nullify
|
||||
module_eval "before_destroy { |record| #{reflection.class_name}.update_all(%(#{reflection.primary_key_name} = NULL), %(#{dependent_conditions})) }"
|
||||
when nil, false
|
||||
when nil
|
||||
# pass
|
||||
else
|
||||
raise ArgumentError, 'The :dependent option expects either :destroy, :delete_all, or :nullify'
|
||||
@ -1180,34 +1140,23 @@ def configure_dependency_for_has_many(reflection)
|
||||
|
||||
def configure_dependency_for_has_one(reflection)
|
||||
case reflection.options[:dependent]
|
||||
when :destroy, true
|
||||
when :destroy
|
||||
module_eval "before_destroy '#{reflection.name}.destroy unless #{reflection.name}.nil?'"
|
||||
when :delete
|
||||
module_eval "before_destroy '#{reflection.class_name}.delete(#{reflection.name}.id) unless #{reflection.name}.nil?'"
|
||||
when :nullify
|
||||
module_eval "before_destroy '#{reflection.name}.update_attribute(\"#{reflection.primary_key_name}\", nil) unless #{reflection.name}.nil?'"
|
||||
when nil, false
|
||||
when nil
|
||||
# pass
|
||||
else
|
||||
raise ArgumentError, "The :dependent option expects either :destroy, :delete or :nullify."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def add_deprecated_api_for_has_many(association_name)
|
||||
deprecated_collection_count_method(association_name)
|
||||
deprecated_add_association_relation(association_name)
|
||||
deprecated_remove_association_relation(association_name)
|
||||
deprecated_has_collection_method(association_name)
|
||||
deprecated_find_in_collection_method(association_name)
|
||||
deprecated_collection_create_method(association_name)
|
||||
deprecated_collection_build_method(association_name)
|
||||
end
|
||||
|
||||
def create_has_many_reflection(association_id, options, &extension)
|
||||
options.assert_valid_keys(
|
||||
:class_name, :table_name, :foreign_key,
|
||||
:exclusively_dependent, :dependent,
|
||||
:dependent,
|
||||
:select, :conditions, :include, :order, :group, :limit, :offset,
|
||||
:as, :through, :source, :source_type,
|
||||
:uniq,
|
||||
|
@ -1,93 +0,0 @@
|
||||
module ActiveRecord
|
||||
module Associations # :nodoc:
|
||||
module ClassMethods
|
||||
def deprecated_collection_count_method(collection_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def #{collection_name}_count(force_reload = false)
|
||||
unless has_attribute?(:#{collection_name}_count)
|
||||
ActiveSupport::Deprecation.warn :#{collection_name}_count
|
||||
end
|
||||
#{collection_name}.reload if force_reload
|
||||
#{collection_name}.size
|
||||
end
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_add_association_relation(association_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def add_#{association_name}(*items)
|
||||
#{association_name}.concat(items)
|
||||
end
|
||||
deprecate :add_#{association_name} => "use #{association_name}.concat instead"
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_remove_association_relation(association_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def remove_#{association_name}(*items)
|
||||
#{association_name}.delete(items)
|
||||
end
|
||||
deprecate :remove_#{association_name} => "use #{association_name}.delete instead"
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_has_collection_method(collection_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def has_#{collection_name}?(force_reload = false)
|
||||
!#{collection_name}(force_reload).empty?
|
||||
end
|
||||
deprecate :has_#{collection_name}? => "use !#{collection_name}.empty? instead"
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_find_in_collection_method(collection_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def find_in_#{collection_name}(association_id)
|
||||
#{collection_name}.find(association_id)
|
||||
end
|
||||
deprecate :find_in_#{collection_name} => "use #{collection_name}.find instead"
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_collection_create_method(collection_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def create_in_#{collection_name}(attributes = {})
|
||||
#{collection_name}.create(attributes)
|
||||
end
|
||||
deprecate :create_in_#{collection_name} => "use #{collection_name}.create instead"
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_collection_build_method(collection_name)# :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def build_to_#{collection_name}(attributes = {})
|
||||
#{collection_name}.build(attributes)
|
||||
end
|
||||
deprecate :build_to_#{collection_name} => "use #{collection_name}.build instead"
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_association_comparison_method(association_name, association_class_name) # :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def #{association_name}?(comparison_object, force_reload = false)
|
||||
if comparison_object.kind_of?(#{association_class_name})
|
||||
#{association_name}(force_reload) == comparison_object
|
||||
else
|
||||
raise "Comparison object is a #{association_class_name}, should have been \#{comparison_object.class.name}"
|
||||
end
|
||||
end
|
||||
deprecate :#{association_name}? => :==
|
||||
end_eval
|
||||
end
|
||||
|
||||
def deprecated_has_association_method(association_name) # :nodoc:
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def has_#{association_name}?(force_reload = false)
|
||||
!#{association_name}(force_reload).nil?
|
||||
end
|
||||
deprecate :has_#{association_name}? => "use !#{association_name} insead"
|
||||
end_eval
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -83,19 +83,6 @@ def add_on_blank(attributes, msg = @@default_error_messages[:blank])
|
||||
end
|
||||
end
|
||||
|
||||
# Will add an error message to each of the attributes in +attributes+ that has a length outside of the passed boundary +range+.
|
||||
# If the length is above the boundary, the too_long_msg message will be used. If below, the too_short_msg.
|
||||
def add_on_boundary_breaking(attributes, range, too_long_msg = @@default_error_messages[:too_long], too_short_msg = @@default_error_messages[:too_short])
|
||||
for attr in [attributes].flatten
|
||||
value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s]
|
||||
add(attr, too_short_msg % range.begin) if value && value.length < range.begin
|
||||
add(attr, too_long_msg % range.end) if value && value.length > range.end
|
||||
end
|
||||
end
|
||||
|
||||
alias :add_on_boundry_breaking :add_on_boundary_breaking
|
||||
deprecate :add_on_boundary_breaking => :validates_length_of, :add_on_boundry_breaking => :validates_length_of
|
||||
|
||||
# Returns true if the specified +attribute+ has errors associated with it.
|
||||
#
|
||||
# class Company < ActiveRecord::Base
|
||||
|
@ -30,18 +30,12 @@ def test_force_reload
|
||||
firm.save
|
||||
firm.clients.each {|c|} # forcing to load all clients
|
||||
assert firm.clients.empty?, "New firm shouldn't have client objects"
|
||||
assert_deprecated do
|
||||
assert !firm.has_clients?, "New firm shouldn't have clients"
|
||||
end
|
||||
assert_equal 0, firm.clients.size, "New firm should have 0 clients"
|
||||
|
||||
client = Client.new("name" => "TheClient.com", "firm_id" => firm.id)
|
||||
client.save
|
||||
|
||||
assert firm.clients.empty?, "New firm should have cached no client objects"
|
||||
assert_deprecated do
|
||||
assert !firm.has_clients?, "New firm should have cached a no-clients response"
|
||||
end
|
||||
assert_equal 0, firm.clients.size, "New firm should have cached 0 clients count"
|
||||
|
||||
assert !firm.clients(true).empty?, "New firm should have reloaded client objects"
|
||||
@ -215,12 +209,6 @@ def test_dependence
|
||||
assert_equal [account_id], Account.destroyed_account_ids[firm.id]
|
||||
end
|
||||
|
||||
def test_deprecated_exclusive_dependence
|
||||
assert_deprecated(/:exclusively_dependent.*:dependent => :delete_all/) do
|
||||
Firm.has_many :deprecated_exclusively_dependent_clients, :class_name => 'Client', :exclusively_dependent => true
|
||||
end
|
||||
end
|
||||
|
||||
def test_exclusive_dependence
|
||||
num_accounts = Account.count
|
||||
|
||||
|
@ -1,175 +0,0 @@
|
||||
require 'abstract_unit'
|
||||
require 'fixtures/developer'
|
||||
require 'fixtures/project'
|
||||
require 'fixtures/company'
|
||||
require 'fixtures/topic'
|
||||
require 'fixtures/reply'
|
||||
|
||||
# Can't declare new classes in test case methods, so tests before that
|
||||
bad_collection_keys = false
|
||||
begin
|
||||
class Car < ActiveRecord::Base; has_many :wheels, :name => "wheels"; end
|
||||
rescue ArgumentError
|
||||
bad_collection_keys = true
|
||||
end
|
||||
raise "ActiveRecord should have barked on bad collection keys" unless bad_collection_keys
|
||||
|
||||
|
||||
class DeprecatedAssociationWarningsTest < Test::Unit::TestCase
|
||||
def test_deprecation_warnings
|
||||
assert_deprecated('has_account?') { Firm.find(:first).has_account? }
|
||||
assert_deprecated('has_clients?') { Firm.find(:first).has_clients? }
|
||||
end
|
||||
end
|
||||
|
||||
class DeprecatedAssociationsTest < Test::Unit::TestCase
|
||||
fixtures :accounts, :companies, :developers, :projects, :topics,
|
||||
:developers_projects
|
||||
|
||||
def setup
|
||||
@firm = companies(:first_firm)
|
||||
end
|
||||
|
||||
def test_has_many
|
||||
assert !@firm.clients.loaded?
|
||||
assert_deprecated 'has_clients?' do
|
||||
assert_queries(1) { assert @firm.has_clients? }
|
||||
end
|
||||
assert !@firm.clients.loaded?
|
||||
assert_deprecated 'clients_count' do
|
||||
assert_queries(1) { assert_equal 2, @firm.clients_count }
|
||||
end
|
||||
end
|
||||
|
||||
def test_belongs_to
|
||||
client = companies(:second_client)
|
||||
assert_deprecated('has_firm?') do
|
||||
assert companies(:second_client).has_firm?, "Microsoft should have a firm"
|
||||
end
|
||||
assert_equal companies(:first_firm), client.firm, "Microsoft should have a firm"
|
||||
end
|
||||
|
||||
def test_has_one
|
||||
assert_equal accounts(:signals37), @firm.account
|
||||
assert_deprecated 'has_account?' do
|
||||
assert @firm.has_account?, "37signals should have an account"
|
||||
end
|
||||
assert_deprecated 'firm?' do
|
||||
assert accounts(:signals37).firm?(@firm), "37signals account should be able to backtrack"
|
||||
end
|
||||
assert_deprecated 'has_firm?' do
|
||||
assert accounts(:signals37).has_firm?, "37signals account should be able to backtrack"
|
||||
end
|
||||
|
||||
assert_nil accounts(:unknown).firm, "Unknown isn't linked"
|
||||
end
|
||||
|
||||
def test_find_in
|
||||
assert_deprecated 'find_in_clients' do
|
||||
assert_equal companies(:first_client), @firm.find_in_clients(2)
|
||||
assert_raises(ActiveRecord::RecordNotFound) { @firm.find_in_clients(6) }
|
||||
end
|
||||
end
|
||||
|
||||
def test_build_to_collection
|
||||
count = @firm.clients_of_firm.count
|
||||
new_client = nil
|
||||
assert_deprecated 'build_to_clients_of_firm' do
|
||||
new_client = @firm.build_to_clients_of_firm("name" => "Another Client")
|
||||
end
|
||||
assert_equal "Another Client", new_client.name
|
||||
assert new_client.save
|
||||
|
||||
assert_equal @firm, new_client.firm
|
||||
assert_equal count + 1, @firm.clients_of_firm.count
|
||||
end
|
||||
|
||||
def test_create_in_collection
|
||||
assert_deprecated 'create_in_clients_of_firm' do
|
||||
assert_equal @firm.create_in_clients_of_firm("name" => "Another Client"), @firm.clients_of_firm(true).last
|
||||
end
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many
|
||||
david = Developer.find(1)
|
||||
assert_deprecated 'has_projects?' do
|
||||
assert david.has_projects?
|
||||
end
|
||||
assert_deprecated 'projects_count' do
|
||||
assert_equal 2, david.projects_count
|
||||
end
|
||||
|
||||
active_record = Project.find(1)
|
||||
assert_deprecated 'has_developers?' do
|
||||
assert active_record.has_developers?
|
||||
end
|
||||
assert_deprecated 'developers_count' do
|
||||
assert_equal 3, active_record.developers_count
|
||||
end
|
||||
assert active_record.developers.include?(david)
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many_removing
|
||||
david = Developer.find(1)
|
||||
active_record = Project.find(1)
|
||||
|
||||
assert_deprecated do
|
||||
david.remove_projects(active_record)
|
||||
assert_equal 1, david.projects_count
|
||||
assert_equal 2, active_record.developers_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many_zero
|
||||
david = Developer.find(1)
|
||||
assert_deprecated do
|
||||
david.remove_projects Project.find(:all)
|
||||
assert_equal 0, david.projects_count
|
||||
assert !david.has_projects?
|
||||
end
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many_adding
|
||||
jamis = Developer.find(2)
|
||||
action_controller = Project.find(2)
|
||||
|
||||
assert_deprecated do
|
||||
jamis.add_projects(action_controller)
|
||||
assert_equal 2, jamis.projects_count
|
||||
assert_equal 2, action_controller.developers_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many_adding_from_the_project
|
||||
jamis = Developer.find(2)
|
||||
action_controller = Project.find(2)
|
||||
|
||||
assert_deprecated do
|
||||
action_controller.add_developers(jamis)
|
||||
assert_equal 2, jamis.projects_count
|
||||
assert_equal 2, action_controller.developers_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_has_and_belongs_to_many_adding_a_collection
|
||||
aredridel = Developer.new("name" => "Aredridel")
|
||||
aredridel.save
|
||||
|
||||
assert_deprecated do
|
||||
aredridel.add_projects([ Project.find(1), Project.find(2) ])
|
||||
assert_equal 2, aredridel.projects_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_belongs_to_counter
|
||||
topic = Topic.create("title" => "Apple", "content" => "hello world")
|
||||
assert_equal 0, topic.send(:read_attribute, "replies_count"), "No replies yet"
|
||||
|
||||
reply = assert_deprecated { topic.create_in_replies("title" => "I'm saying no!", "content" => "over here") }
|
||||
assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count"), "First reply created"
|
||||
|
||||
reply.destroy
|
||||
assert_equal 0, Topic.find(topic.id).send(:read_attribute, "replies_count"), "First reply deleted"
|
||||
end
|
||||
|
||||
end
|
@ -183,15 +183,6 @@ def test_nil_scope
|
||||
class TreeTest < Test::Unit::TestCase
|
||||
fixtures :mixins
|
||||
|
||||
def test_has_child
|
||||
assert_deprecated 'has_children?' do
|
||||
assert_equal true, mixins(:tree_1).has_children?
|
||||
assert_equal true, mixins(:tree_2).has_children?
|
||||
assert_equal false, mixins(:tree_3).has_children?
|
||||
assert_equal false, mixins(:tree_4).has_children?
|
||||
end
|
||||
end
|
||||
|
||||
def test_children
|
||||
assert_equal mixins(:tree_1).children, mixins(:tree_2, :tree_4)
|
||||
assert_equal mixins(:tree_2).children, [mixins(:tree_3)]
|
||||
@ -199,15 +190,6 @@ def test_children
|
||||
assert_equal mixins(:tree_4).children, []
|
||||
end
|
||||
|
||||
def test_has_parent
|
||||
assert_deprecated 'has_parent?' do
|
||||
assert_equal false, mixins(:tree_1).has_parent?
|
||||
assert_equal true, mixins(:tree_2).has_parent?
|
||||
assert_equal true, mixins(:tree_3).has_parent?
|
||||
assert_equal true, mixins(:tree_4).has_parent?
|
||||
end
|
||||
end
|
||||
|
||||
def test_parent
|
||||
assert_equal mixins(:tree_2).parent, mixins(:tree_1)
|
||||
assert_equal mixins(:tree_2).parent, mixins(:tree_4).parent
|
||||
|
@ -159,8 +159,8 @@ def test_association_reflection_in_modules
|
||||
end
|
||||
|
||||
def test_reflection_of_all_associations
|
||||
assert_equal 17, Firm.reflect_on_all_associations.size
|
||||
assert_equal 15, Firm.reflect_on_all_associations(:has_many).size
|
||||
assert_equal 16, Firm.reflect_on_all_associations.size
|
||||
assert_equal 14, Firm.reflect_on_all_associations(:has_many).size
|
||||
assert_equal 2, Firm.reflect_on_all_associations(:has_one).size
|
||||
assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
|
||||
end
|
||||
|
@ -651,18 +651,6 @@ def test_validates_length_with_globaly_modified_error_message
|
||||
|
||||
assert_equal 'tu est trops petit hombre 10', t.errors['title']
|
||||
end
|
||||
|
||||
def test_add_on_boundary_breaking_is_deprecated
|
||||
t = Topic.new('title' => 'noreplies', 'content' => 'whatever')
|
||||
class << t
|
||||
def validate
|
||||
errors.add_on_boundary_breaking('title', 1..6)
|
||||
end
|
||||
end
|
||||
assert_deprecated 'add_on_boundary_breaking' do
|
||||
assert !t.valid?
|
||||
end
|
||||
end
|
||||
|
||||
def test_validates_size_of_association
|
||||
assert_nothing_raised { Topic.validates_size_of :replies, :minimum => 1 }
|
||||
|
Loading…
Reference in New Issue
Block a user