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

notes_channel_spec.rb « noteable « channels « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a38155e7ffd7f0d73857f338d7006244e2d51cf6 (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
40
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Noteable::NotesChannel, feature_category: :team_planning do
  let_it_be(:project) { create(:project, :repository, :private) }
  let_it_be(:developer) { create(:user).tap { |u| project.add_developer(u) } }

  describe '#subscribed' do
    let(:subscribe_params) do
      {
        project_id: noteable.project_id,
        noteable_type: noteable.class.underscore,
        noteable_id: noteable.id
      }
    end

    before do
      stub_action_cable_connection current_user: developer
    end

    it 'rejects the subscription when noteable params are missing' do
      subscribe(project_id: project.id)

      expect(subscription).to be_rejected
    end

    context 'on an issue' do
      let_it_be(:noteable) { create(:issue, project: project) }

      it_behaves_like 'handle subscription based on user access'
    end

    context 'on a merge request' do
      let_it_be(:noteable) { create(:merge_request, source_project: project) }

      it_behaves_like 'handle subscription based on user access'
    end
  end
end