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:
authorMario de la Ossa <mariodelaossa@gmail.com>2017-12-30 02:36:57 +0300
committerMario de la Ossa <mariodelaossa@gmail.com>2017-12-30 23:33:49 +0300
commit75cf5f5b548c6e6df47eff721a31cd70fe202451 (patch)
treef3e5dcb51c4db54ff29a40ec87df51e83a66c4d7 /spec/models
parent1b447b1642b4a1b91e595d319d7d90f2b43515ef (diff)
User#projects_limit remove DB default and added NOT NULL constraint
This change is required because otherwise if a user is created with a value for `projects_limit` that matches the DB default, it gets overwritten by `current_application_settings.default_projects_limit`. By removing the default we once again can allow a user to be created with a limit of 10 projects without the risk that it'll change to 10000
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/user_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 2557ce71f2b..0d4ab7fdae7 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -134,6 +134,16 @@ describe User do
end
end
+ it 'has a DB-level NOT NULL constraint on projects_limit' do
+ user = create(:user)
+
+ expect(user.persisted?).to eq(true)
+
+ expect do
+ user.update_columns(projects_limit: nil)
+ end.to raise_error(ActiveRecord::StatementInvalid)
+ end
+
it { is_expected.to validate_presence_of(:projects_limit) }
it { is_expected.to validate_numericality_of(:projects_limit) }
it { is_expected.to allow_value(0).for(:projects_limit) }
@@ -805,6 +815,13 @@ describe User do
expect(user.can_create_group).to be_falsey
expect(user.theme_id).to eq(1)
end
+
+ it 'does not undo projects_limit setting if it matches old DB default of 10' do
+ # If the real default project limit is 10 then this test is worthless
+ expect(Gitlab.config.gitlab.default_projects_limit).not_to eq(10)
+ user = described_class.new(projects_limit: 10)
+ expect(user.projects_limit).to eq(10)
+ end
end
context 'when current_application_settings.user_default_external is true' do