Skip to content

Commit 2738ec8

Browse files
committed
removing many unused variables
1 parent 08c64bb commit 2738ec8

15 files changed

+23
-30
lines changed

activerecord/test/cases/associations/inverse_associations_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ class InverseMultipleHasManyInversesForSameModel < ActiveRecord::TestCase
551551
def test_that_we_can_load_associations_that_have_the_same_reciprocal_name_from_different_models
552552
assert_nothing_raised(ActiveRecord::AssociationTypeMismatch) do
553553
i = Interest.find(:first)
554-
z = i.zine
555-
m = i.man
554+
i.zine
555+
i.man
556556
end
557557
end
558558

activerecord/test/cases/associations_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_using_limitable_reflections_helper
120120

121121
def test_force_reload_is_uncached
122122
firm = Firm.create!("name" => "A New Firm, Inc")
123-
client = Client.create!("name" => "TheClient.com", :firm => firm)
123+
Client.create!("name" => "TheClient.com", :firm => firm)
124124
ActiveRecord::Base.cache do
125125
firm.clients.each {}
126126
assert_queries(0) { assert_not_nil firm.clients.each {} }

activerecord/test/cases/attribute_methods_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def test_question_attributes_respect_access_control
568568
def test_bulk_update_respects_access_control
569569
privatize("title=(value)")
570570

571-
assert_raise(ActiveRecord::UnknownAttributeError) { topic = @target.new(:title => "Rants about pants") }
571+
assert_raise(ActiveRecord::UnknownAttributeError) { @target.new(:title => "Rants about pants") }
572572
assert_raise(ActiveRecord::UnknownAttributeError) { @target.new.attributes = { :title => "Ants in pants" } }
573573
end
574574

activerecord/test/cases/autosave_association_test.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,6 @@ def test_invalid_adding
355355
end
356356

357357
def test_invalid_adding_before_save
358-
no_of_firms = Firm.count
359-
no_of_clients = Client.count
360358
new_firm = Firm.new("name" => "A New Firm, Inc")
361359
new_firm.clients_of_firm.concat([c = Client.new, Client.new("name" => "Apple")])
362360
assert !c.persisted?
@@ -461,7 +459,7 @@ def test_build_before_save
461459

462460
def test_build_many_before_save
463461
company = companies(:first_firm)
464-
new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) }
462+
assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) }
465463

466464
company.name += '-changed'
467465
assert_queries(3) { assert company.save }
@@ -481,7 +479,7 @@ def test_build_via_block_before_save
481479

482480
def test_build_many_via_block_before_save
483481
company = companies(:first_firm)
484-
new_clients = assert_no_queries do
482+
assert_no_queries do
485483
company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) do |client|
486484
client.name = "changed"
487485
end

activerecord/test/cases/base_test.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_initialize_with_attributes
182182

183183
def test_initialize_with_invalid_attribute
184184
begin
185-
topic = Topic.new({ "title" => "test",
185+
Topic.new({ "title" => "test",
186186
"last_read(1i)" => "2005", "last_read(2i)" => "2", "last_read(3i)" => "31"})
187187
rescue ActiveRecord::MultiparameterAssignmentErrors => ex
188188
assert_equal(1, ex.errors.size)
@@ -972,7 +972,6 @@ def test_serialized_string_attribute
972972
end
973973

974974
def test_nil_serialized_attribute_with_class_constraint
975-
myobj = MyObject.new('value1', 'value2')
976975
topic = Topic.new
977976
assert_nil topic.content
978977
end

activerecord/test/cases/finder_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ def test_find_by_id_with_conditions_with_or
949949

950950
# http://dev.rubyonrails.org/ticket/6778
951951
def test_find_ignores_previously_inserted_record
952-
post = Post.create!(:title => 'test', :body => 'it out')
952+
Post.create!(:title => 'test', :body => 'it out')
953953
assert_equal [], Post.find_all_by_id(nil)
954954
end
955955

activerecord/test/cases/fixtures_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_attributes
5858
end
5959

6060
def test_inserts
61-
topics = create_fixtures("topics")
61+
create_fixtures("topics")
6262
first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
6363
assert_equal("The First Topic", first_row["title"])
6464

@@ -114,7 +114,7 @@ def test_inserts_with_pre_and_suffix
114114
end
115115

116116
def test_insert_with_datetime
117-
topics = create_fixtures("tasks")
117+
create_fixtures("tasks")
118118
first = Task.find(1)
119119
assert first
120120
end
@@ -240,7 +240,7 @@ def test_resets_to_min_pk_with_default_pk_and_sequence
240240

241241
def test_create_fixtures_resets_sequences_when_not_cached
242242
@instances.each do |instance|
243-
max_id = create_fixtures(instance.class.table_name).inject(0) do |_max_id, (name, fixture)|
243+
max_id = create_fixtures(instance.class.table_name).inject(0) do |_max_id, (_, fixture)|
244244
fixture_id = fixture['id'].to_i
245245
fixture_id > _max_id ? fixture_id : _max_id
246246
end

activerecord/test/cases/migration_test.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ def test_copying_migrations_with_timestamps
19471947
@migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps"
19481948
@existing_migrations = Dir[@migrations_path + "/*.rb"]
19491949

1950-
Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do
1950+
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
19511951
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
19521952
assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb")
19531953
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb")
@@ -1972,7 +1972,7 @@ def test_copying_migrations_with_timestamps_from_2_sources
19721972
sources[:bukkits] = MIGRATIONS_ROOT + "/to_copy_with_timestamps"
19731973
sources[:omg] = MIGRATIONS_ROOT + "/to_copy_with_timestamps2"
19741974

1975-
Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do
1975+
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
19761976
copied = ActiveRecord::Migration.copy(@migrations_path, sources)
19771977
assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb")
19781978
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb")
@@ -1992,7 +1992,7 @@ def test_copying_migrations_with_timestamps_to_destination_with_timestamps_in_fu
19921992
@migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps"
19931993
@existing_migrations = Dir[@migrations_path + "/*.rb"]
19941994

1995-
Time.travel_to(created_at = Time.utc(2010, 2, 20, 10, 10, 10)) do
1995+
Time.travel_to(Time.utc(2010, 2, 20, 10, 10, 10)) do
19961996
ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
19971997
assert File.exists?(@migrations_path + "/20100301010102_people_have_hobbies.rb")
19981998
assert File.exists?(@migrations_path + "/20100301010103_people_have_descriptions.rb")
@@ -2028,7 +2028,7 @@ def test_copying_migrations_to_non_existing_directory
20282028
@migrations_path = MIGRATIONS_ROOT + "/non_existing"
20292029
@existing_migrations = []
20302030

2031-
Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do
2031+
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
20322032
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
20332033
assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb")
20342034
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb")
@@ -2043,7 +2043,7 @@ def test_copying_migrations_to_empty_directory
20432043
@migrations_path = MIGRATIONS_ROOT + "/empty"
20442044
@existing_migrations = []
20452045

2046-
Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do
2046+
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
20472047
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
20482048
assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.rb")
20492049
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb")

activerecord/test/cases/persistence_test.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ def test_create_through_factory_with_block
192192
topic = Topic.create("title" => "New Topic") do |t|
193193
t.author_name = "David"
194194
end
195-
topicReloaded = Topic.find(topic.id)
196195
assert_equal("New Topic", topic.title)
197196
assert_equal("David", topic.author_name)
198197
end
@@ -270,7 +269,7 @@ def test_destroy
270269
end
271270

272271
def test_record_not_found_exception
273-
assert_raise(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
272+
assert_raise(ActiveRecord::RecordNotFound) { Topic.find(99999) }
274273
end
275274

276275
def test_update_all

activerecord/test/cases/query_cache_test.rb

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ def test_cache_is_expired_by_habtm_update
133133
def test_cache_is_expired_by_habtm_delete
134134
ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
135135
ActiveRecord::Base.cache do
136-
c = Category.find(1)
137136
p = Post.find(1)
138137
assert p.categories.any?
139138
p.categories.delete_all

activerecord/test/cases/relation_scoping_test.rb

-2
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,11 @@ def test_nested_scope_finder
254254
end
255255

256256
def test_should_maintain_default_scope_on_associations
257-
person = people(:michael)
258257
magician = BadReference.find(1)
259258
assert_equal [magician], people(:michael).bad_references
260259
end
261260

262261
def test_should_default_scope_on_associations_is_overriden_by_association_conditions
263-
person = people(:michael)
264262
assert_equal [], people(:michael).fixed_bad_references
265263
end
266264

activerecord/test/cases/timestamp_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_touching_a_record_with_a_belongs_to_that_uses_a_counter_cache_should_up
113113

114114
pet = Pet.first
115115
owner = pet.owner
116-
owner.update_attribute(:happy_at, (time = 3.days.ago))
116+
owner.update_attribute(:happy_at, 3.days.ago)
117117
previously_owner_updated_at = owner.updated_at
118118

119119
pet.name = "I'm a parrot"

activerecord/test/cases/transactions_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_cancellation_from_before_filters_rollbacks_in_save!
163163
@first.author_name += '_this_should_not_end_up_in_the_db'
164164
@first.save!
165165
flunk
166-
rescue => e
166+
rescue
167167
assert_equal original_author_name, @first.reload.author_name
168168
assert_equal nbooks_before_save, Book.count
169169
ensure

activerecord/test/cases/validations/association_validation_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_validates_size_of_association
1717
o = Owner.new('name' => 'nopets')
1818
assert !o.save
1919
assert o.errors[:pets].any?
20-
pet = o.pets.build('name' => 'apet')
20+
o.pets.build('name' => 'apet')
2121
assert o.valid?
2222
end
2323

@@ -27,7 +27,7 @@ def test_validates_size_of_association_using_within
2727
assert !o.save
2828
assert o.errors[:pets].any?
2929

30-
pet = o.pets.build('name' => 'apet')
30+
o.pets.build('name' => 'apet')
3131
assert o.valid?
3232

3333
2.times { o.pets.build('name' => 'apet') }

activerecord/test/cases/validations/uniqueness_validation_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_validate_uniqueness
6060

6161
def test_validates_uniqueness_with_validates
6262
Topic.validates :title, :uniqueness => true
63-
t = Topic.create!('title' => 'abc')
63+
Topic.create!('title' => 'abc')
6464

6565
t2 = Topic.new('title' => 'abc')
6666
assert !t2.valid?
@@ -201,7 +201,7 @@ def test_validate_case_sensitive_uniqueness
201201

202202
def test_validate_case_sensitive_uniqueness_with_attribute_passed_as_integer
203203
Topic.validates_uniqueness_of(:title, :case_sensitve => true)
204-
t = Topic.create!('title' => 101)
204+
Topic.create!('title' => 101)
205205

206206
t2 = Topic.new('title' => 101)
207207
assert !t2.valid?

0 commit comments

Comments
 (0)