Skip to content

Commit

Permalink
Replaced Cookie #set_before? with #set_since?
Browse files Browse the repository at this point in the history
  • Loading branch information
pda committed Dec 8, 2010
1 parent 7be5431 commit 4ecb386
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/devise_login_cookie/cookie.rb
Expand Up @@ -42,9 +42,9 @@ def present?
@cookies[cookie_name].present?
end

# Whether the cookie was set before the given Time
def set_before?(time)
created_at && created_at < time
# Whether the cookie was set since the given Time
def set_since?(time)
created_at && created_at >= time
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/devise_login_cookie/strategy.rb
Expand Up @@ -29,7 +29,7 @@ def cookie
end

def fresh?(cookie)
cookie.set_before?(Time.now - COOKIE_TTL)
cookie.set_since?(Time.now - COOKIE_TTL)
end

def resource
Expand Down
9 changes: 5 additions & 4 deletions spec/cookie_spec.rb
Expand Up @@ -23,7 +23,7 @@ module DeviseLoginCookie
describe "Cookie instance" do
it { should_not be_present }
it { should_not be_valid }
it { should_not be_set_before(Time.at(0)) }
it { should_not be_set_since(Time.at(0)) }
end

describe "#id" do
Expand Down Expand Up @@ -51,7 +51,7 @@ module DeviseLoginCookie
describe "Cookie instance" do
it { should be_present }
it { should_not be_valid }
it { should_not be_set_before(Time.at(0)) }
it { should_not be_set_since(Time.at(0)) }
end

describe "#id" do
Expand Down Expand Up @@ -81,8 +81,9 @@ module DeviseLoginCookie
describe "Cookie instance" do
it { should be_present }
it { should be_valid }
it { should_not be_set_before(now) }
it { should be_set_before(now + 1) }
it { should_not be_set_since(now + 1) }
it { should be_set_since(now) }
it { should be_set_since(now - 1) }
end

describe "#id" do
Expand Down

0 comments on commit 4ecb386

Please sign in to comment.