Skip to content

Commit

Permalink
specs for GET #show
Browse files Browse the repository at this point in the history
  • Loading branch information
npauzenga committed Nov 20, 2015
1 parent b28457f commit a55bf94
Showing 1 changed file with 62 additions and 12 deletions.
74 changes: 62 additions & 12 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
RSpec.describe UsersController, type: :controller do
let(:user) { create(:unconfirmed_user) }

describe "GET #new" do
context "when successful" do
it "assigns new User to @user" do
get :new
expect(assigns(:user)).to be_a_new(User)
end

it "returns http status 200" do
get :new
expect(response).to have_http_status(200)
end

it "renders the #new template" do
get :new
expect(response).to render_template :new
end
end
end

describe "POST #create" do
let(:params) { { user: interactor_input.fetch(:user_params) } }

Expand Down Expand Up @@ -36,30 +55,61 @@
expect(response).to have_http_status(302)
end

it "renders view sessions#new" do
it "redirects to sign in" 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] = ""
context "when invalid invalid params are passed" do
before(:example) { allow(interactor_context).
to receive(:success?) { false } }

it "redirects to sign up" do
expect(post :create, params).to redirect_to(sign_up_path)
end
end
end

describe "GET #show" do
let(:confirmed_user_1) { create(:confirmed_user) }
let(:current_user) { create(:confirmed_user) }
let(:unconfirmed_user) { create(:unconfirmed_user) }

let(:params) { { id: confirmed_user_1.id } }
let(:arguments) { { id: confirmed_user_1.id,
current_id: current_user.id } }

let(:interactor_context) do
Interactor::Context.new(errors: :val, user: confirmed_user_1)
end

before(:example) do
allow(ShowUser).to receive(:call).with(arguments)
.and_return(interactor_context)
end
context "when user logged in" do
it "calls the ShowUser interactor" do
expect(ShowUser).to receive(:call)
binding.pry
get :show, arguments

end

it "assigns valid User to @user" do

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

it "renders the correct user's profile" do

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)
context "when user not logged in" do
it "redirects to sign in" do

end

end
end
end

0 comments on commit a55bf94

Please sign in to comment.