Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from alphagov/content_change_form_for_inside_go…

…vernment

Changes to the "Content change form" for Inside Government
  • Loading branch information...
commit 060095fed881724df803d122de26514be511df04 2 parents 2b93b88 + 513b24d
@jamiecobbett jamiecobbett authored
View
4 Gemfile
@@ -20,8 +20,8 @@ gem 'less-rails-bootstrap'
group :test do
gem "mocha", "0.12.6", require: false
- gem "shoulda-context", "~> 1.0.1"
+ gem "shoulda", "~> 3.3.2"
gem "webmock", "1.8.11"
end
-gem 'unicorn', '4.3.1'
+gem 'unicorn', '4.3.1'
View
7 Gemfile.lock
@@ -140,7 +140,12 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
+ shoulda (3.3.2)
+ shoulda-context (~> 1.0.1)
+ shoulda-matchers (~> 1.4.1)
shoulda-context (1.0.1)
+ shoulda-matchers (1.4.1)
+ activesupport (>= 3.0.0)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -189,7 +194,7 @@ DEPENDENCIES
plek (= 0.5.0)
rails (= 3.2.8)
sass-rails (~> 3.2.3)
- shoulda-context (~> 1.0.1)
+ shoulda (~> 3.3.2)
therubyracer (~> 0.9.4)
uglifier (>= 1.0.3)
unicorn (= 4.3.1)
View
2  app/controllers/content_change_requests_controller.rb
@@ -1,3 +1,5 @@
+require 'guard'
+
class ContentChangeRequestsController < ApplicationController
def new
@formdata = {}
View
11 app/controllers/support_controller.rb
@@ -1,17 +1,6 @@
require "guard"
class SupportController < ApplicationController
- def amend_content
- if request.method == "GET"
- on_get("content/amend")
- elsif request.method == "POST"
- @template = "content/amend"
-
- @errors = Guard.validationsForAmendContent(params)
- on_post(params, "amend-content")
- end
- end
-
def create_user
if request.method == "GET"
on_get("useraccess/user")
View
0  app/models/.gitkeep
No changes.
View
49 app/views/content_change_requests/new.html.erb
@@ -2,17 +2,36 @@
<%= content_for :header, "Request a change to existing GOV.UK content" %>
<div class="alert alert-info alert-block">
- <p>If requesting an urgent content amend request, please follow up your submission of the form with a phone call to 07827 992603.</p>
- <p>An urgent content amend request should only be made if the public or the government is facing immediate and significant financial, legal or physical risk.</p>
+ <p>You'll get an automated response to confirm we've received your request. We'll then review your request within 2 working days.</p>
+ <p>When filling out this form...</p>
+ <p>Please do:</p>
+ <ul>
+ <li>explain the problem – what specifically needs to be addressed and why?</li>
+ <li>focus on the facts not the presentation</li>
+ <li>focus on what the user needs to know to complete a specific task, rather than the policy background</li>
+ <li>combine changes to one item into one ticket where possible</li>
+ </ul>
+ <p>Please don't:</p>
+ <ul>
+ <li>cut-and-paste long email chains</li>
+ <li>re-write the content</li>
+ </ul>
</div>
<div class="well">
-<%= form_tag(content_change_request_url, :method => :post) do %>
+ <%= form_tag(content_change_request_url, :method => :post) do %>
+ <%= render "support/author" %>
- <%= render "support/author" %>
+ <fieldset>
+ <label for="inside_government">Does this affect Inside Government?</label>
+ <select id="inside_government" name="inside_government">
+ <option selected="selected" value="no">No</option>
+ <option value="yes">Yes</option>
+ </select>
+ </fieldset>
<fieldset>
- <legend>URL(s) of content to be changed</legend>
+ <legend>URL(s) affected</legend>
<label class="visuallyhidden" for="target_url1">URL 1</label>
<input class="span6 input-block-level" id="target_url1" name="url1" type="text" placeholder="http://www.gov.uk/" <%= render "support/assignvalue", {:param => @formdata[:url1]} %> >
@@ -24,25 +43,29 @@
<input class="span6 input-block-level" id="target_url3" name="url3" type="text" placeholder="http://www.gov.uk/" <%= render "support/assignvalue", {:param => @formdata[:url3]} %> >
<div class="comments">
- <label for="add_content">Details of what should be added, amended, or removed:</label>
+ <label for="add_content">Details of the requested change:</label>
<textarea class="span6" id="add_content" name="add_content" rows="6" cols="70"><%= @formdata[:add_content] %></textarea>
- </div>
+ </div>
</fieldset>
- <%= render "support/date", {:title => "When should this change be published?", :label => 'need_by', :day => @formdata[:need_by_day], :month => @formdata[:need_by_month], :year => @formdata[:need_by_year]} %>
+ <%= render "support/date", {:title => "MUST be published by (optional)", :label => 'need_by', :day => @formdata[:need_by_day], :month => @formdata[:need_by_month], :year => @formdata[:need_by_year]} %>
<%= render "support/errors", {errors: @errors, key: "Need by"} %>
- <%= render "support/date", {:title => "Not to be amended before (optional)", :label => 'not_before', :day => @formdata[:not_before_day], :month => @formdata[:not_before_month], :year => @formdata[:not_before_year]} %>
+ <%= render "support/date", {:title => "MUST NOT be published BEFORE (optional)", :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"} %>
<fieldset>
<div class="comments">
- <label for="comments">Additional comments:</label>
- <textarea class="span6" id="comments" rows="6" cols="70" name="additional"><%= @formdata[:additional] %></textarea>
+ <label for="comments">Reason for the above dates (optional):</label>
+ <textarea class="span6" id="comments" rows="3" cols="70" name="additional"><%= @formdata[:additional] %></textarea>
</div>
</fieldset>
- <input class="btn btn-success" name="commit" type="submit" value="Submit">
-<% end %>
+ <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>
+ </div>
+
+ <input class="btn btn-success" name="commit" type="submit" value="Submit">
+ <% end %>
</div>
View
4 lib/zendesk_request.rb
@@ -11,7 +11,7 @@ def self.get_organisations(client)
end
def self.raise_zendesk_request(client, params, from_route)
- ticket_to_raise = ZendeskTicket.new(client, params, from_route)
+ ticket_to_raise = ZendeskTicket.new(params, from_route)
client.ticket.create(
:subject => ticket_to_raise.subject,
:description => "Created via Govt API",
@@ -22,7 +22,7 @@ def self.raise_zendesk_request(client, params, from_route)
{"id" => "21471291", "value" => ticket_to_raise.phone},
{"id" => "21485833", "value" => ticket_to_raise.need_by_date},
{"id" => "21502036", "value" => ticket_to_raise.not_before_date}],
- :tags => [ticket_to_raise.tag],
+ :tags => ticket_to_raise.tags,
:comment => {:value => ticket_to_raise.comment})
end
end
View
13 lib/zendesk_ticket.rb
@@ -1,6 +1,6 @@
class ZendeskTicket
- attr_reader :name, :email, :organisation, :job, :phone, :comment, :subject, :tag, :need_by_date, :not_before_date
+ attr_reader :name, :email, :organisation, :job, :phone, :comment, :subject, :need_by_date, :not_before_date
@@in_comments = {"amend-content" => [:other_organisation, :url1, :url2, :url3],
"create-user" => [:other_organisation, :user_name, :user_email, :additional],
"remove-user" => [:other_organisation, :user_name, :user_email, :additional],
@@ -25,7 +25,10 @@ class ZendeskTicket
"publish-tool" => "publishing_tool_tech"
}
- def initialize(client, params, from_route)
+ def initialize(params, from_route)
+ @params = params
+ @from_route = from_route
+
#author information
@name = params[:name]
@email = params[:email]
@@ -39,7 +42,6 @@ def initialize(client, params, from_route)
#ticket information
@comment = format_comment(from_route, params)
@subject = @@in_subject[from_route]
- @tag = @@in_tag[from_route]
if has_value(params[:need_by_day])
@need_by_date = params[:need_by_day] + "/" + params[:need_by_month] + "/" + params[:need_by_year]
@@ -54,6 +56,11 @@ def initialize(client, params, from_route)
end
end
+ def tags
+ inside_government_tag = @params[:inside_government] == "yes" ? ["inside_government"] : []
+ [@@in_tag[@from_route]] + inside_government_tag
+ end
+
private
def has_value(param)
View
52 test/functional/content_change_requests_controller_test.rb
@@ -1,33 +1,17 @@
+require 'ostruct'
require_relative "../test_helper"
class ContentChangeRequestsControllerTest < ActionController::TestCase
include ZenDeskOrganisationListHelper
+ include TestData
setup do
login_as_stub_user
+ @zendesk_api = ZenDeskAPIClientDouble.new
+ ZendeskClient.stubs(:get_client).returns(@zendesk_api)
end
- VALID_CONTENT_CHANGE_REQUEST_PARAMS = {
- "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"Dev",
- "phone"=>"",
- "organisation"=>"cabinet_office",
- "other_organisation"=>"",
- "url1"=>"",
- "url2"=>"",
- "url3"=>"",
- "add_content"=>"",
- "need_by_day"=>"",
- "need_by_month"=>"",
- "need_by_year"=>"",
- "not_before_day"=>"",
- "not_before_month"=>"",
- "not_before_year"=>"",
- "additional"=>""
- }
-
- context "GET amend_content" do
+ context "a new content change request" do
setup do
stub_zendesk_organisation_list
end
@@ -43,13 +27,9 @@ class ContentChangeRequestsControllerTest < ActionController::TestCase
end
end
- context "POST amend_content" do
- setup do
- stub_zendesk_organisation_list
- end
-
+ context "a submitted content change request" do
should "reject invalid change requests" do
- params = VALID_CONTENT_CHANGE_REQUEST_PARAMS.merge("organisation" => "")
+ params = valid_content_change_request_params.merge("organisation" => "")
post :create, params
assert_response 200 # should actually be an error status, but let's worry about that later
assert_template "new"
@@ -57,10 +37,24 @@ class ContentChangeRequestsControllerTest < ActionController::TestCase
end
should "submit it to ZenDesk" do
- params = VALID_CONTENT_CHANGE_REQUEST_PARAMS
- ZendeskRequest.expects(:raise_zendesk_request).returns("not a null")
+ params = valid_content_change_request_params
post :create, params
+
+ assert_equal ['content_amend'], @zendesk_api.ticket.options[:tags]
+
assert_redirected_to "/acknowledge"
end
+
+ context "concerning Inside Government" do
+ should "submit it to ZenDesk" do
+ params = valid_content_change_request_params.merge("inside_government" => "yes")
+
+ post :create, params
+
+ assert_equal ['content_amend', 'inside_government'], @zendesk_api.ticket.options[:tags]
+
+ assert_redirected_to "/acknowledge"
+ end
+ end
end
end
View
135 test/functional/support_controller_test.rb
@@ -2,9 +2,12 @@
class SupportControllerTest < ActionController::TestCase
include ZenDeskOrganisationListHelper
+ include TestData
setup do
login_as_stub_user
+ @zendesk_api = ZenDeskAPIClientDouble.new
+ ZendeskClient.stubs(:get_client).returns(@zendesk_api)
end
context "GET landing" do
@@ -31,22 +34,8 @@ class SupportControllerTest < ActionController::TestCase
end
context "POST create_user" 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"=>"", # organisation must be set
- "other_organisation"=>"",
- "user_name"=>"",
- "user_email"=>"",
- "additional"=>""
- }
+ params = valid_create_new_user_request_params.merge("organisation" => "")
post :create_user, params
assert_response 200 # should actually be an error status, but let's worry about that later
assert_template "useraccess/user"
@@ -54,19 +43,11 @@ class SupportControllerTest < ActionController::TestCase
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"=>"",
- "user_name"=>"subject",
- "user_email"=>"subject@digital.cabinet-office.gov.uk",
- "additional"=>""
- }
- ZendeskRequest.expects(:raise_zendesk_request).returns("not a null")
+ params = valid_create_new_user_request_params
+
post :create_user, params
+
+ assert_equal ['new_user'], @zendesk_api.ticket.options[:tags]
assert_redirected_to "/acknowledge"
end
end
@@ -93,20 +74,7 @@ class SupportControllerTest < ActionController::TestCase
end
should "reject invalid requests" do
- params = {
- "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"This is just a test",
- "phone"=>"",
- "organisation"=>"", # this has to be filled in
- "other_organisation"=>"",
- "user_name"=>"testing",
- "user_email"=>"ignore-me@foo.com",
- "not_before_day"=>"",
- "not_before_month"=>"",
- "not_before_year"=>"",
- "additional"=>""
- }
+ params = valid_remove_user_request_params.merge("organisation" => "")
post :remove_user, params
assert_response 200 # should actually be an error status, but let's worry about that later
assert_template "useraccess/user"
@@ -114,22 +82,11 @@ class SupportControllerTest < ActionController::TestCase
end
should "submit it to ZenDesk" do
- 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"=>""
- }
- ZendeskRequest.expects(:raise_zendesk_request).returns("not a null")
+ params = valid_remove_user_request_params
+
post :remove_user, params
+
+ assert_equal ['remove_user'], @zendesk_api.ticket.options[:tags]
assert_redirected_to "/acknowledge"
end
end
@@ -156,23 +113,7 @@ class SupportControllerTest < ActionController::TestCase
end
should "reject invalid requests" do
- params = {
- "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"doo",
- "phone"=>"",
- "organisation"=>"",
- "other_organisation"=>"",
- "campaign_name"=>"Testing",
- "erg_number"=>"1234",
- "start_day"=>"",
- "start_month"=>"",
- "start_year"=>"",
- "description"=>"Testing",
- "company"=>"",
- "url"=>"",
- "additional"=>""
- }
+ params = valid_campaign_request_params.merge("organisation" => "")
post :campaign, params
assert_response 200 # should actually be an error status, but let's worry about that later
assert_template "campaigns/campaign"
@@ -180,25 +121,11 @@ class SupportControllerTest < ActionController::TestCase
end
should "submit it to ZenDesk" do
- params = {
- "name"=>"Testing",
- "email"=>"testing@digital.cabinet-office.gov.uk",
- "job"=>"doo",
- "phone"=>"",
- "organisation"=>"cabinet_office",
- "other_organisation"=>"",
- "campaign_name"=>"Testing",
- "erg_number"=>"1234",
- "start_day"=>"",
- "start_month"=>"",
- "start_year"=>"",
- "description"=>"Testing",
- "company"=>"",
- "url"=>"",
- "additional"=>""
- }
- ZendeskRequest.expects(:raise_zendesk_request).returns("not a null")
+ params = valid_campaign_request_params
+
post :campaign, params
+
+ assert_equal ['campaign'], @zendesk_api.ticket.options[:tags]
assert_redirected_to "/acknowledge"
end
end
@@ -225,16 +152,7 @@ class SupportControllerTest < ActionController::TestCase
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"=>""
- }
+ params = valid_general_request_params.merge("organisation" => "")
post :general, params
assert_response 200 # should actually be an error status, but let's worry about that later
assert_template "tech-issues/general"
@@ -242,18 +160,11 @@ class SupportControllerTest < ActionController::TestCase
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")
+ params = valid_general_request_params
+
post :general, params
+
+ assert_equal ['govt_agency_general'], @zendesk_api.ticket.options[:tags]
assert_redirected_to "/acknowledge"
end
end
View
78 test/test_data.rb
@@ -0,0 +1,78 @@
+module TestData
+ def valid_content_change_request_params
+ { "name"=>"Testing",
+ "email"=>"testing@digital.cabinet-office.gov.uk",
+ "job"=>"Dev",
+ "phone"=>"",
+ "organisation"=>"cabinet_office",
+ "other_organisation"=>"",
+ "inside_government" => "no",
+ "url1"=>"",
+ "url2"=>"",
+ "url3"=>"",
+ "add_content"=>"",
+ "need_by_day"=>"",
+ "need_by_month"=>"",
+ "need_by_year"=>"",
+ "not_before_day"=>"",
+ "not_before_month"=>"",
+ "not_before_year"=>"",
+ "additional"=>"" }
+ end
+
+ def valid_create_new_user_request_params
+ { "name"=>"Testing",
+ "email"=>"testing@digital.cabinet-office.gov.uk",
+ "job"=>"dev",
+ "phone"=>"",
+ "organisation"=>"cabinet_office",
+ "other_organisation"=>"",
+ "user_name"=>"subject",
+ "user_email"=>"subject@digital.cabinet-office.gov.uk",
+ "additional"=>"" }
+ 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"=>"" }
+ end
+
+ def valid_campaign_request_params
+ { "name"=>"Testing",
+ "email"=>"testing@digital.cabinet-office.gov.uk",
+ "job"=>"doo",
+ "phone"=>"",
+ "organisation"=>"cabinet_office",
+ "other_organisation"=>"",
+ "campaign_name"=>"Testing",
+ "erg_number"=>"1234",
+ "start_day"=>"",
+ "start_month"=>"",
+ "start_year"=>"",
+ "description"=>"Testing",
+ "company"=>"",
+ "url"=>"",
+ "additional"=>"" }
+ end
+
+ def valid_general_request_params
+ { "name"=>"Testing",
+ "email"=>"testing@digital.cabinet-office.gov.uk",
+ "job"=>"dev",
+ "phone"=>"",
+ "organisation"=>"cabinet_office",
+ "other_organisation"=>"",
+ "url"=>"testing",
+ "additional"=>"" }
+ end
+end
View
33 test/test_helper.rb
@@ -5,6 +5,7 @@
require 'mocha_standalone'
require 'webmock/minitest'
+require_relative 'test_data'
class ActiveSupport::TestCase
def setup
@@ -53,3 +54,35 @@ def stub_zendesk_organisation_list
to_return(:status => 200, :body => body.to_json, :headers => {"Content-Type" => "application/json"})
end
end
+
+class ZenDeskAPITicketDouble
+ attr_reader :options
+
+ def create(options)
+ @options = options
+ end
+end
+
+class ZenDeskAPIClientDouble
+ attr_reader :ticket
+
+ def initialize
+ @ticket = ZenDeskAPITicketDouble.new
+ end
+
+ def ticket_fields
+ self
+ end
+
+ def find(some_criteria)
+ self
+ end
+
+ def custom_field_options
+ [ {"name"=>"Advocate General for Scotland", "value"=>"advocate_general_for_scotland"},
+ {"name"=>"Attorney General's Office", "value"=>"attorney_generals_office"},
+ {"name"=>"Cabinet Office", "value"=>"cabinet_office"}
+ ].collect {|params| OpenStruct.new(params)}
+ end
+end
+
View
0  test/unit/.gitkeep
No changes.
View
19 test/unit/zendesk_ticket_test.rb
@@ -0,0 +1,19 @@
+require 'test/unit'
+require 'shoulda/context'
+require 'zendesk_ticket'
+require 'test_data'
+
+class ZendeskTicketTest < Test::Unit::TestCase
+ include TestData
+ context "content change request" do
+ should "set the tags correctly for valid tickets" do
+ ticket = ZendeskTicket.new(valid_content_change_request_params, "amend-content")
+ assert_equal ['content_amend'], ticket.tags
+ end
+
+ should "set the tags correctly for valid inside govt tickets" do
+ ticket = ZendeskTicket.new(valid_content_change_request_params.merge(:inside_government => "yes"), "amend-content")
+ assert_equal ['content_amend', 'inside_government'], ticket.tags
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.