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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0ff27ce0
Commit
0ff27ce0
authored
Dec 14, 2018
by
Lin Jen-Shin
Committed by
Rémy Coutable
Dec 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Method `create_from_defaults` will never give nil
parent
cc5099c5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
15 deletions
+9
-15
app/models/application_setting.rb
app/models/application_setting.rb
+1
-1
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+1
-2
spec/lib/gitlab/current_settings_spec.rb
spec/lib/gitlab/current_settings_spec.rb
+7
-12
No files found.
app/models/application_setting.rb
View file @
0ff27ce0
...
@@ -311,7 +311,7 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -311,7 +311,7 @@ class ApplicationSetting < ActiveRecord::Base
end
end
def
self
.
create_from_defaults
def
self
.
create_from_defaults
create
(
defaults
)
build_from_defaults
.
tap
(
&
:save
)
end
end
def
self
.
human_attribute_name
(
attr
,
_options
=
{})
def
self
.
human_attribute_name
(
attr
,
_options
=
{})
...
...
lib/gitlab/current_settings.rb
View file @
0ff27ce0
...
@@ -51,8 +51,7 @@ module Gitlab
...
@@ -51,8 +51,7 @@ module Gitlab
elsif
current_settings
.
present?
elsif
current_settings
.
present?
current_settings
current_settings
else
else
::
ApplicationSetting
.
create_from_defaults
||
::
ApplicationSetting
.
create_from_defaults
in_memory_application_settings
end
end
end
end
...
...
spec/lib/gitlab/current_settings_spec.rb
View file @
0ff27ce0
...
@@ -54,7 +54,7 @@ describe Gitlab::CurrentSettings do
...
@@ -54,7 +54,7 @@ describe Gitlab::CurrentSettings do
expect
(
ApplicationSetting
).
not_to
receive
(
:current
)
expect
(
ApplicationSetting
).
not_to
receive
(
:current
)
end
end
it
'returns a
n in-memory ApplicationSetting
object'
do
it
'returns a
FakeApplicationSettings
object'
do
expect
(
described_class
.
current_application_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
expect
(
described_class
.
current_application_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
end
end
...
@@ -157,17 +157,12 @@ describe Gitlab::CurrentSettings do
...
@@ -157,17 +157,12 @@ describe Gitlab::CurrentSettings do
end
end
end
end
context
'when the application_settings table does not exists'
do
context
'when the application_settings table does not exist'
do
it
'returns an in-memory ApplicationSetting object'
do
it
'returns a FakeApplicationSettings object'
do
expect
(
ApplicationSetting
).
to
receive
(
:create_from_defaults
).
and_raise
(
ActiveRecord
::
StatementInvalid
)
expect
(
Gitlab
::
Database
)
.
to
receive
(
:cached_table_exists?
)
expect
(
described_class
.
current_application_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
.
with
(
'application_settings'
)
end
.
and_return
(
false
)
end
context
'when the application_settings table is not fully migrated'
do
it
'returns an in-memory ApplicationSetting object'
do
expect
(
ApplicationSetting
).
to
receive
(
:create_from_defaults
).
and_raise
(
ActiveRecord
::
UnknownAttributeError
)
expect
(
described_class
.
current_application_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
expect
(
described_class
.
current_application_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
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