Skip to content

Commit

Permalink
Merge pull request #16 from alphagov/removing_the_need_to_specify_org…
Browse files Browse the repository at this point in the history
…anisation

Removing the need to specify organisation
  • Loading branch information
jamiecobbett committed Nov 29, 2012
2 parents fbf33a1 + 501bafa commit 06365b2
Show file tree
Hide file tree
Showing 32 changed files with 66 additions and 313 deletions.
19 changes: 0 additions & 19 deletions app/controllers/requests_controller.rb
Expand Up @@ -4,15 +4,13 @@
class RequestsController < ApplicationController
def new
@request = new_request
prepopulate_organisation_list
end

def create
@request = parse_request_from_params
if @request.valid?
raise_ticket(zendesk_ticket_class.new(@request))
else
prepopulate_organisation_list
render :new, :status => 400
end
end
Expand All @@ -30,24 +28,7 @@ def raise_ticket(ticket)
end
end

def load_client_and_organisations(error_string)
load_client
load_organisations(error_string)
end

def load_client
@client = ZendeskClient.get_client(logger)
end

def load_organisations(error_string)
begin
@organisations = ZendeskRequest.get_organisations(@client)
rescue ZendeskError
return render :"support/zendesk_error", :locals => {:error_string => error_string}
end
end

def prepopulate_organisation_list
load_client_and_organisations("zendesk_error_upon_new_form")
end
end
4 changes: 1 addition & 3 deletions app/models/requester.rb
@@ -1,10 +1,8 @@
require 'tableless_model'

class Requester < TablelessModel
attr_accessor :name, :email, :job, :phone, :organisation, :other_organisation
attr_accessor :name, :email, :job, :phone

validates_presence_of :name, :email, :job
validates_presence_of :organisation, :message => "information is required for a valid request."
validates :email, :format => {:with => /^[\w\d]+[^@]*@[\w\d]+[^@]*\.[\w\d]+[^@]*$/}
validates_presence_of :other_organisation, :if => Proc.new {|request| request.organisation == "other_organisation"}
end
2 changes: 0 additions & 2 deletions app/views/support/_requester.html.erb
Expand Up @@ -4,7 +4,5 @@
<%= r.input :email, :label => "Email", :as => :email, :required => true, :input_html => {:"aria-required" => true, :class => "span6"} %>
<%= r.input :job, :label => "Job title", :required => true, :input_html => {:"aria-required" => true, :class => "span6"} %>
<%= r.input :phone, :label => "Phone number", :as => :phone, :input_html => {:"aria-required" => true, :class => "span6"} %>
<%= r.input :organisation, :label => "Organisation", :as => :select, :collection => @organisations, :include_blank => "Select Organisation", :input_html => {:"aria-required" => true, :class => "span6"} %>
<%= r.input :other_organisation, :label => "Please specify the organisation if you didn't find it in the list above", :input_html => {:class => "span6"} %>
<% end %>
<% end %>
8 changes: 4 additions & 4 deletions features/campaign_requests.feature
Expand Up @@ -5,16 +5,16 @@ Feature: Campaign requests

Background:
* the following user has SSO access:
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
| Name | Email | Job title | Phone |
| John Smith | john.smith@email.com | Developer | 12345 |

Scenario: successful campaign request
When the user submits the following campaign request:
| Campaign title | ERG ref number | Start date | Description | Affiliated group | Info URL | Additional comments |
| Workplace pensions | 123456 | 01-01-2020 | Pensions | AXA | https://www.gov.uk | Some comment |
Then the following ticket is raised in ZenDesk:
| Subject | Requester email | Requester name | Phone | Job title | Organisation |
| Campaign | john.smith@email.com | John Smith | 12345 | Developer | cabinet_office |
| Subject | Requester email | Requester name | Phone | Job title |
| Campaign | john.smith@email.com | John Smith | 12345 | Developer |
And the ticket is tagged with "campaign"
And the comment on the ticket is:
"""
Expand Down
8 changes: 4 additions & 4 deletions features/content_change_requests.feature
Expand Up @@ -5,17 +5,17 @@ Feature: Content change requests

Background:
* the following user has SSO access:
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
| Name | Email | Job title | Phone |
| John Smith | john.smith@email.com | Developer | 12345 |

Scenario: successful Mainstream content change request
When the user submits the following content change request:
| Context | Details of change | URL 1 | URL 2 | Needed by date | Not before date | Reason |
| Mainstream (business/citizen) | 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 |
| Subject | Requester email | Requester name | Phone | Job title |
| Content change request | john.smith@email.com | John Smith | 12345 | Developer |
And the time constraints on the ticket are:
| Need by date | Not before date |
| 31-12-2020 | 01-12-2020 |
Expand Down
8 changes: 4 additions & 4 deletions features/create_new_user_requests.feature
Expand Up @@ -6,16 +6,16 @@ Feature: Create new user requests

Background:
* the following user has SSO access:
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
| Name | Email | Job title | Phone |
| John Smith | john.smith@email.com | Developer | 12345 |

Scenario: successful create user request for publisher
When the user submits the following create user request:
| 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 |
| Subject | Requester email | Requester name | Phone | Job title |
| Create new user | john.smith@email.com | John Smith | 12345 | Developer |
And the ticket is tagged with "new_user"
And the comment on the ticket is:
"""
Expand Down
8 changes: 4 additions & 4 deletions features/general_requests.feature
Expand Up @@ -5,16 +5,16 @@ Feature: General requests

Background:
* the following user has SSO access:
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
| Name | Email | Job title | Phone |
| John Smith | john.smith@email.com | Developer | 12345 |

Scenario: successful request
When the user submits the following general request:
| Details | URL |
| The site is down | https://www.gov.uk |
Then the following ticket is raised in ZenDesk:
| Subject | Requester email | Requester name | Phone | Job title | Organisation |
| Govt Agency General Issue | john.smith@email.com | John Smith | 12345 | Developer | cabinet_office |
| Subject | Requester email | Requester name | Phone | Job title |
| Govt Agency General Issue | john.smith@email.com | John Smith | 12345 | Developer |
And the ticket is tagged with "govt_agency_general"
And the comment on the ticket is:
"""
Expand Down
8 changes: 4 additions & 4 deletions features/new_feature_requests.feature
Expand Up @@ -5,17 +5,17 @@ Feature: New feature requests

Background:
* the following user has SSO access:
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
| Name | Email | Job title | Phone |
| John Smith | john.smith@email.com | Developer | 12345 |

Scenario: successful request
When the user submits the following new feature request:
| 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 |
| Subject | Requester email | Requester name | Phone | Job title |
| New Feature Request | john.smith@email.com | John Smith | 12345 | Developer |
And the time constraints on the ticket are:
| Need by date | Not before date |
| 31-12-2020 | 01-12-2020 |
Expand Down
8 changes: 4 additions & 4 deletions features/remove_user_requests.feature
Expand Up @@ -5,16 +5,16 @@ Feature: Remove user requests

Background:
* the following user has SSO access:
| Name | Email | Job title | Organisation | Phone |
| John Smith | john.smith@email.com | Developer | Cabinet Office | 12345 |
| Name | Email | Job title | Phone |
| John Smith | john.smith@email.com | Developer | 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 |
| Subject | Requester email | Requester name | Phone | Job title |
| Remove user | john.smith@email.com | John Smith | 12345 | Developer |
And the ticket is tagged with "remove_user"
And the time constraints on the ticket are:
| Not before date |
Expand Down
1 change: 0 additions & 1 deletion features/step_definitions/request_steps.rb
Expand Up @@ -3,7 +3,6 @@
fill_in "Email", :with => @user_details["Email"]
fill_in "Job title", :with => @user_details["Job title"]
fill_in "Phone number", :with => @user_details["Phone"]
select @user_details["Organisation"], :from => 'Organisation'
end

When /^the user fills out the time constraints$/ do
Expand Down
1 change: 0 additions & 1 deletion features/step_definitions/zendesk_steps.rb
Expand Up @@ -6,7 +6,6 @@
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

Expand Down
1 change: 0 additions & 1 deletion features/support/hooks.rb
@@ -1,4 +1,3 @@
Before do
stub_zendesk_organisation_list
stub_zendesk_ticket_submission
end
2 changes: 0 additions & 2 deletions features/support/zendesk_helper.rb
@@ -1,5 +1,3 @@
require_relative '../../test/zendesk_organisation_list_helper'
require_relative '../../test/zendesk_api_stubs'

World(ZendeskOrganisationListHelper)
World(ZendeskApiStubsHelper)
14 changes: 3 additions & 11 deletions lib/campaign_request_zendesk_ticket.rb
@@ -1,13 +1,7 @@
require 'zendesk_ticket'
require 'forwardable'
require 'comment_snippet'

class CampaignRequestZendeskTicket < ZendeskTicket
def initialize(request)
super(request, nil)
@requester = request.requester
end

def subject
"Campaign"
end
Expand All @@ -16,12 +10,9 @@ def tags
["campaign"]
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.requester, field: :other_organisation),
[
CommentSnippet.new(on: @request.campaign, field: :title,
label: "Campaign title"),
CommentSnippet.new(on: @request.campaign, field: :erg_reference_number,
Expand All @@ -31,6 +22,7 @@ def comment_snippets
CommentSnippet.new(on: @request.campaign, field: :affiliated_group_or_company),
CommentSnippet.new(on: @request.campaign, field: :info_url,
label: "URL with more information"),
CommentSnippet.new(on: @request, field: :additional_comments) ]
CommentSnippet.new(on: @request, field: :additional_comments)
]
end
end
12 changes: 0 additions & 12 deletions lib/content_change_request_zendesk_ticket.rb
@@ -1,15 +1,7 @@
require 'zendesk_ticket'
require 'forwardable'
require 'comment_snippet'

class ContentChangeRequestZendeskTicket < ZendeskTicket
attr_reader :time_constraint

def initialize(request)
super(request, nil)
@requester = request.requester
end

def subject
"Content change request"
end
Expand All @@ -18,15 +10,11 @@ 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
def_delegators :@requester, :name, :email, :organisation, :job

protected
def comment_snippets
[
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,
Expand Down
10 changes: 0 additions & 10 deletions lib/create_new_user_request_zendesk_ticket.rb
@@ -1,13 +1,7 @@
require 'zendesk_ticket'
require 'forwardable'
require 'comment_snippet'

class CreateNewUserRequestZendeskTicket < ZendeskTicket
def initialize(request)
super(request, nil)
@requester = request.requester
end

def subject
"Create new user"
end
Expand All @@ -16,15 +10,11 @@ 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
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)
Expand Down
14 changes: 3 additions & 11 deletions lib/general_request_zendesk_ticket.rb
@@ -1,13 +1,7 @@
require 'zendesk_ticket'
require 'forwardable'
require 'comment_snippet'

class GeneralRequestZendeskTicket < ZendeskTicket
def initialize(request)
super(request, nil)
@requester = request.requester
end

def subject
"Govt Agency General Issue"
end
Expand All @@ -16,14 +10,12 @@ def tags
["govt_agency_general"]
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.requester, field: :other_organisation),
[
CommentSnippet.new(on: @request, field: :url),
CommentSnippet.new(on: @request, field: :user_agent),
CommentSnippet.new(on: @request, field: :additional) ]
CommentSnippet.new(on: @request, field: :additional)
]
end
end
10 changes: 0 additions & 10 deletions lib/new_feature_request_zendesk_ticket.rb
@@ -1,15 +1,9 @@
require 'zendesk_ticket'
require 'forwardable'
require 'comment_snippet'

class NewFeatureRequestZendeskTicket < ZendeskTicket
attr_reader :time_constraint

def initialize(request)
super(request, nil)
@requester = request.requester
end

def subject
@request.inside_government_related? ? "New Feature Request" : "New Need Request"
end
Expand All @@ -19,15 +13,11 @@ def tags
specific_tag + 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_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)
Expand Down

0 comments on commit 06365b2

Please sign in to comment.