Commit 2825932b authored by Justin Ho's avatar Justin Ho

Fix feature specs around project integrations

- With https://gitlab.com/gitlab-org/gitlab/merge_requests/23009,
new services are active by default. Thus, we do not
need to manually activate them.
- Specs now need to execute with the `:js` option to
enable the active toggle
- Extract common spec functionality to a shared
context to DRY up code
parent 964f191d
......@@ -3,17 +3,11 @@
require 'spec_helper'
describe 'User activates GitHub Service' do
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
end
include_context 'project service activation'
context 'without a license' do
it "is excluded from the integrations index" do
visit project_settings_integrations_path(project)
visit_project_integrations
expect(page).not_to have_link('GitHub')
end
......@@ -25,18 +19,16 @@ describe 'User activates GitHub Service' do
end
end
context 'with valid license' do
context 'with valid license', :js do
before do
stub_licensed_features(github_project_service_integration: true)
visit project_settings_integrations_path(project)
visit_project_integration('GitHub')
click_link('GitHub')
fill_in_details
end
def fill_in_details
check('Active')
fill_in "Token", with: "aaaaaaaaaa"
fill_in "Repository URL", with: 'https://github.com/h5bp/html5-boilerplate'
end
......
......@@ -3,23 +3,14 @@
require 'spec_helper'
describe 'User activates Asana' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Asana')
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Asana')
fill_in('Api key', with: 'verySecret')
fill_in('Restrict to branch', with: 'verySecret')
click_button('Save')
click_test_then_save_integration
expect(page).to have_content('Asana activated.')
end
......
......@@ -3,22 +3,17 @@
require 'spec_helper'
describe 'User activates Assembla' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Assembla')
stub_request(:post, /.*atlas.assembla.com.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Assembla')
fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('Assembla activated.')
end
......
......@@ -3,31 +3,26 @@
require 'spec_helper'
describe 'User activates Atlassian Bamboo CI' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Atlassian Bamboo CI')
stub_request(:get, /.*bamboo.example.com.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Atlassian Bamboo CI')
fill_in('Bamboo url', with: 'http://bamboo.example.com')
fill_in('Build key', with: 'KEY')
fill_in('Username', with: 'user')
fill_in('Password', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('Atlassian Bamboo CI activated.')
# Password field should not be filled in.
click_link('Atlassian Bamboo CI')
expect(find_field('Enter new password').value).to be_nil
expect(find_field('Enter new password').value).to be_blank
end
end
......@@ -3,22 +3,13 @@
require 'spec_helper'
describe 'User activates Emails on push' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Emails on push')
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Emails on push')
fill_in('Recipients', with: 'qa@company.name')
click_button('Save')
click_test_integration
expect(page).to have_content('Emails on push activated.')
end
......
......@@ -3,22 +3,18 @@
require 'spec_helper'
describe 'User activates Flowdock' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
let(:project) { create(:project, :repository) }
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Flowdock')
stub_request(:post, /.*api.flowdock.com.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Flowdock')
fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('Flowdock activated.')
end
......
......@@ -2,37 +2,37 @@
require 'spec_helper'
describe 'User activates HipChat' do
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('HipChat')
end
describe 'User activates HipChat', :js do
include_context 'project service activation'
context 'with standart settings' do
before do
stub_request(:post, /.*api.hipchat.com.*/)
end
it 'activates service' do
check('Active')
visit_project_integration('HipChat')
fill_in('Room', with: 'gitlab')
fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('HipChat activated.')
end
end
context 'with custom settings' do
before do
stub_request(:post, /.*chat.example.com.*/)
end
it 'activates service' do
check('Active')
visit_project_integration('HipChat')
fill_in('Room', with: 'gitlab_custom')
fill_in('Token', with: 'secretCustom')
fill_in('Server', with: 'https://chat.example.com')
click_button('Save')
click_test_integration
expect(page).to have_content('HipChat activated.')
end
......
......@@ -3,23 +3,14 @@
require 'spec_helper'
describe 'User activates Irker (IRC gateway)' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Irker (IRC gateway)')
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Irker (IRC gateway)')
check('Colorize messages')
fill_in('Recipients', with: 'irc://chat.freenode.net/#commits')
click_button('Save')
click_test_integration
expect(page).to have_content('Irker (IRC gateway) activated.')
end
......
......@@ -3,27 +3,22 @@
require 'spec_helper'
describe 'User activates JetBrains TeamCity CI' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('JetBrains TeamCity CI')
stub_request(:post, /.*teamcity.example.com.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('JetBrains TeamCity CI')
check('Push')
check('Merge request')
fill_in('Teamcity url', with: 'http://teamcity.example.com')
fill_in('Build type', with: 'GitlabTest_Build')
fill_in('Username', with: 'user')
fill_in('Password', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('JetBrains TeamCity CI activated.')
end
......
......@@ -3,23 +3,18 @@
require 'spec_helper'
describe 'User activates Packagist' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Packagist')
stub_request(:post, /.*packagist.org.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Packagist')
fill_in('Username', with: 'theUser')
fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_then_save_integration
expect(page).to have_content('Packagist activated.')
end
......
......@@ -3,22 +3,17 @@
require 'spec_helper'
describe 'User activates PivotalTracker' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('PivotalTracker')
stub_request(:post, /.*www.pivotaltracker.com.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('PivotalTracker')
fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('PivotalTracker activated.')
end
......
......@@ -3,21 +3,17 @@
require 'spec_helper'
describe 'User activates Prometheus' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Prometheus')
stub_request(:get, /.*prometheus.example.com.*/)
end
it 'does not activate service and informs about deprecation' do
it 'does not activate service and informs about deprecation', :js do
visit_project_integration('Prometheus')
check('Active')
fill_in('API URL', with: 'http://prometheus.example.com')
click_button('Save changes')
expect(page).not_to have_content('Prometheus activated.')
......
......@@ -3,26 +3,21 @@
require 'spec_helper'
describe 'User activates Pushover' do
let(:project) { create(:project) }
let(:user) { create(:user) }
include_context 'project service activation'
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Pushover')
stub_request(:post, /.*api.pushover.net.*/)
end
it 'activates service' do
check('Active')
it 'activates service', :js do
visit_project_integration('Pushover')
fill_in('Api key', with: 'verySecret')
fill_in('User key', with: 'verySecret')
fill_in('Device', with: 'myDevice')
select('High Priority', from: 'Priority')
select('Bike', from: 'Sound')
click_button('Save')
click_test_integration
expect(page).to have_content('Pushover activated.')
end
......
......@@ -3,32 +3,26 @@
require 'spec_helper'
describe 'User activates Slack notifications' do
let(:user) { create(:user) }
let(:service) { SlackService.new }
let(:project) { create(:project, slack_service: service) }
before do
project.add_maintainer(user)
sign_in(user)
end
include_context 'project service activation'
context 'when service is not configured yet' do
before do
visit(project_settings_integrations_path(project))
click_link('Slack notifications')
visit_project_integration('Slack notifications')
end
it 'activates service' do
check('Active')
it 'activates service', :js do
fill_in('Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685')
click_button('Save')
click_test_then_save_integration
expect(page).to have_content('Slack notifications activated.')
end
end
context 'when service is already configured' do
let(:service) { SlackService.new }
let(:project) { create(:project, slack_service: service) }
before do
service.fields
service.update(
......
......@@ -3,17 +3,11 @@
require 'spec_helper'
describe 'User views services' do
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
end
include_context 'project service activation'
it 'shows the list of available services' do
visit_project_integrations
expect(page).to have_content('Integrations')
expect(page).to have_content('Campfire')
expect(page).to have_content('HipChat')
......
# frozen_string_literal: true
shared_context 'project service activation' do
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
def click_test_integration
click_button('Test settings and save changes')
end
def click_test_then_save_integration
click_test_integration
expect(page).to have_content('Test failed.')
click_link('Save anyway')
end
end
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