In Michael Hartl's *Ruby on Rails Tutorial, 2nd Ed*, chapter 9's exercise 6, says:

> 
> Signed-in users have no reason to access the new and create actions in
>  the Users controller. Arrange for such users to be redirected to the
>  root URL if they do try to hit those pages.
> 
> 
> 

How does one write the rspec test for this? I tried this 

```
  describe "POST on Users#create" do
    before { post users_path }
    specify { response.should redirect_to(root_path) }
  end

```

I have tried using a do/end block, adding a hash of user attributes, etc. The snippet above was added to line #162 in [the official sample code](https://github.com/railstutorial/sample_app_2nd_ed/blob/master/spec/requests/authentication_pages_spec.rb). All of them give me this error:

```
Failures:

  1) Authentication authorization as non-admin user POST on Users#create 
     Failure/Error: before { post users_path }
     AbstractController::DoubleRenderError:
       Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".
     # ./app/controllers/users_controller.rb:27:in `create'
     # ./spec/requests/authentication_pages_spec.rb:72:in `block (5 levels) in <top (required)>'

Finished in 2.72 seconds
88 examples, 1 failure

```

As for the actual objective which is to limit access to the new and create actions in the Users controller, I solved them by adding this line:

```
admin_user if signed_in?

```

I know this works because I tested it by hand. The only problem is I am unable to write an rspec test for it. [The code I have created as I follow this tutorial is available at github.](https://github.com/haloflightleader/sample_app)

Why am I getting this error? What am I doing wrong? What is the solution? Thank you.