Commit a4f5e481 authored by Sean Gregory's avatar Sean Gregory Committed by Luke Duncalfe

Refactor examples to use scoped integrations

This change changes the examples to use a list of integrations
scoped to the context in which they are generated vs a hard coded
list.
parent 3312e2b3
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Instance integrations', :js do
include_context 'instance integration activation'
it_behaves_like 'integration settings form' do
let(:integrations) { Integration.find_or_initialize_all_non_project_specific(Integration.for_instance) }
def navigate_to_integration(integration)
visit_instance_integration(integration.title)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Group integrations', :js do
include_context 'group integration activation'
it_behaves_like 'integration settings form' do
let(:integrations) { Integration.find_or_initialize_all_non_project_specific(Integration.for_group(group)) }
def navigate_to_integration(integration)
visit_group_integration(integration.title)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Project integrations', :js do
include_context 'project integration activation'
it_behaves_like 'integration settings form' do
let(:integrations) { project.find_or_initialize_integrations }
def navigate_to_integration(integration)
visit_project_integration(integration.title)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Integrations settings form', :js do
RSpec.shared_examples 'integration settings form' do
include IntegrationsHelper
include_context 'project integration activation'
# Github integration is EE, so let's remove it here.
integration_names = Integration.available_integration_names - %w[github]
integrations = integration_names.map do |name|
Integration.integration_name_to_model(name).new
end
# Note: these specs don't validate channel fields
# which are present on a few integrations
integrations.each do |integration|
it "shows on #{integration.title}" do
visit_project_integration(integration.title)
it 'displays all the integrations' do
aggregate_failures do
integrations.each do |integration|
navigate_to_integration(integration)
aggregate_failures do
page.within('form.integration-settings-form') do
expect(page).to have_field('Active', type: 'checkbox', wait: 0),
"#{integration.title} active field not present"
......@@ -43,6 +33,8 @@ RSpec.describe 'Integrations settings form', :js do
end
end
private
def normalize_title(title, integration)
return 'Merge request' if integration.is_a?(Integrations::Jira) && title == 'merge_request'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment