From 2738ec891b6b6584ec7bd79532e5eac71282436e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 16 Nov 2010 17:06:50 -0800 Subject: removing many unused variables --- .../test/cases/associations/inverse_associations_test.rb | 4 ++-- activerecord/test/cases/associations_test.rb | 2 +- activerecord/test/cases/attribute_methods_test.rb | 2 +- activerecord/test/cases/autosave_association_test.rb | 6 ++---- activerecord/test/cases/base_test.rb | 3 +-- activerecord/test/cases/finder_test.rb | 2 +- activerecord/test/cases/fixtures_test.rb | 6 +++--- activerecord/test/cases/migration_test.rb | 10 +++++----- activerecord/test/cases/persistence_test.rb | 3 +-- activerecord/test/cases/query_cache_test.rb | 1 - activerecord/test/cases/relation_scoping_test.rb | 2 -- activerecord/test/cases/timestamp_test.rb | 2 +- activerecord/test/cases/transactions_test.rb | 2 +- .../test/cases/validations/association_validation_test.rb | 4 ++-- .../test/cases/validations/uniqueness_validation_test.rb | 4 ++-- 15 files changed, 23 insertions(+), 30 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index fa5c2e49df..081583038f 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -551,8 +551,8 @@ class InverseMultipleHasManyInversesForSameModel < ActiveRecord::TestCase def test_that_we_can_load_associations_that_have_the_same_reciprocal_name_from_different_models assert_nothing_raised(ActiveRecord::AssociationTypeMismatch) do i = Interest.find(:first) - z = i.zine - m = i.man + i.zine + i.man end end diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index dd8152b219..93a51d3606 100644 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -120,7 +120,7 @@ class AssociationsTest < ActiveRecord::TestCase def test_force_reload_is_uncached firm = Firm.create!("name" => "A New Firm, Inc") - client = Client.create!("name" => "TheClient.com", :firm => firm) + Client.create!("name" => "TheClient.com", :firm => firm) ActiveRecord::Base.cache do firm.clients.each {} assert_queries(0) { assert_not_nil firm.clients.each {} } diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index ab9a65944f..bb0166a60c 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -568,7 +568,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase def test_bulk_update_respects_access_control privatize("title=(value)") - assert_raise(ActiveRecord::UnknownAttributeError) { topic = @target.new(:title => "Rants about pants") } + assert_raise(ActiveRecord::UnknownAttributeError) { @target.new(:title => "Rants about pants") } assert_raise(ActiveRecord::UnknownAttributeError) { @target.new.attributes = { :title => "Ants in pants" } } end diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 459f9fa55c..b13cb2d7a2 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -355,8 +355,6 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa end def test_invalid_adding_before_save - no_of_firms = Firm.count - no_of_clients = Client.count new_firm = Firm.new("name" => "A New Firm, Inc") new_firm.clients_of_firm.concat([c = Client.new, Client.new("name" => "Apple")]) assert !c.persisted? @@ -461,7 +459,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa def test_build_many_before_save company = companies(:first_firm) - new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } + assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } company.name += '-changed' assert_queries(3) { assert company.save } @@ -481,7 +479,7 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa def test_build_many_via_block_before_save company = companies(:first_firm) - new_clients = assert_no_queries do + assert_no_queries do company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) do |client| client.name = "changed" end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 73c76606ad..26f388ca46 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -182,7 +182,7 @@ class BasicsTest < ActiveRecord::TestCase def test_initialize_with_invalid_attribute begin - topic = Topic.new({ "title" => "test", + Topic.new({ "title" => "test", "last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"}) rescue ActiveRecord::MultiparameterAssignmentErrors => ex assert_equal(1, ex.errors.size) @@ -972,7 +972,6 @@ class BasicsTest < ActiveRecord::TestCase end def test_nil_serialized_attribute_with_class_constraint - myobj = MyObject.new('value1', 'value2') topic = Topic.new assert_nil topic.content end diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 39ce47d9d6..31e4981a1d 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -949,7 +949,7 @@ class FinderTest < ActiveRecord::TestCase # http://dev.rubyonrails.org/ticket/6778 def test_find_ignores_previously_inserted_record - post = Post.create!(:title => 'test', :body => 'it out') + Post.create!(:title => 'test', :body => 'it out') assert_equal [], Post.find_all_by_id(nil) end diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index d5ef30e137..9ce163a00f 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -58,7 +58,7 @@ class FixturesTest < ActiveRecord::TestCase end def test_inserts - topics = create_fixtures("topics") + create_fixtures("topics") first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'") assert_equal("The First Topic", first_row["title"]) @@ -114,7 +114,7 @@ class FixturesTest < ActiveRecord::TestCase end def test_insert_with_datetime - topics = create_fixtures("tasks") + create_fixtures("tasks") first = Task.find(1) assert first end @@ -240,7 +240,7 @@ if Account.connection.respond_to?(:reset_pk_sequence!) def test_create_fixtures_resets_sequences_when_not_cached @instances.each do |instance| - max_id = create_fixtures(instance.class.table_name).inject(0) do |_max_id, (name, fixture)| + max_id = create_fixtures(instance.class.table_name).inject(0) do |_max_id, (_, fixture)| fixture_id = fixture['id'].to_i fixture_id > _max_id ? fixture_id : _max_id end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 698075ea0c..ab9b35172b 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1947,7 +1947,7 @@ if ActiveRecord::Base.connection.supports_migrations? @migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps" @existing_migrations = Dir[@migrations_path + "/*.rb"] - Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do + Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb") assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb") @@ -1972,7 +1972,7 @@ if ActiveRecord::Base.connection.supports_migrations? sources[:bukkits] = MIGRATIONS_ROOT + "/to_copy_with_timestamps" sources[:omg] = MIGRATIONS_ROOT + "/to_copy_with_timestamps2" - Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do + Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, sources) assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb") assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb") @@ -1992,7 +1992,7 @@ if ActiveRecord::Base.connection.supports_migrations? @migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps" @existing_migrations = Dir[@migrations_path + "/*.rb"] - Time.travel_to(created_at = Time.utc(2010, 2, 20, 10, 10, 10)) do + Time.travel_to(Time.utc(2010, 2, 20, 10, 10, 10)) do ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) assert File.exists?(@migrations_path + "/20100301010102_people_have_hobbies.rb") assert File.exists?(@migrations_path + "/20100301010103_people_have_descriptions.rb") @@ -2028,7 +2028,7 @@ if ActiveRecord::Base.connection.supports_migrations? @migrations_path = MIGRATIONS_ROOT + "/non_existing" @existing_migrations = [] - Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do + Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb") assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb") @@ -2043,7 +2043,7 @@ if ActiveRecord::Base.connection.supports_migrations? @migrations_path = MIGRATIONS_ROOT + "/empty" @existing_migrations = [] - Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do + Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"}) assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb") assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb") diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 07262f56be..8ca9d626d1 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -192,7 +192,6 @@ class PersistencesTest < ActiveRecord::TestCase topic = Topic.create("title" => "New Topic") do |t| t.author_name = "David" end - topicReloaded = Topic.find(topic.id) assert_equal("New Topic", topic.title) assert_equal("David", topic.author_name) end @@ -270,7 +269,7 @@ class PersistencesTest < ActiveRecord::TestCase end def test_record_not_found_exception - assert_raise(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) } + assert_raise(ActiveRecord::RecordNotFound) { Topic.find(99999) } end def test_update_all diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index 5bb21a54bd..33916c4e46 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -133,7 +133,6 @@ class QueryCacheExpiryTest < ActiveRecord::TestCase def test_cache_is_expired_by_habtm_delete ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) ActiveRecord::Base.cache do - c = Category.find(1) p = Post.find(1) assert p.categories.any? p.categories.delete_all diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb index a27e2e72cd..dae9721a63 100644 --- a/activerecord/test/cases/relation_scoping_test.rb +++ b/activerecord/test/cases/relation_scoping_test.rb @@ -254,13 +254,11 @@ class HasManyScopingTest< ActiveRecord::TestCase end def test_should_maintain_default_scope_on_associations - person = people(:michael) magician = BadReference.find(1) assert_equal [magician], people(:michael).bad_references end def test_should_default_scope_on_associations_is_overriden_by_association_conditions - person = people(:michael) assert_equal [], people(:michael).fixed_bad_references end diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index eb93761fb2..70c098bc6d 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -113,7 +113,7 @@ class TimestampTest < ActiveRecord::TestCase pet = Pet.first owner = pet.owner - owner.update_attribute(:happy_at, (time = 3.days.ago)) + owner.update_attribute(:happy_at, 3.days.ago) previously_owner_updated_at = owner.updated_at pet.name = "I'm a parrot" diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index dd9de3510b..b0ccd71836 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -163,7 +163,7 @@ class TransactionTest < ActiveRecord::TestCase @first.author_name += '_this_should_not_end_up_in_the_db' @first.save! flunk - rescue => e + rescue assert_equal original_author_name, @first.reload.author_name assert_equal nbooks_before_save, Book.count ensure diff --git a/activerecord/test/cases/validations/association_validation_test.rb b/activerecord/test/cases/validations/association_validation_test.rb index 1246dd4276..56e345990f 100644 --- a/activerecord/test/cases/validations/association_validation_test.rb +++ b/activerecord/test/cases/validations/association_validation_test.rb @@ -17,7 +17,7 @@ class AssociationValidationTest < ActiveRecord::TestCase o = Owner.new('name' => 'nopets') assert !o.save assert o.errors[:pets].any? - pet = o.pets.build('name' => 'apet') + o.pets.build('name' => 'apet') assert o.valid? end @@ -27,7 +27,7 @@ class AssociationValidationTest < ActiveRecord::TestCase assert !o.save assert o.errors[:pets].any? - pet = o.pets.build('name' => 'apet') + o.pets.build('name' => 'apet') assert o.valid? 2.times { o.pets.build('name' => 'apet') } diff --git a/activerecord/test/cases/validations/uniqueness_validation_test.rb b/activerecord/test/cases/validations/uniqueness_validation_test.rb index 9a863c25a8..679d67553b 100644 --- a/activerecord/test/cases/validations/uniqueness_validation_test.rb +++ b/activerecord/test/cases/validations/uniqueness_validation_test.rb @@ -60,7 +60,7 @@ class UniquenessValidationTest < ActiveRecord::TestCase def test_validates_uniqueness_with_validates Topic.validates :title, :uniqueness => true - t = Topic.create!('title' => 'abc') + Topic.create!('title' => 'abc') t2 = Topic.new('title' => 'abc') assert !t2.valid? @@ -201,7 +201,7 @@ class UniquenessValidationTest < ActiveRecord::TestCase def test_validate_case_sensitive_uniqueness_with_attribute_passed_as_integer Topic.validates_uniqueness_of(:title, :case_sensitve => true) - t = Topic.create!('title' => 101) + Topic.create!('title' => 101) t2 = Topic.new('title' => 101) assert !t2.valid? -- cgit v1.2.3