Sha256: 8ed16a04e94cdfb62ce1a4a4d5d33161fe561d5d417d932d1ab44302064f24c4

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Devise::Oauth::AuthorizationsController do
  render_views

  before(:each) {
    @routes = Devise::Oauth::Engine.routes
    @user   = create(:user)
    @client = create(:client)
    @authorization = create(:authorization, client: @client, resource_owner: @user)
    @access = create(:access, client: @client, resource_owner: @user)
  }

  let(:user)          { @user }
  let(:client)        { @client }
  let(:authorization) { @authorization }
  let(:access)        { @access}

  context "Authorization code flow" do
    before { sign_in user }
    let(:attributes) {
      {
        client_id: client.identifier,
        redirect_uri: client.redirect_uris.first,
        response_type: 'code'
      }
    }

    context "when valid" do
      before { get :show, attributes }

      it { should respond_with :ok }
      it { response.content_type.should == "text/html" }
      it { should render_template 'devise/oauth/authorizations/show' }
      it { should render_with_layout 'application' }
      it "renders client name" do
        response.body.should include(client.name)
      end

      context "#grant" do
        before { post :create, attributes }
        it { should respond_with :redirect }
        it { response.content_type.should == "text/html" }
      end

      context "#deny" do
        before { delete :destroy, attributes }
        it { should respond_with :redirect }
        it { response.content_type.should == "text/html" }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise_oauth-3.0.3 spec/controllers/authorizations_controller_spec.rb
devise_oauth-3.0.2 spec/controllers/authorizations_controller_spec.rb
devise_oauth-3.0.1 spec/controllers/authorizations_controller_spec.rb
devise_oauth-3.0.0 spec/controllers/authorizations_controller_spec.rb