diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-05-01 11:36:18 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-05-01 18:30:37 +1100 |
commit | 0319da686d6422bda351c945ea6519d672afb60c (patch) | |
tree | f5e0bdf553208de3b983daf46a4abf0cd0ae455f | |
parent | 4e2787a66746e52242c664d0a48c27ba90ef4037 (diff) | |
download | gitlab-ce-0319da686d6422bda351c945ea6519d672afb60c.tar.gz |
[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.rb | 7 |
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 |