debian-mirror-gitlab/spec/services/feature_flags/hook_service_spec.rb

32 lines
1,006 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe FeatureFlags::HookService do
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) }
describe 'HOOK_NAME' do
specify { expect(described_class::HOOK_NAME).to eq(:feature_flag_hooks) }
end
before do
allow(Gitlab::DataBuilder::FeatureFlag).to receive(:build).with(feature_flag, user).once.and_return(hook_data)
end
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