Commit ef4a23ce authored by James Lopez's avatar James Lopez

Merge branch '199882-project-integrations-active-checkbox-specs' into 'master'

Update project services feature specs to use JS

See merge request gitlab-org/gitlab!28415
parents 4dfbaebf ace728b1
...@@ -3,17 +3,11 @@ ...@@ -3,17 +3,11 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates GitHub Service' do describe 'User activates GitHub Service' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
end
context 'without a license' do context 'without a license' do
it "is excluded from the integrations index" 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') expect(page).not_to have_link('GitHub')
end end
...@@ -25,18 +19,16 @@ describe 'User activates GitHub Service' do ...@@ -25,18 +19,16 @@ describe 'User activates GitHub Service' do
end end
end end
context 'with valid license' do context 'with valid license', :js do
before do before do
stub_licensed_features(github_project_service_integration: true) stub_licensed_features(github_project_service_integration: true)
visit project_settings_integrations_path(project) visit_project_integration('GitHub')
click_link('GitHub')
fill_in_details fill_in_details
end end
def fill_in_details def fill_in_details
check('Active')
fill_in "Token", with: "aaaaaaaaaa" fill_in "Token", with: "aaaaaaaaaa"
fill_in "Repository URL", with: 'https://github.com/h5bp/html5-boilerplate' fill_in "Repository URL", with: 'https://github.com/h5bp/html5-boilerplate'
end end
......
...@@ -3,23 +3,14 @@ ...@@ -3,23 +3,14 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Asana' do describe 'User activates Asana' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do it 'activates service', :js do
project.add_maintainer(user) visit_project_integration('Asana')
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Asana')
end
it 'activates service' do
check('Active')
fill_in('Api key', with: 'verySecret') fill_in('Api key', with: 'verySecret')
fill_in('Restrict to branch', with: 'verySecret') fill_in('Restrict to branch', with: 'verySecret')
click_button('Save')
click_test_then_save_integration
expect(page).to have_content('Asana activated.') expect(page).to have_content('Asana activated.')
end end
......
...@@ -3,22 +3,17 @@ ...@@ -3,22 +3,17 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Assembla' do describe 'User activates Assembla' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:post, /.*atlas.assembla.com.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Assembla')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('Assembla')
fill_in('Token', with: 'verySecret') fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('Assembla activated.') expect(page).to have_content('Assembla activated.')
end end
......
...@@ -3,31 +3,26 @@ ...@@ -3,31 +3,26 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Atlassian Bamboo CI' do describe 'User activates Atlassian Bamboo CI' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:get, /.*bamboo.example.com.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Atlassian Bamboo CI')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('Atlassian Bamboo CI')
fill_in('Bamboo url', with: 'http://bamboo.example.com') fill_in('Bamboo url', with: 'http://bamboo.example.com')
fill_in('Build key', with: 'KEY') fill_in('Build key', with: 'KEY')
fill_in('Username', with: 'user') fill_in('Username', with: 'user')
fill_in('Password', with: 'verySecret') fill_in('Password', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('Atlassian Bamboo CI activated.') expect(page).to have_content('Atlassian Bamboo CI activated.')
# Password field should not be filled in. # Password field should not be filled in.
click_link('Atlassian Bamboo CI') 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
end end
...@@ -3,22 +3,13 @@ ...@@ -3,22 +3,13 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Emails on push' do describe 'User activates Emails on push' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do it 'activates service', :js do
project.add_maintainer(user) visit_project_integration('Emails on push')
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Emails on push')
end
it 'activates service' do
check('Active')
fill_in('Recipients', with: 'qa@company.name') fill_in('Recipients', with: 'qa@company.name')
click_button('Save')
click_test_integration
expect(page).to have_content('Emails on push activated.') expect(page).to have_content('Emails on push activated.')
end end
......
...@@ -3,22 +3,19 @@ ...@@ -3,22 +3,19 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Flowdock' do describe 'User activates Flowdock' do
let(:project) { create(:project) } include_context 'project service activation' do
let(:user) { create(:user) } let(:project) { create(:project, :repository) }
end
before do before do
project.add_maintainer(user) stub_request(:post, /.*api.flowdock.com.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Flowdock')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('Flowdock')
fill_in('Token', with: 'verySecret') fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('Flowdock activated.') expect(page).to have_content('Flowdock activated.')
end end
......
...@@ -2,37 +2,37 @@ ...@@ -2,37 +2,37 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates HipChat' do describe 'User activates HipChat', :js do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('HipChat')
end
context 'with standart settings' do context 'with standart settings' do
before do
stub_request(:post, /.*api.hipchat.com.*/)
end
it 'activates service' do it 'activates service' do
check('Active') visit_project_integration('HipChat')
fill_in('Room', with: 'gitlab') fill_in('Room', with: 'gitlab')
fill_in('Token', with: 'verySecret') fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('HipChat activated.') expect(page).to have_content('HipChat activated.')
end end
end end
context 'with custom settings' do context 'with custom settings' do
before do
stub_request(:post, /.*chat.example.com.*/)
end
it 'activates service' do it 'activates service' do
check('Active') visit_project_integration('HipChat')
fill_in('Room', with: 'gitlab_custom') fill_in('Room', with: 'gitlab_custom')
fill_in('Token', with: 'secretCustom') fill_in('Token', with: 'secretCustom')
fill_in('Server', with: 'https://chat.example.com') fill_in('Server', with: 'https://chat.example.com')
click_button('Save')
click_test_integration
expect(page).to have_content('HipChat activated.') expect(page).to have_content('HipChat activated.')
end end
......
...@@ -3,23 +3,14 @@ ...@@ -3,23 +3,14 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Irker (IRC gateway)' do describe 'User activates Irker (IRC gateway)' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do it 'activates service', :js do
project.add_maintainer(user) visit_project_integration('Irker (IRC gateway)')
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Irker (IRC gateway)')
end
it 'activates service' do
check('Active')
check('Colorize messages') check('Colorize messages')
fill_in('Recipients', with: 'irc://chat.freenode.net/#commits') fill_in('Recipients', with: 'irc://chat.freenode.net/#commits')
click_button('Save')
click_test_integration
expect(page).to have_content('Irker (IRC gateway) activated.') expect(page).to have_content('Irker (IRC gateway) activated.')
end end
......
...@@ -3,27 +3,22 @@ ...@@ -3,27 +3,22 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates JetBrains TeamCity CI' do describe 'User activates JetBrains TeamCity CI' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:post, /.*teamcity.example.com.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('JetBrains TeamCity CI')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('JetBrains TeamCity CI')
check('Push') check('Push')
check('Merge request') check('Merge request')
fill_in('Teamcity url', with: 'http://teamcity.example.com') fill_in('Teamcity url', with: 'http://teamcity.example.com')
fill_in('Build type', with: 'GitlabTest_Build') fill_in('Build type', with: 'GitlabTest_Build')
fill_in('Username', with: 'user') fill_in('Username', with: 'user')
fill_in('Password', with: 'verySecret') fill_in('Password', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('JetBrains TeamCity CI activated.') expect(page).to have_content('JetBrains TeamCity CI activated.')
end end
......
...@@ -3,23 +3,18 @@ ...@@ -3,23 +3,18 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Packagist' do describe 'User activates Packagist' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:post, /.*packagist.org.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Packagist')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('Packagist')
fill_in('Username', with: 'theUser') fill_in('Username', with: 'theUser')
fill_in('Token', with: 'verySecret') fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_then_save_integration
expect(page).to have_content('Packagist activated.') expect(page).to have_content('Packagist activated.')
end end
......
...@@ -3,22 +3,17 @@ ...@@ -3,22 +3,17 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates PivotalTracker' do describe 'User activates PivotalTracker' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:post, /.*www.pivotaltracker.com.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('PivotalTracker')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('PivotalTracker')
fill_in('Token', with: 'verySecret') fill_in('Token', with: 'verySecret')
click_button('Save')
click_test_integration
expect(page).to have_content('PivotalTracker activated.') expect(page).to have_content('PivotalTracker activated.')
end end
......
...@@ -3,21 +3,17 @@ ...@@ -3,21 +3,17 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Prometheus' do describe 'User activates Prometheus' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:get, /.*prometheus.example.com.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Prometheus')
end 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') check('Active')
fill_in('API URL', with: 'http://prometheus.example.com') fill_in('API URL', with: 'http://prometheus.example.com')
click_button('Save changes') click_button('Save changes')
expect(page).not_to have_content('Prometheus activated.') expect(page).not_to have_content('Prometheus activated.')
......
...@@ -3,26 +3,21 @@ ...@@ -3,26 +3,21 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Pushover' do describe 'User activates Pushover' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do before do
project.add_maintainer(user) stub_request(:post, /.*api.pushover.net.*/)
sign_in(user)
visit(project_settings_integrations_path(project))
click_link('Pushover')
end end
it 'activates service' do it 'activates service', :js do
check('Active') visit_project_integration('Pushover')
fill_in('Api key', with: 'verySecret') fill_in('Api key', with: 'verySecret')
fill_in('User key', with: 'verySecret') fill_in('User key', with: 'verySecret')
fill_in('Device', with: 'myDevice') fill_in('Device', with: 'myDevice')
select('High Priority', from: 'Priority') select('High Priority', from: 'Priority')
select('Bike', from: 'Sound') select('Bike', from: 'Sound')
click_button('Save')
click_test_integration
expect(page).to have_content('Pushover activated.') expect(page).to have_content('Pushover activated.')
end end
......
...@@ -3,32 +3,26 @@ ...@@ -3,32 +3,26 @@
require 'spec_helper' require 'spec_helper'
describe 'User activates Slack notifications' do describe 'User activates Slack notifications' do
let(:user) { create(:user) } include_context 'project service activation'
let(:service) { SlackService.new }
let(:project) { create(:project, slack_service: service) }
before do
project.add_maintainer(user)
sign_in(user)
end
context 'when service is not configured yet' do context 'when service is not configured yet' do
before do before do
visit(project_settings_integrations_path(project)) visit_project_integration('Slack notifications')
click_link('Slack notifications')
end end
it 'activates service' do it 'activates service', :js do
check('Active')
fill_in('Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685') 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.') expect(page).to have_content('Slack notifications activated.')
end end
end end
context 'when service is already configured' do context 'when service is already configured' do
let(:service) { SlackService.new }
let(:project) { create(:project, slack_service: service) }
before do before do
service.fields service.fields
service.update( service.update(
......
...@@ -3,17 +3,11 @@ ...@@ -3,17 +3,11 @@
require 'spec_helper' require 'spec_helper'
describe 'User views services' do describe 'User views services' do
let(:project) { create(:project) } include_context 'project service activation'
let(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
visit(project_settings_integrations_path(project))
end
it 'shows the list of available services' do it 'shows the list of available services' do
visit_project_integrations
expect(page).to have_content('Integrations') expect(page).to have_content('Integrations')
expect(page).to have_content('Campfire') expect(page).to have_content('Campfire')
expect(page).to have_content('HipChat') 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