summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/health_controller_spec.rb19
-rw-r--r--spec/features/users/signup_spec.rb145
-rw-r--r--spec/lib/gitlab/health_checks/probes/liveness_spec.rb17
-rw-r--r--spec/lib/gitlab/health_checks/probes/readiness_spec.rb39
-rw-r--r--spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb105
-rw-r--r--spec/models/group_spec.rb16
-rw-r--r--spec/models/namespace_spec.rb21
-rw-r--r--spec/models/project_services/bugzilla_service_spec.rb2
-rw-r--r--spec/models/project_services/custom_issue_tracker_service_spec.rb2
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb2
-rw-r--r--spec/models/project_services/jira_service_spec.rb2
-rw-r--r--spec/models/project_services/redmine_service_spec.rb2
-rw-r--r--spec/models/project_services/youtrack_service_spec.rb2
-rw-r--r--spec/models/service_spec.rb2
-rw-r--r--spec/requests/api/groups_spec.rb37
-rw-r--r--spec/requests/api/users_spec.rb45
-rw-r--r--spec/support/helpers/group_api_helpers.rb11
17 files changed, 354 insertions, 115 deletions
diff --git a/spec/controllers/health_controller_spec.rb b/spec/controllers/health_controller_spec.rb
index dd6aac4b126..8a2291bccd7 100644
--- a/spec/controllers/health_controller_spec.rb
+++ b/spec/controllers/health_controller_spec.rb
@@ -24,11 +24,12 @@ describe HealthController do
it 'responds with readiness checks data' do
subject
- expect(json_response['db_check']['status']).to eq('ok')
- expect(json_response['cache_check']['status']).to eq('ok')
- expect(json_response['queues_check']['status']).to eq('ok')
- expect(json_response['shared_state_check']['status']).to eq('ok')
- expect(json_response['gitaly_check']['status']).to eq('ok')
+ expect(json_response['db_check']).to contain_exactly({ 'status' => 'ok' })
+ expect(json_response['cache_check']).to contain_exactly({ 'status' => 'ok' })
+ expect(json_response['queues_check']).to contain_exactly({ 'status' => 'ok' })
+ expect(json_response['shared_state_check']).to contain_exactly({ 'status' => 'ok' })
+ expect(json_response['gitaly_check']).to contain_exactly(
+ { 'status' => 'ok', 'labels' => { 'shard' => 'default' } })
end
it 'responds with readiness checks data when a failure happens' do
@@ -37,9 +38,9 @@ describe HealthController do
subject
- expect(json_response['redis_check']['status']).to eq('failed')
- expect(json_response['redis_check']['message']).to eq('check error')
- expect(json_response['cache_check']['status']).to eq('ok')
+ expect(json_response['cache_check']).to contain_exactly({ 'status' => 'ok' })
+ expect(json_response['redis_check']).to contain_exactly(
+ { 'status' => 'failed', 'message' => 'check error' })
expect(response.status).to eq(503)
expect(response.headers['X-GitLab-Custom-Error']).to eq(1)
@@ -90,7 +91,7 @@ describe HealthController do
it 'responds with liveness checks data' do
subject
- expect(json_response['status']).to eq('ok')
+ expect(json_response).to eq('status' => 'ok')
end
end
diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb
index fb927a9ca3b..0846ec8dfb4 100644
--- a/spec/features/users/signup_spec.rb
+++ b/spec/features/users/signup_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe 'Signup' do
+shared_examples 'Signup' do
include TermsHelper
before do
@@ -13,8 +13,7 @@ describe 'Signup' do
describe 'username validation', :js do
before do
- visit root_path
- click_link 'Register'
+ visit new_user_registration_path
end
it 'does not show an error border if the username is available' do
@@ -130,8 +129,7 @@ describe 'Signup' do
describe 'user\'s full name validation', :js do
before do
- visit root_path
- click_link 'Register'
+ visit new_user_registration_path
end
it 'does not show an error border if the user\'s fullname length is not longer than 128 characters' do
@@ -177,13 +175,17 @@ describe 'Signup' do
end
it 'creates the user account and sends a confirmation email' do
- visit root_path
+ visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
+
+ unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ fill_in 'new_user_email_confirmation', with: new_user.email
+ end
+
+ fill_in 'new_user_password', with: new_user.password
expect { click_button 'Register' }.to change { User.count }.by(1)
@@ -198,13 +200,17 @@ describe 'Signup' do
end
it 'creates the user account and sends a confirmation email' do
- visit root_path
+ visit new_user_registration_path
+
+ fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
+
+ unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ fill_in 'new_user_email_confirmation', with: new_user.email
+ end
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in 'new_user_password', with: new_user.password
expect { click_button 'Register' }.to change { User.count }.by(1)
@@ -216,13 +222,17 @@ describe 'Signup' do
context "when sigining up with different cased emails" do
it "creates the user successfully" do
- visit root_path
+ visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email.capitalize
- fill_in 'new_user_password', with: new_user.password
+ fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
+
+ unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ fill_in 'new_user_email_confirmation', with: new_user.email.capitalize
+ end
+
+ fill_in 'new_user_password', with: new_user.password
click_button "Register"
expect(current_path).to eq dashboard_projects_path
@@ -236,13 +246,17 @@ describe 'Signup' do
end
it 'creates the user account and goes to dashboard' do
- visit root_path
+ visit new_user_registration_path
+
+ fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ fill_in 'new_user_email_confirmation', with: new_user.email
+ end
+
+ fill_in 'new_user_password', with: new_user.password
click_button "Register"
expect(current_path).to eq dashboard_projects_path
@@ -255,28 +269,34 @@ describe 'Signup' do
it "displays the errors" do
existing_user = create(:user)
- visit root_path
+ visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: existing_user.email
+ fill_in 'new_user_email', with: existing_user.email
fill_in 'new_user_password', with: new_user.password
click_button "Register"
expect(current_path).to eq user_registration_path
- expect(page).to have_content("errors prohibited this user from being saved")
- expect(page).to have_content("Email has already been taken")
- expect(page).to have_content("Email confirmation doesn't match")
+
+ if Feature.enabled?(:experimental_separate_sign_up_flow)
+ expect(page).to have_content("error prohibited this user from being saved")
+ expect(page).to have_content("Email has already been taken")
+ else
+ expect(page).to have_content("errors prohibited this user from being saved")
+ expect(page).to have_content("Email has already been taken")
+ expect(page).to have_content("Email confirmation doesn't match")
+ end
end
it 'does not redisplay the password' do
existing_user = create(:user)
- visit root_path
+ visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: existing_user.email
+ fill_in 'new_user_email', with: existing_user.email
fill_in 'new_user_password', with: new_user.password
click_button "Register"
@@ -291,13 +311,17 @@ describe 'Signup' do
end
it 'requires the user to check the checkbox' do
- visit root_path
+ visit new_user_registration_path
+
+ fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
+
+ unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ fill_in 'new_user_email_confirmation', with: new_user.email
+ end
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in 'new_user_password', with: new_user.password
click_button 'Register'
@@ -306,13 +330,17 @@ describe 'Signup' do
end
it 'asks the user to accept terms before going to the dashboard' do
- visit root_path
+ visit new_user_registration_path
+
+ fill_in 'new_user_name', with: new_user.name
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
+
+ unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ fill_in 'new_user_email_confirmation', with: new_user.email
+ end
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in 'new_user_password', with: new_user.password
check :terms_opt_in
click_button "Register"
@@ -321,3 +349,20 @@ describe 'Signup' do
end
end
end
+
+describe 'With original flow' do
+ it_behaves_like 'Signup' do
+ before do
+ stub_feature_flags(experimental_separate_sign_up_flow: false)
+ end
+ end
+end
+
+describe 'With experimental flow on GitLab.com' do
+ it_behaves_like 'Signup' do
+ before do
+ expect(Gitlab).to receive(:com?).and_return(true).at_least(:once)
+ stub_feature_flags(experimental_separate_sign_up_flow: true)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/health_checks/probes/liveness_spec.rb b/spec/lib/gitlab/health_checks/probes/liveness_spec.rb
new file mode 100644
index 00000000000..91066cb8ba0
--- /dev/null
+++ b/spec/lib/gitlab/health_checks/probes/liveness_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::HealthChecks::Probes::Liveness do
+ let(:liveness) { described_class.new }
+
+ describe '#call' do
+ subject { liveness.execute }
+
+ it 'responds with liveness checks data' do
+ expect(subject.http_status).to eq(200)
+
+ expect(subject.json[:status]).to eq('ok')
+ end
+ end
+end
diff --git a/spec/lib/gitlab/health_checks/probes/readiness_spec.rb b/spec/lib/gitlab/health_checks/probes/readiness_spec.rb
new file mode 100644
index 00000000000..d88ffd984c2
--- /dev/null
+++ b/spec/lib/gitlab/health_checks/probes/readiness_spec.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::HealthChecks::Probes::Readiness do
+ let(:readiness) { described_class.new }
+
+ describe '#call' do
+ subject { readiness.execute }
+
+ it 'responds with readiness checks data' do
+ expect(subject.http_status).to eq(200)
+
+ expect(subject.json[:status]).to eq('ok')
+ expect(subject.json['db_check']).to contain_exactly(status: 'ok')
+ expect(subject.json['cache_check']).to contain_exactly(status: 'ok')
+ expect(subject.json['queues_check']).to contain_exactly(status: 'ok')
+ expect(subject.json['shared_state_check']).to contain_exactly(status: 'ok')
+ expect(subject.json['gitaly_check']).to contain_exactly(
+ status: 'ok', labels: { shard: 'default' })
+ end
+
+ context 'when Redis fails' do
+ before do
+ allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(
+ Gitlab::HealthChecks::Result.new('redis_check', false, "check error"))
+ end
+
+ it 'responds with failure' do
+ expect(subject.http_status).to eq(503)
+
+ expect(subject.json[:status]).to eq('failed')
+ expect(subject.json['cache_check']).to contain_exactly(status: 'ok')
+ expect(subject.json['redis_check']).to contain_exactly(
+ status: 'failed', message: 'check error')
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb b/spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb
index 5fd7438d28a..bedf4fedcfa 100644
--- a/spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb
+++ b/spec/lib/gitlab/metrics/exporter/base_exporter_spec.rb
@@ -4,35 +4,42 @@ require 'spec_helper'
describe Gitlab::Metrics::Exporter::BaseExporter do
let(:exporter) { described_class.new }
- let(:server) { double('server') }
- let(:socket) { double('socket') }
let(:log_filename) { File.join(Rails.root, 'log', 'sidekiq_exporter.log') }
let(:settings) { double('settings') }
before do
- allow(::WEBrick::HTTPServer).to receive(:new).and_return(server)
- allow(server).to receive(:mount)
- allow(server).to receive(:start)
- allow(server).to receive(:shutdown)
- allow(server).to receive(:listeners) { [socket] }
- allow(socket).to receive(:close)
allow_any_instance_of(described_class).to receive(:log_filename).and_return(log_filename)
allow_any_instance_of(described_class).to receive(:settings).and_return(settings)
end
describe 'when exporter is enabled' do
before do
+ allow(::WEBrick::HTTPServer).to receive(:new).with(
+ Port: anything,
+ BindAddress: anything,
+ Logger: anything,
+ AccessLog: anything
+ ).and_wrap_original do |m, *args|
+ m.call(DoNotListen: true, Logger: args.first[:Logger])
+ end
+
+ allow_any_instance_of(::WEBrick::HTTPServer).to receive(:start)
+
allow(settings).to receive(:enabled).and_return(true)
- allow(settings).to receive(:port).and_return(3707)
+ allow(settings).to receive(:port).and_return(8082)
allow(settings).to receive(:address).and_return('localhost')
end
+ after do
+ exporter.stop
+ end
+
describe 'when exporter is stopped' do
describe '#start' do
it 'starts the exporter' do
- expect { exporter.start.join }.to change { exporter.thread? }.from(false).to(true)
+ expect_any_instance_of(::WEBrick::HTTPServer).to receive(:start)
- expect(server).to have_received(:start)
+ expect { exporter.start.join }.to change { exporter.thread? }.from(false).to(true)
end
describe 'with custom settings' do
@@ -45,23 +52,25 @@ describe Gitlab::Metrics::Exporter::BaseExporter do
end
it 'starts server with port and address from settings' do
- exporter.start.join
-
- expect(::WEBrick::HTTPServer).to have_received(:new).with(
+ expect(::WEBrick::HTTPServer).to receive(:new).with(
Port: port,
BindAddress: address,
Logger: anything,
AccessLog: anything
- )
+ ).and_wrap_original do |m, *args|
+ m.call(DoNotListen: true, Logger: args.first[:Logger])
+ end
+
+ exporter.start.join
end
end
end
describe '#stop' do
it "doesn't shutdown stopped server" do
- expect { exporter.stop }.not_to change { exporter.thread? }
+ expect_any_instance_of(::WEBrick::HTTPServer).not_to receive(:shutdown)
- expect(server).not_to have_received(:shutdown)
+ expect { exporter.stop }.not_to change { exporter.thread? }
end
end
end
@@ -73,20 +82,66 @@ describe Gitlab::Metrics::Exporter::BaseExporter do
describe '#start' do
it "doesn't start running server" do
- expect { exporter.start.join }.not_to change { exporter.thread? }
+ expect_any_instance_of(::WEBrick::HTTPServer).not_to receive(:start)
- expect(server).to have_received(:start).once
+ expect { exporter.start.join }.not_to change { exporter.thread? }
end
end
describe '#stop' do
it 'shutdowns server' do
+ expect_any_instance_of(::WEBrick::HTTPServer).to receive(:shutdown)
+
expect { exporter.stop }.to change { exporter.thread? }.from(true).to(false)
+ end
+ end
+ end
+ end
+
+ describe 'request handling' do
+ using RSpec::Parameterized::TableSyntax
- expect(socket).to have_received(:close)
- expect(server).to have_received(:shutdown)
+ where(:method_class, :path, :http_status) do
+ Net::HTTP::Get | '/metrics' | 200
+ Net::HTTP::Get | '/liveness' | 200
+ Net::HTTP::Get | '/readiness' | 200
+ Net::HTTP::Get | '/' | 404
+ end
+
+ before do
+ allow(settings).to receive(:enabled).and_return(true)
+ allow(settings).to receive(:port).and_return(0)
+ allow(settings).to receive(:address).and_return('127.0.0.1')
+
+ # We want to wrap original method
+ # and run handling of requests
+ # in separate thread
+ allow_any_instance_of(::WEBrick::HTTPServer)
+ .to receive(:start).and_wrap_original do |m, *args|
+ Thread.new do
+ m.call(*args)
+ rescue IOError
+ # is raised as we close listeners
end
end
+
+ exporter.start.join
+ end
+
+ after do
+ exporter.stop
+ end
+
+ with_them do
+ let(:config) { exporter.server.config }
+ let(:request) { method_class.new(path) }
+
+ it 'responds with proper http_status' do
+ http = Net::HTTP.new(config[:BindAddress], config[:Port])
+ response = http.request(request)
+
+ expect(response.code).to eq(http_status.to_s)
+ end
end
end
@@ -97,18 +152,18 @@ describe Gitlab::Metrics::Exporter::BaseExporter do
describe '#start' do
it "doesn't start" do
+ expect_any_instance_of(::WEBrick::HTTPServer).not_to receive(:start)
+
expect(exporter.start).to be_nil
expect { exporter.start }.not_to change { exporter.thread? }
-
- expect(server).not_to have_received(:start)
end
end
describe '#stop' do
it "doesn't shutdown" do
- expect { exporter.stop }.not_to change { exporter.thread? }
+ expect_any_instance_of(::WEBrick::HTTPServer).not_to receive(:shutdown)
- expect(server).not_to have_received(:shutdown)
+ expect { exporter.stop }.not_to change { exporter.thread? }
end
end
end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 796b6917fb2..3f149f9d7ee 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -880,22 +880,6 @@ describe Group do
end
end
- describe '#has_parent?' do
- context 'when the group has a parent' do
- it 'is truthy' do
- group = create(:group, :nested)
- expect(group.has_parent?).to be_truthy
- end
- end
-
- context 'when the group has no parent' do
- it 'is falsy' do
- group = create(:group, parent: nil)
- expect(group.has_parent?).to be_falsy
- end
- end
- end
-
context 'with uploads' do
it_behaves_like 'model with uploads', true do
let(:model_object) { create(:group, :with_avatar) }
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index 797be0d1fe2..60f0dd49ff3 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -933,4 +933,25 @@ describe Namespace do
end
end
end
+
+ describe '#has_parent?' do
+ it 'returns true when the group has a parent' do
+ group = create(:group, :nested)
+
+ expect(group.has_parent?).to be_truthy
+ end
+
+ it 'returns true when the group has an unsaved parent' do
+ parent = build(:group)
+ group = build(:group, parent: parent)
+
+ expect(group.has_parent?).to be_truthy
+ end
+
+ it 'returns false when the group has no parent' do
+ group = create(:group, parent: nil)
+
+ expect(group.has_parent?).to be_falsy
+ end
+ end
end
diff --git a/spec/models/project_services/bugzilla_service_spec.rb b/spec/models/project_services/bugzilla_service_spec.rb
index 66481a461ca..d0ab5afc765 100644
--- a/spec/models/project_services/bugzilla_service_spec.rb
+++ b/spec/models/project_services/bugzilla_service_spec.rb
@@ -41,7 +41,7 @@ describe BugzillaService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/custom_issue_tracker_service_spec.rb b/spec/models/project_services/custom_issue_tracker_service_spec.rb
index 50bf15cfc8c..e749ea6eacc 100644
--- a/spec/models/project_services/custom_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/custom_issue_tracker_service_spec.rb
@@ -55,7 +55,7 @@ describe CustomIssueTrackerService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
index 2dc0b67239c..defebcee9c6 100644
--- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
@@ -58,7 +58,7 @@ describe GitlabIssueTrackerService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index c3b2e52848c..28d2ea79641 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -278,7 +278,7 @@ describe JiraService do
end
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { data_params.merge(title: title, description: description) }
let!(:service) do
diff --git a/spec/models/project_services/redmine_service_spec.rb b/spec/models/project_services/redmine_service_spec.rb
index 2339c5a8421..6220d7b1fac 100644
--- a/spec/models/project_services/redmine_service_spec.rb
+++ b/spec/models/project_services/redmine_service_spec.rb
@@ -57,7 +57,7 @@ describe RedmineService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/youtrack_service_spec.rb b/spec/models/project_services/youtrack_service_spec.rb
index fe608baf16b..19d4cb95315 100644
--- a/spec/models/project_services/youtrack_service_spec.rb
+++ b/spec/models/project_services/youtrack_service_spec.rb
@@ -45,7 +45,7 @@ describe YoutrackService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 4049ddcff7f..64077b76f01 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -121,7 +121,7 @@ describe Service do
end
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'when data are stored in properties' do
let(:properties) { data_params.merge(title: title, description: description) }
let!(:template) do
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index ec587a28f4f..902a5ec2a86 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe API::Groups do
+ include GroupAPIHelpers
include UploadHelpers
let(:user1) { create(:user, can_create_group: false) }
@@ -350,6 +351,13 @@ describe API::Groups do
expect(json_response['description']).to eq(group1.description)
expect(json_response['visibility']).to eq(Gitlab::VisibilityLevel.string_level(group1.visibility_level))
expect(json_response['avatar_url']).to eq(group1.avatar_url(only_path: false))
+ expect(json_response['share_with_group_lock']).to eq(group1.share_with_group_lock)
+ expect(json_response['require_two_factor_authentication']).to eq(group1.require_two_factor_authentication)
+ expect(json_response['two_factor_grace_period']).to eq(group1.two_factor_grace_period)
+ expect(json_response['auto_devops_enabled']).to eq(group1.auto_devops_enabled)
+ expect(json_response['emails_disabled']).to eq(group1.emails_disabled)
+ expect(json_response['project_creation_level']).to eq('maintainer')
+ expect(json_response['subgroup_creation_level']).to eq('maintainer')
expect(json_response['web_url']).to eq(group1.web_url)
expect(json_response['request_access_enabled']).to eq(group1.request_access_enabled)
expect(json_response['full_name']).to eq(group1.full_name)
@@ -485,11 +493,30 @@ describe API::Groups do
context 'when authenticated as the group owner' do
it 'updates the group' do
- put api("/groups/#{group1.id}", user1), params: { name: new_group_name, request_access_enabled: true }
+ put api("/groups/#{group1.id}", user1), params: {
+ name: new_group_name,
+ request_access_enabled: true,
+ project_creation_level: "noone",
+ subgroup_creation_level: "maintainer"
+ }
expect(response).to have_gitlab_http_status(200)
expect(json_response['name']).to eq(new_group_name)
+ expect(json_response['description']).to eq('')
+ expect(json_response['visibility']).to eq('public')
+ expect(json_response['share_with_group_lock']).to eq(false)
+ expect(json_response['require_two_factor_authentication']).to eq(false)
+ expect(json_response['two_factor_grace_period']).to eq(48)
+ expect(json_response['auto_devops_enabled']).to eq(nil)
+ expect(json_response['emails_disabled']).to eq(nil)
+ expect(json_response['project_creation_level']).to eq("noone")
+ expect(json_response['subgroup_creation_level']).to eq("maintainer")
expect(json_response['request_access_enabled']).to eq(true)
+ expect(json_response['parent_id']).to eq(nil)
+ expect(json_response['projects']).to be_an Array
+ expect(json_response['projects'].length).to eq(2)
+ expect(json_response['shared_projects']).to be_an Array
+ expect(json_response['shared_projects'].length).to eq(0)
end
it 'returns 404 for a non existing group' do
@@ -864,7 +891,9 @@ describe API::Groups do
describe "POST /groups" do
context "when authenticated as user without group permissions" do
it "does not create group" do
- post api("/groups", user1), params: attributes_for(:group)
+ group = attributes_for_group_api
+
+ post api("/groups", user1), params: group
expect(response).to have_gitlab_http_status(403)
end
@@ -896,7 +925,7 @@ describe API::Groups do
context "when authenticated as user with group permissions" do
it "creates group" do
- group = attributes_for(:group, { request_access_enabled: false })
+ group = attributes_for_group_api request_access_enabled: false
post api("/groups", user3), params: group
@@ -911,7 +940,7 @@ describe API::Groups do
it "creates a nested group" do
parent = create(:group)
parent.add_owner(user3)
- group = attributes_for(:group, { parent_id: parent.id })
+ group = attributes_for_group_api parent_id: parent.id
post api("/groups", user3), params: group
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index af2bee4563a..df76b62b40e 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -634,10 +634,47 @@ describe API::Users do
end
describe "GET /users/sign_up" do
- it "redirects to sign in page" do
- get "/users/sign_up"
- expect(response).to have_gitlab_http_status(302)
- expect(response).to redirect_to(new_user_session_path)
+ context 'when experimental_separate_sign_up_flow is active' do
+ before do
+ stub_feature_flags(experimental_separate_sign_up_flow: true)
+ end
+
+ context 'on gitlab.com' do
+ before do
+ allow(::Gitlab).to receive(:com?).and_return(true)
+ end
+
+ it "shows sign up page" do
+ get "/users/sign_up"
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to render_template(:new)
+ end
+ end
+
+ context 'not on gitlab.com' do
+ before do
+ allow(::Gitlab).to receive(:com?).and_return(false)
+ end
+
+ it "redirects to sign in page" do
+ get "/users/sign_up"
+ expect(response).to have_gitlab_http_status(302)
+ expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane'))
+ end
+ end
+ end
+
+ context 'when experimental_separate_sign_up_flow is not active' do
+ before do
+ allow(::Gitlab).to receive(:com?).and_return(true)
+ stub_feature_flags(experimental_separate_sign_up_flow: false)
+ end
+
+ it "redirects to sign in page" do
+ get "/users/sign_up"
+ expect(response).to have_gitlab_http_status(302)
+ expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane'))
+ end
end
end
diff --git a/spec/support/helpers/group_api_helpers.rb b/spec/support/helpers/group_api_helpers.rb
new file mode 100644
index 00000000000..56c4cc121a7
--- /dev/null
+++ b/spec/support/helpers/group_api_helpers.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module GroupAPIHelpers
+ extend self
+
+ def attributes_for_group_api(params = {})
+ # project_creation_level and subgroup_creation_level are Integers in the model
+ # but are strings in the API
+ attributes_for(:group, params).except(:project_creation_level, :subgroup_creation_level)
+ end
+end