Skip to content
Snippets Groups Projects
Verified Commit bc8f0a13 authored by Rutger Wessels's avatar Rutger Wessels Committed by GitLab
Browse files

Use with_default_organization instead of with_current_organization

As the user by default has access to the default organization.
parent 70bf096c
1 merge request!161598Enable Organization Presence validation in Registration controllers
Showing
with 29 additions and 44 deletions
......@@ -38,13 +38,11 @@ def new
def create
set_resource_fields
Namespace.with_disabled_organization_validation do
super do |new_user|
if new_user.persisted?
after_successful_create_hook(new_user)
else
track_error(new_user)
end
super do |new_user|
if new_user.persisted?
after_successful_create_hook(new_user)
else
track_error(new_user)
end
end
# Devise sets a flash message on both successful & failed signups,
......@@ -236,7 +234,8 @@ def resource_name
def resource
@resource ||= Users::RegistrationsBuildService
.new(current_user, sign_up_params.merge({ skip_confirmation: skip_confirmation?,
preferred_language: preferred_language }))
preferred_language: preferred_language,
organization_id: Current.organization_id }))
.execute
end
......
......@@ -59,7 +59,9 @@ def sign_up_params_attributes
override :resource
def resource
@resource ||= Users::AuthorizedBuildService.new(current_user, sign_up_params).execute
@resource ||= Users::AuthorizedBuildService.new(
current_user, sign_up_params.merge(organization_id: Current.organization_id)
).execute
end
override :preregistration_tracking_label
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe RegistrationsController, feature_category: :system_access do
RSpec.describe RegistrationsController, :with_current_organization, feature_category: :system_access do
let(:member) { nil }
shared_examples 'an unrestricted IP address' do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Group or Project invitations', :js, feature_category: :onboarding do
RSpec.describe 'Group or Project invitations', :with_current_organization, :js, feature_category: :onboarding do
let(:group) { create(:group, name: 'Owned') }
let(:project) { create(:project, :repository, namespace: group) }
let(:group_invite) { create(:group_member, :invited, group: group) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'SaaS registration from an invite', :js, :saas_registration, :sidekiq_inline, feature_category: :onboarding do
RSpec.describe 'SaaS registration from an invite', :with_current_organization, :js, :saas_registration, :sidekiq_inline, feature_category: :onboarding do
it 'registers the user and sends them to the group page' do
group = create(:group, name: 'Test Group', organization: create(:organization))
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'SaaS registration from an invite', :js, :saas_registration, feature_category: :onboarding do
RSpec.describe 'SaaS registration from an invite', :with_current_organization, :js, :saas_registration, feature_category: :onboarding do
context 'when user has not completed welcome step before being added to group', :sidekiq_inline do
it 'registers the user, completes 2fa and sends them to the profile account page' do
group = create(:group, name: 'Test Group', require_two_factor_authentication: true)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Sign up with trial from external site without confirmation', :saas, :js,
RSpec.describe 'Sign up with trial from external site without confirmation', :saas, :js, :with_default_organization,
feature_category: :onboarding do
include SaasRegistrationHelpers
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Start trial from external site without confirmation', :saas, :js, feature_category: :onboarding do
RSpec.describe 'Start trial from external site without confirmation', :with_default_organization, :saas, :js, feature_category: :onboarding do
include SaasRegistrationHelpers
let_it_be(:glm_params) do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Signup on EE', :js, feature_category: :user_profile do
RSpec.describe 'Signup on EE', :with_current_organization, :js, feature_category: :user_profile do
let(:new_user) { build_stubbed(:user) }
before do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Trial Sign Up', :saas, feature_category: :acquisition do
RSpec.describe 'Trial Sign Up', :with_current_organization, :saas, feature_category: :acquisition do
before do
stub_application_setting(require_admin_approval_after_user_signup: false)
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Signup', feature_category: :system_access do
RSpec.describe 'Signup', :with_current_organization, feature_category: :system_access do
context 'almost there page' do
context 'when public visibility is restricted' do
before do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe RegistrationsController, type: :request, feature_category: :system_access do
RSpec.describe RegistrationsController, :with_current_organization, type: :request, feature_category: :system_access do
include SessionHelpers
let_it_be(:user_attrs) do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe TrialRegistrationsController, :saas, feature_category: :onboarding do
RSpec.describe TrialRegistrationsController, :with_current_organization, :saas, feature_category: :onboarding do
include FullNameHelper
describe 'GET new' do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe RegistrationsController, feature_category: :user_profile do
RSpec.describe RegistrationsController, :with_current_organization, feature_category: :user_profile do
include TermsHelper
include FullNameHelper
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_category: :acquisition do
RSpec.describe 'Group or Project invitations', :with_current_organization, :aggregate_failures, feature_category: :acquisition do
let_it_be(:owner) { create(:user, name: 'John Doe') }
# private will ensure we really have access to the group when we land on the group page
let_it_be(:group) { create(:group, :private, name: 'Owned') }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Registrations', feature_category: :system_access do
RSpec.describe 'Registrations', :with_current_organization, feature_category: :system_access do
let_it_be(:user) { create(:user) }
context 'when the user visits the registration page when already signed in', :clean_gitlab_redis_sessions do
......
......@@ -40,7 +40,7 @@
end
end
RSpec.describe 'Signup', :js, feature_category: :user_management do
RSpec.describe 'Signup', :with_current_organization, :js, feature_category: :user_management do
include TermsHelper
let(:new_user) { build_stubbed(:user) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe RegistrationsController, type: :request, feature_category: :system_access do
RSpec.describe RegistrationsController, :with_current_organization, type: :request, feature_category: :system_access do
describe '#create' do
let_it_be(:user_attrs) { build_stubbed(:user).slice(:first_name, :last_name, :username, :email, :password) }
let(:expected_context) do
......
......@@ -4,9 +4,10 @@
RSpec.describe Users::RegistrationsBuildService, feature_category: :system_access do
describe '#execute' do
let_it_be(:organization) { create(:organization) }
let(:base_params) { build_stubbed(:user).slice(:first_name, :last_name, :username, :email, :password) }
let(:skip_param) { {} }
let(:params) { base_params.merge(skip_param) }
let(:params) { base_params.merge(skip_param).merge(organization_id: organization.id) }
subject(:service) { described_class.new(nil, params) }
......@@ -18,7 +19,7 @@
it 'creates the user_detail record' do
user = service.execute
expect { Namespace.with_disabled_organization_validation { user.save! } }.to change { UserDetail.count }.by(1)
expect { user.save! }.to change { UserDetail.count }.by(1)
end
end
......
---
- ee/spec/controllers/ee/groups_controller_spec.rb
- ee/spec/controllers/ee/registrations_controller_spec.rb
- ee/spec/controllers/ee/omniauth_callbacks_controller_spec.rb
- ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb
- ee/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb
- ee/spec/features/groups_spec.rb
- ee/spec/features/registrations/combined_registration_spec.rb
- ee/spec/features/registrations/saas/sso_signin_standard_flow_company_creating_project_spec.rb
- ee/spec/features/registrations/saas/standard_flow_company_creating_project_spec.rb
- ee/spec/features/registrations/saas/standard_flow_just_me_creating_project_spec.rb
- ee/spec/features/registrations/saas/standard_flow_just_me_importing_project_spec.rb
- ee/spec/features/registrations/saas/subscription_flow_company_paid_plan_spec.rb
- ee/spec/features/registrations/saas/subscription_flow_just_me_paid_plan_spec.rb
- ee/spec/features/registrations/saas/trial_flow_company_creating_project_spec.rb
- ee/spec/features/registrations/saas/trial_flow_company_importing_project_spec.rb
- ee/spec/features/registrations/saas/trial_flow_just_me_creating_project_spec.rb
- ee/spec/features/registrations/saas/trial_flow_just_me_importing_project_spec.rb
- ee/spec/features/registrations/sign_up_with_trial_from_external_site_without_confirmation_spec.rb
- ee/spec/features/registrations/start_trial_from_external_site_without_confirmation_spec.rb
- ee/spec/features/trials/saas/creation_with_no_existing_namespace_flow_spec.rb
- ee/spec/lib/gitlab/auth/group_saml/user_spec.rb
- ee/spec/lib/gitlab/auth/saml/user_spec.rb
- ee/spec/lib/ee/gitlab/scim/provisioning_service_spec.rb
......@@ -31,7 +16,6 @@
- spec/controllers/admin/groups_controller_spec.rb
- spec/controllers/admin/users_controller_spec.rb
- spec/controllers/groups_controller_spec.rb
- spec/controllers/registrations_controller_spec.rb
- spec/features/admin/admin_groups_spec.rb
- spec/features/dashboard/group_spec.rb
- spec/features/groups_spec.rb
......@@ -43,6 +27,5 @@
- spec/models/hooks/system_hook_spec.rb
- spec/requests/api/groups_spec.rb
- spec/services/users/create_service_spec.rb
- spec/services/users/registrations_build_service_spec.rb
- spec/services/groups/create_service_spec.rb
- spec/services/resource_access_tokens/create_service_spec.rb
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment