Skip to content

Commit

Permalink
fixup! Update request base calculated status
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Oct 27, 2023
1 parent c7c54e5 commit dbaebae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
7 changes: 3 additions & 4 deletions app/models/info_request/state/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ def transitions(opts = {})
other: {}
}
end
opts.merge!(
in_internal_review: state == 'internal_review',
internal_review_requested: @info_request.internal_review_requested?
)
opts[:in_internal_review] = state == 'internal_review'
opts[:internal_review_requested] =
@info_request.internal_review_requested?
build_transitions_hash(opts)
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/info_request/state/transitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def self.owner_gone_postal_transition_label(_opts = {})

def self.owner_internal_review_transition_label(opts = {})
if opts.fetch(:in_internal_review, false) ||
opts.fetch(:internal_review_requested, false)
opts.fetch(:internal_review_requested, false)
_("I'm still <strong>waiting</strong> for the internal review")
else
_("I'm waiting for an <strong>internal review</strong> response")
Expand Down Expand Up @@ -141,7 +141,7 @@ def self.other_user_gone_postal_transition_label(_opts = {})

def self.other_user_internal_review_transition_label(opts = {})
if opts.fetch(:in_internal_review, false) ||
opts.fetch(:internal_review_requested, false)
opts.fetch(:internal_review_requested, false)
_("Still awaiting an <strong>internal review</strong>")
else
# To match what would happen if this method didn't exist, because
Expand Down
22 changes: 14 additions & 8 deletions spec/models/info_request/state/calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,36 +253,42 @@
end

context "and the user is the owner" do
it "returns only two pending states" do
it "returns only all pending states with internal_review first" do
transitions = calculator.transitions(
is_owning_user: true,
user_asked_to_update_status: false)
expected = %w[internal_review waiting_response waiting_clarification gone_postal]
user_asked_to_update_status: false
)
expected = %w[internal_review waiting_response waiting_clarification
gone_postal]
expect(transitions[:pending].keys).to eq(expected)
end

it "returns a different label for the internal_review status" do
transitions = calculator.transitions(
is_owning_user: true,
user_asked_to_update_status: false)
user_asked_to_update_status: false
)
expected = "I'm still <strong>waiting</strong> for the internal review"

Check warning on line 271 in spec/models/info_request/state/calculator_spec.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Layout/LineLength: Line is too long. [81/80] (https://rubystyle.guide#max-line-length) Raw Output: spec/models/info_request/state/calculator_spec.rb:271:81: C: Layout/LineLength: Line is too long. [81/80] (https://rubystyle.guide#max-line-length) expected = "I'm still <strong>waiting</strong> for the internal review" ^
expect(transitions[:pending]["internal_review"]).to eq expected
end
end

context "and the user is some other user" do
it "returns only two pending states" do
it "returns only all pending states with internal_review first" do
transitions = calculator.transitions(
is_owning_user: false,
user_asked_to_update_status: false)
expected = %w[internal_review waiting_response waiting_clarification gone_postal]
user_asked_to_update_status: false
)
expected = %w[internal_review waiting_response waiting_clarification
gone_postal]
expect(transitions[:pending].keys).to eq(expected)
end

it "returns a different label for the internal_review status" do
transitions = calculator.transitions(
is_owning_user: false,
user_asked_to_update_status: false)
user_asked_to_update_status: false
)
expected = "Still awaiting an <strong>internal review</strong>"
expect(transitions[:pending]["internal_review"]).to eq expected
end
Expand Down

0 comments on commit dbaebae

Please sign in to comment.