2020-04-06 09:09:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-24 15:08:50 +00:00
|
|
|
RSpec.shared_context 'project service activation' do
|
2020-04-06 09:09:17 +00:00
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_project_integrations
|
|
|
|
visit project_settings_integrations_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_project_integration(name)
|
|
|
|
visit_project_integrations
|
|
|
|
click_link(name)
|
|
|
|
end
|
|
|
|
|
2020-08-24 12:10:17 +00:00
|
|
|
def click_active_checkbox
|
|
|
|
find('input[name="service[active]"]').click
|
2020-04-22 09:09:36 +00:00
|
|
|
end
|
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
def click_save_integration
|
|
|
|
click_button('Save changes')
|
|
|
|
end
|
|
|
|
|
2020-04-06 09:09:17 +00:00
|
|
|
def click_test_integration
|
2020-09-15 18:09:43 +00:00
|
|
|
click_link('Test settings')
|
2020-04-06 09:09:17 +00:00
|
|
|
end
|
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
def click_test_then_save_integration(expect_test_to_fail: true)
|
2020-04-06 09:09:17 +00:00
|
|
|
click_test_integration
|
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
if expect_test_to_fail
|
|
|
|
expect(page).to have_content('Connection failed.')
|
|
|
|
else
|
|
|
|
expect(page).to have_content('Connection successful.')
|
|
|
|
end
|
2020-04-06 09:09:17 +00:00
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
click_save_integration
|
2020-04-06 09:09:17 +00:00
|
|
|
end
|
|
|
|
end
|