Commit graph

21 commits

Author SHA1 Message Date
Lin Jen-Shin
43afcd0333 Apply suggestion to spec/lib/gitlab/current_settings_spec.rb 2019-03-28 07:05:12 +00:00
Rémy Coutable
90718774e1
Use a Gitlab::FakeApplicationSettings when migrations are pending
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-03-26 23:02:57 +01:00
Takuya Noguchi
a565f3d88d Fix misspellings in app/spec executable lines
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2019-02-27 22:41:34 +09:00
Bob Van Landuyt
7e55a227a5 Revert "Merge branch 'use_gitlab_current_settings' into 'master'"
This reverts merge request !25370
2019-02-19 12:58:05 +00:00
Thong Kuah
8a1b6041c8 Use Gitlab::CurrentSettings in UrlValidator
Gitlab::CurrentSettings will create ApplicationSetting.current if not
present which means we don't have to use `&.`. We can also more easily
use stub_application_setting in specs
2019-02-19 22:04:08 +13:00
Rémy Coutable
cc06bb2c6e
Simplify spec/lib/gitlab/current_settings_spec.rb a bit
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-12-19 11:24:55 +01:00
Lin Jen-Shin
0ff27ce059
Method create_from_defaults will never give nil 2018-12-19 11:24:54 +01:00
Rémy Coutable
71672dfa6a
Return an ApplicationSetting in CurrentSettings
This replaces the use of fake_application_settings with
`::ApplicationSetting.build`_from_defaults. The reason is that
`fake_application_settings` doesn't have the custom accessors that
`ApplicationSetting` has, e.g. `#commit_email_hostname`, thus this
can lead to unexpected `nil` values which comes from the database
column instead of `.default_commit_email_hostname` returned by
`ApplicationSetting#commit_email_hostname`.

Using `::ApplicationSetting.build_from_defaults` should be safe as it
doesn't try to `INSERT` a DB record, in contrary to
`::ApplicationSetting.create_from_defaults` which we used to use, and
which created issues that the introduction of
`fake_application_settings` tried to resolve (575dced5).

Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-12-19 11:24:53 +01:00
Rémy Coutable
6afe6fa6bc
Make Gitlab::CurrentSettings.current_application_settings return cached settings early if they exist without issuing any DB query
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-06-07 17:23:49 +02:00
Rémy Coutable
2bdf6edefa
Simplify Gitlab::CurrentSettings now that the logic is in CacheableAttributes
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-05-23 16:14:43 +02:00
Mario de la Ossa
eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Winnie Hellmann
beeed14f04 Fix failure in current_settings_spec.rb 2017-10-20 18:33:00 +00:00
Nick Thomas
aeb2869f66 Prevent bad data being added to application settings when Redis is unavailable 2017-07-10 15:40:51 +01:00
Stan Hu
575dced5d7 If migrations are pending, make CurrentSettings use existing values and populate missing columns with defaults
master was failing because `ApplicationSetting.create_from_defaults` attempted
to write to a column that did not exist in the database. This occurred in a
`rake db:migrate` task, which was unable to perform the migration that would
have added the missing column in the first place.

In 9.3 RC2, we also had a bug where password sign-ins were disabled because
there were many pending migrations. The problem occurred because
`fake_application_settings` was being returned with an OpenStruct that did not
include the predicate method `signup_enabled?`. As a result, the value would
erroneously return `nil` instead of `true`. This commit uses the values of the
defaults to mimic this behavior.

This commit also refactors some of the logic to be clearer.
2017-06-19 09:54:48 -07:00
Paul Charlton
d93352825a redesign caching of application settings 2017-06-06 16:48:10 +00:00
Robert Speicher
d49768296c Auto-correct RSpec/DescribedClass violations 2017-05-01 11:13:33 -04:00
Grzegorz Bizon
632c2939bb Revert "Merge branch 'revert-9cac0317' into 'master' "
This reverts commit c20934869f, reversing
changes made to 4b7ec44b91.
2017-01-23 16:35:24 +01:00
Grzegorz Bizon
baeaa97ef4 Revert "Merge branch 'dont-persist-application-settings-in-test-env' into 'master'"
This reverts merge request !8573
2017-01-21 22:55:35 +00:00
Rémy Coutable
f6cc29ed83 Don't persist ApplicationSetting in test env
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-15 01:07:29 -05:00
Stan Hu
d10642a4b8 Handle case when Redis cache returns an empty setting 2016-06-29 14:28:41 -07:00
Stan Hu
c600cf8348 Fix database migrations when Redis is not running
If Redis were not running or USE_DB were set to false, the
application settings retrieval would fail completely. This
change only attempts to use the cache if the system actually
wants to connect to the DB and rescues any failures in talking to
Redis.

Closes #17557
2016-06-29 14:04:59 -07:00