2021-11-18 22:05:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe FeatureFlags::HookService, feature_category: :feature_flags do
|
2021-11-18 22:05:49 +05:30
|
|
|
describe '#execute_hooks' do
|
|
|
|
let_it_be(:namespace) { create(:namespace) }
|
|
|
|
let_it_be(:project) { create(:project, :repository, namespace: namespace) }
|
|
|
|
let_it_be(:feature_flag) { create(:operations_feature_flag, project: project) }
|
2022-03-02 08:16:31 +05:30
|
|
|
let_it_be(:user) { namespace.first_owner }
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
let!(:hook) { create(:project_hook, project: project) }
|
|
|
|
let(:hook_data) { double }
|
|
|
|
|
|
|
|
subject(:service) { described_class.new(feature_flag, user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab::DataBuilder::FeatureFlag).to receive(:build).with(feature_flag, user).once.and_return(hook_data)
|
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
describe 'HOOK_NAME' do
|
|
|
|
specify { expect(described_class::HOOK_NAME).to eq(:feature_flag_hooks) }
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
it 'calls feature_flag.project.execute_hooks' do
|
|
|
|
expect(feature_flag.project).to receive(:execute_hooks).with(hook_data, described_class::HOOK_NAME)
|
|
|
|
|
|
|
|
service.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|