2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe ServicesHelper do
|
|
|
|
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-11-24 15:15:51 +05:30
|
|
|
:inherit_from_id,
|
|
|
|
:integration_level
|
2020-07-28 23:09:34 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
describe '#scoped_reset_integration_path' do
|
|
|
|
let(:integration) { build_stubbed(:jira_service) }
|
|
|
|
let(:group) { nil }
|
|
|
|
|
|
|
|
subject { helper.scoped_reset_integration_path(integration, group: group) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
context 'when no group is present' do
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'returns instance-level path' do
|
|
|
|
is_expected.to eq(reset_admin_application_settings_integration_path(integration))
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when group is present' do
|
|
|
|
let(:group) { build_stubbed(:group) }
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'returns group-level path' do
|
|
|
|
is_expected.to eq(reset_group_settings_integration_path(group, integration))
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#reset_integration?' do
|
|
|
|
let(:group) { nil }
|
|
|
|
|
|
|
|
subject { helper.reset_integration?(integration, group: group) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
context 'when integration is existing record' do
|
|
|
|
let_it_be(:integration) { create(:jira_service) }
|
|
|
|
|
|
|
|
context 'when `reset_integrations` is not enabled' do
|
2020-11-24 15:15:51 +05:30
|
|
|
it 'returns false' do
|
2021-02-22 17:27:13 +05:30
|
|
|
stub_feature_flags(reset_integrations: false)
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
is_expected.to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
context 'when `reset_integrations` is enabled' do
|
|
|
|
it 'returns true' do
|
|
|
|
stub_feature_flags(reset_integrations: true)
|
|
|
|
|
|
|
|
is_expected.to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when `reset_integrations` is enabled for a group' do
|
|
|
|
let(:group) { build_stubbed(:group) }
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
it 'returns true' do
|
2021-02-22 17:27:13 +05:30
|
|
|
stub_feature_flags(reset_integrations: group)
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
is_expected.to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
context 'when integration is a new record' do
|
|
|
|
let_it_be(:integration) { build(:jira_service) }
|
|
|
|
|
|
|
|
context 'when `reset_integrations` is enabled' do
|
|
|
|
it 'returns false' do
|
|
|
|
stub_feature_flags(reset_integrations: true)
|
|
|
|
|
|
|
|
is_expected.to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|