Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ci/services/web_hook_service_spec.rb')
-rw-r--r--spec/ci/services/web_hook_service_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/ci/services/web_hook_service_spec.rb b/spec/ci/services/web_hook_service_spec.rb
new file mode 100644
index 00000000000..2bb153942e8
--- /dev/null
+++ b/spec/ci/services/web_hook_service_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe WebHookService do
+ let (:project) { FactoryGirl.create :project }
+ let (:commit) { FactoryGirl.create :commit, project: project }
+ let (:build) { FactoryGirl.create :build, commit: commit }
+ let (:hook) { FactoryGirl.create :web_hook, project: project }
+
+ describe :execute do
+ it "should execute successfully" do
+ stub_request(:post, hook.url).to_return(status: 200)
+ WebHookService.new.build_end(build).should be_true
+ end
+ end
+
+ context 'build_data' do
+ it "contains all needed fields" do
+ build_data(build).should include(
+ :build_id,
+ :project_id,
+ :ref,
+ :build_status,
+ :build_started_at,
+ :build_finished_at,
+ :before_sha,
+ :project_name,
+ :gitlab_url,
+ :build_name
+ )
+ end
+ end
+
+ def build_data(build)
+ WebHookService.new.send :build_data, build
+ end
+end