Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-24 21:09:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-24 21:09:05 +0300
commitc2367afbf57ebc65d5b78a743b5d6a91f0aece9f (patch)
tree165c2c54bf72ab3a3a9417d97f63ece5c9eba9f5 /spec/features/projects/settings/webhooks_settings_spec.rb
parent51a9512965d86e3094968fa514e4ae8a96d38cf3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/projects/settings/webhooks_settings_spec.rb')
-rw-r--r--spec/features/projects/settings/webhooks_settings_spec.rb143
1 files changed, 143 insertions, 0 deletions
diff --git a/spec/features/projects/settings/webhooks_settings_spec.rb b/spec/features/projects/settings/webhooks_settings_spec.rb
new file mode 100644
index 00000000000..7e22117c63c
--- /dev/null
+++ b/spec/features/projects/settings/webhooks_settings_spec.rb
@@ -0,0 +1,143 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Projects > Settings > Webhook Settings' do
+ let(:project) { create(:project) }
+ let(:user) { create(:user) }
+ let(:webhooks_path) { project_hooks_path(project) }
+
+ before do
+ sign_in(user)
+ project.add_role(user, role)
+ end
+
+ context 'for developer' do
+ let(:role) { :developer }
+
+ it 'to be disallowed to view' do
+ visit webhooks_path
+
+ expect(page.status_code).to eq(404)
+ end
+ end
+
+ context 'for maintainer' do
+ let(:role) { :maintainer }
+
+ context 'Webhooks' do
+ let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) }
+ let(:url) { generate(:url) }
+
+ it 'show list of webhooks' do
+ hook
+
+ visit webhooks_path
+
+ expect(page.status_code).to eq(200)
+ expect(page).to have_content(hook.url)
+ expect(page).to have_content('SSL Verification: enabled')
+ 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')
+ end
+
+ it 'create webhook' do
+ visit webhooks_path
+
+ fill_in 'hook_url', with: url
+ check 'Tag push events'
+ fill_in 'hook_push_events_branch_filter', with: 'master'
+ check 'Enable SSL verification'
+ check 'Job events'
+
+ click_button 'Add webhook'
+
+ expect(page).to have_content(url)
+ expect(page).to have_content('SSL Verification: enabled')
+ expect(page).to have_content('Push events')
+ expect(page).to have_content('Tag push events')
+ expect(page).to have_content('Job events')
+ end
+
+ it 'edit existing webhook' do
+ hook
+ visit webhooks_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
+
+ it 'test existing webhook', :js do
+ WebMock.stub_request(:post, hook.url)
+ visit webhooks_path
+
+ find('.hook-test-button.dropdown').click
+ click_link 'Push events'
+
+ expect(current_path).to eq(webhooks_path)
+ end
+
+ context 'delete existing webhook' do
+ it 'from webhooks list page' do
+ hook
+ visit webhooks_path
+
+ expect { click_link 'Delete' }.to change(ProjectHook, :count).by(-1)
+ end
+
+ it 'from webhook edit page' do
+ hook
+ visit webhooks_path
+ click_link 'Edit'
+
+ expect { click_link 'Delete' }.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') }
+
+ it '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
+
+ it '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
+
+ it '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'
+
+ expect(current_path).to eq(edit_project_hook_path(project, hook))
+ end
+ end
+ end
+end