diff options
Diffstat (limited to 'spec/services/test_hooks/project_service_spec.rb')
-rw-r--r-- | spec/services/test_hooks/project_service_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/services/test_hooks/project_service_spec.rb b/spec/services/test_hooks/project_service_spec.rb index 31f97edbd08..35c827d5448 100644 --- a/spec/services/test_hooks/project_service_spec.rb +++ b/spec/services/test_hooks/project_service_spec.rb @@ -207,5 +207,26 @@ RSpec.describe TestHooks::ProjectService, feature_category: :code_testing do expect(service.execute).to include(success_result) end end + + context 'emoji' do + let(:trigger) { 'emoji_events' } + let(:trigger_key) { :emoji_hooks } + + it 'returns error message if not enough data' do + expect(hook).not_to receive(:execute) + expect(service.execute).to have_attributes(status: :error, message: 'Ensure the project has notes.') + end + + it 'executes hook' do + note = create(:note) + allow(project).to receive_message_chain(:notes, :any?).and_return(true) + allow(project).to receive_message_chain(:notes, :last).and_return(note) + allow(Gitlab::DataBuilder::Emoji).to receive(:build).with(anything, current_user, 'award') + .and_return(sample_data) + + expect(hook).to receive(:execute).with(sample_data, trigger_key, force: true).and_return(success_result) + expect(service.execute).to include(success_result) + end + end end end |