Sha256: b5c881dfad898349edf2ad46328bb3a98895d4e03ff1f865636cef73081d66e7
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
require "spec_helper" describe "Token expiration" do describe "after signing in" do before do create_user_and_sign_in @initial_cookies = remember_token_cookies end it "should have a remember_token cookie with a future expiration" do expect(first_cookie.expires).to be_between( 1.years.from_now - 1.second, 1.years.from_now, ) end end describe "after signing in and making a followup request" do before do create_user_and_sign_in @initial_cookies = remember_token_cookies Timecop.travel(1.minute.from_now) do get root_path @followup_cookies = remember_token_cookies end end it "should set a remember_token on each request with updated expiration" do expect(@followup_cookies.length).to be >= 1, "remember token wasn't set on second request" expect(second_cookie.expires).to be > first_cookie.expires end end def first_cookie Rack::Test::Cookie.new @initial_cookies.last end def second_cookie Rack::Test::Cookie.new @followup_cookies.last end def create_user_and_sign_in user = create(:user, password: "password") get sign_in_path post session_path, params: { session: { email: user.email, password: "password" }, } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clearance-2.0.0.beta1 | spec/requests/token_expiration_spec.rb |
clearance-1.17.0 | spec/requests/token_expiration_spec.rb |
clearance-1.16.2 | spec/requests/token_expiration_spec.rb |