Skip to content

Commit

Permalink
working on #create with invalid input specs
Browse files Browse the repository at this point in the history
  • Loading branch information
npauzenga committed Nov 17, 2015
1 parent f83c6fd commit a99c5fb
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Interactor::Context.new(errors: :val, user: user)
end


before(:example) do
allow(CreateUser).to receive(:call).with(interactor_input)
.and_return(interactor_context)
Expand All @@ -31,35 +32,35 @@
post :create, params
end

# # 200 because we're redirecting to sign_in?
# it "returns http status 200" do
# expect(response).to have_http_status(200)
# post :create, interactor_input
# end
#
# it "renders view sessions#new" do
# expect(post :create, interactor_input).to redirect_to(sign_in_path)
# end
it "returns http status 302" do
post :create, params
expect(response).to have_http_status(302)
end

it "renders view sessions#new" do
expect(post :create, params).to redirect_to(sign_in_path)
end
end

context "when email is not provided" do
it "redirects to sign_up" do
interactor_input[:user_params][:email] = ""
expect(post :create, params).to redirect_to(sign_up_path)
end
end
#
# # it'll still call CreateUser.call but this has been tested?
# context "when email is not provided" do
# it "redirects to sign_up" do
# interactor_input[:user][:email] = nil
# expect(post :create, interactor_input).to redirect_to(sign_up_path)
# end
# end
#
# context "when password is not provided" do
# it "redirects to sign_up" do
# end
# end
#
# context "when password confirmation is not provided" do
# it "redirects to sign_up" do
# end
# end

context "when password is not provided" do
it "redirects to sign_up" do
interactor_input[:user_params][:password] = ""
expect(post :create, params).to redirect_to(sign_up_path)
end
end

context "when password confirmation is not provided" do
it "redirects to sign_up" do
interactor_input[:user_params][:password_confirmation] = ""
expect(post :create, params).to redirect_to(sign_up_path)
end
end
end
end

0 comments on commit a99c5fb

Please sign in to comment.