Skip to content

Commit 31fbb28

Browse files
authored
chore: rename testing classes as new versions became reserved (#477)
* chore: rename testing classes as new versions became reserved * rename the sqliterecord * chore: lock minitest version
1 parent cde4d29 commit 31fbb28

19 files changed

+64
-79
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby 3.4.7
1+
ruby 3.4.8

closure_tree.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Gem::Specification.new do |gem|
3030
gem.add_dependency 'zeitwerk', '~> 2.7'
3131

3232
gem.add_development_dependency 'database_cleaner'
33-
gem.add_development_dependency 'minitest'
33+
gem.add_development_dependency 'minitest', '~> 5.0'
3434
gem.add_development_dependency 'minitest-reporters'
3535
gem.add_development_dependency 'parallel'
3636
gem.add_development_dependency 'simplecov'

lib/closure_tree/support.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def abstract_base_class
4242
klass = model_class
4343
while klass.superclass != ActiveRecord::Base
4444
parent = klass.superclass
45-
# Stop at abstract class (ApplicationRecord, MysqlRecord, etc.)
45+
# Stop at abstract class (ApplicationRecord, SecondaryRecord, etc.)
4646
return parent if parent.abstract_class?
4747
# Stop at connection boundary (handles non-abstract parents with custom connections)
4848
return parent if parent.connection_specification_name != parent.superclass.connection_specification_name

test/closure_tree/adopt_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def run_adopt_tests_for(model_class)
255255
run_adopt_tests_for(AdoptableTag) if postgresql?(ApplicationRecord.connection)
256256

257257
# Test with MySQL
258-
run_adopt_tests_for(MysqlAdoptableTag) if mysql?(MysqlRecord.connection)
258+
run_adopt_tests_for(SecondaryAdoptableTag) if mysql?(SecondaryRecord.connection)
259259

260260
# Test with SQLite
261-
run_adopt_tests_for(MemoryAdoptableTag) if sqlite?(SqliteRecord.connection)
261+
run_adopt_tests_for(MemoryAdoptableTag) if sqlite?(LiteRecord.connection)

test/closure_tree/multi_database_test.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ class MultiDatabaseTest < ActiveSupport::TestCase
66
def setup
77
super
88
# Create memory tables - always recreate for clean state
9-
SqliteRecord.connection.create_table :memory_tags, force: true do |t|
9+
LiteRecord.connection.create_table :memory_tags, force: true do |t|
1010
t.string :name
1111
t.integer :parent_id
1212
t.timestamps
1313
end
1414

15-
SqliteRecord.connection.create_table :memory_tag_hierarchies, id: false, force: true do |t|
15+
LiteRecord.connection.create_table :memory_tag_hierarchies, id: false, force: true do |t|
1616
t.integer :ancestor_id, null: false
1717
t.integer :descendant_id, null: false
1818
t.integer :generations, null: false
1919
end
2020

21-
SqliteRecord.connection.add_index :memory_tag_hierarchies, %i[ancestor_id descendant_id generations],
21+
LiteRecord.connection.add_index :memory_tag_hierarchies, %i[ancestor_id descendant_id generations],
2222
unique: true, name: 'memory_tag_anc_desc_idx'
23-
SqliteRecord.connection.add_index :memory_tag_hierarchies, [:descendant_id], name: 'memory_tag_desc_idx'
23+
LiteRecord.connection.add_index :memory_tag_hierarchies, [:descendant_id], name: 'memory_tag_desc_idx'
2424
end
2525

2626
def teardown
2727
# Clean up SQLite tables after each test
28-
SqliteRecord.connection.drop_table :memory_tag_hierarchies, if_exists: true
29-
SqliteRecord.connection.drop_table :memory_tags, if_exists: true
28+
LiteRecord.connection.drop_table :memory_tag_hierarchies, if_exists: true
29+
LiteRecord.connection.drop_table :memory_tags, if_exists: true
3030
super
3131
end
3232

@@ -46,13 +46,13 @@ def test_postgresql_with_advisory_lock
4646
end
4747

4848
def test_mysql_with_advisory_lock
49-
skip 'MySQL not configured' unless mysql?(MysqlRecord.connection)
49+
skip 'MySQL not configured' unless mysql?(SecondaryRecord.connection)
5050

51-
tag = MysqlTag.create!(name: 'MySQL Root')
51+
tag = SecondaryTag.create!(name: 'MySQL Root')
5252
child = nil
5353

5454
# Advisory locks should work on MySQL
55-
MysqlTag.with_advisory_lock('test_lock') do
55+
SecondaryTag.with_advisory_lock('test_lock') do
5656
child = tag.children.create!(name: 'MySQL Child')
5757
end
5858

@@ -80,21 +80,21 @@ def test_concurrent_operations_different_databases
8080
pg_tag.children.create!(name: 'PG Child 1')
8181
end
8282

83-
mysql_tag = MysqlTag.create!(name: 'MySQL Root')
83+
mysql_tag = SecondaryTag.create!(name: 'MySQL Root')
8484
sqlite_tag = MemoryTag.create!(name: 'SQLite Root')
8585

8686
# Test concurrent operations only for MySQL and SQLite
8787
threads = []
8888

8989
threads << Thread.new do
90-
MysqlRecord.connection_pool.with_connection do
91-
tag = MysqlTag.find(mysql_tag.id)
90+
SecondaryRecord.connection_pool.with_connection do
91+
tag = SecondaryTag.find(mysql_tag.id)
9292
tag.children.create!(name: 'MySQL Child 1')
9393
end
9494
end
9595

9696
threads << Thread.new do
97-
SqliteRecord.connection_pool.with_connection do
97+
LiteRecord.connection_pool.with_connection do
9898
tag = MemoryTag.find(sqlite_tag.id)
9999
tag.children.create!(name: 'SQLite Child 1')
100100
end

test/closure_tree/parallel_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def work
6767
# Clean up SQLite database file if it exists
6868
db_file = 'test/dummy/db/test.sqlite3'
6969
if File.exist?(db_file)
70-
SqliteRecord.connection.disconnect!
70+
LiteRecord.connection.disconnect!
7171
File.delete(db_file)
72-
SqliteRecord.connection.reconnect!
72+
LiteRecord.connection.reconnect!
7373
end
7474
Tag.delete_all
7575
Tag.hierarchy_class.delete_all
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
class LiteRecord < ApplicationRecord
4+
self.abstract_class = true
5+
connects_to database: { writing: :lite, reading: :lite }
6+
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

3-
class MemoryAdoptableTag < SqliteRecord
3+
class MemoryAdoptableTag < LiteRecord
44
has_closure_tree dependent: :adopt, name_column: 'name'
55
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

3-
class MemoryTag < SqliteRecord
3+
class MemoryTag < LiteRecord
44
has_closure_tree
55
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

3-
class MysqlAdoptableTag < MysqlRecord
3+
class SecondaryAdoptableTag < SecondaryRecord
44
has_closure_tree dependent: :adopt, name_column: 'name'
55
end

0 commit comments

Comments
 (0)