2014-03-05 20:23:49 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-09 10:55:49 +00:00
|
|
|
describe GitTagPushService, services: true do
|
2014-12-05 21:56:43 +00:00
|
|
|
include RepoHelpers
|
|
|
|
|
2015-06-22 12:39:07 +00:00
|
|
|
let(:user) { create :user }
|
|
|
|
let(:project) { create :project }
|
|
|
|
let(:service) { GitTagPushService.new }
|
2014-03-05 20:23:49 +00:00
|
|
|
|
|
|
|
before do
|
2014-12-05 21:56:43 +00:00
|
|
|
@oldrev = Gitlab::Git::BLANK_SHA
|
|
|
|
@newrev = "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" # gitlab-test: git rev-parse refs/tags/v1.1.0
|
|
|
|
@ref = 'refs/tags/v1.1.0'
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
|
|
|
|
2014-12-05 21:56:43 +00:00
|
|
|
describe "Git Tag Push Data" do
|
2014-03-05 20:23:49 +00:00
|
|
|
before do
|
2014-03-06 15:08:51 +00:00
|
|
|
service.execute(project, user, @oldrev, @newrev, @ref)
|
2014-03-05 20:23:49 +00:00
|
|
|
@push_data = service.push_data
|
2014-12-05 21:56:43 +00:00
|
|
|
@tag_name = Gitlab::Git.ref_name(@ref)
|
|
|
|
@tag = project.repository.find_tag(@tag_name)
|
2015-04-21 13:13:40 +00:00
|
|
|
@commit = project.commit(@tag.target)
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { @push_data }
|
|
|
|
|
2014-12-05 21:56:43 +00:00
|
|
|
it { is_expected.to include(object_kind: 'tag_push') }
|
2015-02-12 18:17:35 +00:00
|
|
|
it { is_expected.to include(ref: @ref) }
|
|
|
|
it { is_expected.to include(before: @oldrev) }
|
|
|
|
it { is_expected.to include(after: @newrev) }
|
2014-12-05 21:56:43 +00:00
|
|
|
it { is_expected.to include(message: @tag.message) }
|
2015-02-12 18:17:35 +00:00
|
|
|
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) }
|
2014-03-05 20:23:49 +00:00
|
|
|
|
2014-12-05 21:56:43 +00:00
|
|
|
context "with repository data" do
|
2014-03-05 20:23:49 +00:00
|
|
|
subject { @push_data[:repository] }
|
|
|
|
|
2015-02-12 18:17:35 +00:00
|
|
|
it { is_expected.to include(name: project.name) }
|
|
|
|
it { is_expected.to include(url: project.url_to_repo) }
|
|
|
|
it { is_expected.to include(description: project.description) }
|
|
|
|
it { is_expected.to include(homepage: project.web_url) }
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
2014-12-05 21:56:43 +00:00
|
|
|
|
|
|
|
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(
|
2015-12-15 02:53:52 +00:00
|
|
|
url: [
|
|
|
|
Gitlab.config.gitlab.url,
|
|
|
|
project.namespace.to_param,
|
|
|
|
project.to_param,
|
|
|
|
'commit',
|
|
|
|
@commit.id
|
|
|
|
].join('/')
|
|
|
|
)
|
2014-12-05 21:56:43 +00:00
|
|
|
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
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Web Hooks" do
|
|
|
|
context "execute web hooks" do
|
|
|
|
it "when pushing tags" do
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(project).to receive(:execute_hooks)
|
2014-03-06 15:08:51 +00:00
|
|
|
service.execute(project, user, 'oldrev', 'newrev', 'refs/tags/v1.0.0')
|
2014-03-05 20:23:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|