File tree Expand file tree Collapse file tree 4 files changed +15
-17
lines changed Expand file tree Collapse file tree 4 files changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -22,23 +22,26 @@ def setup
22
22
23
23
@connection = ActiveRecord ::Base . connection
24
24
25
- @old_schema_migration_table_name = ActiveRecord ::SchemaMigration . table_name
26
25
@old_table_name_prefix = ActiveRecord ::Base . table_name_prefix
27
26
@old_table_name_suffix = ActiveRecord ::Base . table_name_suffix
28
27
29
28
ActiveRecord ::Base . table_name_prefix = "p_"
30
29
ActiveRecord ::Base . table_name_suffix = "_s"
30
+ ActiveRecord ::SchemaMigration . reset_table_name
31
+ ActiveRecord ::InternalMetadata . reset_table_name
32
+
31
33
ActiveRecord ::SchemaMigration . delete_all rescue nil
32
- ActiveRecord ::SchemaMigration . table_name = "p_schema_migrations_s"
33
34
ActiveRecord ::Migration . verbose = false
34
35
end
35
36
36
37
def teardown
37
- ActiveRecord ::Base . table_name_prefix = @old_table_name_prefix
38
- ActiveRecord ::Base . table_name_suffix = @old_table_name_suffix
39
38
ActiveRecord ::SchemaMigration . delete_all rescue nil
40
39
ActiveRecord ::Migration . verbose = true
41
- ActiveRecord ::SchemaMigration . table_name = @old_schema_migration_table_name
40
+
41
+ ActiveRecord ::Base . table_name_prefix = @old_table_name_prefix
42
+ ActiveRecord ::Base . table_name_suffix = @old_table_name_suffix
43
+ ActiveRecord ::SchemaMigration . reset_table_name
44
+ ActiveRecord ::InternalMetadata . reset_table_name
42
45
43
46
super
44
47
end
Original file line number Diff line number Diff line change @@ -51,11 +51,11 @@ def test_schema_define
51
51
assert_equal 7 , @connection . migration_context . current_version
52
52
end
53
53
54
- def test_schema_define_w_table_name_prefix
55
- table_name = ActiveRecord ::SchemaMigration . table_name
54
+ def test_schema_define_with_table_name_prefix
56
55
old_table_name_prefix = ActiveRecord ::Base . table_name_prefix
57
56
ActiveRecord ::Base . table_name_prefix = "nep_"
58
- ActiveRecord ::SchemaMigration . table_name = "nep_#{ table_name } "
57
+ ActiveRecord ::SchemaMigration . reset_table_name
58
+ ActiveRecord ::InternalMetadata . reset_table_name
59
59
ActiveRecord ::Schema . define ( version : 7 ) do
60
60
create_table :fruits do |t |
61
61
t . column :color , :string
@@ -67,7 +67,8 @@ def test_schema_define_w_table_name_prefix
67
67
assert_equal 7 , @connection . migration_context . current_version
68
68
ensure
69
69
ActiveRecord ::Base . table_name_prefix = old_table_name_prefix
70
- ActiveRecord ::SchemaMigration . table_name = table_name
70
+ ActiveRecord ::SchemaMigration . reset_table_name
71
+ ActiveRecord ::InternalMetadata . reset_table_name
71
72
end
72
73
73
74
def test_schema_raises_an_error_for_invalid_column_type
Original file line number Diff line number Diff line change @@ -385,6 +385,7 @@ def test_schema_migrations_table_name
385
385
assert_equal "changed" , ActiveRecord ::SchemaMigration . table_name
386
386
ensure
387
387
ActiveRecord ::Base . schema_migrations_table_name = original_schema_migrations_table_name
388
+ ActiveRecord ::SchemaMigration . reset_table_name
388
389
Reminder . reset_table_name
389
390
end
390
391
@@ -405,6 +406,7 @@ def test_internal_metadata_table_name
405
406
assert_equal "changed" , ActiveRecord ::InternalMetadata . table_name
406
407
ensure
407
408
ActiveRecord ::Base . internal_metadata_table_name = original_internal_metadata_table_name
409
+ ActiveRecord ::InternalMetadata . reset_table_name
408
410
Reminder . reset_table_name
409
411
end
410
412
Original file line number Diff line number Diff line change @@ -1001,18 +1001,14 @@ class DatabaseTasksTruncateAllWithPrefixTest < DatabaseTasksTruncateAllTest
1001
1001
ActiveRecord ::Base . table_name_prefix = "p_"
1002
1002
1003
1003
SchemaMigration . reset_table_name
1004
- SchemaMigration . reset_column_information
1005
1004
InternalMetadata . reset_table_name
1006
- InternalMetadata . reset_column_information
1007
1005
end
1008
1006
1009
1007
teardown do
1010
1008
ActiveRecord ::Base . table_name_prefix = nil
1011
1009
1012
1010
SchemaMigration . reset_table_name
1013
- SchemaMigration . reset_column_information
1014
1011
InternalMetadata . reset_table_name
1015
- InternalMetadata . reset_column_information
1016
1012
end
1017
1013
end
1018
1014
@@ -1021,18 +1017,14 @@ class DatabaseTasksTruncateAllWithSuffixTest < DatabaseTasksTruncateAllTest
1021
1017
ActiveRecord ::Base . table_name_suffix = "_s"
1022
1018
1023
1019
SchemaMigration . reset_table_name
1024
- SchemaMigration . reset_column_information
1025
1020
InternalMetadata . reset_table_name
1026
- InternalMetadata . reset_column_information
1027
1021
end
1028
1022
1029
1023
teardown do
1030
1024
ActiveRecord ::Base . table_name_suffix = nil
1031
1025
1032
1026
SchemaMigration . reset_table_name
1033
- SchemaMigration . reset_column_information
1034
1027
InternalMetadata . reset_table_name
1035
- InternalMetadata . reset_column_information
1036
1028
end
1037
1029
end
1038
1030
end
You can’t perform that action at this time.
0 commit comments