Skip to content

Instantly share code, notes, and snippets.

@jonstorer
Created February 20, 2012 17:36
Show Gist options
  • Save jonstorer/1870227 to your computer and use it in GitHub Desktop.
Save jonstorer/1870227 to your computer and use it in GitHub Desktop.
describe Client, ".visit" do
subject { Factory(:client) }
let(:time) { Time.now }
it "creates a sign in timestamp if the client has not visited today" do
subject.stubs(:has_visited_today? => false)
subject.signin_timestamps.each(&:destroy)
Timecop.travel(time){ subject.visit }
subject.signin_timestamps.count.should == 1
subject.signin_timestamps.first.created_at.utc.to_s.should == time.utc.to_s
end
it "does not create a sign in timestamp if the client visited today" do
subject.stubs(:has_visited_today? => true)
subject.visit
subject.signin_timestamps.count.should == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment