summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-12 09:52:34 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-12 09:52:34 +0200
commit56318a24b1f7c07f7fe5d3fd23bf7d26c0240a87 (patch)
tree64efa32672bfc9261c1c277ecc694a32ef92436d /spec
parentcc57a25c39855933435e0ff9bf462474e1224109 (diff)
parente6ceec9d60b9fe5eaec8faf777307f39bd4b1fa3 (diff)
downloadgitlab-ce-56318a24b1f7c07f7fe5d3fd23bf7d26c0240a87.tar.gz
Merge pull request #6474 from jvanbaarsen/post-tag-hook
Add web hooks on tag
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_hook_spec.rb19
-rw-r--r--spec/services/git_tag_push_service_spec.rb47
2 files changed, 66 insertions, 0 deletions
diff --git a/spec/models/project_hook_spec.rb b/spec/models/project_hook_spec.rb
new file mode 100644
index 00000000000..7bd7c431bcd
--- /dev/null
+++ b/spec/models/project_hook_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe ProjectHook do
+ describe '.push_hooks' do
+ it 'should return hooks for push events only' do
+ hook = create(:project_hook, push_events: true)
+ hook2 = create(:project_hook, push_events: false)
+ expect(ProjectHook.push_hooks).to eq([hook])
+ end
+ end
+
+ describe '.tag_push_hooks' do
+ it 'should return hooks for tag push events only' do
+ hook = create(:project_hook, tag_push_events: true)
+ hook2 = create(:project_hook, tag_push_events: false)
+ expect(ProjectHook.tag_push_hooks).to eq([hook])
+ end
+ end
+end
diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb
new file mode 100644
index 00000000000..e65a8204c54
--- /dev/null
+++ b/spec/services/git_tag_push_service_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe GitTagPushService do
+ let (:user) { create :user }
+ let (:project) { create :project }
+ let (:service) { GitTagPushService.new }
+
+ before do
+ @ref = 'refs/tags/super-tag'
+ @oldrev = 'b98a310def241a6fd9c9a9a3e7934c48e498fe81'
+ @newrev = 'b19a04f53caeebf4fe5ec2327cb83e9253dc91bb'
+ end
+
+ describe 'Git Tag Push Data' do
+ before do
+ service.execute(project, user, @oldrev, @newrev, @ref)
+ @push_data = service.push_data
+ end
+
+ subject { @push_data }
+
+ it { should include(ref: @ref) }
+ it { should include(before: @oldrev) }
+ it { should include(after: @newrev) }
+ it { should include(user_id: user.id) }
+ it { should include(user_name: user.name) }
+ it { should include(project_id: project.id) }
+
+ context 'With repository data' do
+ subject { @push_data[:repository] }
+
+ it { should include(name: project.name) }
+ it { should include(url: project.url_to_repo) }
+ it { should include(description: project.description) }
+ it { should include(homepage: project.web_url) }
+ end
+ end
+
+ describe "Web Hooks" do
+ context "execute web hooks" do
+ it "when pushing tags" do
+ project.should_receive(:execute_hooks)
+ service.execute(project, user, 'oldrev', 'newrev', 'refs/tags/v1.0.0')
+ end
+ end
+ end
+end