Commit 0319da68 authored by blackst0ne's avatar blackst0ne

[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.
parent 4e2787a6
...@@ -40,7 +40,12 @@ RSpec.describe NotificationSetting do ...@@ -40,7 +40,12 @@ RSpec.describe NotificationSetting do
expect(notification_setting.new_issue).to eq(true) expect(notification_setting.new_issue).to eq(true)
expect(notification_setting.close_issue).to eq(true) expect(notification_setting.close_issue).to eq(true)
expect(notification_setting.merge_merge_request).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) expect(notification_setting.reopen_merge_request).to eq(false)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment