Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a framework support request in Case Management #806

Merged
merged 4 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/support/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Case < ApplicationRecord
# digital - specify cases
# nw_hub - north west hub cases
# sw_hub - south west hub cases
enum source: { digital: 0, nw_hub: 1, sw_hub: 2, incoming_email: 3 }
# faf - find a framework

enum source: { digital: 0, nw_hub: 1, sw_hub: 2, incoming_email: 3, faf: 4 }

# Savings status
#
Expand Down
1 change: 1 addition & 0 deletions app/models/support/interaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def self.model_name
hub_notes: 5,
hub_progress_notes: 6,
hub_migration: 7,
faf_support_request: 8,
}

validates :body, presence: true, unless: proc { |a| a.support_request? }
Expand Down
2 changes: 2 additions & 0 deletions app/presenters/support/case_hub_migration_form_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def full_name

# @return [String]
def category_name
return I18n.t("support.case_categorisations.label.none") if category_id.blank?

@category_name ||= Support::Category.find(category_id).title
end

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/support/category_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Support
class CategoryPresenter < BasePresenter
# @return [String]
def title
__getobj__.nil? ? "n/a" : super
__getobj__.nil? ? I18n.t("support.case_categorisations.label.none") : super
end
end
end
8 changes: 5 additions & 3 deletions app/presenters/support/interaction_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def additional_data
when "organisation_id"
formatted_hash["organisation_id"] = organisation(value).name
when "category_id"
formatted_hash["category_id"] = category(value).title
formatted_hash["category_id"] = category(value).title if value.present?
when "referer"
formatted_hash["referer"] = referer
else
formatted_hash[field] = value
end
Expand Down Expand Up @@ -80,8 +82,8 @@ def date_format
#
# @return [Array] with
def contact_events
Interaction.event_types.reject do |key, _int|
%w[note support_request hub_notes hub_progress_notes hub_migration].include?(key)
Support::Interaction.event_types.reject do |key, _int|
%w[note support_request hub_notes hub_progress_notes hub_migration faf_support_request].include?(key)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
%>

<%= form.govuk_select(:category_id, label: { text: I18n.t("support.case_hub_migration.label.category") }) do %>
<option data-tags="<%= I18n.t("support.case_categorisations.label.none") %>" value=""><%= I18n.t("support.case_categorisations.label.none") %></option>
<% Support::Category.grouped_opts.each do |parent_name, sub_categories| %>
<optgroup label="<%= parent_name%>">
<% sub_categories.each do |name, value| %>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ en:
digital: Specify case
nw_hub: North west hub case
sw_hub: South west hub case
faf: Find a Framework
category: Category
last_updated: Last updated
date_received: Date received
Expand Down Expand Up @@ -442,6 +443,8 @@ en:
submit: Save and continue
flash:
updated: Successfully changed case category
label:
none: Not Yet Known

case_contract:
existing:
Expand Down Expand Up @@ -649,6 +652,7 @@ en:
hub_notes: Hub notes
hub_progress_notes: Hub progress notes
hub_migration: Hub migration
faf_support_request: Find a Framework Support Request
label:
email_unread: Unread
contact_detail: Contact details
Expand Down
1 change: 1 addition & 0 deletions spec/models/support/case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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 pending closed pipeline no_response]) }
it { is_expected.to define_enum_for(:source).with_values(%i[digital nw_hub sw_hub incoming_email faf]) }

describe "#generate_ref" do
context "when no cases exist" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/support/interaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

it "can be a note, email (inbound/outbound) or phone call" do
expect(interaction).to define_enum_for(:event_type).with_values(%i[
note phone_call email_from_school email_to_school support_request hub_notes hub_progress_notes hub_migration
note phone_call email_from_school email_to_school support_request hub_notes hub_progress_notes hub_migration faf_support_request
])
end

Expand Down
23 changes: 21 additions & 2 deletions spec/presenters/support/case_hub_migration_form_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,27 @@
end

describe "#category_name" do
it "gives category name from the category id" do
expect(presenter.category_name).to eq "Catering"
context "when category is provided" do
it "gives category name from the category id" do
expect(presenter.category_name).to eq "Catering"
end
end

context "when category is not provided" do
let(:form_hash) do
{
school_urn: "000001",
hub_case_ref: "ce-00001",
first_name: "first_name",
last_name: "last_name",
email: "test@example.com",
phone_number: "00000000000",
}
end

it "gives Not Yet Known label" do
expect(presenter.category_name).to eq "Not Yet Known"
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/support/category_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
let(:category) { nil }

describe "#title" do
it "returns a placeholder for title" do
expect(presenter.title).to eq("n/a")
it "returns Not Yet Known for title" do
expect(presenter.title).to eq("Not Yet Known")
end
end
end
Expand Down
57 changes: 32 additions & 25 deletions spec/services/self-serve/submit_support_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,43 @@
end

describe "case creation" do
before { service.call }

it "submits the request and creates a case" do
expect(support_case).to be_persisted
expect(support_case.phone_number).to eq "01234567890"
expect(support_case.request_text).to eq "Support request message from a School Buying Professional"
expect(support_case.organisation.name).to eq chosen_organisation["name"]
expect(support_case.organisation.urn).to eq chosen_organisation["urn"]
expect(support_case.category).to eq support_category
expect(support_case.interactions.first.event_type).to eq "support_request"
expect(support_case.interactions.first.additional_data).to have_key("category")
expect(support_case.interactions.first.additional_data).to have_key("message")
end
context "with a specify support request" do
before { service.call }

context "with a specification" do
it "attaches the specification as a document" do
expect(support_case.documents.count).to eq 1
it "submits the request and creates a case" do
expect(support_case).to be_persisted
expect(support_case.phone_number).to eq "01234567890"
expect(support_case.request_text).to eq "Support request message from a School Buying Professional"
expect(support_case.organisation.name).to eq chosen_organisation["name"]
expect(support_case.organisation.urn).to eq chosen_organisation["urn"]
expect(support_case.category).to eq support_category
expect(support_case.interactions.first.event_type).to eq "support_request"
expect(support_case.interactions.first.additional_data).to have_key("category")
expect(support_case.interactions.first.additional_data).to have_key("message")
end
end

context "without a specification" do
let(:support_request) do
create(:support_request,
user: user,
phone_number: "01234567890",
school_urn: chosen_organisation["urn"])
context "with a specification" do
it "attaches the specification as a document" do
expect(support_case.documents.count).to eq 1
end
end

context "without a specification" do
let(:support_request) do
create(:support_request,
user: user,
phone_number: "01234567890",
school_urn: chosen_organisation["urn"])
end

it "has no support document" do
expect(support_case.documents.count).to eq 0
end
end
end

it "has no support document" do
expect(support_case.documents.count).to eq 0
context "with a find a framework support request" do
xit "submits the request and creates a case" do
end
end
end
Expand Down