title: Filter chain halted as :doorkeeper_authorize! rendered or redirected
body: <p>I am building a Rails API and am currently using doorkeeper and devise to authenticate users with the <strong>ResourceOwnerFromCredentials</strong> flow. All works fine however, I cannot get the authentication to work in <strong>Rspec</strong>. </p>
  
  <p>Here is how am integrating the app in rspec:</p>
  
  <pre><code>    let(:app_country) { FactoryGirl.create(:app_country)}
      let(:valid_attributes) { FactoryGirl.attributes_for(:app_city, {:app_country_id =&gt; app_country.id}) }
      let(:valid_session) { {:format =&gt; :json} }
  
      let(:application) { Doorkeeper::Application.create!(:name =&gt; "App HQ dashboard", :redirect_uri =&gt; "https://localhost:3000/callback") }
      let(:hq_user) { app_country.hq_users.create!(FactoryGirl.attributes_for :hq_user) }
      let(:token) { Doorkeeper::AccessToken.create! :application_id =&gt; application.id, :resource_owner_id =&gt; hq_user.id }
  </code></pre>
  
  <p>But each time I try to test a protected action, the tests fail and I get the following output from the console:</p>
  
  <pre><code>Filter chain halted as :doorkeeper_authorize! rendered or redirected
  Completed 403 Forbidden in 5ms (ActiveRecord: 1.2ms)
  </code></pre>
  
  <p>This was working fine with the previous version of doorkeeper. The tests broke when I upgraded the doorkeeper gem. What am I doing wrong? Or is there a new way of testing doorkeeper protected controllers? </p>
  
  <p><strong>UPDATE</strong><br>
  Below is an actual test sample</p>
  
  <pre><code>    describe "POST create" do
          describe "with valid params" do
              it "creates a new AppCity" do
                  expect {
                      post :create, {:app_city =&gt; valid_attributes, :v =&gt; "HEAD", :payload_type =&gt; "NODE", :access_token =&gt; token.token}, valid_session
                  }.to change(AppCity, :count).by(1)
              end
  
              it "persists the AppCity" do
                  post :create, {:app_city =&gt; valid_attributes, :v =&gt; "HEAD", :access_token =&gt; token.token}, valid_session
                  response_body = JSON.parse(response.body, symbolize_names: true)
                  expect(response_body[:id]).to be_present
              end
  
              it "returns a 201 status" do
                  post :create, {:app_city =&gt; valid_attributes, :v =&gt; "HEAD", :access_token =&gt; token.token}, valid_session
                  response.status.should eq(201)
              end
          end
  
          describe "with invalid params" do
              it "returns validation error message" do
                  post :create, {:app_city =&gt; { "name" =&gt; "" }, :v =&gt; "HEAD", :access_token =&gt; token.token}, valid_session
                  response_body = JSON.parse(response.body, symbolize_names: true)
                  expect(response_body[:name]).to include "can't be blank"
              end
  
              it "returns a 422 status" do
                  post :create, {:app_city =&gt; { "name" =&gt; "" }, :v =&gt; "HEAD", :access_token =&gt; token.token}, valid_session
                  response.status.should eq(422)
              end
          end
      end
  </code></pre>