I have spec:
describe "#delete_salary_version" do
let(:version_id) { { id: user.salary.versions.last.id} }
it "delete salary version" do
delete :delete_salary_version, params: version_id
expect(response.status).to eq 200
expect(user.salary.versions.last).to eq nil
end
end
Controller:
def delete_salary_version
@user.salary.versions.find_by(id: params[:version_id])&.destroy
render :show
end
And routes:
update_salary_management_user PUT /management/users/:id/update_salary(.:format) management/users_management#update_salary
delete_salary_version_management_user DELETE /management/users/:id/delete_salary_version(.:format) management/users_management#delete_salary_version
And I run rspec:
1) Management::UsersManagementController#delete_salary_version delete salary version
Failure/Error: expect(response.status).to eq 200
expected: 200
got: 404
(compared using ==)
I'm use gem papertrail
I don't understand why I receive 404
Aucun commentaire:
Enregistrer un commentaire