Commit ca95400e authored by Sean McGivern's avatar Sean McGivern

Merge branch 'issue_207497' into 'master'

Display warning for issues moved from service desk

See merge request gitlab-org/gitlab!29617
parents ee09ef37 444d09c2
......@@ -177,6 +177,10 @@ module IssuesHelper
end
end
def show_moved_service_desk_issue_warning?(issue)
false
end
# Required for Banzai::Filter::IssueReferenceFilter
module_function :url_for_issue
module_function :url_for_internal_issue
......
......@@ -29,10 +29,12 @@ class Issue < ApplicationRecord
SORTING_PREFERENCE_FIELD = :issues_sort
belongs_to :project
belongs_to :moved_to, class_name: 'Issue'
belongs_to :duplicated_to, class_name: 'Issue'
belongs_to :closed_by, class_name: 'User'
belongs_to :moved_to, class_name: 'Issue'
has_one :moved_from, class_name: 'Issue', foreign_key: :moved_to_id
has_internal_id :iid, scope: :project, track_if: -> { !importing? }, init: ->(s) { s&.project&.issues&.maximum(:iid) }
has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
......
......@@ -39,5 +39,13 @@ module EE
super
end
end
override :show_moved_service_desk_issue_warning?
def show_moved_service_desk_issue_warning?(issue)
return false unless issue.moved_from
return false unless issue.from_service_desk?
issue.moved_from.project.service_desk_enabled? && !issue.project.service_desk_enabled?
end
end
end
......@@ -2,7 +2,7 @@
require "spec_helper"
describe IssuesHelper do
describe EE::IssuesHelper do
let(:project) { create(:project) }
let(:issue) { create :issue, project: project }
......@@ -42,4 +42,26 @@ describe IssuesHelper do
end
end
end
describe '#show_moved_service_desk_issue_warning?' do
let(:project1) { create(:project, service_desk_enabled: true) }
let(:project2) { create(:project, service_desk_enabled: true) }
let!(:old_issue) { create(:issue, author: User.support_bot, project: project1) }
let!(:new_issue) { create(:issue, author: User.support_bot, project: project2) }
before do
allow(::EE::Gitlab::ServiceDesk).to receive(:enabled?).and_return(true)
old_issue.update(moved_to: new_issue)
end
it 'is true when moved issue project has service desk disabled' do
project2.update!(service_desk_enabled: false)
expect(helper.show_moved_service_desk_issue_warning?(new_issue)).to be(true)
end
it 'is false when moved issue project has service desk enabled' do
expect(helper.show_moved_service_desk_issue_warning?(new_issue)).to be(false)
end
end
end
......@@ -18,6 +18,7 @@ issues:
- todos
- user_agent_detail
- moved_to
- moved_from
- duplicated_to
- promoted_to_epic
- events
......
......@@ -9,6 +9,7 @@ describe Issue do
it { is_expected.to belong_to(:milestone) }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:moved_to).class_name('Issue') }
it { is_expected.to have_one(:moved_from).class_name('Issue') }
it { is_expected.to belong_to(:duplicated_to).class_name('Issue') }
it { is_expected.to belong_to(:closed_by).class_name('User') }
it { is_expected.to have_many(:assignees) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment