2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe IssuesChannel do
|
2020-05-24 23:13:21 +05:30
|
|
|
let_it_be(:issue) { create(:issue) }
|
|
|
|
|
|
|
|
it 'rejects when project path is invalid' do
|
|
|
|
subscribe(project_path: 'invalid_project_path', iid: issue.iid)
|
|
|
|
|
|
|
|
expect(subscription).to be_rejected
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'rejects when iid is invalid' do
|
|
|
|
subscribe(project_path: issue.project.full_path, iid: non_existing_record_iid)
|
|
|
|
|
|
|
|
expect(subscription).to be_rejected
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'rejects when the user does not have access' do
|
2020-06-23 00:09:42 +05:30
|
|
|
stub_action_cable_connection current_user: nil
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
subscribe(project_path: issue.project.full_path, iid: issue.iid)
|
|
|
|
|
|
|
|
expect(subscription).to be_rejected
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'subscribes to a stream when the user has access' do
|
2020-06-23 00:09:42 +05:30
|
|
|
stub_action_cable_connection current_user: issue.author
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
subscribe(project_path: issue.project.full_path, iid: issue.iid)
|
|
|
|
|
|
|
|
expect(subscription).to be_confirmed
|
|
|
|
expect(subscription).to have_stream_for(issue)
|
|
|
|
end
|
|
|
|
end
|