Sha256: dc560589599d77c2d66e7bd051d05a6663d2ec7d37df4747482a94432ce7f532

Contents?: true

Size: 883 Bytes

Versions: 42

Compression:

Stored size: 883 Bytes

Contents

require 'spec_helper'

describe CoalescingPanda::Oauth2Controller, :type => :controller do
  routes { CoalescingPanda::Engine.routes }
  let(:account) { FactoryGirl.create(:account, settings: {base_url: 'foo.com'}) }
  let(:user) { FactoryGirl.create(:user, account: account) }

  describe "#redirect" do
    it 'creates a token in the db' do
      ENV['OAUTH_PROTOCOL'] = 'http'
      Bearcat::Client.any_instance.stub(retrieve_token: 'foobar')
      session[:state] = 'test'
      get :redirect, {user_id: user.id, api_domain: 'foo.com', code: 'bar', key: account.key, state: 'test'}
      auth = CoalescingPanda::CanvasApiAuth.find_by_user_id_and_api_domain(user.id, 'foo.com')
      auth.should_not == nil
    end

    it "doesn't create a token in the db" do
      get :redirect, {error: 'your face'}
      CoalescingPanda::CanvasApiAuth.all.count.should == 0
    end
  end

end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
coalescing_panda-4.0.11 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.0.10 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.0.9 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.0.8 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.0.7 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.2.2 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.2.1 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.2.0 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.26 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.25 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.24 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.23 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.22 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.21 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.20 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.19 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.18 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.17 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.16 spec/controllers/coalescing_panda/oauth2_controller_spec.rb
coalescing_panda-4.1.15 spec/controllers/coalescing_panda/oauth2_controller_spec.rb