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

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
context 'service 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')
expect(subject[:title]).to eq('push')
expect(subject[:value]).to be(true)
end
end
context 'service with fields' do
2021-09-04 01:27:46 +05:30
let(:integration) { create(:slack_service, 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')
expect(subject[:title]).to eq('note')
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