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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-29 22:57:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-29 22:57:17 +0300
commit37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9 (patch)
tree9d3739f627b491b42ede6424acd11b589beed25f /spec/requests
parentb55baf593e63db9be3f446ea0cca0281a69dd2e2 (diff)
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb41
-rw-r--r--spec/requests/api/settings_spec.rb28
2 files changed, 61 insertions, 8 deletions
diff --git a/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb b/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb
index 4057aa4ba9e..00b93984f98 100644
--- a/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb
+++ b/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb
@@ -8,15 +8,17 @@ RSpec.describe 'Importing Jira Users' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
+ let(:importer) { instance_double(JiraImport::UsersImporter) }
let(:project_path) { project.full_path }
let(:start_at) { 7 }
-
- let(:mutation) do
- variables = {
+ let(:variables) do
+ {
start_at: start_at,
project_path: project_path
}
+ end
+ let(:mutation) do
graphql_mutation(:jira_import_users, variables)
end
@@ -65,9 +67,38 @@ RSpec.describe 'Importing Jira Users' do
end
end
- context 'when all params and permissions are ok' do
- let(:importer) { instance_double(JiraImport::UsersImporter) }
+ context 'with start_at' do
+ RSpec.shared_examples 'start users import at zero' do
+ it 'returns imported users' do
+ users = [{ jira_account_id: '12a', jira_display_name: 'user 1' }]
+ result = ServiceResponse.success(payload: users)
+
+ expect(importer).to receive(:execute).and_return(result)
+ expect(JiraImport::UsersImporter).to receive(:new).with(current_user, project, 0).and_return(importer)
+ post_graphql_mutation(mutation, current_user: current_user)
+ end
+ end
+
+ context 'when nil' do
+ let(:variables) do
+ {
+ start_at: nil,
+ project_path: project_path
+ }
+ end
+
+ it_behaves_like 'start users import at zero'
+ end
+
+ context 'when not provided' do
+ let(:variables) { { project_path: project_path } }
+
+ it_behaves_like 'start users import at zero'
+ end
+ end
+
+ context 'when all params and permissions are ok' do
before do
expect(JiraImport::UsersImporter).to receive(:new).with(current_user, project, 7)
.and_return(importer)
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb
index 602aacb6ced..8db0cdcbc2c 100644
--- a/spec/requests/api/settings_spec.rb
+++ b/spec/requests/api/settings_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe API::Settings, 'Settings' do
expect(json_response).to be_an Hash
expect(json_response['default_projects_limit']).to eq(42)
expect(json_response['password_authentication_enabled_for_web']).to be_truthy
- expect(json_response['repository_storages']).to eq(['default'])
+ expect(json_response['repository_storages_weighted']).to eq({ 'default' => 100 })
expect(json_response['password_authentication_enabled']).to be_truthy
expect(json_response['plantuml_enabled']).to be_falsey
expect(json_response['plantuml_url']).to be_nil
@@ -55,6 +55,28 @@ RSpec.describe API::Settings, 'Settings' do
stub_feature_flags(sourcegraph: true)
end
+ it "coerces repository_storages_weighted to an int" do
+ put api("/application/settings", admin),
+ params: {
+ repository_storages_weighted: { 'custom' => '75' }
+ }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['repository_storages_weighted']).to eq({ 'custom' => 75 })
+ end
+
+ context "repository_storages_weighted value is outside a 0-100 range" do
+ [-1, 101].each do |out_of_range_int|
+ it "returns a :bad_request for #{out_of_range_int}" do
+ put api("/application/settings", admin),
+ params: {
+ repository_storages_weighted: { 'custom' => out_of_range_int }
+ }
+ expect(response).to have_gitlab_http_status(:bad_request)
+ end
+ end
+ end
+
it "updates application settings" do
put api("/application/settings", admin),
params: {
@@ -62,7 +84,7 @@ RSpec.describe API::Settings, 'Settings' do
default_projects_limit: 3,
default_project_creation: 2,
password_authentication_enabled_for_web: false,
- repository_storages: 'custom',
+ repository_storages_weighted: { 'custom' => 100 },
plantuml_enabled: true,
plantuml_url: 'http://plantuml.example.com',
sourcegraph_enabled: true,
@@ -104,7 +126,7 @@ RSpec.describe API::Settings, 'Settings' do
expect(json_response['default_projects_limit']).to eq(3)
expect(json_response['default_project_creation']).to eq(::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS)
expect(json_response['password_authentication_enabled_for_web']).to be_falsey
- expect(json_response['repository_storages']).to eq(['custom'])
+ expect(json_response['repository_storages_weighted']).to eq({ 'custom' => 100 })
expect(json_response['plantuml_enabled']).to be_truthy
expect(json_response['plantuml_url']).to eq('http://plantuml.example.com')
expect(json_response['sourcegraph_enabled']).to be_truthy