Skip to content

Commit

Permalink
Rails 6.1 spec fixes - change references to deprecated update_attribu…
Browse files Browse the repository at this point in the history
…tes 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
  • Loading branch information
yuenmichelle1 authored Mar 10, 2023
1 parent 5aa6a6d commit 6912c54
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions spec/controllers/api/v1/organizations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,22 @@ 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
end

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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/formatter/csv/workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/support/optimistic_locking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 6912c54

Please sign in to comment.