summaryrefslogtreecommitdiff
path: root/spec/services/git_tag_push_service_spec.rb
blob: e65a8204c54ac71d309fcf967844181a12ec619d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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