Commit 195ac087 authored by marcheing's avatar marcheing

Remove profiles controller spec db dependency

Signed-off-by: Rafael Reggiani Manzo's avatarRafael Reggiani Manzo <[email protected]>
parent 42d0c53f
Pipeline #3555109 passed with stage
in 5 minutes and 55 seconds
......@@ -106,29 +106,31 @@ RSpec.describe ProfilesController, type: :controller do
end
describe "PUT #update" do
let(:profile) { build(:profile, id: 1) }
before do
expect(Profile).to receive(:find).with(profile.id.to_s).and_return profile
end
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested profile" do
profile = Profile.create! valid_attributes
put :update, params: {id: profile.to_param, profile: new_attributes}, session: valid_session
profile.reload
skip("Add assertions for updated state")
end
it "redirects to the profile" do
profile = Profile.create! valid_attributes
put :update, params: {id: profile.to_param, profile: valid_request_parameters }, session: valid_session
expect(response).to redirect_to(profile)
end
end
context "with invalid params" do
let(:profile) { build(:profile, id: 1) }
before do
expect(Profile).to receive(:find).with(profile.id.to_s).and_return profile
expect_any_instance_of(Profile).to receive(:update).and_return false
put :update, params: {id: profile.to_param, profile: valid_request_parameters }, session: valid_session
end
......@@ -138,15 +140,18 @@ RSpec.describe ProfilesController, type: :controller do
end
describe "DELETE #destroy" do
let(:profile) { build(:profile, id: 1) }
before do
expect(Profile).to receive(:find).with(profile.id.to_s).and_return profile
end
it "destroys the requested profile" do
profile = Profile.create! valid_attributes
expect {
delete :destroy, params: {id: profile.to_param}, session: valid_session
}.to change(Profile, :count).by(-1)
expect(profile).to receive(:destroy)
delete :destroy, params: { id: profile.id }, session: valid_session
end
it "redirects to the profiles list" do
profile = Profile.create! valid_attributes
delete :destroy, params: {id: profile.to_param}, session: valid_session
expect(response).to redirect_to(profiles_url)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment