aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-09-03 00:17:09 +0000
committerMichael Koziarski <michael@koziarski.com>2007-09-03 00:17:09 +0000
commit6246fad19a5ec747f5914c142b8631af212d47ea (patch)
tree7693248f7fd9e42a69bd13b4bbb94c4ed2d576e9 /activerecord/test
parentf0dbd22c4647bf8e37fd9b58ce6652aaca27376e (diff)
downloadrails-6246fad19a5ec747f5914c142b8631af212d47ea.tar.gz
rails-6246fad19a5ec747f5914c142b8631af212d47ea.tar.bz2
rails-6246fad19a5ec747f5914c142b8631af212d47ea.zip
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
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/associations_test.rb12
-rwxr-xr-xactiverecord/test/deprecated_associations_test.rb175
-rw-r--r--activerecord/test/mixin_test.rb18
-rw-r--r--activerecord/test/reflection_test.rb4
-rwxr-xr-xactiverecord/test/validations_test.rb12
5 files changed, 2 insertions, 219 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 9da5552c09..6b97a92612 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -30,18 +30,12 @@ class AssociationsTest < Test::Unit::TestCase
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 @@ class HasOneAssociationsTest < Test::Unit::TestCase
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
diff --git a/activerecord/test/deprecated_associations_test.rb b/activerecord/test/deprecated_associations_test.rb
deleted file mode 100755
index e40ff9b4c4..0000000000
--- a/activerecord/test/deprecated_associations_test.rb
+++ /dev/null
@@ -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
diff --git a/activerecord/test/mixin_test.rb b/activerecord/test/mixin_test.rb
index 26ec59dec5..44a84f62c8 100644
--- a/activerecord/test/mixin_test.rb
+++ b/activerecord/test/mixin_test.rb
@@ -183,15 +183,6 @@ end
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 @@ class TreeTest < Test::Unit::TestCase
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
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb
index 1ed5c2610c..eca8b5e989 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/reflection_test.rb
@@ -159,8 +159,8 @@ class ReflectionTest < Test::Unit::TestCase
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
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb
index 47a4d4d034..cd4b27a7dd 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/validations_test.rb
@@ -651,18 +651,6 @@ class ValidationsTest < Test::Unit::TestCase
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 }