Guest User

Untitled

a guest
Dec 24th, 2017
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. let(:new_user_attributes) do
  2. {
  3. name: "BlocHead",
  4. email: "blochead@bloc.io",
  5. password: "blochead",
  6. password_confirmation: "blochead"
  7. }
  8. end
  9.  
  10. it "sets user name properly" do
  11. post :create, params: { user: new_user_attributes }
  12. expect(assigns(:user).name).to eq new_user_attributes[:name]
  13. end
  14.  
  15. def create
  16. @user = User.new
  17. @user.name = params[:user][:name]
  18. @user.email = params[:user][:email]
  19. @user.password = params[:user][:password]
  20. @user.password_confirmation = params[:user][:password_confirmation]
  21.  
  22. if @user.save
  23. flash[:notice] = "Welcome to Bloccit #{@user.name}!"
  24. redirect_to root_path
  25. else
  26. flash.now[:alert] = "There was an error creating your account. Please try again."
  27. render :new
  28. end
  29. end
Add Comment
Please, Sign In to add comment