gitlab_ci_service_spec.rb 1.88 KB
Newer Older
1 2 3 4
# == Schema Information
#
# Table name: services
#
5 6 7
#  id                    :integer          not null, primary key
#  type                  :string(255)
#  title                 :string(255)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
8
#  project_id            :integer
9 10 11 12
#  created_at            :datetime
#  updated_at            :datetime
#  active                :boolean          default(FALSE), not null
#  properties            :text
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
13 14 15 16 17
#  template              :boolean          default(FALSE)
#  push_events           :boolean          default(TRUE)
#  issues_events         :boolean          default(TRUE)
#  merge_requests_events :boolean          default(TRUE)
#  tag_push_events       :boolean          default(TRUE)
Stan Hu's avatar
Stan Hu committed
18
#  note_events           :boolean          default(TRUE), not null
19 20 21 22 23
#

require 'spec_helper'

describe GitlabCiService do
24 25 26
  describe 'associations' do
    it { is_expected.to belong_to(:project) }
    it { is_expected.to have_one(:service_hook) }
27 28 29 30
  end

  describe 'commits methods' do
    before do
31
      @ci_project = create(:ci_project)
32
      @service = GitlabCiService.new
33
      allow(@service).to receive_messages(
34 35
        service_hook: true,
        project_url: 'http://ci.gitlab.org/projects/2',
36 37
        token: 'verySecret',
        project: @ci_project.gl_project
38 39 40
      )
    end

41
    describe :build_page do
42
      it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://localhost/#{@ci_project.gl_project.path_with_namespace}/commit/2ab7834c/ci")}
43
    end
44 45 46 47 48 49

    describe "execute" do
      let(:user)    { create(:user, username: 'username') }
      let(:project) { create(:project, name: 'project') }
      let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }

50 51
      it "calls CreateCommitService" do
        expect_any_instance_of(Ci::CreateCommitService).to receive(:execute).with(@ci_project, user, push_sample_data)
52 53 54 55

        @service.execute(push_sample_data)
      end
    end
56 57
  end
end