From 0319da686d6422bda351c945ea6519d672afb60c Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Tue, 1 May 2018 11:36:18 +1100 Subject: [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. --- spec/models/notification_setting_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3