Don't use update_attribute
This method is ambiguous. Sometimes we use it to set invalid data in tests (which can usually be done with `update_column`), and other times we use it instead of `update!`. I'm removing it because, even if sometimes it could make sense to use it, it's too similar to `update_attributes` (which is an alias for `update` and runs validations), making it confusing. However, there's one case where we're still using it: in the ActsAsParanoidAliases module, we need to invoke the callbacks, which `update_column` skips, but tests related to translations fail if we use `update!`. The reason for this is the tests check what happens if we restore a record without restoring its translations. But that will make the record invalid, since there's a validation rule checking it has at least one translation. I'm not blacklisting any other method which skips validations because we know they skip validations and use them anyway (hopefully with care).
This commit is contained in:
@@ -23,7 +23,7 @@ describe "Admin Notifications" do
|
||||
|
||||
scenario "Notification with invalid segment recipient" do
|
||||
invalid_notification = create(:admin_notification)
|
||||
invalid_notification.update_attribute(:segment_recipient, "invalid_segment")
|
||||
invalid_notification.update_column(:segment_recipient, "invalid_segment")
|
||||
|
||||
visit admin_admin_notification_path(invalid_notification)
|
||||
|
||||
@@ -56,7 +56,7 @@ describe "Admin Notifications" do
|
||||
|
||||
scenario "Notifications with invalid segment recipient" do
|
||||
invalid_notification = create(:admin_notification)
|
||||
invalid_notification.update_attribute(:segment_recipient, "invalid_segment")
|
||||
invalid_notification.update_column(:segment_recipient, "invalid_segment")
|
||||
|
||||
visit admin_admin_notifications_path
|
||||
|
||||
@@ -209,7 +209,7 @@ describe "Admin Notifications" do
|
||||
|
||||
scenario "Admin notification with invalid segment recipient cannot be sent", :js do
|
||||
invalid_notification = create(:admin_notification)
|
||||
invalid_notification.update_attribute(:segment_recipient, "invalid_segment")
|
||||
invalid_notification.update_column(:segment_recipient, "invalid_segment")
|
||||
visit admin_admin_notification_path(invalid_notification)
|
||||
|
||||
expect(page).not_to have_link("Send")
|
||||
|
||||
Reference in New Issue
Block a user