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:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-05-01 03:36:18 +0300
committerblackst0ne <blackst0ne.ru@gmail.com>2018-05-01 10:30:37 +0300
commit0319da686d6422bda351c945ea6519d672afb60c (patch)
treef5e0bdf553208de3b983daf46a4abf0cd0ae455f
parent4e2787a66746e52242c664d0a48c27ba90ef4037 (diff)
[Rails5] Fix spec/models/notification_setting_spec.rb
In Rails 5 assigning a value which is not explicitly `true` or `false` to a boolean column transforms it to `true`. In Rails 4 it transforms the value to `false` with the deprecation warning: ``` DEPRECATION WARNING: You attempted to assign a value which is not explicitly `true` or `false` ("nil") to a boolean column. Currently this value casts to `false`. This will change to match Ruby's semantics, and will cast to `true` in Rails 5. If you would like to maintain the current behavior, you should explicitly handle the values you would like cast to `false`. ``` This commit fixes the spec that expects to receive Rails 4 behavior.
-rw-r--r--spec/models/notification_setting_spec.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb
index 2a0d102d3fe..12681a147b4 100644
--- a/spec/models/notification_setting_spec.rb
+++ b/spec/models/notification_setting_spec.rb
@@ -40,7 +40,12 @@ RSpec.describe NotificationSetting do
expect(notification_setting.new_issue).to eq(true)
expect(notification_setting.close_issue).to eq(true)
expect(notification_setting.merge_merge_request).to eq(true)
- expect(notification_setting.close_merge_request).to eq(false)
+
+ # In Rails 5 assigning a value which is not explicitly `true` or `false` ("nil" in this case)
+ # to a boolean column transforms it to `true`.
+ # In Rails 4 it transforms the value to `false` with deprecation warning.
+ # Replace `eq(Gitlab.rails5?)` with `eq(true)` when removing rails5? code.
+ expect(notification_setting.close_merge_request).to eq(Gitlab.rails5?)
expect(notification_setting.reopen_merge_request).to eq(false)
end
end