File: issue_links_spec.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (59 lines) | stat: -rw-r--r-- 1,831 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Client do
  it { is_expected.to respond_to :issue_links }
  it { is_expected.to respond_to :create_issue_link }
  it { is_expected.to respond_to :delete_issue_link }

  describe '.issue_links' do
    before do
      stub_get('/projects/4/issues/14/links', 'project_issue_links')
      @issue_link = Gitlab.issue_links(4, 14)
    end

    it 'gets the correct resource' do
      expect(a_get('/projects/4/issues/14/links')).to have_been_made
    end

    it 'returns a paginated response of projects' do
      expect(@issue_link).to be_a Gitlab::PaginatedResponse
      expect(@issue_link.first.title).to eq('Issues with auth')
      expect(@issue_link.first.author.name).to eq('Alexandra Bashirian')
    end
  end

  describe '.create_issue_link' do
    before do
      stub_post('/projects/3/issues/14/links', 'create_issue_link')
      @issue_link = Gitlab.create_issue_link(3, 14, 4, 11)
    end

    it 'gets the correct resource' do
      expect(a_post('/projects/3/issues/14/links')
        .with(body: { target_project_id: 4, target_issue_iid: 11 })).to have_been_made
    end

    it 'returns information about a created issue' do
      expect(@issue_link.source_issue.iid).to eq(11)
      expect(@issue_link.target_issue.iid).to eq(14)
    end
  end

  describe '.delete_issue_link' do
    before do
      stub_delete('/projects/3/issues/14/links/1', 'delete_issue_link')
      @issue_link = Gitlab.delete_issue_link(3, 14, 1)
    end

    it 'deletes the correct resource' do
      expect(a_delete('/projects/3/issues/14/links/1')).to have_been_made
    end

    it 'returns information about the deleted issue link' do
      expect(@issue_link.source_issue.iid).to eq(11)
      expect(@issue_link.target_issue.iid).to eq(14)
    end
  end
end