Skip to content

Commit

Permalink
feat(cms): add new e&o case stage and show value
Browse files Browse the repository at this point in the history
Jira: PWNN-1378
  • Loading branch information
EdwinKruglov committed Jul 11, 2023
1 parent e339e2a commit 96a36d2
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/controllers/engagement/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def form_params
:request_text,
:procurement_amount,
).merge({
source: :engagement_and_outreach.to_s,
source: :engagement_and_outreach_cms.to_s,
creation_source: :engagement_and_outreach_team.to_s,
})
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/support/concerns/filter_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def filter_params_for(filter_scope, persist: true)
request_filter.presence || cached_filter.presence || {}
end

def sort_params = %i[ref support_level organisation_name subcategory state agent last_updated received action created_by created]
def sort_params = %i[ref support_level organisation_name subcategory state agent last_updated received action created_by created value]
end
end
end
3 changes: 2 additions & 1 deletion app/models/support/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Case < ApplicationRecord
),
)
}
scope :order_by_value, ->(sort_direction = "ASC") { order("value #{sort_direction}") }

# Support level
#
Expand Down Expand Up @@ -184,7 +185,7 @@ class Case < ApplicationRecord
# sw_hub - south west hub cases
# incoming_email -
# faf - find a framework
enum source: { digital: 0, nw_hub: 1, sw_hub: 2, incoming_email: 3, faf: 4, engagement_and_outreach: 5, schools_commercial_team: 6 }
enum source: { digital: 0, nw_hub: 1, sw_hub: 2, incoming_email: 3, faf: 4, engagement_and_outreach: 5, schools_commercial_team: 6, engagement_and_outreach_cms: 7 }

# Creation Source
#
Expand Down
4 changes: 4 additions & 0 deletions app/views/engagement/cases/index/_detailed_case.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<%= kase.creator_full_name %>
</td>

<td class="govuk-table__cell">
<%= kase.value %>
</td>

<td class="govuk-table__cell">
<span title="<%= kase.last_updated_at %>"><%= short_date_format(kase.created_at, show_time: false, always_show_year: true) %></span>
</td>
Expand Down
1 change: 1 addition & 0 deletions app/views/engagement/cases/index/_detailed_cases.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<%= sortable_th :organisation_name, I18n.t("support.case.label.organisation"), sort_scope, sort_form, th_classes: "col-organisation" %>
<%= sortable_th :subcategory, I18n.t("support.case.label.category"), sort_scope, sort_form, th_classes: "col-sub-category", th_attributes: { title: I18n.t("support.case.label.sub_category") } %>
<%= sortable_th :created_by, I18n.t("support.case.label.created_by"), sort_scope, sort_form %>
<%= sortable_th :value, I18n.t("support.case.label.case_value_short"), sort_scope, sort_form %>
<%= sortable_th :created, I18n.t("support.case.label.created"), sort_scope, sort_form, sort_order: :desc_asc %>
</tr>
</thead>
Expand Down
25 changes: 24 additions & 1 deletion config/brakeman.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,29 @@
],
"note": ""
},
{
"warning_type": "SQL Injection",
"warning_code": 0,
"fingerprint": "c243bd8831e9f51e2220e604cdeb80cd1d041462f2ee1255d329987266eda992",
"check_name": "SQL",
"message": "Possible SQL injection",
"file": "app/models/support/case.rb",
"line": 150,
"link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
"code": "order(\"value #{sort_direction}\")",
"render_path": null,
"location": {
"type": "method",
"class": "Support::Case",
"method": "order_by_value"
},
"user_input": "sort_direction",
"confidence": "Medium",
"cwe_id": [
89
],
"note": ""
},
{
"warning_type": "Cross-Site Scripting",
"warning_code": 2,
Expand Down Expand Up @@ -388,6 +411,6 @@
"note": ""
}
],
"updated": "2023-07-07 11:07:56 +0100",
"updated": "2023-07-11 17:05:33 +0100",
"brakeman_version": "6.0.0"
}
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ en:
note: Note
type: Type
case_value: Case value
case_value_short: Value
category: Category
change_owner: Change case owner
close: Close case
Expand Down Expand Up @@ -861,6 +862,7 @@ en:
source:
digital: Specify case
engagement_and_outreach: Engagement and Outreach (E&O)
engagement_and_outreach_cms: E&O CMS
faf: Find a Framework
header: Source
incoming_email: Email
Expand Down
4 changes: 4 additions & 0 deletions spec/features/engagement/create_case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
end

within table_cell(1, 6) do
expect(page).to have_content("45.22")
end

within table_cell(1, 7) do
expect(page).to have_content(Time.zone.now.strftime("%d %b %Y"))
end
end
Expand Down
46 changes: 35 additions & 11 deletions spec/models/support/case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

it { is_expected.to define_enum_for(:support_level).with_values(%i[L1 L2 L3 L4 L5]) }
it { is_expected.to define_enum_for(:state).with_values(%i[initial opened resolved on_hold closed pipeline no_response]) }
it { is_expected.to define_enum_for(:source).with_values(%i[digital nw_hub sw_hub incoming_email faf engagement_and_outreach schools_commercial_team]) }
it { is_expected.to define_enum_for(:source).with_values(%i[digital nw_hub sw_hub incoming_email faf engagement_and_outreach schools_commercial_team engagement_and_outreach_cms]) }

describe "#reopen_due_to_email" do
context "when the has been resolved" do
Expand Down Expand Up @@ -111,16 +111,16 @@
describe "ordering" do
before do
cat_e = create(:support_category, title: "E-cat")
create(:support_case, :opened, ref: "000500", action_required: true, organisation: create(:support_organisation, name: "A-org"), category: create(:support_category, title: "A-cat"), agent: create(:support_agent, first_name: "Avery", last_name: "Jones"))
create(:support_case, :opened, ref: "000501", action_required: false, organisation: create(:support_organisation, name: "B-org"), category: create(:support_category, title: "B-cat"), agent: create(:support_agent, first_name: "Brooke", last_name: "Davis"))
create(:support_case, :on_hold, ref: "000502", action_required: true, organisation: create(:support_establishment_group, name: "C-org"), category: create(:support_category, title: "C-cat"), agent: create(:support_agent, first_name: "Chloe", last_name: "Hernandez"))
create(:support_case, :on_hold, ref: "000503", action_required: true, organisation: create(:support_establishment_group, name: "D-org"), category: create(:support_category, title: "D-cat"), agent: create(:support_agent, first_name: "Daisy", last_name: "Carter"))
create(:support_case, :initial, ref: "000504", action_required: false, organisation: create(:support_organisation, name: "E-org"), category: cat_e, agent: create(:support_agent, first_name: "Emma", last_name: "Lee"))
create(:support_case, :initial, ref: "000505", action_required: true, organisation: create(:support_organisation, name: "F-org"), category: cat_e, agent: create(:support_agent, first_name: "Faith", last_name: "Rodriguez"))
create(:support_case, :closed, ref: "000506", action_required: false, organisation: create(:support_establishment_group, name: "G-org"), category: create(:support_category, title: "F-cat"), agent: create(:support_agent, first_name: "Grace", last_name: "Patel"))
create(:support_case, :closed, ref: "000507", action_required: false, organisation: create(:support_organisation, name: "H-org"), category: create(:support_category, title: "G-cat"), agent: create(:support_agent, first_name: "Harper", last_name: "Sims"))
create(:support_case, :resolved, ref: "000508", action_required: false, organisation: create(:support_organisation, name: "I-org"), category: create(:support_category, title: "H-cat"), agent: create(:support_agent, first_name: "Harper", last_name: "Kim"))
create(:support_case, :resolved, ref: "000509", action_required: true, organisation: create(:support_establishment_group, name: "I-org"), category: create(:support_category, title: "I-cat"), agent: create(:support_agent, first_name: "Isabella", last_name: "Singh"))
create(:support_case, :opened, ref: "000500", action_required: true, value: 14_504.22, organisation: create(:support_organisation, name: "A-org"), category: create(:support_category, title: "A-cat"), agent: create(:support_agent, first_name: "Avery", last_name: "Jones"))
create(:support_case, :opened, ref: "000501", action_required: false, value: 26.99, organisation: create(:support_organisation, name: "B-org"), category: create(:support_category, title: "B-cat"), agent: create(:support_agent, first_name: "Brooke", last_name: "Davis"))
create(:support_case, :on_hold, ref: "000502", action_required: true, value: 56_228.00, organisation: create(:support_establishment_group, name: "C-org"), category: create(:support_category, title: "C-cat"), agent: create(:support_agent, first_name: "Chloe", last_name: "Hernandez"))
create(:support_case, :on_hold, ref: "000503", action_required: true, value: 50_000.40, organisation: create(:support_establishment_group, name: "D-org"), category: create(:support_category, title: "D-cat"), agent: create(:support_agent, first_name: "Daisy", last_name: "Carter"))
create(:support_case, :initial, ref: "000504", action_required: false, value: 576.50, organisation: create(:support_organisation, name: "E-org"), category: cat_e, agent: create(:support_agent, first_name: "Emma", last_name: "Lee"))
create(:support_case, :initial, ref: "000505", action_required: true, value: 1_034.05, organisation: create(:support_organisation, name: "F-org"), category: cat_e, agent: create(:support_agent, first_name: "Faith", last_name: "Rodriguez"))
create(:support_case, :closed, ref: "000506", action_required: false, value: 900.00, organisation: create(:support_establishment_group, name: "G-org"), category: create(:support_category, title: "F-cat"), agent: create(:support_agent, first_name: "Grace", last_name: "Patel"))
create(:support_case, :closed, ref: "000507", action_required: false, value: 125_899.00, organisation: create(:support_organisation, name: "H-org"), category: create(:support_category, title: "G-cat"), agent: create(:support_agent, first_name: "Harper", last_name: "Sims"))
create(:support_case, :resolved, ref: "000508", action_required: false, value: nil, organisation: create(:support_organisation, name: "I-org"), category: create(:support_category, title: "H-cat"), agent: create(:support_agent, first_name: "Harper", last_name: "Kim"))
create(:support_case, :resolved, ref: "000509", action_required: true, value: 2.50, organisation: create(:support_establishment_group, name: "I-org"), category: create(:support_category, title: "I-cat"), agent: create(:support_agent, first_name: "Isabella", last_name: "Singh"))
end

describe ".order_by_action" do
Expand Down Expand Up @@ -359,5 +359,29 @@
end
end
end

describe ".order_by_value" do
context "when ascending" do
let(:order) { "ASC" }

it "sorts in ascending order" do
results = described_class.order_by_value(order).pluck(:ref)
expect(results).to eq(%w[
000509 000501 000504 000506 000505 000500 000503 000502 000507 000508
])
end
end

context "when descending" do
let(:order) { "DESC" }

it "sorts in descending order" do
results = described_class.order_by_value(order).pluck(:ref)
expect(results).to eq(%w[
000508 000507 000502 000503 000500 000505 000506 000504 000501 000509
])
end
end
end
end
end

0 comments on commit 96a36d2

Please sign in to comment.