Commit 13d2bcc3 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen
Browse files

Created a basic Git Tag Push service

This is the first version, and only has the most basic information about
the tag that is created.
parent 321fcfba3d90
class GitTagPushService
attr_accessor :project, :user, :push_data
def execute(project, user, ref)
@project, @user = project, user
@push_data = create_push_data(ref)
project.execute_hooks(@push_data.dup, :tag_push_hooks)
end
private
def create_push_data(ref)
data = {
ref: ref,
user_id: user.id,
user_name: user.name,
project_id: project.id,
repository: {
name: project.name,
url: project.url_to_repo,
description: project.description,
homepage: project.web_url
}
}
end
end
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'
end
describe 'Git Tag Push Data' do
before do
service.execute(project, user, @ref)
@push_data = service.push_data
end
subject { @push_data }
it { should include(ref: @ref) }
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, 'refs/tags/v1.0.0')
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment