From aaa2234205858c468b700c229ed163a59a99ee2c Mon Sep 17 00:00:00 2001 From: Neil van Beinum Date: Wed, 10 Aug 2016 12:55:45 +0100 Subject: [PATCH 1/3] Replace several fields on analytics form We now have no need to supply date ranges or format requirements on the submission of the analytics form. This change modifies the form to have just a few text inputs. The user is required to fill in at least one of these. --- .../analytics_requests_controller.rb | 19 +++-- app/controllers/requests_controller.rb | 5 +- .../_request_details.html.erb | 33 +------- lib/support/requests/analytics_request.rb | 23 ++++-- .../ticket/analytics_request_ticket.rb | 30 +++++--- spec/features/analytics_requests_spec.rb | 76 +++++++------------ .../requests/analytics_request_spec.rb | 6 +- 7 files changed, 87 insertions(+), 105 deletions(-) diff --git a/app/controllers/analytics_requests_controller.rb b/app/controllers/analytics_requests_controller.rb index f845fe0f5..2f78a3fc7 100644 --- a/app/controllers/analytics_requests_controller.rb +++ b/app/controllers/analytics_requests_controller.rb @@ -6,7 +6,7 @@ class AnalyticsRequestsController < RequestsController protected def new_request - AnalyticsRequest.new(needed_report: Support::GDS::NeededReport.new) + AnalyticsRequest.new end def zendesk_ticket_class @@ -19,15 +19,14 @@ def parse_request_from_params def analytics_request_params params.require(:support_requests_analytics_request).permit( - :justification_for_needing_report, - requester_attributes: [:email, :name, :collaborator_emails], - needed_report_attributes: [ - :reporting_period_start, - :reporting_period_end, - :pages_or_sections, - :non_standard_requirements, - :frequency, - :format + :google_analytics_request_details, + :single_point_of_contact_request_details, + :report_request_details, + :help_request_details, + requester_attributes: [ + :email, + :name, + :collaborator_emails ], ) end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 6f57cc902..478623a87 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -21,7 +21,10 @@ def create end else respond_to do |format| - format.html { render :new, status: 400 } + format.html do + flash.now[:alert] = @request.errors.full_messages.join('\n') + render :new, status: 400 + end format.json { render json: {"errors" => @request.errors.to_a}, status: 400 } end end diff --git a/app/views/analytics_requests/_request_details.html.erb b/app/views/analytics_requests/_request_details.html.erb index 992a58160..e29ca1061 100644 --- a/app/views/analytics_requests/_request_details.html.erb +++ b/app/views/analytics_requests/_request_details.html.erb @@ -1,32 +1,7 @@ -<%= f.semantic_fields_for :needed_report do |r| %> - <%= r.inputs name: "What reporting period are you interested in?" do %> - <%= r.input :reporting_period_start, label: "From", required: true, input_html: {:class => "input-md-6", :"aria-required" => true} %> - <%= r.input :reporting_period_end, label: "To", required: true, input_html: {:class => "input-md-6", :"aria-required" => true} %> - <%= r.input :pages_or_sections, as: :text, label: "Which page(s) or section(s) on GOV.UK do you want data for? (Please provide URLs and, if possible or relevant, Need IDs)", required: true, input_html: {:class => "input-md-6", :rows => 6, :cols => 50, :"aria-required" => true } %> - <% end %> +<%= f.input :google_analytics_request_details, as: :text, label: "Access to Google Analytics", input_html: {:class => "input-md-6", :rows => 6, :cols => 50 } %> - <%= f.input :justification_for_needing_report, as: :text, label: "How will you use the report and what decisions will it help you make?", required: true, input_html: {:class => "input-md-6", :rows => 6, :cols => 50, :"aria-required" => true } %> +<%= f.input :single_point_of_contact_request_details, as: :text, label: "Tell me who my Analytics Single Point of Contact (SPOC) is", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> -
-

The basic report includes the following metrics:

- -
+<%= f.input :report_request_details, as: :text, label: "Analytics Report Request", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> - <%= r.input :non_standard_requirements, as: :text, label: "Beyond the basic report, what other information are you interested in?", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> - -
- <%= r.input :frequency, as: :radio, required: true, label: "How often do you need to receive these reports?", collection: r.object.frequency_options, input_html: { :"aria-required" => true } %> -
- -
- <%= r.input :format, as: :radio, label: "Do you want a CSV file (so you can manipulate data) or a PDF (which will be more visual)?", collection: r.object.format_options %> -
- -
-

For recurring reports, you will need to renew your request every 6 months.

-
-<% end %> +<%= f.input :help_request_details, as: :text, label: "Analytics Help", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> diff --git a/lib/support/requests/analytics_request.rb b/lib/support/requests/analytics_request.rb index f425859d0..839da80bf 100644 --- a/lib/support/requests/analytics_request.rb +++ b/lib/support/requests/analytics_request.rb @@ -4,13 +4,16 @@ module Support module Requests class AnalyticsRequest < Request - attr_accessor :needed_report, :justification_for_needing_report + REQUEST_DETAILS_ATTRS = [ + :google_analytics_request_details, + :single_point_of_contact_request_details, + :report_request_details, + :help_request_details + ].freeze - validates_presence_of :needed_report, :justification_for_needing_report + attr_accessor(*REQUEST_DETAILS_ATTRS) - def needed_report_attributes=(attr) - self.needed_report = Support::GDS::NeededReport.new(attr) - end + validate :one_or_more_request_details_present def self.label "Analytics access, reports and help" @@ -19,6 +22,16 @@ def self.label def self.description "Request access to Google Analytics or help with analytics or reports" end + + def one_or_more_request_details_present + request_details = REQUEST_DETAILS_ATTRS.select do |request_details_attribute| + !send(request_details_attribute).to_s.empty? + end + + if request_details.empty? + errors.add(:base, 'Please enter details for at least one type of request') + end + end end end end diff --git a/lib/zendesk/ticket/analytics_request_ticket.rb b/lib/zendesk/ticket/analytics_request_ticket.rb index fa0276307..171ba033e 100644 --- a/lib/zendesk/ticket/analytics_request_ticket.rb +++ b/lib/zendesk/ticket/analytics_request_ticket.rb @@ -15,16 +15,26 @@ def tags protected def comment_snippets [ - LabelledSnippet.new(on: @request.needed_report, field: :reporting_period), - LabelledSnippet.new(on: @request.needed_report, field: :pages_or_sections, - label: "Requested pages/sections"), - LabelledSnippet.new(on: @request, field: :justification_for_needing_report), - LabelledSnippet.new(on: @request.needed_report, field: :non_standard_requirements, - label: "More detailed analysis needed?"), - LabelledSnippet.new(on: @request.needed_report, field: :formatted_frequency, - label: "Reporting frequency"), - LabelledSnippet.new(on: @request.needed_report, field: :formatted_format, - label: "Report format"), + LabelledSnippet.new( + on: @request, + field: :google_analytics_request_details, + label: 'Google Analytics Access' + ), + LabelledSnippet.new( + on: @request, + field: :single_point_of_contact_request_details, + label: 'Single Point of Contact' + ), + LabelledSnippet.new( + on: @request, + field: :report_request_details, + label: 'Report Request' + ), + LabelledSnippet.new( + on: @request, + field: :help_request_details, + label: 'Help' + ) ] end end diff --git a/spec/features/analytics_requests_spec.rb b/spec/features/analytics_requests_spec.rb index 170ca3198..83cbf7133 100644 --- a/spec/features/analytics_requests_spec.rb +++ b/spec/features/analytics_requests_spec.rb @@ -1,10 +1,6 @@ require 'rails_helper' feature "Analytics requests" do - # In order to measure how well my content is meeting user need - # As a government content producer - # I want a means to request analytics data from GDS - let(:user) { create(:user, name: "John Smith", email: "john.smith@agency.gov.uk") } background do @@ -18,65 +14,49 @@ "requester" => hash_including("name" => "John Smith", "email" => "john.smith@agency.gov.uk"), "tags" => [ "govt_form", "analytics" ], "comment" => { "body" => -"[Reporting period] -From Start Q4 2012 to End 2012 - -[Requested pages/sections] -https://gov.uk/X - -[Justification for needing report] -To measure campaign success +"[Google Analytics Access] +Sarah Jones sarah@example.com some area -[More detailed analysis needed?] -I also need KPI Y +[Single Point of Contact] +Government Digital Service -[Reporting frequency] -One-off +[Report Request] +/my-page -[Report format] -PDF"}) +[Help] +Need help with cats"}) - user_makes_an_analytics_request( - from: "Start Q4 2012", - to: "End 2012", - which_part_of_govuk: "https://gov.uk/X", - justification: "To measure campaign success", - more_detailed_analysis: "I also need KPI Y", - frequency: "One-off", - format: "PDF", - ) - - expect(request).to have_been_made - end - - private - def user_makes_an_analytics_request(details) visit '/' click_on "Analytics access, reports and help" expect(page).to have_content("Request access to Google Analytics or help with analytics or reports") - fill_in "From", :with => details[:from] - fill_in "To", :with => details[:to] + fill_in "Access to Google Analytics", + with: "Sarah Jones sarah@example.com some area" - fill_in "Which page(s) or section(s) on GOV.UK do you want data for? (Please provide URLs and, if possible or relevant, Need IDs)", - with: details[:which_part_of_govuk] + fill_in "Tell me who my Analytics Single Point of Contact (SPOC) is", + with: "Government Digital Service" - fill_in "How will you use the report and what decisions will it help you make?", - with: details[:justification] + fill_in "Analytics Report Request", + with: "/my-page" - fill_in "Beyond the basic report, what other information are you interested in?", - with: details[:more_detailed_analysis] + fill_in "Analytics Help", + with: "Need help with cats" - within "#frequency" do - choose details[:frequency] - end + user_submits_the_request_successfully - within "#format" do - choose details[:format] - end + expect(request).to have_been_made + end - user_submits_the_request_successfully + scenario 'submitting a form with no inputs fails and shows a flash message' do + visit '/' + + click_on "Analytics access, reports and help" + + click_on "Submit" + + expect(page).to have_content("Request access to Google Analytics or help with analytics or reports") + expect(page).to have_content 'Please enter details for at least one type of request' end end diff --git a/spec/models/support/requests/analytics_request_spec.rb b/spec/models/support/requests/analytics_request_spec.rb index da6b0aa7e..c036b002d 100644 --- a/spec/models/support/requests/analytics_request_spec.rb +++ b/spec/models/support/requests/analytics_request_spec.rb @@ -6,8 +6,10 @@ module Requests describe AnalyticsRequest do it { should validate_presence_of(:requester) } - it { should validate_presence_of(:needed_report) } - it { should validate_presence_of(:justification_for_needing_report) } + it 'fails validation if there is no request type' do + expect(subject.valid?).to be false + expect(subject.errors[:base]).to include 'Please enter details for at least one type of request' + end end end end From b7f6096af6a671892672d6366d9c8d8936cd344e Mon Sep 17 00:00:00 2001 From: Neil van Beinum Date: Mon, 15 Aug 2016 16:00:44 +0100 Subject: [PATCH 2/3] Remove collaborators emails from analytics form The new simplified analytics form does not require this field. --- .../_request_details.html.erb | 2 ++ app/views/campaign_requests/_request_details.html.erb | 2 ++ .../_request_details.html.erb | 2 ++ app/views/content_advice_requests/_request_details.html.erb | 2 ++ app/views/content_change_requests/_request_details.html.erb | 2 ++ app/views/general_requests/_request_details.html.erb | 2 ++ app/views/remove_user_requests/_request_details.html.erb | 2 ++ app/views/requests/new.html.erb | 2 -- app/views/technical_fault_reports/_request_details.html.erb | 2 ++ app/views/unpublish_content_requests/_request_details.html.erb | 2 ++ 10 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/views/accounts_permissions_and_training_requests/_request_details.html.erb b/app/views/accounts_permissions_and_training_requests/_request_details.html.erb index d2dc89ef3..ccaebb690 100644 --- a/app/views/accounts_permissions_and_training_requests/_request_details.html.erb +++ b/app/views/accounts_permissions_and_training_requests/_request_details.html.erb @@ -11,3 +11,5 @@ <%= f.input :additional_comments, as: :text, label: "Additional comments", input_html: { class: "input-md-6", rows: 6, cols: 50 } %> + +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/campaign_requests/_request_details.html.erb b/app/views/campaign_requests/_request_details.html.erb index 4fc3d0075..351a2f673 100644 --- a/app/views/campaign_requests/_request_details.html.erb +++ b/app/views/campaign_requests/_request_details.html.erb @@ -14,3 +14,5 @@ <% end %> <%= f.input :additional_comments, as: :text, label: "Additional comments", input_html: { class: "input-md-6", rows: 6, cols: 50 } %> + +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/changes_to_publishing_apps_requests/_request_details.html.erb b/app/views/changes_to_publishing_apps_requests/_request_details.html.erb index 001fe2214..4cb95776b 100644 --- a/app/views/changes_to_publishing_apps_requests/_request_details.html.erb +++ b/app/views/changes_to_publishing_apps_requests/_request_details.html.erb @@ -11,3 +11,5 @@ <%= render partial: "support/attachment_instructions" %> <%= render partial: "support/time_constraint", locals: { f: f } %> + +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/content_advice_requests/_request_details.html.erb b/app/views/content_advice_requests/_request_details.html.erb index 85012e6bf..4c74a7467 100644 --- a/app/views/content_advice_requests/_request_details.html.erb +++ b/app/views/content_advice_requests/_request_details.html.erb @@ -27,3 +27,5 @@ <%= r.input :time_constraint_reason, label: "Reason for deadline", input_html: { class: "input-md-6" } %> <% end %> <% end %> + +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/content_change_requests/_request_details.html.erb b/app/views/content_change_requests/_request_details.html.erb index 81ef3aaf3..6fcdea04d 100644 --- a/app/views/content_change_requests/_request_details.html.erb +++ b/app/views/content_change_requests/_request_details.html.erb @@ -16,3 +16,5 @@

If your request is urgent, please fill in this form then call 07827 992603 to let us know. (It's ONLY urgent when the public or the government is facing immediate and significant financial, legal or physical risk.)

+ +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/general_requests/_request_details.html.erb b/app/views/general_requests/_request_details.html.erb index 4e2d3fc96..69cb21125 100644 --- a/app/views/general_requests/_request_details.html.erb +++ b/app/views/general_requests/_request_details.html.erb @@ -5,3 +5,5 @@ <%= f.input :url, label: "URL (if applicable)", input_html: { class: "input-md-6" } %> <% end %> + +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/remove_user_requests/_request_details.html.erb b/app/views/remove_user_requests/_request_details.html.erb index 21f474623..a374552b0 100644 --- a/app/views/remove_user_requests/_request_details.html.erb +++ b/app/views/remove_user_requests/_request_details.html.erb @@ -11,3 +11,5 @@ <%= f.input :reason_for_removal, as: :text, label: "Reason for removal", input_html: { class: "input-md-6", rows: 6, cols: 50 } %> <% end %> + +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/requests/new.html.erb b/app/views/requests/new.html.erb index c347919bc..df76ec294 100644 --- a/app/views/requests/new.html.erb +++ b/app/views/requests/new.html.erb @@ -12,7 +12,5 @@ <%= render partial: "request_details", locals: { f: f } %> - <%= render partial: "support/collaborators", locals: { f: f } %> - <%= f.action :submit, label: "Submit", button_html: { class: "btn btn-success" } %> <% end %> diff --git a/app/views/technical_fault_reports/_request_details.html.erb b/app/views/technical_fault_reports/_request_details.html.erb index ba4b80320..dd65130ee 100644 --- a/app/views/technical_fault_reports/_request_details.html.erb +++ b/app/views/technical_fault_reports/_request_details.html.erb @@ -17,3 +17,5 @@

If you have screenshots please send them as attachments in reply to the acknowledgement email you will receive shortly.

+ +<%= render partial: "support/collaborators", locals: { f: f } %> diff --git a/app/views/unpublish_content_requests/_request_details.html.erb b/app/views/unpublish_content_requests/_request_details.html.erb index 2b0409957..6c1118dac 100644 --- a/app/views/unpublish_content_requests/_request_details.html.erb +++ b/app/views/unpublish_content_requests/_request_details.html.erb @@ -35,3 +35,5 @@

Pages cannot be recovered once you have deleted them. Please ensure that all requests to GDS to unpublish content have been approved at the correct level in your organisation - if you aren't sure check with your GDS single point of contact.

+ +<%= render partial: "support/collaborators", locals: { f: f } %> From 39c616804d3e64e941b1fd9a773cf01004dfcead Mon Sep 17 00:00:00 2001 From: Neil van Beinum Date: Mon, 15 Aug 2016 16:47:26 +0100 Subject: [PATCH 3/3] Add help and placeholder text to analytics form inputs --- .../_request_details.html.erb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/views/analytics_requests/_request_details.html.erb b/app/views/analytics_requests/_request_details.html.erb index e29ca1061..58a17ee18 100644 --- a/app/views/analytics_requests/_request_details.html.erb +++ b/app/views/analytics_requests/_request_details.html.erb @@ -1,7 +1,17 @@ -<%= f.input :google_analytics_request_details, as: :text, label: "Access to Google Analytics", input_html: {:class => "input-md-6", :rows => 6, :cols => 50 } %> +
+

Only department/organisation Analytics Single Point of Contact (SPOC) can request access.

+
-<%= f.input :single_point_of_contact_request_details, as: :text, label: "Tell me who my Analytics Single Point of Contact (SPOC) is", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> +<%= f.input :google_analytics_request_details, as: :text, label: "Access to Google Analytics", placeholder: 'Detail full name, email address and areas of content.', input_html: {:class => "input-md-6", :rows => 6, :cols => 50 } %> -<%= f.input :report_request_details, as: :text, label: "Analytics Report Request", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> +<%= f.input :single_point_of_contact_request_details, as: :text, label: "Tell me who my Analytics Single Point of Contact (SPOC) is", placeholder: 'Detail information on department/organisation/agency. If you have one include your parent or sponsoring department.', input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> -<%= f.input :help_request_details, as: :text, label: "Analytics Help", input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> +
+

GDS no longer provide basic analytic reports - you should contact your department/organisation Analytics Single Point of Contact (SPOC) for analytic reporting.

+
+<%= f.input :report_request_details, as: :text, label: "Analytics Report Request", placeholder: 'Detail of report including date range.', input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %> + +
+

Before contacting the GDS performance analytics team please check the GOV.UK Performance Analytics Basecamp community for tips or post your query there for help.

+
+<%= f.input :help_request_details, as: :text, label: "Analytics Help", placeholder: 'Detail what help you require and be specific in the examples you submit.', input_html: {:class => "input-md-6", :rows => 6, :cols => 50} %>