Commit 44d218ee authored by Simon Tomlinson's avatar Simon Tomlinson Committed by Andreas Brandl

Improve subject name in partition_manager_spec

parent 4323b1c3
...@@ -16,7 +16,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -16,7 +16,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
end end
context 'creating partitions (mocked)' do context 'creating partitions (mocked)' do
subject { described_class.new(models).sync_partitions } subject(:sync_partitions) { described_class.new(models).sync_partitions }
let(:models) { [model] } let(:models) { [model] }
let(:model) { double(partitioning_strategy: partitioning_strategy, table_name: table) } let(:model) { double(partitioning_strategy: partitioning_strategy, table_name: table) }
...@@ -42,7 +42,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -42,7 +42,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.first.to_sql) expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.first.to_sql)
expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.second.to_sql) expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.second.to_sql)
subject sync_partitions
end end
context 'error handling with 2 models' do context 'error handling with 2 models' do
...@@ -61,13 +61,13 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -61,13 +61,13 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.first.to_sql) expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.first.to_sql)
expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.second.to_sql) expect(ActiveRecord::Base.connection).to receive(:execute).with(partitions.second.to_sql)
subject sync_partitions
end end
end end
end end
context 'creating partitions' do context 'creating partitions' do
subject { described_class.new([my_model]).sync_partitions } subject(:sync_partitions) { described_class.new([my_model]).sync_partitions }
let(:connection) { ActiveRecord::Base.connection } let(:connection) { ActiveRecord::Base.connection }
let(:my_model) do let(:my_model) do
...@@ -89,14 +89,12 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -89,14 +89,12 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
end end
it 'creates partitions' do it 'creates partitions' do
expect { subject }.to change { find_partitions(my_model.table_name, schema: Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA).size }.from(0) expect { sync_partitions }.to change { find_partitions(my_model.table_name, schema: Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA).size }.from(0)
subject
end end
end end
context 'detaching partitions (mocked)' do context 'detaching partitions (mocked)' do
subject { manager.sync_partitions } subject(:sync_partitions) { manager.sync_partitions }
let(:manager) { described_class.new(models) } let(:manager) { described_class.new(models) }
let(:models) { [model] } let(:models) { [model] }
...@@ -125,7 +123,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -125,7 +123,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
it 'detaches each extra partition' do it 'detaches each extra partition' do
extra_partitions.each { |p| expect(manager).to receive(:detach_one_partition).with(p) } extra_partitions.each { |p| expect(manager).to receive(:detach_one_partition).with(p) }
subject sync_partitions
end end
context 'error handling' do context 'error handling' do
...@@ -142,7 +140,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -142,7 +140,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
expect(error_strategy).to receive(:extra_partitions).and_raise('injected error!') expect(error_strategy).to receive(:extra_partitions).and_raise('injected error!')
extra_partitions.each { |p| expect(manager).to receive(:detach_one_partition).with(p) } extra_partitions.each { |p| expect(manager).to receive(:detach_one_partition).with(p) }
subject sync_partitions
end end
end end
end end
...@@ -154,7 +152,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do ...@@ -154,7 +152,7 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
it 'returns immediately' do it 'returns immediately' do
expect(manager).not_to receive(:detach) expect(manager).not_to receive(:detach)
subject sync_partitions
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment