Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/lib/clearance/authentication.rb b/lib/clearance/authentication.rb
- index b8e3c1d..750beef 100644
- --- a/lib/clearance/authentication.rb
- +++ b/lib/clearance/authentication.rb
- @@ -64,7 +64,7 @@ module Clearance
- if user
- cookies[:remember_token] = {
- :value => user.remember_token,
- - :expires => Clearance.configuration.cookie_expiration.call
- + :expires => self.instance_eval(&Clearance.configuration.cookie_expiration)
- }
- self.current_user = user
- end
- diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
- index 040eb7e..63a6e33 100644
- --- a/test/controllers/sessions_controller_test.rb
- +++ b/test/controllers/sessions_controller_test.rb
- @@ -94,6 +94,29 @@ class SessionsControllerTest < ActionController::TestCase
- end
- end
- + context "on POST to #create with good credentials - cookie duration passed as parameter" do
- + custom_duration = 5.months.from_now.utc
- +
- + setup do
- + Clearance.configuration.cookie_expiration = lambda { params[:duration] }
- + # this lambda will work only if 'self' is the current controller and therefore has access to 'params'
- + @user = Factory(:email_confirmed_user)
- + @user.update_attribute(:remember_token, "old-token4")
- + post :create, :duration => custom_duration, :session => {
- + :email => @user.email,
- + :password => @user.password }
- + end
- +
- + should_set_cookie("remember_token", "old-token4", custom_duration)
- +
- + teardown do
- + # restore default Clearance configuration
- + Clearance.configuration = nil
- + Clearance.configure {}
- + end
- + end
- +
- +
- context "on POST to #create with good credentials and a session return url" do
- setup do
- @user = Factory(:email_confirmed_user)
Add Comment
Please, Sign In to add comment