Commit 57a36570 authored by Peter Leitzen's avatar Peter Leitzen

Allow passing include_confidential for find_by_id

parent 59d90368
......@@ -10,8 +10,10 @@
#
# finder = StatusPage::IncidentsFinder.new(project_id: project_id)
#
# # A single issue (including confidential issue)
# # A single issue which includes confidential issues by default)
# issue = finder.find_by_id(issue_id)
# # Find a "public only" issue
# issue = finder.find_by_id(issue_id, include_confidential: false)
#
# # Most recent 20 non-confidential issues
# issues = finder.all
......@@ -24,8 +26,8 @@ module StatusPage
@project_id = project_id
end
def find_by_id(issue_id)
execute(include_confidential: true)
def find_by_id(issue_id, include_confidential: true)
execute(include_confidential: include_confidential)
.find_by_id(issue_id)
end
......
......@@ -17,24 +17,38 @@ describe StatusPage::IncidentsFinder do
let(:finder) { described_class.new(project_id: project.id) }
describe '#find_by_id' do
subject { finder.find_by_id(issue.id) }
subject { finder.find_by_id(issue.id, **params) }
context 'for public issue' do
let(:issue) { public_issues.first }
context 'without params' do
let(:params) { {} }
it { is_expected.to eq(issue) }
end
context 'for public issue' do
let(:issue) { public_issues.first }
it { is_expected.to eq(issue) }
end
context 'for confidential issue' do
let(:issue) { issues.fetch(:confidential) }
context 'for confidential issue' do
let(:issue) { issues.fetch(:confidential) }
it { is_expected.to eq(issue) }
end
it { is_expected.to eq(issue) }
context 'for unrelated issue' do
let(:issue) { issues.fetch(:unrelated) }
it { is_expected.to be_nil }
end
end
context 'for unrelated issue' do
let(:issue) { issues.fetch(:unrelated) }
context 'with include_confidential' do
let(:params) { { include_confidential: false } }
it { is_expected.to be_nil }
context 'for confidential issue' do
let(:issue) { issues.fetch(:confidential) }
it { is_expected.to be_nil }
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