diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 18:26:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 18:26:46 +0000 |
commit | 5509e479900ee537980a126287c20327c41a61d6 (patch) | |
tree | 8272f06bd58b1518eca38975f95656ffc5497bd2 /spec/support/helpers | |
parent | e0529f76a36026dc4bd51fbec1e5c52e7f3866e1 (diff) | |
download | gitlab-ce-5509e479900ee537980a126287c20327c41a61d6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/database/inject_failure_helpers.rb | 41 | ||||
-rw-r--r-- | spec/support/helpers/filtered_search_helpers.rb | 2 |
2 files changed, 42 insertions, 1 deletions
diff --git a/spec/support/helpers/database/inject_failure_helpers.rb b/spec/support/helpers/database/inject_failure_helpers.rb new file mode 100644 index 00000000000..df98f45e69f --- /dev/null +++ b/spec/support/helpers/database/inject_failure_helpers.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Database + module InjectFailureHelpers + # These methods are used by specs that inject faults into the migration procedure and then ensure + # that it migrates correctly when rerun + def fail_first_time + # We can't directly use a boolean here, as we need something that will be passed by-reference to the proc + fault_status = { faulted: false } + proc do |m, *args, **kwargs| + next m.call(*args, **kwargs) if fault_status[:faulted] + + fault_status[:faulted] = true + raise 'fault!' + end + end + + def fail_sql_matching(regex) + proc do + allow(migration_context.connection).to receive(:execute).and_call_original + allow(migration_context.connection).to receive(:execute).with(regex).and_wrap_original(&fail_first_time) + end + end + + def fail_adding_fk(from_table, to_table) + proc do + allow(migration_context.connection).to receive(:add_foreign_key).and_call_original + expect(migration_context.connection).to receive(:add_foreign_key).with(from_table, to_table, any_args) + .and_wrap_original(&fail_first_time) + end + end + + def fail_removing_fk(from_table, to_table) + proc do + allow(migration_context.connection).to receive(:remove_foreign_key).and_call_original + expect(migration_context.connection).to receive(:remove_foreign_key).with(from_table, to_table, any_args) + .and_wrap_original(&fail_first_time) + end + end + end +end diff --git a/spec/support/helpers/filtered_search_helpers.rb b/spec/support/helpers/filtered_search_helpers.rb index ecc749b1e45..60638eb06cd 100644 --- a/spec/support/helpers/filtered_search_helpers.rb +++ b/spec/support/helpers/filtered_search_helpers.rb @@ -213,7 +213,7 @@ module FilteredSearchHelpers def submit_search_term(value) click_filtered_search_bar - send_keys(value, :enter) + send_keys(value, :enter, :enter) end def click_filtered_search_bar |