Welcome to mirror list, hosted at ThFree Co, Russian Federation.

jira_projects_context.rb « jira_import « graphql « api « requests « shared_contexts « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f0722beb3ed4fef16315728931b12242c56f0d22 (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
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
# frozen_string_literal: true

shared_context 'jira projects request context' do
  let(:url) { 'https://jira.example.com' }
  let(:username) { 'jira-username' }
  let(:password) { 'jira-password' }
  let!(:jira_service) do
    create(:jira_service,
      project: project,
      url: url,
      username: username,
      password: password
    )
  end

  let_it_be(:jira_projects_json) do
    '{
          "self": "https://your-domain.atlassian.net/rest/api/2/project/search?startAt=0&maxResults=2",
          "nextPage": "https://your-domain.atlassian.net/rest/api/2/project/search?startAt=2&maxResults=2",
          "maxResults": 2,
          "startAt": 0,
          "total": 7,
          "isLast": false,
          "values": [
            {
              "self": "https://your-domain.atlassian.net/rest/api/2/project/EX",
              "id": "10000",
              "key": "EX",
              "name": "Example",
              "avatarUrls": {
                "48x48": "https://your-domain.atlassian.net/secure/projectavatar?size=large&pid=10000",
                "24x24": "https://your-domain.atlassian.net/secure/projectavatar?size=small&pid=10000",
                "16x16": "https://your-domain.atlassian.net/secure/projectavatar?size=xsmall&pid=10000",
                "32x32": "https://your-domain.atlassian.net/secure/projectavatar?size=medium&pid=10000"
              },
              "projectCategory": {
                "self": "https://your-domain.atlassian.net/rest/api/2/projectCategory/10000",
                "id": "10000",
                "name": "FIRST",
                "description": "First Project Category"
              },
              "simplified": false,
              "style": "classic",
              "insight": {
                "totalIssueCount": 100,
                "lastIssueUpdateTime": "2020-03-31T05:45:24.792+0000"
              }
            },
            {
              "self": "https://your-domain.atlassian.net/rest/api/2/project/ABC",
              "id": "10001",
              "key": "ABC",
              "name": "Alphabetical",
              "avatarUrls": {
                "48x48": "https://your-domain.atlassian.net/secure/projectavatar?size=large&pid=10001",
                "24x24": "https://your-domain.atlassian.net/secure/projectavatar?size=small&pid=10001",
                "16x16": "https://your-domain.atlassian.net/secure/projectavatar?size=xsmall&pid=10001",
                "32x32": "https://your-domain.atlassian.net/secure/projectavatar?size=medium&pid=10001"
              },
              "projectCategory": {
                "self": "https://your-domain.atlassian.net/rest/api/2/projectCategory/10000",
                "id": "10000",
                "name": "FIRST",
                "description": "First Project Category"
              },
              "simplified": false,
              "style": "classic",
              "insight": {
                "totalIssueCount": 100,
                "lastIssueUpdateTime": "2020-03-31T05:45:24.792+0000"
              }
            }
          ]
        }'
  end

  let_it_be(:empty_jira_projects_json) do
    '{
          "self": "https://your-domain.atlassian.net/rest/api/2/project/search?startAt=0&maxResults=2",
          "nextPage": "https://your-domain.atlassian.net/rest/api/2/project/search?startAt=2&maxResults=2",
          "maxResults": 2,
          "startAt": 0,
          "total": 7,
          "isLast": false,
          "values": []
    }'
  end

  let(:test_url) { "#{url}/rest/api/2/project/search?maxResults=50&query=&startAt=0" }
  let(:start_at_20_url) { "#{url}/rest/api/2/project/search?maxResults=50&query=&startAt=20" }
  let(:start_at_1_url) { "#{url}/rest/api/2/project/search?maxResults=50&query=&startAt=1" }
  let(:max_results_1_url) { "#{url}/rest/api/2/project/search?maxResults=1&query=&startAt=0" }

  before do
    WebMock.stub_request(:get, test_url).with(basic_auth: [username, password])
      .to_return(body: jira_projects_json, headers: { "Content-Type": "application/json" })
    WebMock.stub_request(:get, start_at_20_url).with(basic_auth: [username, password])
      .to_return(body: empty_jira_projects_json, headers: { "Content-Type": "application/json" })
    WebMock.stub_request(:get, start_at_1_url).with(basic_auth: [username, password])
      .to_return(body: jira_projects_json, headers: { "Content-Type": "application/json" })
    WebMock.stub_request(:get, max_results_1_url).with(basic_auth: [username, password])
      .to_return(body: jira_projects_json, headers: { "Content-Type": "application/json" })
  end
end