Welcome to mirror list, hosted at ThFree Co, Russian Federation.

websocket_spec.rb « lib « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84001fc9fcdcfa572e17bd9b31da89da8088ce14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

require 'spec_helper'

describe Diaspora::WebSocket do
  before do
    @user = Factory.create(:user)
    @aspect = @user.aspect(:name => "losers")
    @post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id)
    unstub_sockets
  end

  it 'should queue a job' do
    Diaspora::WebSocket.should_receive(:queue_to_user)
    @post.socket_to_uid(@user.id, :aspect_ids => @aspect.id)
  end

  describe 'queuing and dequeuing ' do
    before do
      @channel = Magent::GenericChannel.new('websocket')
      @messages = @channel.message_count
      @post.socket_to_uid(@user.id, :aspect_ids => @aspect.id)
    end

    it 'should send the queued job to Magent' do
      @channel.message_count.should == @messages + 1
    end

    it 'should dequeue the job successfully' do
      @channel.dequeue
      @channel.message_count.should == @messages
    end
  end

end