Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #13 from alphagov/improving_capture_of_request_con…

…text_and_new_architecture_part2

Improving capture of request context and new architecture part2
  • Loading branch information...
commit 47981f01b707e8d297acedb4f85adefc481f7889 2 parents 1bd840c + 8d51d03
@jamiecobbett jamiecobbett authored
Showing with 467 additions and 260 deletions.
  1. +1 −0  app/controllers/content_change_requests_controller.rb
  2. +9 −8 app/controllers/remove_user_requests_controller.rb
  3. +0 −23 app/controllers/support_controller.rb
  4. +2 −2 app/models/content_change_request.rb
  5. +2 −2 app/models/create_new_user_request.rb
  6. +2 −2 app/models/new_feature_request.rb
  7. +14 −0 app/models/remove_user_request.rb
  8. +0 −3  app/models/with_inside_government.rb
  9. +28 −0 app/models/with_request_context.rb
  10. +28 −0 app/models/with_tool_role_choice.rb
  11. +2 −0  app/views/content_change_requests/_request_details.html.erb
  12. +1 −3 app/views/content_change_requests/new.html.erb
  13. +3 −1 app/views/create_new_user_requests/_request_details.html.erb
  14. +0 −2  app/views/create_new_user_requests/new.html.erb
  15. +2 −0  app/views/new_feature_requests/_request_details.html.erb
  16. +0 −2  app/views/new_feature_requests/new.html.erb
  17. +15 −0 app/views/remove_user_requests/_request_details.html.erb
  18. +4 −25 app/views/remove_user_requests/new.html.erb
  19. +0 −1  app/views/support/_inside_government_new.html.erb
  20. +3 −0  app/views/support/_request_context.html.erb
  21. +3 −0  app/views/support/_tool_role_choice.html.erb
  22. +0 −25 app/views/tech-issues/publish_tool.html.erb
  23. +0 −1  config/routes.rb
  24. +19 −6 features/content_change_requests.feature
  25. +7 −4 features/create_new_user_requests.feature
  26. +7 −4 features/new_feature_requests.feature
  27. +35 −0 features/remove_user_requests.feature
  28. +39 −1 features/step_definitions/request_steps.rb
  29. +8 −8 features/step_definitions/zendesk_steps.rb
  30. +8 −4 lib/content_change_request_zendesk_ticket.rb
  31. +8 −4 lib/create_new_user_request_zendesk_ticket.rb
  32. +2 −2 lib/general_request_zendesk_ticket.rb
  33. +0 −25 lib/guard.rb
  34. +8 −4 lib/new_feature_request_zendesk_ticket.rb
  35. +33 −0 lib/remove_user_request_zendesk_ticket.rb
  36. +6 −12 lib/zendesk_ticket.rb
  37. +1 −1  test/functional/content_change_requests_controller_test.rb
  38. +1 −1  test/functional/create_new_user_requests_controller_test.rb
  39. +4 −4 test/functional/remove_user_requests_controller_test.rb
  40. +0 −55 test/functional/support_controller_test.rb
  41. +13 −16 test/test_data.rb
  42. +1 −1  test/unit/models/content_change_request_test.rb
  43. +1 −1  test/unit/models/create_new_user_request_test.rb
  44. +1 −1  test/unit/models/new_feature_request_test.rb
  45. +28 −0 test/unit/models/remove_user_request_test.rb
  46. +27 −0 test/unit/models/with_request_context_test.rb
  47. +27 −0 test/unit/models/with_tool_role_choice_test.rb
  48. +16 −0 test/unit/zendesk/content_change_request_zendesk_ticket_test.rb
  49. +16 −0 test/unit/zendesk/create_new_user_request_zendesk_ticket_test.rb
  50. 0  test/unit/{ → zendesk}/general_request_zendesk_ticket_test.rb
  51. +16 −0 test/unit/zendesk/new_feature_request_zendesk_ticket_test.rb
  52. +16 −0 test/unit/zendesk/remove_user_request_zendesk_ticket_test.rb
  53. +0 −6 test/unit/{ → zendesk}/zendesk_ticket_test.rb
View
1  app/controllers/content_change_requests_controller.rb
@@ -1,6 +1,7 @@
require 'content_change_request_zendesk_ticket'
class ContentChangeRequestsController < RequestsController
+ protected
def new_request
ContentChangeRequest.new(:requester => Requester.new, :time_constraint => TimeConstraint.new)
end
View
17 app/controllers/remove_user_requests_controller.rb
@@ -1,15 +1,16 @@
-require 'guard'
+require 'remove_user_request_zendesk_ticket'
class RemoveUserRequestsController < RequestsController
- def new
- @formdata = {}
- prepopulate_organisation_list
+ protected
+ def new_request
+ RemoveUserRequest.new(:requester => Requester.new, :time_constraint => TimeConstraint.new)
end
- def create
- @template = "remove_user_requests/new"
+ def zendesk_ticket_class
+ RemoveUserRequestZendeskTicket
+ end
- @errors = Guard.validationsForDeleteUser(params)
- on_post(params, "remove-user")
+ def parse_request_from_params
+ RemoveUserRequest.new(params[:remove_user_request])
end
end
View
23 app/controllers/support_controller.rb
@@ -1,17 +1,6 @@
require "guard"
class SupportController < RequestsController
- def remove_user
- if request.method == "GET"
- on_get("useraccess/userremove")
- elsif request.method == "POST"
- @template = "useraccess/userremove"
-
- @errors = Guard.validationsForDeleteUser(params)
- on_post(params, "remove-user")
- end
- end
-
def campaign
if request.method == "GET"
on_get("campaigns/campaign")
@@ -23,18 +12,6 @@ def campaign
end
end
- def publish_tool
- if request.method == "GET"
- on_get("tech-issues/publish_tool")
- elsif request.method == "POST"
- params[:user_agent] = request.user_agent
- @template = "tech-issues/publish_tool"
-
- @errors = Guard.validationsForPublishTool(params)
- on_post(params, "publish-tool")
- end
- end
-
def landing
render :landing, :layout => "application"
end
View
4 app/models/content_change_request.rb
@@ -1,12 +1,12 @@
require 'tableless_model'
require 'with_requester'
require 'with_time_constraint'
-require 'with_inside_government'
+require 'with_request_context'
class ContentChangeRequest < TablelessModel
include WithRequester
include WithTimeConstraint
- include WithInsideGovernment
+ include WithRequestContext
attr_accessor :details_of_change, :url1, :url2, :url3
validates_presence_of :details_of_change
View
4 app/models/create_new_user_request.rb
@@ -1,10 +1,10 @@
require 'tableless_model'
require 'with_requester'
-require 'with_inside_government'
+require 'with_tool_role_choice'
class CreateNewUserRequest < TablelessModel
include WithRequester
- include WithInsideGovernment
+ include WithToolRoleChoice
attr_accessor :user_name, :user_email, :additional_comments
validates_presence_of :user_name, :user_email
View
4 app/models/new_feature_request.rb
@@ -1,12 +1,12 @@
require 'tableless_model'
require 'with_requester'
require 'with_time_constraint'
-require 'with_inside_government'
+require 'with_request_context'
class NewFeatureRequest < TablelessModel
include WithRequester
include WithTimeConstraint
- include WithInsideGovernment
+ include WithRequestContext
attr_accessor :user_need, :url_of_example
validates_presence_of :user_need
View
14 app/models/remove_user_request.rb
@@ -0,0 +1,14 @@
+require 'tableless_model'
+require 'with_requester'
+require 'with_tool_role_choice'
+require 'with_time_constraint'
+
+class RemoveUserRequest < TablelessModel
+ include WithRequester
+ include WithToolRoleChoice
+ include WithTimeConstraint
+
+ attr_accessor :user_name, :user_email, :additional_comments
+ validates_presence_of :user_name, :user_email
+ validates :user_email, :format => {:with => /@/}
+end
View
3  app/models/with_inside_government.rb
@@ -1,3 +0,0 @@
-module WithInsideGovernment
- attr_accessor :inside_government
-end
View
28 app/models/with_request_context.rb
@@ -0,0 +1,28 @@
+module WithRequestContext
+ attr_accessor :request_context
+
+ def self.included(base)
+ base.validates_presence_of :request_context
+ base.validates :request_context, :inclusion => {
+ :in => %w(mainstream inside_government detailed_guidance other),
+ :message => "%{value} is not valid option"
+ }
+ end
+
+ def formatted_request_context
+ Hash[request_context_options].key(request_context)
+ end
+
+ def inside_government_related?
+ %w{inside_government detailed_guidance}.include?(request_context)
+ end
+
+ def request_context_options
+ [
+ ["Mainstream GOV.UK", "mainstream"],
+ ["Inside Government", "inside_government"],
+ ["Detailed Guidance", "detailed_guidance"],
+ ["Other/Not sure", "other"]
+ ]
+ end
+end
View
28 app/models/with_tool_role_choice.rb
@@ -0,0 +1,28 @@
+module WithToolRoleChoice
+ attr_accessor :tool_role
+
+ def self.included(base)
+ base.validates_presence_of :tool_role
+ base.validates :tool_role, :inclusion => {
+ :in => %w(inside_government_writer inside_government_editor govt_form other),
+ :message => "%{value} is not valid option"
+ }
+ end
+
+ def formatted_tool_role
+ Hash[tool_role_options].key(tool_role)
+ end
+
+ def inside_government_related?
+ %w{inside_government_editor inside_government_writer}.include?(tool_role)
+ end
+
+ def tool_role_options
+ [
+ ["Inside Government editor", "inside_government_editor"],
+ ["Inside Government writer", "inside_government_writer"],
+ ["Departmental Contact Form", "govt_form"],
+ ["Other/Not sure", "other"]
+ ]
+ end
+end
View
2  app/views/content_change_requests/_request_details.html.erb
@@ -1,3 +1,5 @@
+<%= render :partial => "support/request_context", :locals => {:f => f} %>
+
<%= f.inputs :name => "URL(s) affected" do %>
<%= f.input :url1, :label => "URL 1", :input_html => {:class => "span6", :placeholder => "https://www.gov.uk/"} %>
<%= f.input :url2, :label => "URL 2", :input_html => {:class => "span6", :placeholder => "https://www.gov.uk/"} %>
View
4 app/views/content_change_requests/new.html.erb
@@ -23,11 +23,9 @@
<%= render :partial => "support/requester", :locals => {:f => f} %>
- <%= render :partial => "support/inside_government_new", :locals => {:f => f} %>
-
<%= render :partial => "request_details", :locals => {:f => f} %>
- <%= render :partial => "support/time_constraint", :locals => {:f => f} %>
+ <%= render :partial => "support/time_constraint", :locals => {:f => f} %>
<div class="alert alert-info alert-block">
<p>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.)</p>
View
4 app/views/create_new_user_requests/_request_details.html.erb
@@ -1,9 +1,11 @@
+<%= render :partial => 'support/tool_role_choice', :locals => {:f => f} %>
+
<div id="user_details" %>
<%= f.inputs "User details" do %>
<%= f.input :user_name, :label => "Name", :required => true, :input_html => {:class => "span6", :"aria-required" => true } %>
<%= f.input :user_email, :as => :email, :label => "Email", :required => true, :input_html => {:class => "span6", :"aria-required" => true } %>
- <%= f.input :additional_comments, :as => :text, :label => "Additional comments (specify editor or writer as required for Inside Government)", :input_html => {:class => "span6", :rows => 6, :cols => 50 } %>
+ <%= f.input :additional_comments, :as => :text, :label => "Additional comments", :input_html => {:class => "span6", :rows => 6, :cols => 50 } %>
<% end %>
</div>
View
2  app/views/create_new_user_requests/new.html.erb
@@ -6,8 +6,6 @@
<%= render :partial => "support/requester", :locals => {:f => f} %>
- <%= render :partial => "support/inside_government_new", :locals => {:f => f} %>
-
<%= render :partial => "request_details", :locals => {:f => f} %>
<%= f.action :submit, :label => "Submit", :button_html => {:class => "btn btn-success"} %>
View
2  app/views/new_feature_requests/_request_details.html.erb
@@ -1,3 +1,5 @@
+<%= render :partial => "support/request_context", :locals => {:f => f} %>
+
<%= f.inputs :name => "Details of the new feature/need" do %>
<%= f.input :user_need, :as => :text, :required => :true, :label => "What is the user need/feature request?", :input_html => {:"aria-required" => true, :class => "span6", :rows => 6, :cols => 50 } %>
View
2  app/views/new_feature_requests/new.html.erb
@@ -6,8 +6,6 @@
<%= render :partial => "support/requester", :locals => {:f => f} %>
- <%= render :partial => "support/inside_government_new", :locals => {:f => f} %>
-
<%= render :partial => "request_details", :locals => {:f => f} %>
<%= render :partial => "support/time_constraint", :locals => {:f => f} %>
View
15 app/views/remove_user_requests/_request_details.html.erb
@@ -0,0 +1,15 @@
+<%= render :partial => 'support/tool_role_choice', :locals => {:f => f} %>
+
+<div id="user_details" %>
+ <%= f.inputs "User details" do %>
+ <%= f.input :user_name, :label => "Name", :required => true, :input_html => {:class => "span6", :"aria-required" => true } %>
+
+ <%= f.input :user_email, :as => :email, :label => "Email", :required => true, :input_html => {:class => "span6", :"aria-required" => true } %>
+
+ <%= f.semantic_fields_for :time_constraint do |r| %>
+ <%= r.input :not_before_date, :label => "MUST NOT be removed BEFORE", :required => false, :input_html => {:"calendar-enabled" => true, :placeholder => "dd-mm-YYYY", :value => r.object.not_before_date} %>
+ <% end %>
+
+ <%= f.input :additional_comments, :as => :text, :label => "Additional comments", :input_html => {:class => "span6", :rows => 6, :cols => 50 } %>
+ <% end %>
+</div>
View
29 app/views/remove_user_requests/new.html.erb
@@ -2,33 +2,12 @@
<%= content_for :header, "Request to remove user access" %>
<div class="well">
- <%= form_tag(remove_user_request_path) do %>
- <%= render "support/author" %>
- <%= render "support/inside_government" %>
+ <%= semantic_form_for @request, :url => { :action => "create" }, :html => { :novalidate => false} do |f| %>
- <section id="user">
- <header class="section-header">User details</header>
+ <%= render :partial => "support/requester", :locals => {:f => f} %>
- <label for="user_name">Username</label>
- <input id="user_name" name="user_name" type="text" class="span6" <%= render "support/assignvalue", {:param => @formdata[:user_name]} %>>
- <%= render "support/errors", {errors: @errors, key: "User name"} %>
+ <%= render :partial => "request_details", :locals => {:f => f} %>
- <label for="email">Email</label>
- <input id="email" name="user_email" type="email" class="span6" <%= render "support/assignvalue", {:param => @formdata[:user_email]} %>>
- <%= render "support/errors", {errors: @errors, key: "User email"} %>
-
- <%= render "support/date", {:title => "Not before", :label => 'not_before', :day => @formdata[:not_before_day], :month => @formdata[:not_before_month], :year => @formdata[:not_before_year]}%>
- <%= render "support/errors", {errors: @errors, key: "Not before"} %>
- <div style="clear:both;"></div>
-
- <fieldset>
- <div class="comments">
- <label for="comments">Additional comments</label>
- <textarea id="comments" class="span6" rows="6" cols="50" name="additional"><%= @formdata[:additional] %></textarea>
- </div>
- </fieldset>
-
- </section>
- <input class="btn btn-success" name="commit" type="submit" value="Submit">
+ <%= f.action :submit, :label => "Submit", :button_html => {:class => "btn btn-success"} %>
<% end %>
</div>
View
1  app/views/support/_inside_government_new.html.erb
@@ -1 +0,0 @@
- <%= f.input :inside_government, :as => :select, :label => "Does this affect Inside Government?", :collection => [["No", "no"], ["Yes", "yes"]], :include_blank => false %>
View
3  app/views/support/_request_context.html.erb
@@ -0,0 +1,3 @@
+<div id="request-context">
+ <%= f.input :request_context, :as => :radio, :required => true, :label => "Which part of GOV.UK is this about?", :collection => f.object.request_context_options, :input_html => {:"aria-required" => true} %>
+</div>
View
3  app/views/support/_tool_role_choice.html.erb
@@ -0,0 +1,3 @@
+<div id="tool-role-choice">
+ <%= f.input :tool_role, :as => :radio, :required => true, :label => "Which tool/role is this about?", :collection => f.object.tool_role_options, :input_html => {:"aria-required" => true} %>
+</div>
View
25 app/views/tech-issues/publish_tool.html.erb
@@ -1,25 +0,0 @@
-<%= content_for :page_title, "Publishing tool" %>
-<%= content_for :header, "Request GDS support for the publishing tool" %>
-
-<div class="well">
- <%= form_tag('/publish-tool', :method => :post) do %>
-
- <%= render "author" %>
- <fieldset>
- <legend>Publishing Tool</legend>
- <label for="target_url">URL on <span style="background-color: #F2F2F2;">gov.uk</span> (required)</label>
- <input id="target_url" name="url" type="text" class="span6" required aria-required="true" <%= render "assignvalue", {:param => @formdata[:url]} %> >
- <%= render "errors", {errors: @errors, key: "Url"} %>
-
- <label for="username">Username (required)</label>
- <input id="username" name="username" type="text" class="span6" required aria-required="true" <%= render "assignvalue", {:param => @formdata[:username]} %> >
- <%= render "errors", {errors: @errors, key: "Username"} %>
-
- <div class="comments">
- <label for="comments">Please describe briefly the problem which was encountered</label>
- <textarea id="comments" rows="6" cols="70" class="span6" name="additional"><%= @formdata[:additional] %></textarea>
- </div>
- </fieldset>
- <input class="btn btn-success" name="commit" type="submit" value="Submit">
- <% end %>
-</div>
View
1  config/routes.rb
@@ -6,7 +6,6 @@
resource :new_feature_request, :only => [:new, :create]
match "campaign" => "support#campaign"
- match "publish-tool" => "support#publish_tool"
match "acknowledge" => "support#acknowledge"
root :to => 'support#landing'
end
View
25 features/content_change_requests.feature
@@ -8,22 +8,25 @@ Feature: Content change requests
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
- Scenario: successful request
+ Scenario: successful Mainstream content change request
When the user submits the following content change request:
- | Details of change | URL 1 | URL 2 | Needed by date | Not before date | Reason |
- | Out of date XX YY | http://gov.com/X | http://gov.uk/Y | 31-12-2012 | 01-12-2012 | New law |
+ | Context | Details of change | URL 1 | URL 2 | Needed by date | Not before date | Reason |
+ | Mainstream GOV.UK | Out of date XX YY | http://gov.uk/X | http://gov.uk/Y | 31-12-2020 | 01-12-2020 | New law |
Then the following ticket is raised in ZenDesk:
| Subject | Requester email | Requester name | Phone | Job title | Organisation |
| Content change request | john.smith@email.com | John Smith | 12345 | Developer | cabinet_office |
And the time constraints on the ticket are:
| Need by date | Not before date |
- | 31-12-2012 | 01-12-2012 |
+ | 31-12-2020 | 01-12-2020 |
And the ticket is tagged with "content_amend"
And the comment on the ticket is:
"""
+ [Which part of GOV.UK is this about?]
+ Mainstream GOV.UK
+
[URl(s) of content to be changed]
- http://gov.com/X
+ http://gov.uk/X
http://gov.uk/Y
[Details of what should be added, amended or removed]
@@ -31,4 +34,14 @@ Feature: Content change requests
[Time constraint reason]
New law
- """
+ """
+
+ Scenario: successful Inside Government content change request
+ When the user submits the following content change request:
+ | Context | Details of change |
+ | Inside Government | Out of date XX YY |
+
+ Then the following ticket is raised in ZenDesk:
+ | Subject |
+ | Content change request |
+ And the ticket is tagged with "content_amend inside_government"
View
11 features/create_new_user_requests.feature
@@ -9,16 +9,19 @@ Feature: Create new user requests
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
- Scenario: successful request
+ Scenario: successful create user request for publisher
When the user submits the following create user request:
- | User's name | User's email | Additional comments |
- | Bob Fields | bob@gov.uk | Editor |
+ | Tool/Role | User's name | User's email | Additional comments |
+ | Departmental Contact Form | Bob Fields | bob@gov.uk | XXXX |
Then the following ticket is raised in ZenDesk:
| Subject | Requester email | Requester name | Phone | Job title | Organisation |
| Create new user | john.smith@email.com | John Smith | 12345 | Developer | cabinet_office |
And the ticket is tagged with "new_user"
And the comment on the ticket is:
"""
+ [Tool/Role]
+ Departmental Contact Form
+
[User name]
Bob Fields
@@ -26,5 +29,5 @@ Feature: Create new user requests
bob@gov.uk
[Additional comments]
- Editor
+ XXXX
"""
View
11 features/new_feature_requests.feature
@@ -10,18 +10,21 @@ Feature: New feature requests
Scenario: successful request
When the user submits the following new feature request:
- | User need | URL of example | Needed by date | Not before date | Reason |
- | Information on XYZ | http://www.example.com | 31-12-2012 | 01-12-2012 | Legal requirement |
+ | Context | User need | URL of example | Needed by date | Not before date | Reason |
+ | Inside Government | Information on XYZ | http://www.example.com | 31-12-2020 | 01-12-2020 | Legal requirement |
Then the following ticket is raised in ZenDesk:
| Subject | Requester email | Requester name | Phone | Job title | Organisation |
| New Feature Request | john.smith@email.com | John Smith | 12345 | Developer | cabinet_office |
And the time constraints on the ticket are:
| Need by date | Not before date |
- | 31-12-2012 | 01-12-2012 |
- And the ticket is tagged with "new_feature_request"
+ | 31-12-2020 | 01-12-2020 |
+ And the ticket is tagged with "new_feature_request inside_government"
And the comment on the ticket is:
"""
+ [Which part of GOV.UK is this about?]
+ Inside Government
+
[User need]
Information on XYZ
View
35 features/remove_user_requests.feature
@@ -0,0 +1,35 @@
+Feature: Remove user requests
+ In order to revoke access from users who are no longer authorised to use GDS tools
+ As a government employee
+ I want a means to request removal of GDS tool access for other users
+
+ Background:
+ * the following user has SSO access:
+ | Name | Email | Job title | Organisation | Phone |
+ | John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
+
+ Scenario: successful remove user request for publisher
+ When the user submits the following remove user request:
+ | Tool/Role | User's name | User's email | Not before date | Additional comments |
+ | Departmental Contact Form | Bob Wasfired | bob@gov.uk | 31-12-2020 | XXXX |
+ Then the following ticket is raised in ZenDesk:
+ | Subject | Requester email | Requester name | Phone | Job title | Organisation |
+ | Remove user | john.smith@email.com | John Smith | 12345 | Developer | cabinet_office |
+ And the ticket is tagged with "remove_user"
+ And the time constraints on the ticket are:
+ | Not before date |
+ | 31-12-2020 |
+ And the comment on the ticket is:
+ """
+ [Tool/Role]
+ Departmental Contact Form
+
+ [User name]
+ Bob Wasfired
+
+ [User email]
+ bob@gov.uk
+
+ [Additional comments]
+ XXXX
+ """
View
40 features/step_definitions/request_steps.rb
@@ -45,6 +45,10 @@
step "the user fills out their details"
+ within "#request-context" do
+ choose @request_details["Context"]
+ end
+
fill_in "What is the user need/feature request?", :with => @request_details['User need']
fill_in "Can you provide a link to an example of this feature?", :with => @request_details['URL of example']
@@ -63,6 +67,10 @@
step "the user fills out their details"
+ within "#request-context" do
+ choose @request_details["Context"]
+ end
+
fill_in "Details of the requested change", :with => @request_details["Details of change"]
fill_in "URL 1", :with => @request_details["URL 1"]
fill_in "URL 2", :with => @request_details["URL 2"]
@@ -83,11 +91,41 @@
step "the user fills out their details"
+ within "#tool-role-choice" do
+ choose @request_details["Tool/Role"]
+ end
+
within("#user_details") do
fill_in "Name", :with => @request_details["User's name"]
fill_in "Email", :with => @request_details["User's email"]
- fill_in "Additional comments (specify editor or writer as required for Inside Government)", :with => @request_details["Additional comments"]
+ fill_in "Additional comments", :with => @request_details["Additional comments"]
end
step "the user submits the request successfully"
+end
+
+When /^the user submits the following remove user request:$/ do |request_details_table|
+ @request_details = request_details_table.hashes.first
+
+ visit '/'
+
+ click_on "Remove user"
+
+ assert page.has_content?("Request to remove user access")
+
+ step "the user fills out their details"
+
+ within "#tool-role-choice" do
+ choose @request_details["Tool/Role"]
+ end
+
+ within("#user_details") do
+ fill_in "Name", :with => @request_details["User's name"]
+ fill_in "Email", :with => @request_details["User's email"]
+ fill_in "Additional comments", :with => @request_details["Additional comments"]
+ end
+
+ fill_in "MUST NOT be removed BEFORE", :with => @request_details["Not before date"]
+
+ step "the user submits the request successfully"
end
View
16 features/step_definitions/zendesk_steps.rb
@@ -2,12 +2,12 @@
expected_ticket_props = ticket_properties_table.hashes.first
@raised_ticket = @zendesk_api.ticket
- assert_equal expected_ticket_props["Subject"], @raised_ticket.subject
- assert_equal expected_ticket_props["Requester email"], @raised_ticket.email
- assert_equal expected_ticket_props["Requester name"], @raised_ticket.name
- assert_equal expected_ticket_props["Job title"], @raised_ticket.job
- assert_equal expected_ticket_props["Organisation"], @raised_ticket.organisation
- assert_equal expected_ticket_props["Phone"], @raised_ticket.phone
+ assert_equal expected_ticket_props["Subject"], @raised_ticket.subject if expected_ticket_props["Subject"]
+ assert_equal expected_ticket_props["Requester email"], @raised_ticket.email if expected_ticket_props["Requester email"]
+ assert_equal expected_ticket_props["Requester name"], @raised_ticket.name if expected_ticket_props["Requester name"]
+ assert_equal expected_ticket_props["Job title"], @raised_ticket.job if expected_ticket_props["Job title"]
+ assert_equal expected_ticket_props["Organisation"], @raised_ticket.organisation if expected_ticket_props["Organisation"]
+ assert_equal expected_ticket_props["Phone"], @raised_ticket.phone if expected_ticket_props["Phone"]
end
Then /^the ticket is tagged with "(.*?)"$/ do |expected_tags|
@@ -22,6 +22,6 @@
expected_ticket_props = ticket_properties_table.hashes.first
@raised_ticket = @zendesk_api.ticket
- assert_equal expected_ticket_props["Need by date"], @raised_ticket.needed_by_date
- assert_equal expected_ticket_props["Not before date"], @raised_ticket.not_before_date
+ assert_equal expected_ticket_props["Need by date"], @raised_ticket.needed_by_date if expected_ticket_props["Need by date"]
+ assert_equal expected_ticket_props["Not before date"], @raised_ticket.not_before_date if expected_ticket_props["Not before date"]
end
View
12 lib/content_change_request_zendesk_ticket.rb
@@ -14,8 +14,8 @@ def subject
"Content change request"
end
- def request_specific_tag
- "content_amend"
+ def tags
+ ["content_amend"] + inside_government_tag_if_needed
end
# the following methods will be pushed down to the superclass as soon as everything is converted to ActiveModel
@@ -23,11 +23,15 @@ def request_specific_tag
protected
def comment_snippets
- [ CommentSnippet.new(on: @request.requester, field: :other_organisation),
+ [
+ CommentSnippet.new(on: @request, field: :formatted_request_context,
+ label: "Which part of GOV.UK is this about?"),
+ CommentSnippet.new(on: @request.requester, field: :other_organisation),
CommentSnippet.new(on: @request, fields: [:url1, :url2, :url3],
label: "URl(s) of content to be changed"),
CommentSnippet.new(on: @request, field: :details_of_change,
label: "Details of what should be added, amended or removed"),
- CommentSnippet.new(on: @request.time_constraint, field: :time_constraint_reason) ]
+ CommentSnippet.new(on: @request.time_constraint, field: :time_constraint_reason)
+ ]
end
end
View
12 lib/create_new_user_request_zendesk_ticket.rb
@@ -12,8 +12,8 @@ def subject
"Create new user"
end
- def request_specific_tag
- "new_user"
+ def tags
+ ["new_user"] + inside_government_tag_if_needed
end
# the following methods will be pushed down to the superclass as soon as everything is converted to ActiveModel
@@ -21,9 +21,13 @@ def request_specific_tag
protected
def comment_snippets
- [ CommentSnippet.new(on: @request.requester, field: :other_organisation),
+ [
+ CommentSnippet.new(on: @request, field: :formatted_tool_role,
+ label: "Tool/Role"),
+ CommentSnippet.new(on: @request.requester, field: :other_organisation),
CommentSnippet.new(on: @request, field: :user_name),
CommentSnippet.new(on: @request, field: :user_email),
- CommentSnippet.new(on: @request, field: :additional_comments) ]
+ CommentSnippet.new(on: @request, field: :additional_comments)
+ ]
end
end
View
4 lib/general_request_zendesk_ticket.rb
@@ -12,8 +12,8 @@ def subject
"Govt Agency General Issue"
end
- def request_specific_tag
- "govt_agency_general"
+ def tags
+ ["govt_agency_general"]
end
# the following methods will be pushed down to the superclass as soon as everything is converted to ActiveModel
View
25 lib/guard.rb
@@ -1,23 +1,6 @@
require "date"
class Guard
-
- #User validations
- def self.validationsForDeleteUser(form_data)
- @@errors = {}
-
- required = ["name", "email", "job", "user_name", "user_email"]
-
- validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
- self.checkOptionalDateFieldsAreComplete(form_data, [["Not before", "not_before_day", "not_before_month", "not_before_year"]])
-
- not_before = validate_date_in_valid_range("Not_before", "not_before_day", "not_before_month", "not_before_year", form_data)
- self.validate_date_is_equal_or_greater_than_today("Not before", not_before, "Not before date should be the same or later than today.")
-
- @@errors
- end
-
-
#Campaign validations
def self.validationsForCampaign(form_data)
@@errors = {}
@@ -32,14 +15,6 @@ def self.validationsForCampaign(form_data)
@@errors
end
- def self.validationsForPublishTool(form_data)
- @@errors = {}
- required = ["name", "email", "job", "url", "username"]
- validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
-
- @@errors
- end
-
private
def self.validate(form_data, required, phone_fields, email_fields)
View
12 lib/new_feature_request_zendesk_ticket.rb
@@ -14,8 +14,8 @@ def subject
"New Feature Request"
end
- def request_specific_tag
- "new_feature_request"
+ def tags
+ ["new_feature_request"] + inside_government_tag_if_needed
end
# the following methods will be pushed down to the superclass as soon as everything is converted to ActiveModel
@@ -23,9 +23,13 @@ def request_specific_tag
protected
def comment_snippets
- [ CommentSnippet.new(on: @request.requester, field: :other_organisation),
+ [
+ CommentSnippet.new(on: @request, field: :formatted_request_context,
+ label: "Which part of GOV.UK is this about?"),
+ CommentSnippet.new(on: @request.requester, field: :other_organisation),
CommentSnippet.new(on: @request, field: :user_need),
CommentSnippet.new(on: @request, field: :url_of_example),
- CommentSnippet.new(on: @request.time_constraint, field: :time_constraint_reason) ]
+ CommentSnippet.new(on: @request.time_constraint, field: :time_constraint_reason)
+ ]
end
end
View
33 lib/remove_user_request_zendesk_ticket.rb
@@ -0,0 +1,33 @@
+require 'zendesk_ticket'
+require 'forwardable'
+require 'comment_snippet'
+
+class RemoveUserRequestZendeskTicket < ZendeskTicket
+ def initialize(request)
+ super(request, nil)
+ @requester = request.requester
+ end
+
+ def subject
+ "Remove user"
+ end
+
+ def tags
+ ["remove_user"] + inside_government_tag_if_needed
+ end
+
+ # the following methods will be pushed down to the superclass as soon as everything is converted to ActiveModel
+ def_delegators :@requester, :name, :email, :organisation, :job
+
+ protected
+ def comment_snippets
+ [
+ CommentSnippet.new(on: @request, field: :formatted_tool_role,
+ label: "Tool/Role"),
+ CommentSnippet.new(on: @request.requester, field: :other_organisation),
+ CommentSnippet.new(on: @request, field: :user_name),
+ CommentSnippet.new(on: @request, field: :user_email),
+ CommentSnippet.new(on: @request, field: :additional_comments)
+ ]
+ end
+end
View
18 lib/zendesk_ticket.rb
@@ -5,19 +5,13 @@
class ZendeskTicket
extend Forwardable
- @@in_comments = {"remove-user" => [:other_organisation, :user_name, :user_email, :additional],
- "campaign" => [:other_organisation, :campaign_name, :erg_number, :company, :description, :url, :additional],
- "publish-tool" => [:other_organisation, :username, :url, :user_agent, :additional]
+ @@in_comments = {"campaign" => [:other_organisation, :campaign_name, :erg_number, :company, :description, :url, :additional]
}
- @@in_subject = {"remove-user" => "Remove user",
- "campaign" => "Campaign",
- "publish-tool" => "Publishing Tool"
+ @@in_subject = {"campaign" => "Campaign",
}
- @@in_tag = {"remove-user" => "remove_user",
- "campaign" => "campaign",
- "publish-tool" => "publishing_tool_tech"
+ @@in_tag = {"campaign" => "campaign",
}
def initialize(request, from_route)
@@ -80,12 +74,12 @@ def needed_by_date
end
end
- def request_specific_tag
- @@in_tag[@from_route]
+ def inside_government_tag_if_needed
+ @request.inside_government_related? ? ["inside_government"] : []
end
def tags
- [request_specific_tag] + inside_government_tag
+ [@@in_tag[@from_route]]
end
private
View
2  test/functional/content_change_requests_controller_test.rb
@@ -49,7 +49,7 @@ class ContentChangeRequestsControllerTest < ActionController::TestCase
context "concerning Inside Government" do
should "tag the ticket with an inside_government tag" do
- params = valid_content_change_request_params.tap {|p| p["content_change_request"].merge!("inside_government" => "yes")}
+ params = valid_content_change_request_params.tap {|p| p["content_change_request"].merge!("request_context" => "inside_government")}
post :create, params
View
2  test/functional/create_new_user_requests_controller_test.rb
@@ -46,7 +46,7 @@ class CreateNewUserRequestsControllerTest < ActionController::TestCase
context "concerning Inside Government" do
should "tag the ticket with an inside_government tag" do
- params = valid_create_new_user_request_params.tap {|p| p["create_new_user_request"].merge!("inside_government" => "yes")}
+ params = valid_create_new_user_request_params.tap {|p| p["create_new_user_request"].merge!("tool_role" => "inside_government_editor")}
post :create, params
View
8 test/functional/remove_user_requests_controller_test.rb
@@ -22,17 +22,17 @@ class RemoveUserRequestsControllerTest < ActionController::TestCase
should "use ZenDesk to populate the organisation dropdown" do
get :new
- assert_select "select#organisation_list option", "Advocate General for Scotland"
+ assert_select "select#remove_user_request_requester_attributes_organisation option", "Advocate General for Scotland"
end
end
context "submitted remove user request" do
should "reject invalid requests" do
- params = valid_remove_user_request_params.merge("organisation" => "")
+ params = valid_remove_user_request_params.tap {|p| p["remove_user_request"]["requester_attributes"].merge!("organisation" => "")}
post :create, params
assert_response 400
assert_template "new"
- assert_select ".help-block", /Organisation information is required/
+ assert_select ".help-inline", /information is required/
end
should "submit it to ZenDesk" do
@@ -46,7 +46,7 @@ class RemoveUserRequestsControllerTest < ActionController::TestCase
context "concerning Inside Government" do
should "tag the ticket with an inside_government tag" do
- params = valid_remove_user_request_params.merge("inside_government" => "yes")
+ params = valid_remove_user_request_params.tap {|p| p["remove_user_request"].merge!("tool_role" => "inside_government_editor")}
post :create, params
View
55 test/functional/support_controller_test.rb
@@ -55,59 +55,4 @@ class SupportControllerTest < ActionController::TestCase
assert_redirected_to "/acknowledge"
end
end
-
- context "GET publish_tool" do
- setup do
- stub_zendesk_organisation_list
- end
-
- should "render the form" do
- get :publish_tool
- assert_select "h1", /Publishing Tool/i
- end
-
- should "use ZenDesk to populate the organisation dropdown" do
- get :publish_tool
- assert_select "select#organisation_list option", "Advocate General for Scotland"
- end
- end
-
- context "POST publish_tool" do
- setup do
- stub_zendesk_organisation_list
- end
-
- should "reject invalid requests" do
- params = {
- "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"dev",
- "phone"=>"",
- "organisation"=>"",
- "other_organisation"=>"",
- "url"=>"testing",
- "additional"=>""
- }
- post :publish_tool, params
- assert_response 400
- assert_template "tech-issues/publish_tool"
- assert_select ".help-block", /Organisation information is required/
- end
-
- should "submit it to ZenDesk" do
- params = {
- "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"dev",
- "phone"=>"",
- "organisation"=>"cabinet_office",
- "other_organisation"=>"",
- "url"=>"testing",
- "additional"=>""
- }
- ZendeskRequest.expects(:raise_zendesk_request).returns("not a null")
- post :publish_tool, params
- assert_redirected_to "/acknowledge"
- end
- end
end
View
29 test/test_data.rb
@@ -4,7 +4,8 @@ def valid_content_change_request_params
{ "requester_attributes" => valid_requester_params,
"time_constraint_attributes" => valid_time_constraint_params,
"url1" => "https://www.gov.uk",
- "details_of_change" => "Content is wrong"}
+ "details_of_change" => "Content is wrong",
+ "request_context" => "mainstream" }
}
end
@@ -13,24 +14,20 @@ def valid_create_new_user_request_params
{ "requester_attributes" => valid_requester_params,
"user_name"=>"subject",
"user_email"=>"subject@digital.cabinet-office.gov.uk",
- "inside_government" => "no",
+ "tool_role" => "govt_form",
"additional_comments"=>"" }
}
end
def valid_remove_user_request_params
- { "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"This is just a test",
- "phone"=>"",
- "organisation"=>"cabinet_office",
- "other_organisation"=>"",
- "user_name"=>"testing",
- "user_email"=>"ignore-me@foo.com",
- "not_before_day"=>"",
- "not_before_month"=>"",
- "not_before_year"=>"",
- "additional"=>"" }
+ { "remove_user_request" =>
+ { "requester_attributes" => valid_requester_params,
+ "time_constraint_attributes" => {"not_before_date" => "01-12-2022"},
+ "user_name"=>"subject",
+ "user_email"=>"subject@digital.cabinet-office.gov.uk",
+ "tool_role" => "govt_form",
+ "additional_comments"=>"" }
+ }
end
def valid_campaign_request_params
@@ -70,8 +67,8 @@ def valid_requester_params
end
def valid_time_constraint_params
- { "needed_by_date" => "01-01-2013",
- "not_before_date" => "01-12-2012",
+ { "needed_by_date" => "01-01-2023",
+ "not_before_date" => "01-12-2022",
"time_constraint_reason" => "Legal requirement"
}
end
View
2  test/unit/models/content_change_request_test.rb
@@ -4,7 +4,7 @@ class ContentChangeRequestTest < Test::Unit::TestCase
should validate_presence_of(:requester)
should validate_presence_of(:details_of_change)
- should allow_value("yes").for(:inside_government)
+ should validate_presence_of(:request_context)
should allow_value("https://www.gov.uk").for(:url1)
should allow_value("https://www.gov.uk").for(:url2)
View
2  test/unit/models/create_new_user_request_test.rb
@@ -4,10 +4,10 @@ class CreateNewUserRequestTest < Test::Unit::TestCase
should validate_presence_of(:requester)
should validate_presence_of(:user_name)
should validate_presence_of(:user_email)
+ should validate_presence_of(:tool_role)
should allow_value("ab@c.com").for(:user_email)
should_not allow_value("ab").for(:user_email)
should allow_value("a comment").for(:additional_comments)
- should allow_value("yes").for(:inside_government)
end
View
2  test/unit/models/new_feature_request_test.rb
@@ -3,5 +3,5 @@
class NewFeatureRequestTest < Test::Unit::TestCase
should validate_presence_of(:requester)
should validate_presence_of(:user_need)
- should allow_value("yes").for(:inside_government)
+ should validate_presence_of(:request_context)
end
View
28 test/unit/models/remove_user_request_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class RemoveUserRequestTest < Test::Unit::TestCase
+ def self.as_str(date)
+ date.strftime("%d-%m-%Y")
+ end
+
+ def as_str(date)
+ RemoveUserRequestTest.as_str(date)
+ end
+
+ should validate_presence_of(:requester)
+ should validate_presence_of(:user_name)
+ should validate_presence_of(:user_email)
+ should validate_presence_of(:tool_role)
+
+ should allow_value("ab@c.com").for(:user_email)
+ should_not allow_value("ab").for(:user_email)
+
+ should allow_value("a comment").for(:additional_comments)
+
+ should "allow time constraints" do
+ request = RemoveUserRequest.new(:time_constraint => stub("time constraint", :valid? => true))
+ assert !request.time_constraint.nil?
+ request.valid?
+ assert_equal 0, request.errors[:time_constraint].size
+ end
+end
View
27 test/unit/models/with_request_context_test.rb
@@ -0,0 +1,27 @@
+require 'tableless_model'
+require 'with_request_context'
+require 'test_helper'
+
+class TestModelWithRequestContext < TablelessModel
+ include WithRequestContext
+end
+
+class TestModelWithRequestContextTest < Test::Unit::TestCase
+ should validate_presence_of(:request_context)
+ should allow_value("mainstream").for(:request_context)
+ should allow_value("inside_government").for(:request_context)
+ should allow_value("detailed_guidance").for(:request_context)
+ should allow_value("other").for(:request_context)
+ should_not allow_value("xxx").for(:request_context)
+
+ should "know if it's related to inside government or not" do
+ assert TestModelWithRequestContext.new(:request_context => "inside_government").inside_government_related?
+ assert TestModelWithRequestContext.new(:request_context => "detailed_guidance").inside_government_related?
+ assert !TestModelWithRequestContext.new(:request_context => "mainstream").inside_government_related?
+ assert !TestModelWithRequestContext.new(:request_context => "other").inside_government_related?
+ end
+
+ should "also define the formatted version" do
+ assert "Inside Government", TestModelWithRequestContext.new(:request_context => "inside_government").formatted_request_context
+ end
+end
View
27 test/unit/models/with_tool_role_choice_test.rb
@@ -0,0 +1,27 @@
+require 'tableless_model'
+require 'with_tool_role_choice'
+require 'test_helper'
+
+class TestModelWithToolRoleChoice < TablelessModel
+ include WithToolRoleChoice
+end
+
+class TestModelWithToolRoleChoiceTest < Test::Unit::TestCase
+ should validate_presence_of(:tool_role)
+ should allow_value("govt_form").for(:tool_role)
+ should allow_value("inside_government_editor").for(:tool_role)
+ should allow_value("inside_government_writer").for(:tool_role)
+ should allow_value("other").for(:tool_role)
+ should_not allow_value("xxx").for(:tool_role)
+
+ should "know if it's related to inside government or not" do
+ assert TestModelWithToolRoleChoice.new(:tool_role => "inside_government_editor").inside_government_related?
+ assert TestModelWithToolRoleChoice.new(:tool_role => "inside_government_editor").inside_government_related?
+ assert !TestModelWithToolRoleChoice.new(:tool_role => "govt_form").inside_government_related?
+ assert !TestModelWithToolRoleChoice.new(:tool_role => "other").inside_government_related?
+ end
+
+ should "also define the formatted version" do
+ assert "Inside Government writer", TestModelWithToolRoleChoice.new(:tool_role => "inside_government_writer").formatted_tool_role
+ end
+end
View
16 test/unit/zendesk/content_change_request_zendesk_ticket_test.rb
@@ -0,0 +1,16 @@
+require 'test/unit'
+require 'shoulda/context'
+require 'content_change_request_zendesk_ticket'
+require 'ostruct'
+
+class ContentChangeRequestZendeskTicketTest < Test::Unit::TestCase
+ def ticket_with(opts)
+ ContentChangeRequestZendeskTicket.new(stub_everything("request", opts))
+ end
+
+ context "an inside government request" do
+ should "be tagged with inside_government" do
+ assert_equal ["content_amend", "inside_government"], ticket_with(:inside_government_related? => true).tags
+ end
+ end
+end
View
16 test/unit/zendesk/create_new_user_request_zendesk_ticket_test.rb
@@ -0,0 +1,16 @@
+require 'test/unit'
+require 'shoulda/context'
+require 'create_new_user_request_zendesk_ticket'
+require 'ostruct'
+
+class CreateNewUserRequestZendeskTicketTest < Test::Unit::TestCase
+ def ticket_with(opts)
+ CreateNewUserRequestZendeskTicket.new(stub_everything("request", opts))
+ end
+
+ context "an inside government request" do
+ should "be tagged with inside_government" do
+ assert_equal ["new_user", "inside_government"], ticket_with(:inside_government_related? => true).tags
+ end
+ end
+end
View
0  test/unit/general_request_zendesk_ticket_test.rb → ...it/zendesk/general_request_zendesk_ticket_test.rb
File renamed without changes
View
16 test/unit/zendesk/new_feature_request_zendesk_ticket_test.rb
@@ -0,0 +1,16 @@
+require 'test/unit'
+require 'shoulda/context'
+require 'new_feature_request_zendesk_ticket'
+require 'ostruct'
+
+class NewFeatureRequestZendeskTicketTest < Test::Unit::TestCase
+ def ticket_with(opts)
+ NewFeatureRequestZendeskTicket.new(stub_everything("request", opts))
+ end
+
+ context "an inside government request" do
+ should "be tagged with inside_government" do
+ assert_equal ["new_feature_request", "inside_government"], ticket_with(:inside_government_related? => true).tags
+ end
+ end
+end
View
16 test/unit/zendesk/remove_user_request_zendesk_ticket_test.rb
@@ -0,0 +1,16 @@
+require 'test/unit'
+require 'shoulda/context'
+require 'remove_user_request_zendesk_ticket'
+require 'ostruct'
+
+class RemoveUserRequestZendeskTicketTest < Test::Unit::TestCase
+ def ticket_with(opts)
+ RemoveUserRequestZendeskTicket.new(stub_everything("request", opts))
+ end
+
+ context "an inside government request" do
+ should "be tagged with inside_government" do
+ assert_equal ["remove_user", "inside_government"], ticket_with(:inside_government_related? => true).tags
+ end
+ end
+end
View
6 test/unit/zendesk_ticket_test.rb → test/unit/zendesk/zendesk_ticket_test.rb
@@ -12,10 +12,6 @@ def new_ticket(attributes, type = nil)
include TestData
context "content change request" do
- should "set the tags correctly for valid inside govt tickets" do
- assert_includes new_ticket(:inside_government => "yes").tags, 'inside_government'
- end
-
should "set the requester details correctly" do
ticket = new_ticket(
:name => "John Smith",
@@ -56,9 +52,7 @@ def new_ticket(attributes, type = nil)
end
should "set the subject according to request type" do
- assert_equal "Remove user", new_ticket({}, "remove-user").subject
assert_equal "Campaign", new_ticket({}, "campaign").subject
- assert_equal "Publishing Tool", new_ticket({}, "publish-tool").subject
end
should "remove spaces from the tel number" do
Please sign in to comment.
Something went wrong with that request. Please try again.