Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/models/operations
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/operations')
-rw-r--r--spec/models/operations/feature_flag_spec.rb34
-rw-r--r--spec/models/operations/feature_flags/user_list_spec.rb19
2 files changed, 53 insertions, 0 deletions
diff --git a/spec/models/operations/feature_flag_spec.rb b/spec/models/operations/feature_flag_spec.rb
index b4e941f2856..93dd7d4f0bb 100644
--- a/spec/models/operations/feature_flag_spec.rb
+++ b/spec/models/operations/feature_flag_spec.rb
@@ -261,4 +261,38 @@ RSpec.describe Operations::FeatureFlag do
expect(flags.map(&:id)).to eq([feature_flag.id, feature_flag_b.id])
end
end
+
+ describe '#hook_attrs' do
+ it 'includes expected attributes' do
+ hook_attrs = {
+ id: subject.id,
+ name: subject.name,
+ description: subject.description,
+ active: subject.active
+ }
+ expect(subject.hook_attrs).to eq(hook_attrs)
+ end
+ end
+
+ describe "#execute_hooks" do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:feature_flag) { create(:operations_feature_flag, project: project) }
+
+ it 'does not execute the hook when feature_flag event is disabled' do
+ create(:project_hook, project: project, feature_flag_events: false)
+ expect(WebHookWorker).not_to receive(:perform_async)
+
+ feature_flag.execute_hooks(user)
+ feature_flag.touch
+ end
+
+ it 'executes hook when feature_flag event is enabled' do
+ hook = create(:project_hook, project: project, feature_flag_events: true)
+ expect(WebHookWorker).to receive(:perform_async).with(hook.id, an_instance_of(Hash), 'feature_flag_hooks')
+
+ feature_flag.execute_hooks(user)
+ feature_flag.touch
+ end
+ end
end
diff --git a/spec/models/operations/feature_flags/user_list_spec.rb b/spec/models/operations/feature_flags/user_list_spec.rb
index 020416aa7bc..3a48d3389a3 100644
--- a/spec/models/operations/feature_flags/user_list_spec.rb
+++ b/spec/models/operations/feature_flags/user_list_spec.rb
@@ -92,6 +92,25 @@ RSpec.describe Operations::FeatureFlags::UserList do
end
end
+ describe '.for_name_like' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user_list_one) { create(:operations_feature_flag_user_list, project: project, name: 'one') }
+ let_it_be(:user_list_two) { create(:operations_feature_flag_user_list, project: project, name: 'list_two') }
+ let_it_be(:user_list_three) { create(:operations_feature_flag_user_list, project: project, name: 'list_three') }
+
+ it 'returns a found name' do
+ lists = project.operations_feature_flags_user_lists.for_name_like('list')
+
+ expect(lists).to contain_exactly(user_list_two, user_list_three)
+ end
+
+ it 'returns an empty array when no lists match the query' do
+ lists = project.operations_feature_flags_user_lists.for_name_like('no match')
+
+ expect(lists).to be_empty
+ end
+ end
+
it_behaves_like 'AtomicInternalId' do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:operations_feature_flag_user_list) }