Sha256: 2b552f2230f5666eb8160b67c0d7fc51b9f2a709518b4633cef40b74a70821af

Contents?: true

Size: 892 Bytes

Versions: 6

Compression:

Stored size: 892 Bytes

Contents

require 'spec_helper'

module Cellect::Server
  describe User do
    let(:user){ User.new 1, workflow_name: 'random' }
    
    it 'should store seen ids' do
      user.seen.should be_a DiffSet::RandomSet
    end
    
    it 'should have a default ttl of 15 minutes' do
      user.ttl.should == 900 # seconds
    end
    
    it 'should allow custom ttl' do
      User.new(2, workflow_name: 'random', ttl: 123).ttl.should == 123
    end
    
    it 'should reset the ttl timer on activity' do
      user.bare_object.should_receive(:restart_ttl_timer).at_least :once
      user.seen
    end
    
    it 'should terminate on ttl expiry' do
      async_workflow = double
      Workflow[user.workflow_name].should_receive(:async).and_return async_workflow
      async_workflow.should_receive(:remove_user).with user.id
      user.ttl_expired!
      user.ttl_timer.should be_nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cellect-server-0.0.7 spec/server/user_spec.rb
cellect-server-0.0.6 spec/server/user_spec.rb
cellect-server-0.0.5 spec/server/user_spec.rb
cellect-server-0.0.4 spec/server/user_spec.rb
cellect-server-0.0.3 spec/server/user_spec.rb
cellect-server-0.0.2 spec/server/user_spec.rb