debian-mirror-gitlab/features/steps/project/hooks.rb

76 lines
2.5 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'webmock'
2015-04-26 12:48:37 +05:30
class Spinach::Features::ProjectHooks < Spinach::FeatureSteps
2014-09-02 18:07:02 +05:30
include SharedAuthentication
include SharedProject
include SharedPaths
include RSpec::Matchers
include RSpec::Mocks::ExampleMethods
include WebMock::API
step 'project has hook' do
@hook = create(:project_hook, project: current_project)
end
step 'I own empty project with hook' do
@project = create(:empty_project,
name: 'Empty Project', namespace: @user.namespace)
@hook = create(:project_hook, project: current_project)
end
step 'I should see project hook' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content @hook.url
2014-09-02 18:07:02 +05:30
end
step 'I submit new hook' do
2015-09-11 14:41:01 +05:30
@url = FFaker::Internet.uri("http")
2014-09-02 18:07:02 +05:30
fill_in "hook_url", with: @url
2016-06-02 11:05:42 +05:30
expect { click_button "Add Webhook" }.to change(ProjectHook, :count).by(1)
2014-09-02 18:07:02 +05:30
end
2015-09-25 12:07:36 +05:30
step 'I submit new hook with SSL verification enabled' do
@url = FFaker::Internet.uri("http")
fill_in "hook_url", with: @url
check "hook_enable_ssl_verification"
2016-06-02 11:05:42 +05:30
expect { click_button "Add Webhook" }.to change(ProjectHook, :count).by(1)
2015-09-25 12:07:36 +05:30
end
2014-09-02 18:07:02 +05:30
step 'I should see newly created hook' do
2015-09-11 14:41:01 +05:30
expect(current_path).to eq namespace_project_hooks_path(current_project.namespace, current_project)
expect(page).to have_content(@url)
2014-09-02 18:07:02 +05:30
end
2015-09-25 12:07:36 +05:30
step 'I should see newly created hook with SSL verification enabled' do
expect(current_path).to eq namespace_project_hooks_path(current_project.namespace, current_project)
expect(page).to have_content(@url)
expect(page).to have_content("SSL Verification: enabled")
end
2014-09-02 18:07:02 +05:30
step 'I click test hook button' do
stub_request(:post, @hook.url).to_return(status: 200)
2016-06-02 11:05:42 +05:30
click_link 'Test'
2014-09-02 18:07:02 +05:30
end
step 'I click test hook button with invalid URL' do
stub_request(:post, @hook.url).to_raise(SocketError)
2016-06-02 11:05:42 +05:30
click_link 'Test'
2014-09-02 18:07:02 +05:30
end
step 'hook should be triggered' do
2015-09-11 14:41:01 +05:30
expect(current_path).to eq namespace_project_hooks_path(current_project.namespace, current_project)
expect(page).to have_selector '.flash-notice',
2016-06-02 11:05:42 +05:30
text: 'Hook executed successfully: HTTP 200'
2014-09-02 18:07:02 +05:30
end
step 'I should see hook error message' do
2015-09-11 14:41:01 +05:30
expect(page).to have_selector '.flash-alert',
2014-09-02 18:07:02 +05:30
text: 'Hook execution failed. '\
'Ensure the project has commits.'
end
step 'I should see hook service down error message' do
2015-09-11 14:41:01 +05:30
expect(page).to have_selector '.flash-alert',
2015-12-23 02:04:40 +05:30
text: 'Hook execution failed: Exception from'
2014-09-02 18:07:02 +05:30
end
end