summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-09-27 23:52:08 +0300
committerrandx <dmitriy.zaporozhets@gmail.com>2012-09-27 23:52:08 +0300
commitdb69836319ebf716b31f52e818605df0816790e0 (patch)
tree3edda28472b9c20e5fdd1c7f4a25d42d171c1814 /features
parent9cabe04368024f44881e4269a008156f1629ab86 (diff)
downloadgitlab-ce-db69836319ebf716b31f52e818605df0816790e0.tar.gz
Move ProjectHooks from spec/requests to spinach
Diffstat (limited to 'features')
-rw-r--r--features/project/hooks.feature21
-rw-r--r--features/steps/project/project_hooks.rb36
-rw-r--r--features/steps/shared/paths.rb4
-rw-r--r--features/steps/shared/project.rb4
4 files changed, 65 insertions, 0 deletions
diff --git a/features/project/hooks.feature b/features/project/hooks.feature
new file mode 100644
index 00000000000..b158e07ad33
--- /dev/null
+++ b/features/project/hooks.feature
@@ -0,0 +1,21 @@
+Feature: Project Hooks
+ Background:
+ Given I sign in as a user
+ And I own project "Shop"
+
+ Scenario: I should see hook list
+ Given project has hook
+ When I visit project hooks page
+ Then I should see project hook
+
+ Scenario: I add new hook
+ Given I visit project hooks page
+ When I submit new hook
+ Then I should see newly created hook
+
+ Scenario: I test hook
+ Given project has hook
+ And I visit project hooks page
+ When I click test hook button
+ Then hook should be triggered
+
diff --git a/features/steps/project/project_hooks.rb b/features/steps/project/project_hooks.rb
new file mode 100644
index 00000000000..1786fe5bc05
--- /dev/null
+++ b/features/steps/project/project_hooks.rb
@@ -0,0 +1,36 @@
+class ProjectHooks < Spinach::FeatureSteps
+ include SharedAuthentication
+ include SharedProject
+ include SharedPaths
+ include RSpec::Matchers
+ include RSpec::Mocks::ExampleMethods
+
+ Given 'project has hook' do
+ @hook = Factory :project_hook, project: current_project
+ end
+
+ Then 'I should see project hook' do
+ page.should have_content @hook.url
+ end
+
+ When '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
+ page.current_path.should == project_hooks_path(current_project)
+ page.should have_content(@url)
+ end
+
+ When 'I click test hook button' do
+ test_hook_context = double(execute: true)
+ TestHookContext.should_receive(:new).and_return(test_hook_context)
+ click_link 'Test Hook'
+ end
+
+ Then 'hook should be triggered' do
+ page.current_path.should == project_hooks_path(current_project)
+ end
+end
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index 8efedfa1083..eda5ab94116 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -125,6 +125,10 @@ module SharedPaths
visit project_wiki_path(@project, :index)
end
+ When 'I visit project hooks page' do
+ visit project_hooks_path(@project)
+ end
+
# ----------------------------------------
# "Shop" Project
# ----------------------------------------
diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb
index 0f93d675786..ae871d63ed5 100644
--- a/features/steps/shared/project.rb
+++ b/features/steps/shared/project.rb
@@ -12,4 +12,8 @@ module SharedProject
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
+
+ def current_project
+ @project ||= Project.first
+ end
end