Reputation: 2019
Why is this test failing? And how can I get it to successfully test
After profiles are edited there is a method called in the controller
def update
call_the_method - method works on my machine
end
test "edit should change approval status" do
login_as(@denied_profile)
patch :update, id: @denied_profile, profile: {ALOT OF DUMMY INFORMATION }
assert @denied_profile.approval_status == Profile::ApprovalStatus::DENIED_EDITED
end
The method isn't called after the patch request. What is the proper way of writing htis test?
Upvotes: 1
Views: 34
Reputation: 53028
Assuming that you saved the approval_status
field in database in update
action, then all you have to do is after the patch
request, reload the @denied_profile
so that it can fetch the updated record from database.
test "edit should change approval status" do
login_as(@denied_profile)
patch :update, id: @denied_profile, profile: {ALOT OF DUMMY INFORMATION }
assert @denied_profile.reload.approval_status == Profile::ApprovalStatus::DENIED_EDITED
end
Use @denied_profile.reload.approval_status
instead of @denied_profile.approval_status
Upvotes: 2