Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56e0496
commit 2abf65c
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe ApplicationController, type: :controller do | ||
|
||
# Anonymous controller stub, FTW! | ||
controller do | ||
def index | ||
@current_user = current_user | ||
render text: 'Just a test, bro!' | ||
end | ||
end | ||
|
||
before :each do | ||
@user = FactoryGirl.create :user_with_facebook_auth | ||
@valid_auth_token = @user.auth_providers.first.token | ||
@invalid_auth_toke = 'INVALIDAUTHTOKEN' | ||
end | ||
|
||
let(:valid_session) { { user_id: @user.id } } | ||
|
||
describe 'Test current_user helper' do | ||
|
||
it 'returns correct user when valid session exists' do | ||
request.session[:user_id] = @user.id | ||
get :index, {} | ||
expect(assigns(:current_user)).to eq(@user) | ||
end | ||
|
||
it 'returns correct user when valid header token is set' do | ||
request.headers['HTTP_ACCESS_TOKEN'] = @valid_auth_token | ||
get :index, {} | ||
expect(assigns(:current_user)).to eq(@user) | ||
end | ||
|
||
it 'returns nil when invalid header token is set' do | ||
request.headers['HTTP_ACCESS_TOKEN'] = @invalid_auth_token | ||
get :index, {} | ||
expect(assigns(:current_user)).to eq(nil) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters