From 6912c54f4e366fb06d7abc3d15a4f00370740bf2 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Fri, 10 Mar 2023 13:05:15 -0600 Subject: [PATCH] Rails 6.1 spec fixes - change references to deprecated update_attributes to update in specs (#4140) * change references to deprecated update_attributes to update in specs * update organizations_controller spec per hound sniffs (spacing inside {} and using Time.zone.now vs Time.now --- spec/controllers/api/v1/organizations_controller_spec.rb | 6 +++--- spec/lib/formatter/csv/workflow_spec.rb | 2 +- spec/models/project_spec.rb | 2 +- spec/support/optimistic_locking.rb | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/controllers/api/v1/organizations_controller_spec.rb b/spec/controllers/api/v1/organizations_controller_spec.rb index 6220d29fa..909f00f6d 100644 --- a/spec/controllers/api/v1/organizations_controller_spec.rb +++ b/spec/controllers/api/v1/organizations_controller_spec.rb @@ -253,14 +253,14 @@ def run_update(params) end it "touches listed_at if listed is true" do - organization.update_attributes({listed: false, listed_at: nil}) + organization.update({ listed: false, listed_at: nil }) params = { organizations: { listed: true }, id: organization.id } run_update(params) expect(json_response["organizations"].first['listed_at']).to be_truthy end it "nulls listed_at if listed is false" do - organization.update_attributes({listed: true, listed_at: Time.now }) + organization.update({ listed: true, listed_at: Time.zone.now }) params = { organizations: { listed: false }, id: organization.id } run_update(params) expect(json_response["organizations"].first['listed_at']).to be_nil @@ -268,7 +268,7 @@ def run_update(params) it "updates the categories" do new_categories = %w(fish snails worms) - organization.update_attributes({listed: true, listed_at: Time.now }) + organization.update({ listed: true, listed_at: Time.zone.now }) params = { organizations: { categories: new_categories diff --git a/spec/lib/formatter/csv/workflow_spec.rb b/spec/lib/formatter/csv/workflow_spec.rb index c82ad685d..05bab3e92 100644 --- a/spec/lib/formatter/csv/workflow_spec.rb +++ b/spec/lib/formatter/csv/workflow_spec.rb @@ -58,7 +58,7 @@ def retirement_json tasks: tasks, pairwise: !workflow.pairwise, grouped: !workflow.grouped, prioritized: !workflow.prioritized } - workflow.update_attributes(updates) + workflow.update(updates) end describe "#to_rows on the latest version" do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index e6b01fe03..383330dfa 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -81,7 +81,7 @@ describe "#live" do before(:each) do - project.update_attributes(live: nil) + project.update(live: nil) end it "should not accept nil values" do diff --git a/spec/support/optimistic_locking.rb b/spec/support/optimistic_locking.rb index 517dffa6f..4fc44ae69 100644 --- a/spec/support/optimistic_locking.rb +++ b/spec/support/optimistic_locking.rb @@ -4,11 +4,11 @@ m1 = described_class.find(model_id) m2 = described_class.find(model_id) - m1.update_attributes(locked_update) + m1.update(locked_update) m1.save expect do - m2.update_attributes(locked_update) + m2.update(locked_update) m2.save end.to raise_error(ActiveRecord::StaleObjectError)