debian-mirror-gitlab/spec/features/projects/settings/integration_settings_spec.rb

142 lines
4 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
feature 'Integration settings' do
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
let(:role) { :developer }
2017-09-10 17:25:29 +05:30
let(:integrations_path) { project_settings_integrations_path(project) }
2017-08-17 22:00:37 +05:30
background do
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
project.team << [user, role]
end
context 'for developer' do
given(:role) { :developer }
scenario 'to be disallowed to view' do
visit integrations_path
expect(page.status_code).to eq(404)
end
end
context 'for master' do
given(:role) { :master }
context 'Webhooks' do
let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) }
let(:url) { generate(:url) }
scenario 'show list of webhooks' do
hook
visit integrations_path
expect(page.status_code).to eq(200)
expect(page).to have_content(hook.url)
expect(page).to have_content('SSL Verification: enabled')
2017-09-10 17:25:29 +05:30
expect(page).to have_content('Push events')
expect(page).to have_content('Tag push events')
expect(page).to have_content('Issues events')
expect(page).to have_content('Confidential issues events')
expect(page).to have_content('Note events')
expect(page).to have_content('Merge requests events')
expect(page).to have_content('Pipeline events')
expect(page).to have_content('Wiki page events')
2017-08-17 22:00:37 +05:30
end
scenario 'create webhook' do
visit integrations_path
fill_in 'hook_url', with: url
check 'Tag push events'
check 'Enable SSL verification'
2017-09-10 17:25:29 +05:30
check 'Job events'
2017-08-17 22:00:37 +05:30
click_button 'Add webhook'
expect(page).to have_content(url)
expect(page).to have_content('SSL Verification: enabled')
2017-09-10 17:25:29 +05:30
expect(page).to have_content('Push events')
expect(page).to have_content('Tag push events')
expect(page).to have_content('Job events')
2017-08-17 22:00:37 +05:30
end
scenario 'edit existing webhook' do
hook
visit integrations_path
click_link 'Edit'
fill_in 'hook_url', with: url
check 'Enable SSL verification'
click_button 'Save changes'
expect(page).to have_content 'SSL Verification: enabled'
expect(page).to have_content(url)
end
2017-09-10 17:25:29 +05:30
scenario 'test existing webhook', js: true do
2017-08-17 22:00:37 +05:30
WebMock.stub_request(:post, hook.url)
visit integrations_path
2017-09-10 17:25:29 +05:30
find('.hook-test-button.dropdown').click
click_link 'Push events'
2017-08-17 22:00:37 +05:30
expect(current_path).to eq(integrations_path)
end
2017-09-10 17:25:29 +05:30
context 'remove existing webhook' do
scenario 'from webhooks list page' do
hook
visit integrations_path
expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1)
end
scenario 'from webhook edit page' do
hook
visit integrations_path
click_link 'Edit'
expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1)
end
end
end
context 'Webhook logs' do
let(:hook) { create(:project_hook, project: project) }
let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: 'some error') }
scenario 'show list of hook logs' do
hook_log
visit edit_project_hook_path(project, hook)
expect(page).to have_content('Recent Deliveries')
expect(page).to have_content(hook_log.url)
end
scenario 'show hook log details' do
hook_log
visit edit_project_hook_path(project, hook)
click_link 'View details'
expect(page).to have_content("POST #{hook_log.url}")
expect(page).to have_content(hook_log.internal_error_message)
expect(page).to have_content('Resend Request')
end
scenario 'retry hook log' do
WebMock.stub_request(:post, hook.url)
hook_log
visit edit_project_hook_path(project, hook)
click_link 'View details'
click_link 'Resend Request'
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(current_path).to eq(edit_project_hook_path(project, hook))
2017-08-17 22:00:37 +05:30
end
end
end
end