Skip to content

Commit

Permalink
PWNN-1653 Request Case Origin from E&O during Create Case
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoaken committed Sep 22, 2023
1 parent 5a6827d commit 2c8a279
Show file tree
Hide file tree
Showing 23 changed files with 215 additions and 91 deletions.
80 changes: 36 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,23 @@ GEM
ast (2.4.2)
attr_required (1.0.1)
aws-eventstream (1.2.0)
aws-partitions (1.822.0)
aws-sdk-core (3.181.0)
aws-partitions (1.826.0)
aws-sdk-core (3.183.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.134.0)
aws-sdk-s3 (1.135.0)
aws-sdk-core (~> 3, >= 3.181.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
backports (3.24.1)
base64 (0.1.1)
better_errors (2.10.1)
erubi (>= 1.0.0)
rack (>= 0.9.0)
Expand All @@ -124,6 +125,7 @@ GEM
bootsnap (1.16.0)
msgpack (~> 1.2)
brakeman (6.0.1)
brow (0.4.1)
builder (3.2.4)
bullet (7.0.7)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -157,7 +159,7 @@ GEM
crass (1.0.6)
crawler_detect (1.2.2)
qonfig (~> 0.24)
cssbundling-rails (1.2.0)
cssbundling-rails (1.3.3)
railties (>= 6.0.0)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
Expand Down Expand Up @@ -187,7 +189,7 @@ GEM
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-schema (1.13.2)
dry-schema (1.13.3)
concurrent-ruby (~> 1.0)
dry-configurable (~> 1.0, >= 1.0.1)
dry-core (~> 1.0, < 2)
Expand Down Expand Up @@ -220,15 +222,16 @@ GEM
exception_notification (4.5.0)
actionmailer (>= 5.2, < 8)
activesupport (>= 5.2, < 8)
execjs (2.8.1)
execjs (2.9.1)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faker (3.2.1)
i18n (>= 1.8.11, < 2)
faraday (2.7.10)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-follow_redirects (0.3.0)
Expand All @@ -241,23 +244,24 @@ GEM
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
flipper (0.28.3)
flipper (1.0.0)
brow (~> 0.4.1)
concurrent-ruby (< 2)
flipper-active_record (0.28.3)
flipper-active_record (1.0.0)
activerecord (>= 4.2, < 8)
flipper (~> 0.28.3)
flipper-ui (0.28.3)
flipper (~> 1.0.0)
flipper-ui (1.0.0)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 0.28.3)
rack (>= 1.4, < 3)
flipper (~> 1.0.0)
rack (>= 1.4, < 4)
rack-protection (>= 1.5.3, <= 4.0.0)
sanitize (< 7)
foreman (0.87.2)
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
globalid (1.1.0)
activesupport (>= 5.0)
globalid (1.2.1)
activesupport (>= 6.1)
govuk_design_system_formbuilder (4.1.1)
actionview (>= 6.1)
activemodel (>= 6.1)
Expand Down Expand Up @@ -302,7 +306,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jsbundling-rails (1.1.2)
jsbundling-rails (1.2.1)
railties (>= 6.0.0)
json (2.6.3)
json-jwt (1.16.3)
Expand All @@ -316,8 +320,6 @@ GEM
rake
language_server-protocol (3.17.0.3)
libv8-node (18.16.0.0-arm64-darwin)
libv8-node (18.16.0.0-x86_64-darwin)
libv8-node (18.16.0.0-x86_64-linux)
liquid (5.4.0)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand All @@ -341,7 +343,7 @@ GEM
mini_mime (1.1.5)
mini_racer (0.8.0)
libv8-node (~> 18.16.0.0)
minitest (5.19.0)
minitest (5.20.0)
mock_redis (0.37.0)
msgpack (1.7.2)
multi_json (1.15.0)
Expand All @@ -355,14 +357,10 @@ GEM
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-linux)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
notifications-ruby-client (5.4.0)
jwt (>= 1.5, < 3)
Expand Down Expand Up @@ -397,7 +395,7 @@ GEM
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.3)
pg (1.5.4)
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
Expand All @@ -410,7 +408,7 @@ GEM
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (5.0.3)
puma (6.3.1)
puma (6.4.0)
nio4r (~> 2.0)
pundit (2.3.1)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -454,7 +452,7 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-i18n (7.0.7)
rails-i18n (7.0.8)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
rails_layout (1.0.42)
Expand Down Expand Up @@ -491,7 +489,7 @@ GEM
redis-actionpack (>= 5.0, < 6)
redis-activesupport (>= 5.0, < 6)
redis-store (>= 1.2, < 2)
redis-store (1.9.2)
redis-store (1.10.0)
redis (>= 4, < 6)
regexp_parser (2.8.1)
request_store (1.5.1)
Expand Down Expand Up @@ -529,17 +527,17 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.23.1)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-govuk (4.12.0)
rubocop (= 1.55.0)
rubocop-ast (= 1.29.0)
rubocop-rails (= 2.20.2)
rubocop-rake (= 0.6.0)
rubocop-rspec (= 2.22.0)
rubocop-performance (1.19.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.20.2)
Expand All @@ -555,7 +553,7 @@ GEM
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sanitize (6.0.2)
sanitize (6.1.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
scenic (1.7.0)
Expand Down Expand Up @@ -591,7 +589,7 @@ GEM
spring (4.1.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (4.2.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
Expand All @@ -607,7 +605,7 @@ GEM
faraday-follow_redirects
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
terser (1.1.17)
terser (1.1.18)
execjs (>= 0.3.0, < 3)
thor (1.2.2)
timeout (0.4.0)
Expand All @@ -628,7 +626,7 @@ GEM
validate_url (1.0.15)
activemodel (>= 3.0.0)
public_suffix
web-console (4.2.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
Expand All @@ -637,11 +635,11 @@ GEM
activesupport
faraday (~> 2.0)
faraday-follow_redirects
webmock (3.18.1)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.9)
websocket (1.2.10)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -657,13 +655,7 @@ GEM
zeitwerk (2.6.11)

PLATFORMS
arm64-darwin-20
arm64-darwin-21
arm64-darwin-22
x86_64-darwin-20
x86_64-darwin-21
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
aasm
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/engagement/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def form_params
:email,
:phone_number,
:extension_number,
:discovery_method,
:discovery_method_other_text,
:category_id,
:query_id,
:other_category,
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/support/cases/previews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def form_params
:email,
:phone_number,
:extension_number,
:discovery_method,
:discovery_method_other_text,
:category_id,
:query_id,
:other_category,
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/support/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def form_params
:email,
:phone_number,
:extension_number,
:discovery_method,
:discovery_method_other_text,
:category_id,
:query_id,
:estimated_procurement_completion_date,
Expand Down
2 changes: 2 additions & 0 deletions app/forms/support/create_case_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class CreateCaseForm
option :email, optional: true
option :phone_number, optional: true
option :extension_number, optional: true
option :discovery_method, optional: true
option :discovery_method_other_text, optional: true
option :source, optional: true
option :creation_source, optional: true
option :procurement_amount, ->(value) { value&.gsub(/[£,]/, "") }, optional: true
Expand Down
13 changes: 13 additions & 0 deletions app/forms/support/create_case_form_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class CreateCaseFormSchema < ::Support::Schema
required(:last_name).value(:string)
required(:email).value(:string)
required(:source).value(:string)

required(:discovery_method).value(:integer)
required(:discovery_method_other_text).value(:str?)

optional(:organisation_id).value(:string)
optional(:organisation_type).value(:string)
optional(:organisation_name).value(:string)
Expand Down Expand Up @@ -60,6 +64,15 @@ class CreateCaseFormSchema < ::Support::Schema
key(:source).failure(:missing) if value.blank?
end

rule(:discovery_method) do
key.failure(:invalid) if
value < (Support::Case.discovery_methods.values.min) || value > (Support::Case.discovery_methods.values.max)
end

rule(:discovery_method_other_text) do
key(:discovery_method_other_text).failure(:missing) if value.blank? && values[:discovery_method].eql?(Support::Case.discovery_methods.keys.index("other"))
end

rule(:procurement_amount) do
validator = Support::Forms::ValidateProcurementAmount.new(value)
key(:procurement_amount).failure(:invalid) if validator.invalid_number?
Expand Down
12 changes: 12 additions & 0 deletions app/models/support/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ class Case < ApplicationRecord
# 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, engagement_and_outreach_cms: 7 }

# Discovery Method
#
# used_before - I've used this service before
# meeting_or_event - Meeting or event
# newsletter - Newsletter
# recommendation - Recommendation
# search_engine - Search engine, such as Google
# social_media - Social media, such as Twitter
# website - Website, such as GOV.UK
# other - Other
enum discovery_method: { used_before: 0, meeting_or_event: 1, newsletter: 2, recommendation: 3, search_engine: 4, social_media: 5, website: 6, other: 7 }

# Creation Source
#
# default - created by a member of the ProcOps team
Expand Down
2 changes: 2 additions & 0 deletions app/services/support/create_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def call
email: @attrs[:email],
phone_number: @attrs[:phone_number],
extension_number: @attrs[:extension_number],
discovery_method: @attrs[:discovery_method],
discovery_method_other_text: @attrs[:discovery_method_other_text],
request_text: @attrs[:request_text],
action_required: @attrs.fetch(:action_required, false),
procurement_amount: @attrs[:procurement_amount],
Expand Down
2 changes: 2 additions & 0 deletions app/views/engagement/cases/forms/_create_case_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<%= form.govuk_phone_field :phone_number, label: { text: I18n.t("support.case_hub_migration.label.phone_number", optional: I18n.t("support.generic.form.optional")) } %>
<%= form.govuk_phone_field :extension_number, label: { text: I18n.t("support.case_hub_migration.label.extension_number", optional: I18n.t("support.generic.form.optional")) } %>

<%= render "support/cases/discovery_method/discovery_method", form: form %>

<%= render "support/cases/request_details/form_fields", form: form, show_request_text: false %>

<%= form.govuk_text_field :procurement_amount, width: 5,
Expand Down
Loading

0 comments on commit 2c8a279

Please sign in to comment.