debian-mirror-gitlab/spec/serializers/service_event_entity_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.3 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ServiceEventEntity do
2020-05-24 23:13:21 +05:30
let(:request) { double('request') }
2021-09-04 01:27:46 +05:30
subject { described_class.new(event, request: request, service: integration).as_json }
2020-05-24 23:13:21 +05:30
before do
2021-09-04 01:27:46 +05:30
allow(request).to receive(:service).and_return(integration)
2020-05-24 23:13:21 +05:30
end
describe '#as_json' do
2021-09-30 23:02:18 +05:30
context 'integration without fields' do
2021-09-04 01:27:46 +05:30
let(:integration) { create(:emails_on_push_integration, push_events: true) }
2020-05-24 23:13:21 +05:30
let(:event) { 'push' }
it 'exposes correct attributes' do
2021-04-29 21:17:54 +05:30
expect(subject[:description]).to eq('Trigger event for pushes to the repository.')
2020-05-24 23:13:21 +05:30
expect(subject[:name]).to eq('push_events')
2022-05-07 20:08:51 +05:30
expect(subject[:title]).to eq('Push')
2020-05-24 23:13:21 +05:30
expect(subject[:value]).to be(true)
end
end
2021-09-30 23:02:18 +05:30
context 'integration with fields' do
let(:integration) { create(:integrations_slack, note_events: false, note_channel: 'note-channel') }
2020-05-24 23:13:21 +05:30
let(:event) { 'note' }
it 'exposes correct attributes' do
2021-04-29 21:17:54 +05:30
expect(subject[:description]).to eq('Trigger event for new comments.')
2020-05-24 23:13:21 +05:30
expect(subject[:name]).to eq('note_events')
2022-05-07 20:08:51 +05:30
expect(subject[:title]).to eq('Note')
2020-05-24 23:13:21 +05:30
expect(subject[:value]).to eq(false)
expect(subject[:field][:name]).to eq('note_channel')
expect(subject[:field][:value]).to eq('note-channel')
end
end
end
end