Remove references for confidential issues from autocomplete

parent 4ded8adf
...@@ -45,6 +45,7 @@ class Issue < ActiveRecord::Base ...@@ -45,6 +45,7 @@ class Issue < ActiveRecord::Base
scope :cared, ->(user) { where(assignee_id: user) } scope :cared, ->(user) { where(assignee_id: user) }
scope :open_for, ->(user) { opened.assigned_to(user) } scope :open_for, ->(user) { opened.assigned_to(user) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids) } scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
scope :not_confidential, -> { where(confidential: false) }
state_machine :state, initial: :opened do state_machine :state, initial: :opened do
event :close do event :close do
......
...@@ -5,7 +5,7 @@ module Projects ...@@ -5,7 +5,7 @@ module Projects
end end
def issues def issues
@project.issues.opened.select([:iid, :title]) @project.issues.not_confidential.opened.select([:iid, :title])
end end
def merge_requests def merge_requests
......
require 'spec_helper'
describe Projects::AutocompleteService, services: true do
let(:project) { create(:empty_project, :public) }
subject(:autocomplete) { described_class.new(project) }
describe '#issues' do
it 'should not list confidential issues' do
issue = create(:issue, project: project)
create(:issue, :confidential, project: project)
expect(autocomplete.issues.map(&:iid)).to eq [issue.iid]
end
end
end
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