summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Michalak <stricte@gumed.edu.pl>2014-11-24 11:52:15 +0100
committerMariusz Michalak <stricte@gumed.edu.pl>2014-11-24 11:52:15 +0100
commit37b13b9f15570eecbb190429709a63775d60810f (patch)
tree5306b92b252325b7cd56e304bc11bf2e0f8d14d0
parent114d22e77d0c66a9548170c18602d3787daad7c5 (diff)
downloadgitlab-ci-37b13b9f15570eecbb190429709a63775d60810f.tar.gz
Tests for Projects API method for webhooks creation
-rw-r--r--spec/requests/api/projects_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index bb2f1cb..2000162 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -52,6 +52,49 @@ describe API::API do
end
end
+ describe "POST /projects/:project_id/webhooks" do
+ let!(:project) { FactoryGirl.create(:project) }
+
+ context "Valid Webhook URL" do
+ let!(:webhook) { {:web_hook => "http://example.com/sth/1/ala_ma_kota" } }
+
+ before do
+ options.merge!(webhook)
+ end
+
+ it "should create webhook for specified project" do
+ post api("/projects/#{project.id}/webhooks"), options
+ response.status.should == 201
+ json_response["url"].should == webhook[:web_hook]
+ end
+
+ it "fails to create webhook for non existsing project" do
+ post api("/projects/non-existant-id/webhooks"), options
+ response.status.should == 404
+ end
+
+ end
+
+ context "Invalid Webhook URL" do
+ let!(:webhook) { {:web_hook => "ala_ma_kota" } }
+
+ before do
+ options.merge!(webhook)
+ end
+
+ it "fails to create webhook for not valid url" do
+ post api("/projects/#{project.id}/webhooks"), options
+ response.status.should == 400
+ end
+ end
+
+ context "Missed web_hook parameter" do
+ it "fails to create webhook for not provided url" do
+ post api("/projects/#{project.id}/webhooks"), options
+ response.status.should == 400
+ end
+ end
+ end
describe "GET /projects/:id" do
let!(:project) { FactoryGirl.create(:project) }