Skip to content

Commit

Permalink
Update request base calculated status
Browse files Browse the repository at this point in the history
Once a requester has asked for a internal review their request's base
status shouldn't ever be `waiting_classification` as this limits the
possible classification statuses.

Returning `internal_review` allows the requester to classify the request
as `I'm still waiting for the internal review` after they receive an
acknowledgement of their review.

Fixes #3830
  • Loading branch information
gbp committed Oct 27, 2023
1 parent 53fa606 commit 82fce05
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
9 changes: 8 additions & 1 deletion app/models/info_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,10 @@ def must_be_internal_or_external
end
end

def internally_reviewed?
outgoing_messages.where(what_doing: 'internal_review').any?
end

def is_external?
external_url.nil? ? false : true
end
Expand Down Expand Up @@ -1039,7 +1043,10 @@ def calculate_status(cached_value_ok=false)
end

def base_calculate_status
return 'waiting_classification' if awaiting_description
if awaiting_description
return 'internal_review' if internally_reviewed?
return 'waiting_classification'
end
return described_state unless described_state == "waiting_response"
# Compare by date, so only overdue on next day, not if 1 second late
return 'waiting_response_very_overdue' if
Expand Down
25 changes: 20 additions & 5 deletions spec/models/info_request/state/calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@
end
end

context "when the request is in internal_review" do
before :each do
info_request.set_described_state("internal_review")
end

shared_examples 'internal_review' do
context "and the user is the owner" do
it "returns only two pending states" do
transitions = calculator.transitions(
Expand Down Expand Up @@ -237,6 +233,25 @@
end
end

context "when the request is in internal_review" do
before :each do
info_request.set_described_state("internal_review")
end

include_examples 'internal_review'
end

context "when the request was in internal_review" do
let(:info_request) do
FactoryBot.create(
:info_request, :with_internal_review_request,
awaiting_description: true, described_state: 'waiting_response'
)
end

include_examples 'internal_review'
end

context "when the request is in an 'other' state" do
context "and the user is the owner" do
it_behaves_like(
Expand Down
17 changes: 17 additions & 0 deletions spec/models/info_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,23 @@
end
end

describe '#internally_reviewed?' do
subject { info_request.internally_reviewed? }

context 'when internal review has been sent' do
let(:info_request) do
FactoryBot.create(:info_request, :with_internal_review_request)
end

it { is_expected.to eq true }
end

context 'when internal review has not been sent' do
let(:info_request) { FactoryBot.create(:info_request) }
it { is_expected.to eq false }
end
end

describe '#is_external?' do

it 'returns true if there is an external url' do
Expand Down

0 comments on commit 82fce05

Please sign in to comment.