Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
90718774
Commit
90718774
authored
Mar 26, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a Gitlab::FakeApplicationSettings when migrations are pending
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
81fe9e9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+1
-1
spec/lib/gitlab/current_settings_spec.rb
spec/lib/gitlab/current_settings_spec.rb
+11
-2
No files found.
lib/gitlab/current_settings.rb
View file @
90718774
...
...
@@ -47,7 +47,7 @@ module Gitlab
# defaults for missing columns.
if
ActiveRecord
::
Migrator
.
needs_migration?
db_attributes
=
current_settings
&
.
attributes
||
{}
::
ApplicationSetting
.
build_from_default
s
(
db_attributes
)
fake_application_setting
s
(
db_attributes
)
elsif
current_settings
.
present?
current_settings
else
...
...
spec/lib/gitlab/current_settings_spec.rb
View file @
90718774
...
...
@@ -116,8 +116,7 @@ describe Gitlab::CurrentSettings do
let
(
:current_settings
)
{
described_class
.
current_application_settings
}
it
'returns a non-persisted ApplicationSetting object'
do
expect
(
current_settings
).
to
be_a
(
ApplicationSetting
)
expect
(
current_settings
).
not_to
be_persisted
expect
(
current_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
end
it
'uses the default value from ApplicationSetting.defaults'
do
...
...
@@ -146,6 +145,16 @@ describe Gitlab::CurrentSettings do
it
'uses the value from the DB attribute if present and not overridden by an accessor'
do
expect
(
current_settings
.
home_page_url
).
to
eq
(
db_settings
.
home_page_url
)
end
context
'when a new column is used before being migrated'
do
before
do
allow
(
ApplicationSetting
).
to
receive
(
:defaults
).
and_return
({
foo:
'bar'
})
end
it
'uses the default value if present'
do
expect
(
current_settings
.
foo
).
to
eq
(
'bar'
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment