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

awareness_spec.rb « concerns « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 67acacc7bb1fafdf767a1b9779dfb2aa87ed5603 (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
38
39
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Awareness, :clean_gitlab_redis_shared_state do
  subject { create(:user) }

  let(:session) { AwarenessSession.for(1) }

  describe "when joining a session" do
    it "increases the number of sessions" do
      expect { subject.join(session) }
        .to change { subject.session_ids.size }
              .by(1)
    end
  end

  describe "when leaving session" do
    it "decreases the number of sessions" do
      subject.join(session)

      expect { subject.leave(session) }
        .to change { subject.session_ids.size }
              .by(-1)
    end
  end

  describe "when joining multiple sessions" do
    let(:session2) { AwarenessSession.for(2) }

    it "increases number of active sessions for user" do
      expect do
        subject.join(session)
        subject.join(session2)
      end.to change { subject.session_ids.size }
               .by(2)
    end
  end
end