Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #102 from VTUL/spec/omniauth-callbacks-controller
Browse files Browse the repository at this point in the history
Spec/omniauth callbacks controller. Closed
  • Loading branch information
yinlinchen committed Nov 11, 2015
2 parents a22f1fc + 4a6c1f4 commit a516d63
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def cas
set_flash_message(:notice, :success, kind: "CAS") if is_navigational_format?
else
session['devise.cas_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
redirect_to root_url
end
end
end
25 changes: 24 additions & 1 deletion spec/controllers/users/omniauth_callbacks_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
require 'rails_helper'

RSpec.describe Users::OmniauthCallbacksController, type: :controller do
pending "can't find a way to test cas"
describe '#cas' do
let(:user) {FactoryGirl.create(:user)}

before do
request.env['devise.mapping'] = Devise.mappings[:user]
end

context 'for persistent user' do
it 'should redirect to the dashboard' do
allow(User).to receive(:from_cas).and_return(user)
get :cas
expect(response).to redirect_to('/dashboard')
end
end

context 'for non persistent user' do
it 'should redirect to new user registration page' do
user.delete
allow(User).to receive(:from_cas).and_return(user)
get :cas
expect(response).to redirect_to('/')
end
end
end
end

0 comments on commit a516d63

Please sign in to comment.