diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/support/shared_contexts | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/support/shared_contexts')
5 files changed, 140 insertions, 10 deletions
diff --git a/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb b/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb index 617701abf27..2b8daa80ab4 100644 --- a/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb +++ b/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb @@ -45,11 +45,32 @@ RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests allow_gitaly_n_plus_1 { create(:project, group: subgroup) } end - let!(:merge_request1) { create(:merge_request, assignees: [user], author: user, source_project: project2, target_project: project1, target_branch: 'merged-target') } - let!(:merge_request2) { create(:merge_request, :conflict, assignees: [user], author: user, source_project: project2, target_project: project1, state: 'closed') } - let!(:merge_request3) { create(:merge_request, :simple, author: user, assignees: [user2], source_project: project2, target_project: project2, state: 'locked', title: 'thing WIP thing') } - let!(:merge_request4) { create(:merge_request, :simple, author: user, source_project: project3, target_project: project3, title: 'WIP thing') } - let!(:merge_request5) { create(:merge_request, :simple, author: user, source_project: project4, target_project: project4, title: '[WIP]') } + let!(:merge_request1) do + create(:merge_request, assignees: [user], author: user, + source_project: project2, target_project: project1, + target_branch: 'merged-target') + end + let!(:merge_request2) do + create(:merge_request, :conflict, assignees: [user], author: user, + source_project: project2, target_project: project1, + state: 'closed') + end + let!(:merge_request3) do + create(:merge_request, :simple, author: user, assignees: [user2], + source_project: project2, target_project: project2, + state: 'locked', + title: 'thing WIP thing') + end + let!(:merge_request4) do + create(:merge_request, :simple, author: user, + source_project: project3, target_project: project3, + title: 'WIP thing') + end + let_it_be(:merge_request5) do + create(:merge_request, :simple, author: user, + source_project: project4, target_project: project4, + title: '[WIP]') + end before do project1.add_maintainer(user) diff --git a/spec/support/shared_contexts/navbar_structure_context.rb b/spec/support/shared_contexts/navbar_structure_context.rb index fe3c32ec0c5..79b5ff44d4f 100644 --- a/spec/support/shared_contexts/navbar_structure_context.rb +++ b/spec/support/shared_contexts/navbar_structure_context.rb @@ -80,10 +80,13 @@ RSpec.shared_context 'project navbar structure' do nav_sub_items: [] }, { + nav_item: _('Members'), + nav_sub_items: [] + }, + { nav_item: _('Settings'), nav_sub_items: [ _('General'), - _('Members'), _('Integrations'), _('Webhooks'), _('Access Tokens'), diff --git a/spec/support/shared_contexts/project_service_shared_context.rb b/spec/support/shared_contexts/project_service_shared_context.rb index 21d67ea71a8..5b0dd26bd7b 100644 --- a/spec/support/shared_contexts/project_service_shared_context.rb +++ b/spec/support/shared_contexts/project_service_shared_context.rb @@ -5,7 +5,6 @@ shared_context 'project service activation' do let(:user) { create(:user) } before do - stub_feature_flags(integration_form_refactor: false) project.add_maintainer(user) sign_in(user) end diff --git a/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb b/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb new file mode 100644 index 00000000000..f0722beb3ed --- /dev/null +++ b/spec/support/shared_contexts/requests/api/graphql/jira_import/jira_projects_context.rb @@ -0,0 +1,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 diff --git a/spec/support/shared_contexts/spam_constants.rb b/spec/support/shared_contexts/spam_constants.rb index b6e92ea3050..32371f4b92f 100644 --- a/spec/support/shared_contexts/spam_constants.rb +++ b/spec/support/shared_contexts/spam_constants.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true shared_context 'includes Spam constants' do - REQUIRE_RECAPTCHA = Spam::SpamConstants::REQUIRE_RECAPTCHA - DISALLOW = Spam::SpamConstants::DISALLOW - ALLOW = Spam::SpamConstants::ALLOW + before do + stub_const('CONDITIONAL_ALLOW', Spam::SpamConstants::CONDITIONAL_ALLOW) + stub_const('DISALLOW', Spam::SpamConstants::DISALLOW) + stub_const('ALLOW', Spam::SpamConstants::ALLOW) + stub_const('BLOCK_USER', Spam::SpamConstants::BLOCK_USER) + end end |