From 26a55fa9b5a40e0f8c4ca20fa2b465b05c3e425d Mon Sep 17 00:00:00 2001 From: Heinrich Lee Yu <heinrich@gitlab.com> Date: Fri, 14 May 2021 22:58:35 +0800 Subject: [PATCH] Remove unused IssuesChannel This is no longer needed since we moved to GraphQL subscriptions for this feature --- app/channels/issues_channel.rb | 13 -------- app/services/issues/update_service.rb | 4 --- spec/channels/issues_channel_spec.rb | 36 --------------------- spec/services/issues/update_service_spec.rb | 2 -- 4 files changed, 55 deletions(-) delete mode 100644 app/channels/issues_channel.rb delete mode 100644 spec/channels/issues_channel_spec.rb diff --git a/app/channels/issues_channel.rb b/app/channels/issues_channel.rb deleted file mode 100644 index 5f3909b77167f..0000000000000 --- a/app/channels/issues_channel.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -class IssuesChannel < ApplicationCable::Channel - def subscribed - project = Project.find_by_full_path(params[:project_path]) - return reject unless project - - issue = project.issues.find_by_iid(params[:iid]) - return reject unless issue && Ability.allowed?(current_user, :read_issue, issue) - - stream_for issue - end -end diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb index d9371e331c14c..dbc7245078950 100644 --- a/app/services/issues/update_service.rb +++ b/app/services/issues/update_service.rb @@ -43,10 +43,6 @@ def before_update(issue, skip_spam_check: false) ).execute(spam_params: spam_params) end - def after_update(issue) - IssuesChannel.broadcast_to(issue, event: 'updated') if Gitlab::ActionCable::Config.in_app? || Feature.enabled?(:broadcast_issue_updates, issue.project) - end - def handle_changes(issue, options) old_associations = options.fetch(:old_associations, {}) old_labels = old_associations.fetch(:labels, []) diff --git a/spec/channels/issues_channel_spec.rb b/spec/channels/issues_channel_spec.rb deleted file mode 100644 index 4c860402f03be..0000000000000 --- a/spec/channels/issues_channel_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe IssuesChannel do - 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 - stub_action_cable_connection current_user: nil - - 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 - stub_action_cable_connection current_user: issue.author - - subscribe(project_path: issue.project.full_path, iid: issue.iid) - - expect(subscription).to be_confirmed - expect(subscription).to have_stream_for(issue) - end -end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 2bb62f49bd0f1..7490ad5b2b347 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -1024,10 +1024,8 @@ def update_issue(opts) stub_feature_flags(broadcast_issue_updates: feature_flag_enabled) if should_broadcast - expect(IssuesChannel).to receive(:broadcast_to).with(issue, event: 'updated') expect(GraphqlTriggers).to receive(:issuable_assignees_updated).with(issue) else - expect(IssuesChannel).not_to receive(:broadcast_to) expect(GraphqlTriggers).not_to receive(:issuable_assignees_updated).with(issue) end -- GitLab