2019-11-26 07:06:18 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe ServicesHelper do
|
2020-07-16 23:09:14 -04:00
|
|
|
describe '#integration_form_data' do
|
|
|
|
subject { helper.integration_form_data(integration) }
|
|
|
|
|
|
|
|
context 'Jira service' do
|
|
|
|
let(:integration) { build(:jira_service) }
|
|
|
|
|
|
|
|
it 'includes Jira specific fields' do
|
|
|
|
is_expected.to include(
|
|
|
|
:id,
|
|
|
|
:show_active,
|
|
|
|
:activated,
|
|
|
|
:type,
|
|
|
|
:merge_request_events,
|
|
|
|
:commit_events,
|
|
|
|
:enable_comments,
|
|
|
|
:comment_detail,
|
|
|
|
:trigger_events,
|
|
|
|
:fields,
|
2020-09-01 08:11:01 -04:00
|
|
|
:inherit_from_id,
|
|
|
|
:integration_level
|
2020-07-16 23:09:14 -04:00
|
|
|
)
|
|
|
|
end
|
2021-01-15 01:10:42 -05:00
|
|
|
|
|
|
|
specify do
|
|
|
|
expect(subject[:reset_path]).to eq(helper.scoped_reset_integration_path(integration))
|
|
|
|
end
|
2020-07-16 23:09:14 -04:00
|
|
|
end
|
|
|
|
end
|
2020-08-24 23:10:50 -04:00
|
|
|
|
2020-12-02 19:09:53 -05:00
|
|
|
describe '#scoped_reset_integration_path' do
|
|
|
|
let(:integration) { build_stubbed(:jira_service) }
|
|
|
|
let(:group) { nil }
|
|
|
|
|
|
|
|
subject { helper.scoped_reset_integration_path(integration, group: group) }
|
|
|
|
|
|
|
|
context 'when no group is present' do
|
|
|
|
it 'returns instance-level path' do
|
|
|
|
is_expected.to eq(reset_admin_application_settings_integration_path(integration))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when group is present' do
|
|
|
|
let(:group) { build_stubbed(:group) }
|
|
|
|
|
|
|
|
it 'returns group-level path' do
|
|
|
|
is_expected.to eq(reset_group_settings_integration_path(group, integration))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-15 01:10:42 -05:00
|
|
|
context 'when a new integration is not persisted' do
|
2020-12-11 16:10:13 -05:00
|
|
|
let_it_be(:integration) { build(:jira_service) }
|
2020-12-02 19:09:53 -05:00
|
|
|
|
2021-01-15 01:10:42 -05:00
|
|
|
it 'returns an empty string' do
|
|
|
|
is_expected.to eq('')
|
2020-12-02 19:09:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-11-26 07:06:18 -05:00
|
|
|
end
|