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

Allow passing include_confidential for find_by_id

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