From 062ff17b1cd65485d88b676584ae793cce8b3345 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Sun, 27 Jul 2014 22:26:23 +0200 Subject: Do not execute hooks on empty projects, fixes #6108 --- features/steps/project/hooks.rb | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'features/steps/project/hooks.rb') diff --git a/features/steps/project/hooks.rb b/features/steps/project/hooks.rb index 19ff3244543..30da589260d 100644 --- a/features/steps/project/hooks.rb +++ b/features/steps/project/hooks.rb @@ -8,31 +8,45 @@ class ProjectHooks < Spinach::FeatureSteps include RSpec::Mocks::ExampleMethods include WebMock::API - Given 'project has hook' do + step 'project has hook' do @hook = create(:project_hook, project: current_project) end - Then 'I should see project hook' do + 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 page.should have_content @hook.url end - When 'I submit new hook' do + step 'I submit new hook' do @url = Faker::Internet.uri("http") fill_in "hook_url", with: @url expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1) end - Then 'I should see newly created hook' do + step 'I should see newly created hook' do page.current_path.should == project_hooks_path(current_project) page.should have_content(@url) end - When 'I click test hook button' do + step 'I click test hook button' do stub_request(:post, @hook.url).to_return(status: 200) click_link 'Test Hook' end - Then 'hook should be triggered' do + step 'hook should be triggered' do page.current_path.should == project_hooks_path(current_project) + page.should have_selector '.flash-notice', + text: 'Hook successfully executed.' + end + + step 'I should see hook error message' do + page.should have_selector '.flash-alert', + text: 'Hook execution failed. '\ + 'Ensure the project has commits.' end end -- cgit v1.2.1