title: Rails unit test assert_template failure
body: <p>I have the following test:
  test/integration/authentication_test.rb:</p>
  
  <pre><code>require 'test_helper'
  
  class AuthenticationTest &lt; ActionDispatch::IntegrationTest
  
    def setup
      @admin = users(:barry) # grab user from fixtures
    end
  
    test "trying to view a user before logging in" do
      get user_path(@admin)
      assert_template 'sessions/new'
      assert_not flash.empty?
      assert_select "div#error_explanation"
      assert_select "div.field_with_errors"
      assert_select "a[href=?]", logout_path, count: 0
      assert_not is_logged_in?
    end
  end
  </code></pre>
  
  <p>The test fails with the following error:</p>
  
  <pre><code>FAIL["test_trying_to_view_a_user_before_logging_in", AuthenticationTest, 2.206536] test_trying_to_view_a_user_before_logging_in#AuthenticationTest (2.21s)
      expecting &lt;"sessions/new"&gt; but rendering with &lt;[]&gt;
      test/integration/authentication_test.rb:11:in `block in &lt;class:AuthenticationTest&gt;'
  </code></pre>
  
  <p>Relevant bits of the users_controller.rb:</p>
  
  <pre><code>class UsersController &lt; ApplicationController
  
    before_action :logged_in_user, only: [:index, :show, :edit, :update, :destroy]
  
    def show
      @user = User.find_by_callsign(params[:callsign])
      @page_name = "user_page"
      redirect_to root_url and return unless @user.activated
    end
    .
    .
  end
  </code></pre>
  
  <p>sessions_helper.rb:</p>
  
  <pre><code>def logged_in_user
    unless logged_in?
      store_location
      flash[:danger] = "Please log in."
      redirect_to login_url
    end
  end
  
  def logged_in?
    !current_user.nil?
  end
  </code></pre>
  
  <p>In routes.rb:</p>
  
  <pre><code>get 'login', to: 'sessions#new'
  </code></pre>
  
  <p>I don't understand why the test is failing. When I perform the steps manually it all works. Is there a known issue with assert_template? When I comment out <code>assert_template 'sessions/new'</code> in the test, it passes.</p>
  
  <p>EDIT:</p>
  
  <p>In log/test.log: it is indeed redirecting to the correct template (Redirected to <a href="http://www.example.com/dominos/newname" rel="nofollow">http://www.example.com/dominos/newname</a>). But it doesn't have any 'rendered' lines. The last few lines of the failed test are:</p>
  
  <pre><code>Redirected to http://www.example.com/dominos/newname
  Completed 302 Found in 21ms (ActiveRecord: 2.5ms)
    [1m[35m (0.4ms)[0m  SELECT COUNT(*) FROM "personas"
    [1m[36m (0.2ms)[0m  [1mROLLBACK[0m
  </code></pre>
  
  <p>In the test.log file for successful tests involving assert_template, there are various 'Rendered' lines following a redirect, for example: </p>
  
  <pre><code>Rendered personas/new.html.erb within layouts/application (2.0ms)
  </code></pre>
  
  <p>Is this perhaps part of why the test is failing? Why does the page not render?</p>