Skip to content

Commit 9abecc4

Browse files
committed
Refactor adopt tests and clean up model files by removing unnecessary blank lines
1 parent da2c379 commit 9abecc4

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

test/closure_tree/adopt_test.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def run_adopt_tests_for(model_class)
6060
assert_equal p2, p3.parent
6161

6262
hierarchy = model_class.hierarchy_class
63-
initial_p2_hierarchies = hierarchy.where(ancestor_id: p2.id).count
64-
initial_p3_hierarchies = hierarchy.where(descendant_id: p3.id).count
63+
hierarchy.where(ancestor_id: p2.id).count
64+
hierarchy.where(descendant_id: p3.id).count
6565

6666
# Destroy p1 (root node)
6767
p1.destroy
@@ -210,7 +210,7 @@ def run_adopt_tests_for(model_class)
210210
leaf = model_class.create!(name: 'leaf', parent: p2)
211211

212212
hierarchy = model_class.hierarchy_class
213-
initial_count = hierarchy.count
213+
hierarchy.count
214214

215215
# Destroy leaf (has no children)
216216
leaf.destroy
@@ -255,16 +255,10 @@ def run_adopt_tests_for(model_class)
255255
end
256256

257257
# Test with PostgreSQL
258-
if postgresql?(ApplicationRecord.connection)
259-
run_adopt_tests_for(AdoptableTag)
260-
end
258+
run_adopt_tests_for(AdoptableTag) if postgresql?(ApplicationRecord.connection)
261259

262260
# Test with MySQL
263-
if mysql?(MysqlRecord.connection)
264-
run_adopt_tests_for(MysqlAdoptableTag)
265-
end
261+
run_adopt_tests_for(MysqlAdoptableTag) if mysql?(MysqlRecord.connection)
266262

267263
# Test with SQLite
268-
if sqlite?(SqliteRecord.connection)
269-
run_adopt_tests_for(MemoryAdoptableTag)
270-
end
264+
run_adopt_tests_for(MemoryAdoptableTag) if sqlite?(SqliteRecord.connection)

test/dummy/app/models/adoptable_tag.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
class AdoptableTag < ApplicationRecord
44
has_closure_tree dependent: :adopt, name_column: 'name'
55
end
6-
7-

test/dummy/app/models/memory_adoptable_tag.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
class MemoryAdoptableTag < SqliteRecord
44
has_closure_tree dependent: :adopt, name_column: 'name'
55
end
6-

test/dummy/app/models/mysql_adoptable_tag.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
class MysqlAdoptableTag < MysqlRecord
44
has_closure_tree dependent: :adopt, name_column: 'name'
55
end
6-

0 commit comments

Comments
 (0)