Commit 42d0c53f authored by marcheing's avatar marcheing

Cover profile create and update actions

Signed-off-by: Rafael Reggiani Manzo's avatarRafael Reggiani Manzo <[email protected]>
parent 5872ba10
......@@ -50,6 +50,13 @@ RSpec.describe ProfilesController, type: :controller do
sign_in user
end
describe 'GET #new' do
it 'responds with ok' do
get :new
expect(response.status).to eq 200
end
end
describe 'GET #show' do
let(:profile) { build(:profile, id: 1) }
context 'profile found' do
......@@ -87,6 +94,15 @@ RSpec.describe ProfilesController, type: :controller do
expect(response).to redirect_to(root_path)
end
end
context "with invalid params" do
before do
expect_any_instance_of(Profile).to receive(:save).and_return false
post :create, params: { profile: valid_request_parameters }, session: valid_session
end
it { is_expected.to respond_with(:ok) }
end
end
describe "PUT #update" do
......@@ -108,6 +124,17 @@ RSpec.describe ProfilesController, type: :controller do
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
it { is_expected.to respond_with(:ok) }
end
end
describe "DELETE #destroy" do
......
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