forked from Sorcery/sorcery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Sorcery#21 from kyuden/rails5
Test against Rails 5 by default
- Loading branch information
Showing
23 changed files
with
99 additions
and
70 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
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
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
require 'spec_helper' | ||
|
||
describe SorceryController do | ||
describe SorceryController, :type => :controller do | ||
|
||
let(:user) { double('user', id: 42, email: '[email protected]') } | ||
|
||
def request_test_login | ||
get :test_login, email: '[email protected]', password: 'blabla' | ||
get :test_login, :params => { email: '[email protected]', password: 'blabla' } | ||
end | ||
|
||
# ----------------- SESSION TIMEOUT ----------------------- | ||
|
@@ -37,7 +37,7 @@ def request_test_login | |
allow(User).to receive(:authenticate).and_return(user) | ||
expect(user).to receive_message_chain(:sorcery_adapter, :update_attribute).with(:failed_logins_count, 0) | ||
|
||
get :test_login, email: '[email protected]', password: 'secret' | ||
get :test_login, :params => { email: '[email protected]', password: 'secret' } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
describe SorceryController do | ||
describe SorceryController, :type => :controller do | ||
|
||
let(:user) { double("user", id: 42, email: '[email protected]') } | ||
|
||
|
@@ -27,15 +27,15 @@ | |
|
||
@request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64::encode64("#{user.email}:secret")}" | ||
expect(User).to receive('authenticate').with('[email protected]', 'secret').and_return(user) | ||
get :test_http_basic_auth, nil, http_authentication_used: true | ||
get :test_http_basic_auth, :params => {}, session: { :http_authentication_used => true } | ||
|
||
expect(response).to be_a_success | ||
end | ||
|
||
it "fails authentication if credentials are wrong" do | ||
@request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64::encode64("#{user.email}:wrong!")}" | ||
expect(User).to receive('authenticate').with('[email protected]', 'wrong!').and_return(nil) | ||
get :test_http_basic_auth, nil, http_authentication_used: true | ||
get :test_http_basic_auth, :params => {}, session: { :http_authentication_used => true } | ||
|
||
expect(response).to redirect_to root_url | ||
end | ||
|
@@ -60,7 +60,7 @@ | |
@request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64::encode64("#{user.email}:secret")}" | ||
expect(User).to receive('authenticate').with('[email protected]', 'secret').and_return(user) | ||
|
||
get :test_http_basic_auth, nil, http_authentication_used: true | ||
get :test_http_basic_auth, :params => {}, session: { :http_authentication_used => true } | ||
|
||
expect(session[:user_id]).to eq "42" | ||
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
describe SorceryController do | ||
describe SorceryController, :type => :controller do | ||
|
||
let!(:user) { double('user', id: 42) } | ||
|
||
|
@@ -27,7 +27,7 @@ | |
expect(User).to receive(:authenticate).with('[email protected]', 'secret').and_return(user) | ||
expect(user).to receive(:remember_me!) | ||
|
||
post :test_login_with_remember, :email => '[email protected]', :password => 'secret' | ||
post :test_login_with_remember, :params => { :email => '[email protected]', :password => 'secret' } | ||
|
||
expect(cookies.signed["remember_me_token"]).to eq assigns[:current_user].remember_me_token | ||
end | ||
|
@@ -51,7 +51,7 @@ | |
expect(user).to receive(:remember_me!) | ||
expect(user).to receive(:remember_me_token).and_return('abracadabra').twice | ||
|
||
post :test_login_with_remember_in_login, :email => '[email protected]', :password => 'secret', :remember => "1" | ||
post :test_login_with_remember_in_login, :params => { :email => '[email protected]', :password => 'secret', :remember => "1" } | ||
|
||
expect(cookies.signed["remember_me_token"]).not_to be_nil | ||
expect(cookies.signed["remember_me_token"]).to eq assigns[:user].remember_me_token | ||
|
@@ -88,13 +88,13 @@ | |
end | ||
|
||
it "doest not remember_me! when not asked to, even if third parameter is used" do | ||
post :test_login_with_remember_in_login, :email => '[email protected]', :password => 'secret', :remember => "0" | ||
post :test_login_with_remember_in_login, :params => { :email => '[email protected]', :password => 'secret', :remember => "0" } | ||
|
||
expect(cookies["remember_me_token"]).to be_nil | ||
end | ||
|
||
it "doest not remember_me! when not asked to" do | ||
post :test_login, :email => '[email protected]', :password => 'secret' | ||
post :test_login, :params => { :email => '[email protected]', :password => 'secret' } | ||
expect(cookies["remember_me_token"]).to be_nil | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
describe SorceryController do | ||
describe SorceryController, :type => :controller do | ||
|
||
let!(:user) { double('user', id: 42) } | ||
|
||
|
@@ -42,7 +42,7 @@ | |
# TODO: ??? | ||
expect(User).to receive(:authenticate).with('[email protected]', 'secret').and_return(user) | ||
|
||
get :test_login, :email => '[email protected]', :password => 'secret' | ||
get :test_login, :params => { :email => '[email protected]', :password => 'secret' } | ||
|
||
expect(session[:user_id]).not_to be_nil | ||
expect(response).to be_a_success | ||
|
@@ -53,7 +53,7 @@ | |
sorcery_controller_property_set(:session_timeout_from_last_action, true) | ||
expect(User).to receive(:authenticate).with('[email protected]', 'secret').and_return(user) | ||
|
||
get :test_login, :email => '[email protected]', :password => 'secret' | ||
get :test_login, :params => { :email => '[email protected]', :password => 'secret' } | ||
Timecop.travel(Time.now.in_time_zone+0.3) | ||
get :test_should_be_logged_in | ||
|
||
|
@@ -68,7 +68,7 @@ | |
|
||
it "with 'session_timeout_from_last_action' logs out if there was no activity" do | ||
sorcery_controller_property_set(:session_timeout_from_last_action, true) | ||
get :test_login, :email => '[email protected]', :password => 'secret' | ||
get :test_login, :params => { :email => '[email protected]', :password => 'secret' } | ||
Timecop.travel(Time.now.in_time_zone+0.6) | ||
get :test_should_be_logged_in | ||
|
||
|
Oops, something went wrong.