summaryrefslogtreecommitdiff
path: root/spec/helpers/ci/triggers_helper_spec.rb
blob: 5e43dbfdd5c824a4a503334d0137b1b7ba1cc194 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::TriggersHelper do
  let(:project_id) { 1 }

  describe '.builds_trigger_url' do
    subject { helper.builds_trigger_url(project_id, ref: ref) }

    context 'with no ref' do
      let(:ref) { nil }

      specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/trigger/pipeline" }
    end

    context 'with ref' do
      let(:ref) { 'master' }

      specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/ref/master/trigger/pipeline" }
    end
  end

  describe '.service_trigger_url' do
    subject { helper.service_trigger_url(service) }

    let(:service) { double(project_id: 1, to_param: 'param') }

    specify { expect(subject).to eq "#{Settings.gitlab.url}/api/v4/projects/1/services/param/trigger" }
  end
end