diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2014-12-05 22:56:43 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-03-21 11:25:27 +0100 |
commit | 5b432e76710eb70cc41c59af1ea9a294202a49fc (patch) | |
tree | c9fa0c82f6b9a3066ef5271027489bb3a80b9d0a /spec | |
parent | 6cf189f0a92772b9174f913e7c74a4889d54e9a6 (diff) | |
download | gitlab-ce-5b432e76710eb70cc41c59af1ea9a294202a49fc.tar.gz |
Extend push_tag event to include tag message and last commit
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/git_push_service_spec.rb | 5 | ||||
-rw-r--r-- | spec/services/git_tag_push_service_spec.rb | 52 |
2 files changed, 47 insertions, 10 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index 1b1e3ca5f8b..aa9b15dd9ec 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -145,11 +145,6 @@ describe GitPushService do expect(project).to receive(:execute_hooks) service.execute(project, user, 'oldrev', 'newrev', 'refs/heads/master') end - - it "when pushing tags" do - expect(project).not_to receive(:execute_hooks) - service.execute(project, user, 'newrev', 'newrev', 'refs/tags/v1.0.0') - end end end diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb index fcf462edbfc..a050fdf6c0e 100644 --- a/spec/services/git_tag_push_service_spec.rb +++ b/spec/services/git_tag_push_service_spec.rb @@ -1,32 +1,39 @@ require 'spec_helper' describe GitTagPushService do + include RepoHelpers + let (:user) { create :user } let (:project) { create :project } let (:service) { GitTagPushService.new } before do - @ref = 'refs/tags/super-tag' - @oldrev = 'b98a310def241a6fd9c9a9a3e7934c48e498fe81' - @newrev = 'b19a04f53caeebf4fe5ec2327cb83e9253dc91bb' + @oldrev = Gitlab::Git::BLANK_SHA + @newrev = "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" # gitlab-test: git rev-parse refs/tags/v1.1.0 + @ref = 'refs/tags/v1.1.0' end - describe 'Git Tag Push Data' do + describe "Git Tag Push Data" do before do service.execute(project, user, @oldrev, @newrev, @ref) @push_data = service.push_data + @tag_name = Gitlab::Git.ref_name(@ref) + @tag = project.repository.find_tag(@tag_name) + @commit = project.repository.commit(@tag.target) end subject { @push_data } + it { is_expected.to include(object_kind: 'tag_push') } it { is_expected.to include(ref: @ref) } it { is_expected.to include(before: @oldrev) } it { is_expected.to include(after: @newrev) } + it { is_expected.to include(message: @tag.message) } it { is_expected.to include(user_id: user.id) } it { is_expected.to include(user_name: user.name) } it { is_expected.to include(project_id: project.id) } - context 'With repository data' do + context "with repository data" do subject { @push_data[:repository] } it { is_expected.to include(name: project.name) } @@ -34,6 +41,41 @@ describe GitTagPushService do it { is_expected.to include(description: project.description) } it { is_expected.to include(homepage: project.web_url) } end + + context "with commits" do + subject { @push_data[:commits] } + + it { is_expected.to be_an(Array) } + it 'has 1 element' do + expect(subject.size).to eq(1) + end + + context "the commit" do + subject { @push_data[:commits].first } + + it { is_expected.to include(id: @commit.id) } + it { is_expected.to include(message: @commit.safe_message) } + it { is_expected.to include(timestamp: @commit.date.xmlschema) } + it do + is_expected.to include( + url: [ + Gitlab.config.gitlab.url, + project.namespace.to_param, + project.to_param, + 'commit', + @commit.id + ].join('/') + ) + end + + context "with a author" do + subject { @push_data[:commits].first[:author] } + + it { is_expected.to include(name: @commit.author_name) } + it { is_expected.to include(email: @commit.author_email) } + end + end + end end describe "Web Hooks" do |