Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 9a1b400

Browse files
grosserbquorning
authored andcommitted
Fix tests
1 parent ce0a859 commit 9a1b400

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

test/migrator_test.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
44
describe ActiveRecord::Migrator do
55
with_phenix
66

7+
before { ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) }
8+
79
it "migrates" do
810
migration_path = File.join(File.dirname(__FILE__), "/migrations")
11+
12+
refute ActiveRecord::Base.current_shard_id
913
ActiveRecord::Migrator.migrate(migration_path)
14+
1015
ActiveRecord::Base.on_all_shards do
1116
assert ActiveRecord::Base.connection.public_send(connection_exist_method, :schema_migrations), "Schema Migrations doesn't exist"
12-
assert ActiveRecord::Base.connection.public_send(connection_exist_method, :accounts)
17+
assert ActiveRecord::Base.connection.public_send(connection_exist_method, :tickets)
18+
refute ActiveRecord::Base.connection.public_send(connection_exist_method, :accounts)
1319
assert ActiveRecord::Base.connection.select_value("select version from schema_migrations where version = '20110824010216'")
1420
assert ActiveRecord::Base.connection.select_value("select version from schema_migrations where version = '20110829215912'")
1521
end
1622

1723
ActiveRecord::Base.on_all_shards do
1824
assert table_has_column?("tickets", "sharded_column")
19-
assert !table_has_column?("accounts", "non_sharded_column")
2025
end
2126

2227
ActiveRecord::Base.on_shard(nil) do
23-
assert !table_has_column?("tickets", "sharded_column")
2428
assert table_has_column?("accounts", "non_sharded_column")
2529
end
2630

test/schema_dumper_extension_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
with_phenix
1010

1111
before do
12+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
13+
1214
# create shard-specific columns
1315
ActiveRecord::Migrator.migrations_paths = [File.join(File.dirname(__FILE__), "/migrations")]
1416
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths)
@@ -25,18 +27,15 @@
2527

2628
ActiveRecord::Base.on_all_shards do
2729
assert ActiveRecord::Base.connection.public_send(connection_exist_method, :schema_migrations), "Schema Migrations doesn't exist"
28-
assert ActiveRecord::Base.connection.public_send(connection_exist_method, :accounts)
2930
assert ActiveRecord::Base.connection.select_value("select version from schema_migrations where version = '20110824010216'")
3031
assert ActiveRecord::Base.connection.select_value("select version from schema_migrations where version = '20110829215912'")
3132
end
3233

3334
ActiveRecord::Base.on_all_shards do
3435
assert table_has_column?("tickets", "sharded_column")
35-
assert !table_has_column?("accounts", "non_sharded_column")
3636
end
3737

3838
ActiveRecord::Base.on_shard(nil) do
39-
assert !table_has_column?("tickets", "sharded_column")
4039
assert table_has_column?("accounts", "non_sharded_column")
4140
end
4241
end

0 commit comments

Comments
 (0)