Skip to content

Commit f874a47

Browse files
authored
Merge pull request #1046 from code0-tech/#984-change-user-reg-to-false
change user registration to false
2 parents 4eda783 + 397ac25 commit f874a47

9 files changed

Lines changed: 23 additions & 2 deletions

File tree

db/fixtures/01_application_settings.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ApplicationSetting.seed_once :setting do |s|
44
s.setting = :user_registration_enabled
5-
s.value = true
5+
s.value = false
66
end
77

88
ApplicationSetting.seed_once :setting do |s|

extensions/ee/spec/services/ee/users/identity/register_service_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def setup_identity_provider(identity)
4040

4141
context 'when user limit of license is reached' do
4242
before do
43+
stub_application_settings(user_registration_enabled: true)
4344
create(:license, restrictions: { user_count: 0 })
4445
end
4546

extensions/ee/spec/services/ee/users/register_service_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
context 'when user limit of license is reached' do
1313
before do
14+
stub_application_settings(user_registration_enabled: true)
1415
create(:license, restrictions: { user_count: 0 })
1516
end
1617

spec/requests/graphql/mutation/users/identity/register_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def setup_identity_provider(identity)
4444
end
4545

4646
before do
47+
stub_application_settings(user_registration_enabled: true)
48+
4749
setup_identity_provider Code0::Identities::Identity.new(:google, 'identifier', 'username', 'test@code0.tech',
4850
'firstname', 'lastname')
4951

spec/requests/graphql/mutation/users/register_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636

3737
let(:variables) { { input: input } }
3838

39-
before { post_graphql mutation, variables: variables }
39+
before do
40+
stub_application_settings(user_registration_enabled: true)
41+
post_graphql mutation, variables: variables
42+
end
4043

4144
it 'creates the user' do
4245
expect(graphql_data_at(:users_register, :user_session, :user, :id)).to be_present

spec/services/application_settings_update_service_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
let(:current_user) { create(:user, :admin) }
4242
let(:params) { { user_registration_enabled: false } }
4343

44+
before do
45+
ApplicationSetting.user_registration_enabled.update!(value: true)
46+
end
47+
4448
it { is_expected.to be_success }
4549
it { expect(service_response.payload).to include(user_registration_enabled: false) }
4650

spec/services/users/identity/register_service_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def setup_identity_provider(identity)
1515
allow(provider).to receive(:load_identity).and_return identity
1616
end
1717

18+
before do
19+
stub_application_settings(user_registration_enabled: true)
20+
end
21+
1822
context 'when user is valid' do
1923
let(:provider_id) do
2024
:google

spec/services/users/register_service_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
RSpec.describe Users::RegisterService do
66
subject(:service_response) { described_class.new(username, email, password).execute }
77

8+
before do
9+
stub_application_settings(user_registration_enabled: true)
10+
end
11+
812
context 'when user is valid' do
913
let(:username) { generate(:username) }
1014
let(:email) { generate(:email) }

spec/support/helpers/stub_application_settings.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module StubApplicationSettings
44
def stub_application_settings(settings)
55
current_settings = ApplicationSetting.current
66

7+
allow(current_settings).to receive(:[]).and_call_original
8+
79
settings.each do |key, value|
810
allow(current_settings).to receive(:[]).with(key.to_sym).and_return(value)
911
allow(current_settings).to receive(:[]).with(key.to_s).and_return(value)

0 commit comments

Comments
 (0)