Updating, showing, and deleting users, exercises
Is there a way to create an Rspec test for User controller actions such as “create” and “new?”
I’m not quite clear on the difference between the two actions “create” and “new” themselves either; could someone please be so kind as to elaborate?
After creating the test how would I go about implementing the redirect_to root_path? I think I am supposed to include the “new” and “create” actions in the before_filter signed_in section but this doesn’t automatically redirect to the root.
I tried to get the tests to pass by modifying the users_controller.rb file as follows:
def create
if signed_in?
redirect_to root_path
else
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
end
create). One is for the page for creating a new user (new).