Commit c6329158 authored by Jarka Košanová's avatar Jarka Košanová

Fix confidential note atttribute getter

- don't display cofidential note icon on
confidential issue public notes
parent 60fcd514
......@@ -350,8 +350,10 @@ class Note < ApplicationRecord
self.special_role = Note::SpecialRole::FIRST_TIME_CONTRIBUTOR
end
def confidential?
confidential || noteable.try(:confidential?)
def confidential?(include_noteable: false)
return true if confidential
include_noteable && noteable.try(:confidential?)
end
def editable?
......
......@@ -36,7 +36,7 @@ module Notes
return unless @note.project
note_data = hook_data
hooks_scope = @note.confidential? ? :confidential_note_hooks : :note_hooks
hooks_scope = @note.confidential?(include_noteable: true) ? :confidential_note_hooks : :note_hooks
@note.project.execute_hooks(note_data, hooks_scope)
@note.project.execute_services(note_data, hooks_scope)
......
---
title: Don't display confidential note icon on confidential issue public notes
merge_request: 32571
author:
type: fixed
......@@ -55,7 +55,7 @@ module Gitlab
end
def build_base_data(project, user, note)
event_type = note.confidential? ? 'confidential_note' : 'note'
event_type = note.confidential?(include_noteable: true) ? 'confidential_note' : 'note'
base_data = {
object_kind: "note",
......
......@@ -304,11 +304,22 @@ describe Note do
describe '#confidential?' do
context 'when note is not confidential' do
it 'is true when a noteable is confidential' do
context 'when include_noteable is set to true' do
it 'is true when a noteable is confidential ' do
issue = create(:issue, :confidential)
note = build(:note, noteable: issue, project: issue.project)
expect(note.confidential?).to be_truthy
expect(note.confidential?(include_noteable: true)).to be_truthy
end
end
context 'when include_noteable is not set to true' do
it 'is false when a noteable is confidential ' do
issue = create(:issue, :confidential)
note = build(:note, noteable: issue, project: issue.project)
expect(note.confidential?).to be_falsey
end
end
it 'is false when a noteable is not confidential' do
......@@ -318,7 +329,7 @@ describe Note do
expect(note.confidential?).to be_falsy
end
it "is falsey when noteable can't be confidential" do
it "is false when noteable can't be confidential" do
commit_note = build(:note_on_commit)
expect(commit_note.confidential?).to be_falsy
......
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