Commit 3b382796 authored by Dylan Griffith's avatar Dylan Griffith Committed by Adam Hegyi

Refactor specs prevent_cross_database_modification_spec

Some time ago we made all specs default to preventing cross database
modification. Thus the `prevent_cross_database_modification` tag was
unecessary. This meant slightly re-organising the tests and removing 1
redundant test and re-writing one test slightly since it wasn't covered
elsewhere.
parent b308ccc3
......@@ -57,31 +57,6 @@ RSpec.describe 'Database::PreventCrossDatabaseModification' do
include_examples 'successful examples'
end
describe 'with_cross_database_modification_prevented block' do
it 'raises error when CI and other data is modified' do
expect do
with_cross_database_modification_prevented do
Project.transaction do
project.touch
pipeline.touch
end
end
end.to raise_error /Cross-database data modification/
end
it 'raises an error when an undefined gitlab_schema table is modified with another table' do
expect do
with_cross_database_modification_prevented do
Project.transaction do
project.touch
project.connection.execute('UPDATE foo_bars_undefined_table SET a=1 WHERE id = -1')
end
end
end.to raise_error /Cross-database data modification.*The gitlab_schema was undefined/
end
end
context 'when running tests with prevent_cross_database_modification', :prevent_cross_database_modification do
context 'when both CI and other data is modified' do
def run_queries
project.touch
......@@ -137,7 +112,6 @@ RSpec.describe 'Database::PreventCrossDatabaseModification' do
end
end
end
end
context 'when CI association is modified through project' do
def run_queries
......@@ -171,4 +145,15 @@ RSpec.describe 'Database::PreventCrossDatabaseModification' do
end
end
end
context 'when some table with a defined schema and another table with undefined gitlab_schema is modified' do
it 'raises an error including including message about undefined schema' do
expect do
Project.transaction do
project.touch
project.connection.execute('UPDATE foo_bars_undefined_table SET a=1 WHERE id = -1')
end
end.to raise_error /Cross-database data modification.*The gitlab_schema was undefined/
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