Commit db69836319ebf716b31f52e818605df0816790e0
1 parent
9cabe043
Exists in
master
and in
4 other branches
Move ProjectHooks from spec/requests to spinach
Showing
5 changed files
with
65 additions
and
43 deletions
Show diff stats
| @@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
| 1 | +Feature: Project Hooks | ||
| 2 | + Background: | ||
| 3 | + Given I sign in as a user | ||
| 4 | + And I own project "Shop" | ||
| 5 | + | ||
| 6 | + Scenario: I should see hook list | ||
| 7 | + Given project has hook | ||
| 8 | + When I visit project hooks page | ||
| 9 | + Then I should see project hook | ||
| 10 | + | ||
| 11 | + Scenario: I add new hook | ||
| 12 | + Given I visit project hooks page | ||
| 13 | + When I submit new hook | ||
| 14 | + Then I should see newly created hook | ||
| 15 | + | ||
| 16 | + Scenario: I test hook | ||
| 17 | + Given project has hook | ||
| 18 | + And I visit project hooks page | ||
| 19 | + When I click test hook button | ||
| 20 | + Then hook should be triggered | ||
| 21 | + |
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +class ProjectHooks < Spinach::FeatureSteps | ||
| 2 | + include SharedAuthentication | ||
| 3 | + include SharedProject | ||
| 4 | + include SharedPaths | ||
| 5 | + include RSpec::Matchers | ||
| 6 | + include RSpec::Mocks::ExampleMethods | ||
| 7 | + | ||
| 8 | + Given 'project has hook' do | ||
| 9 | + @hook = Factory :project_hook, project: current_project | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + Then 'I should see project hook' do | ||
| 13 | + page.should have_content @hook.url | ||
| 14 | + end | ||
| 15 | + | ||
| 16 | + When 'I submit new hook' do | ||
| 17 | + @url = Faker::Internet.uri("http") | ||
| 18 | + fill_in "hook_url", with: @url | ||
| 19 | + expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1) | ||
| 20 | + end | ||
| 21 | + | ||
| 22 | + Then 'I should see newly created hook' do | ||
| 23 | + page.current_path.should == project_hooks_path(current_project) | ||
| 24 | + page.should have_content(@url) | ||
| 25 | + end | ||
| 26 | + | ||
| 27 | + When 'I click test hook button' do | ||
| 28 | + test_hook_context = double(execute: true) | ||
| 29 | + TestHookContext.should_receive(:new).and_return(test_hook_context) | ||
| 30 | + click_link 'Test Hook' | ||
| 31 | + end | ||
| 32 | + | ||
| 33 | + Then 'hook should be triggered' do | ||
| 34 | + page.current_path.should == project_hooks_path(current_project) | ||
| 35 | + end | ||
| 36 | +end |
features/steps/shared/paths.rb
| @@ -125,6 +125,10 @@ module SharedPaths | @@ -125,6 +125,10 @@ module SharedPaths | ||
| 125 | visit project_wiki_path(@project, :index) | 125 | visit project_wiki_path(@project, :index) |
| 126 | end | 126 | end |
| 127 | 127 | ||
| 128 | + When 'I visit project hooks page' do | ||
| 129 | + visit project_hooks_path(@project) | ||
| 130 | + end | ||
| 131 | + | ||
| 128 | # ---------------------------------------- | 132 | # ---------------------------------------- |
| 129 | # "Shop" Project | 133 | # "Shop" Project |
| 130 | # ---------------------------------------- | 134 | # ---------------------------------------- |
features/steps/shared/project.rb
| @@ -12,4 +12,8 @@ module SharedProject | @@ -12,4 +12,8 @@ module SharedProject | ||
| 12 | @project = Factory :project, :name => "Shop" | 12 | @project = Factory :project, :name => "Shop" |
| 13 | @project.add_access(@user, :admin) | 13 | @project.add_access(@user, :admin) |
| 14 | end | 14 | end |
| 15 | + | ||
| 16 | + def current_project | ||
| 17 | + @project ||= Project.first | ||
| 18 | + end | ||
| 15 | end | 19 | end |
spec/requests/hooks_spec.rb
| @@ -1,43 +0,0 @@ | @@ -1,43 +0,0 @@ | ||
| 1 | -require 'spec_helper' | ||
| 2 | - | ||
| 3 | -describe "Hooks" do | ||
| 4 | - before do | ||
| 5 | - login_as :user | ||
| 6 | - @project = Factory :project | ||
| 7 | - @project.add_access(@user, :read, :admin) | ||
| 8 | - end | ||
| 9 | - | ||
| 10 | - describe "GET index" do | ||
| 11 | - it "should be available" do | ||
| 12 | - @hook = Factory :project_hook, project: @project | ||
| 13 | - visit project_hooks_path(@project) | ||
| 14 | - page.should have_content "Hooks" | ||
| 15 | - page.should have_content @hook.url | ||
| 16 | - end | ||
| 17 | - end | ||
| 18 | - | ||
| 19 | - describe "New Hook" do | ||
| 20 | - before do | ||
| 21 | - @url = Faker::Internet.uri("http") | ||
| 22 | - visit project_hooks_path(@project) | ||
| 23 | - fill_in "hook_url", with: @url | ||
| 24 | - expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1) | ||
| 25 | - end | ||
| 26 | - | ||
| 27 | - it "should open new team member popup" do | ||
| 28 | - page.current_path.should == project_hooks_path(@project) | ||
| 29 | - page.should have_content(@url) | ||
| 30 | - end | ||
| 31 | - end | ||
| 32 | - | ||
| 33 | - describe "Test" do | ||
| 34 | - before do | ||
| 35 | - @hook = Factory :project_hook, project: @project | ||
| 36 | - stub_request(:post, @hook.url) | ||
| 37 | - visit project_hooks_path(@project) | ||
| 38 | - click_link "Test Hook" | ||
| 39 | - end | ||
| 40 | - | ||
| 41 | - it { page.current_path.should == project_hooks_path(@project) } | ||
| 42 | - end | ||
| 43 | -end |