Sha256: 937753577433d873181edaef04e4077dd0cd7cbd820d6cbb7fa54d0fe8c943f7
Contents?: true
Size: 1.01 KB
Versions: 6
Compression:
Stored size: 1.01 KB
Contents
require 'spec_helper' describe CoalescingPanda::Oauth2Controller, type: :controller do routes { CoalescingPanda::Engine.routes } let(:account) { FactoryGirl.create(:account, settings: {base_url: 'foo.com'}) } describe "#redirect" do it 'creates a token in the db' do ENV['OAUTH_PROTOCOL'] = 'http' Bearcat::Client.any_instance.stub(retrieve_token: { 'access_token' => 'token', 'refresh_token' => 'token', 'expires_in' => 3600 }) session[:state] = 'test' get :redirect, {user_id: 1, api_domain: 'foo.com', code: 'bar', key: account.key, state: 'test'} auth = CoalescingPanda::CanvasApiAuth.find_by_user_id_and_api_domain(1, 'foo.com') auth.should_not == nil expect(auth.api_token).to eql 'token' expect(auth.refresh_token).to eql 'token' expect(auth.expires_at).to be > 50.minutes.from_now 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
6 entries across 6 versions & 1 rubygems