debian-mirror-gitlab/spec/serializers/integrations/event_entity_spec.rb

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

42 lines
1.4 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-07-23 23:45:48 +05:30
RSpec.describe Integrations::EventEntity do
let(:request) { EntityRequest.new(integration: integration) }
2020-05-24 23:13:21 +05:30
2022-07-23 23:45:48 +05:30
subject { described_class.new(event, request: request, integration: integration).as_json }
2020-05-24 23:13:21 +05:30
before do
2022-07-23 23:45:48 +05:30
allow(request).to receive(:integration).and_return(integration)
2020-05-24 23:13:21 +05:30
end
describe '#as_json' do
2022-07-23 23:45:48 +05:30
context 'with 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
2022-07-23 23:45:48 +05:30
context 'with integration with fields' do
2021-09-30 23:02:18 +05:30
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