diff options
| author | mo khan <mo@mokhan.ca> | 2014-09-28 20:06:17 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-09-28 20:06:17 -0600 |
| commit | f37c10628bfa6c725014b58de9ed380d15f95ecb (patch) | |
| tree | a747e82dc9453177c68d3a541db850e6c7678137 /spec/models | |
| parent | 517a55e39490201881be5d4f502cea0529e2379d (diff) | |
associate user sessions to locations.
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/user_session_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/models/user_session_spec.rb b/spec/models/user_session_spec.rb index df0941e1..10cc706d 100644 --- a/spec/models/user_session_spec.rb +++ b/spec/models/user_session_spec.rb @@ -12,8 +12,13 @@ describe UserSession do describe "#access" do let(:request) { double(ip: '192.168.1.1', user_agent: 'blah') } + let(:location) { build(:location) } let!(:because) { subject.access(request) } + before :each do + Location.stub(:build_from_ip).with('192.168.1.1').and_return(location) + end + it "records the time the session was accessed" do expect(subject.accessed_at).to_not be_nil end @@ -26,6 +31,10 @@ describe UserSession do expect(subject.user_agent).to eql(request.user_agent) end + it 'records a location for the session' do + expect(subject.location).to_not be_nil + end + it "returns a hash to store in the cookie" do expect(because[:value]).to eql(subject.key) expect(because[:httponly]).to be_truthy |
