Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Chapter 11 11.3 should use :update_attributes! #79

Open
YaEvan opened this issue May 18, 2018 · 2 comments
Open

Chapter 11 11.3 should use :update_attributes! #79

YaEvan opened this issue May 18, 2018 · 2 comments

Comments

@YaEvan
Copy link

YaEvan commented May 18, 2018

before do
allow_any_instance_of(Project).to(
receive(:update_attributes).with(completed: true).and_return(false))
end

before do
allow_any_instance_of(Project).to(
receive(:update_attributes!).with(completed: true).and_return(false))
end

@ruralocity
Copy link
Member

The sample code is expecting a true/false response ... update_attributes! raises an exception if it fails. Could you elaborate on why you'd make this change? Thanks.

@YaEvan
Copy link
Author

YaEvan commented May 24, 2018

The reason I did this is because the concrete code used update_attributes! when it was called.
`

def complete
    if @project.update_attributes!(completed: true)    
        flash[:notice] = "Congratulations, this project is complete!"
    else
        flash[:alert] = "Unable to complete project."
    end
    redirect_to @project
end

`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants