File: agile_spec.rb

package info (click to toggle)
ruby-jira 2.1.5-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 968 kB
  • sloc: ruby: 5,125; makefile: 12
file content (135 lines) | stat: -rw-r--r-- 5,897 bytes parent folder | download | duplicates (2)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
require 'spec_helper'

describe JIRA::Resource::Agile do
  let(:client) do
    client = double(options: { rest_base_path: '/jira/rest/api/2', context_path: '/jira' })
    allow(client).to receive(:Issue).and_return(JIRA::Resource::IssueFactory.new(client))
    client
  end
  let(:response) { double }

  describe '#all' do
    it 'should query url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.all(client)
    end
  end

  describe '#get_backlog_issues' do
    it 'should query the url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/backlog?maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_backlog_issues(client, 1)
    end
  end

  describe '#get_board_issues' do
    it 'should query correct url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))

      expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))

      issues = JIRA::Resource::Agile.get_board_issues(client, 1)
      expect(issues).to be_an(Array)
      expect(issues.size).to eql(9)

      issues.each do |issue|
        expect(issue.class).to eq(JIRA::Resource::Issue)
        expect(issue.expanded?).to be_falsey
      end
    end

    it 'should query correct url with parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?startAt=50').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))

      expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))

      issues = JIRA::Resource::Agile.get_board_issues(client, 1, startAt: 50)
      expect(issues).to be_an(Array)
      expect(issues.size).to eql(9)

      issues.each do |issue|
        expect(issue.class).to eq(JIRA::Resource::Issue)
        expect(issue.expanded?).to be_falsey
      end
    end
  end

  describe '#get_sprints' do
    it 'should query correct url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_sprints(client, 1)
    end

    it 'should query correct url with parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?startAt=50&maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_sprints(client, 1, startAt: 50)
    end

    it 'should work with pagination starting at 0' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=0').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_sprints(client, 1, maxResults: 1, startAt: 0)
    end

    it 'should work with pagination not starting at 0' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=1').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_sprints(client, 1, maxResults: 1, startAt: 1)
    end
  end

  describe '#get_sprint_issues' do
    it 'should query correct url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))

      JIRA::Resource::Agile.get_sprint_issues(client, 1)
    end

    it 'should query correct url with parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?startAt=50&maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))

      JIRA::Resource::Agile.get_sprint_issues(client, 1, startAt: 50)
    end
  end

  describe '#get_projects_full' do
    it 'should query correct url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project/full').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_projects_full(client, 1)
    end
  end

  describe '#get_projects' do
    it 'should query correct url without parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_projects(client, 1)
    end

    it 'should query correct url with parameters' do
      expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?startAt=50&maxResults=100').and_return(response)
      expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))

      JIRA::Resource::Agile.get_projects(client, 1, startAt: 50)
    end
  end
end