Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit '54583870479bfb3b8ed88839d975f889b27e82d9' into HEAD

  • Loading branch information...
commit 107cf50a57c9e91c99f13d64f2cf55a141c0fed4 2 parents 4b66534 + 5458387
Jenkins authored
View
4 lib/app.rb
@@ -114,7 +114,7 @@ class App < Sinatra::Base
end
def on_get(head, head_message_form, template)
- @departments = ZendeskRequest.get_departments(@client)
+ @organisations = ZendeskRequest.get_organisations(@client)
@header = head
@header_message = :"#{head_message_form}"
@formdata = {}
@@ -123,7 +123,7 @@ def on_get(head, head_message_form, template)
end
def on_post(params, route)
- @departments = ZendeskRequest.get_departments(@client)
+ @organisations = ZendeskRequest.get_organisations(@client)
@formdata = params
if @errors.empty?
View
2  lib/public/stylesheets/gov_feedback.css
@@ -148,7 +148,7 @@ textarea {
border: 1px solid #BBB;
}
-input#other_department {
+input#other_organisation {
margin-left: 5px;
}
View
16 lib/validations.rb
@@ -103,7 +103,7 @@ def self.validationsForPublishTool(form_data)
def self.validate(form_data, required, phone_fields, email_fields)
self.checkRequiredFieldsHaveValues(required, form_data)
- self.validate_department_or_other_is_entered(form_data)
+ self.validate_organisation_or_other_is_entered(form_data)
self.checkPhoneIsValid(phone_fields)
self.checkEmailIsValid(email_fields)
end
@@ -193,16 +193,16 @@ def self.validate_not_before_date_is_equal_or_greater_than_need_by(not_before, n
end
end
- def self.validate_department_or_other_is_entered(form_data)
- other_department_is_required = form_data[:department].empty? || form_data[:department] == "other_department"
+ def self.validate_organisation_or_other_is_entered(form_data)
+ other_organisation_is_required = form_data[:organisation].empty? || form_data[:organisation] == "other_organisation"
- if other_department_is_required &&
- (form_data[:other_department] && form_data[:other_department].strip.empty?)
- @@errors["Department"] = "Department information is required for a valid request."
+ if other_organisation_is_required &&
+ (form_data[:other_organisation] && form_data[:other_organisation].strip.empty?)
+ @@errors["Organisation"] = "Organisation information is required for a valid request."
end
- if not other_department_is_required
- form_data[:other_department] = ""
+ if not other_organisation_is_required
+ form_data[:other_organisation] = ""
end
end
View
14 lib/views/author.erb
@@ -25,22 +25,22 @@
<%= erb :errors, :locals => {"key" => "Phone"} %>
</div>
<div>
- <label for="department_list">Department</label>
- <select id="department_list" name="department">
- <% @departments.each do |key, value| %>
- <% if value == @formdata["department"] %>
+ <label for="organisation_list">Organisation</label>
+ <select id="organisation_list" name="organisation">
+ <% @organisations.each do |key, value| %>
+ <% if value == @formdata["organisation"] %>
<option selected="selected" value="<%= value %>"><%= key %> </option>
<% else %>
<option value="<%= value %>"><%= key %> </option>
<% end %>
<% end %>
</select>
- <%= erb :errors, :locals => {"key" => "Department"} %>
+ <%= erb :errors, :locals => {"key" => "Organisation"} %>
</div>
<div>
- <label class="long" for="other_department">Please specify the department if you didn't find the department in the list above</label>
- <input id="other_department" name="other_department">
+ <label class="long" for="other_organisation">Please specify the organisation if you didn't find it in the list above</label>
+ <input id="other_organisation" name="other_organisation">
</div>
</fieldset>
View
12 lib/zendesk_request.rb
@@ -6,12 +6,12 @@
class ZendeskRequest
- def self.get_departments(client)
- departments_hash = {"Select Department" => ""}
+ def self.get_organisations(client)
+ organisations_hash = {"Select Organisation" => ""}
#if client && client.current_user && client.current_user.id
- client.ticket_fields.find(:id => '21494928').custom_field_options.each { |tf| departments_hash[tf.name] = tf.value }
+ client.ticket_fields.find(:id => '21494928').custom_field_options.each { |tf| organisations_hash[tf.name] = tf.value }
#end
- departments_hash
+ organisations_hash
end
def self.raise_zendesk_request(client, params, from_route)
@@ -25,7 +25,7 @@ def self.raise_zendesk_request(client, params, from_route)
:description => "Created via Govt API",
:priority => "normal",
:requester => {"locale_id" => 1, "name" => ticket_to_raise.name, "email" => ticket_to_raise.email},
- :fields => [{"id" => "21494928", "value" => ticket_to_raise.department},
+ :fields => [{"id" => "21494928", "value" => ticket_to_raise.organisation},
{"id" => "21487987", "value" => ticket_to_raise.job},
{"id" => "21471291", "value" => ticket_to_raise.phone},
{"id" => "21485833", "value" => ticket_to_raise.need_by_date},
@@ -41,7 +41,7 @@ def self.create_ticket_with_attachment(client, ticket_to_raise)
:description => "Created via Govt API",
:priority => "normal",
:requester => {"locale_id" => 1, "name" => ticket_to_raise.name, "email" => ticket_to_raise.email},
- :fields => [{"id" => "21494928", "value" => ticket_to_raise.department},
+ :fields => [{"id" => "21494928", "value" => ticket_to_raise.organisation},
{"id" => "21487987", "value" => ticket_to_raise.job},
{"id" => "21471291", "value" => ticket_to_raise.phone},
{"id" => "21485833", "value" => ticket_to_raise.need_by_date},
View
20 lib/zendesk_ticket.rb
@@ -3,13 +3,13 @@
class ZendeskTicket
- attr_reader :name, :email, :department, :job, :phone, :comment, :subject, :tag, :need_by_date, :not_before_date, :file_token
- @@in_comments = {"amend-content" => [:other_department, :url1, :url2, :url3],
- "create-user" => [:other_department, :user_name, :user_email, :additional],
- "remove-user" => [:other_department, :user_name, :user_email, :additional],
- "campaign" => [:other_department, :campaign_name, :erg_number, :company, :description, :url, :additional],
- "broken-link" => [:other_department, :url, :user_agent, :additional],
- "publish-tool" => [:other_department, :username, :url, :user_agent, :additional]
+ attr_reader :name, :email, :organisation, :job, :phone, :comment, :subject, :tag, :need_by_date, :not_before_date, :file_token
+ @@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],
+ "campaign" => [:other_organisation, :campaign_name, :erg_number, :company, :description, :url, :additional],
+ "broken-link" => [:other_organisation, :url, :user_agent, :additional],
+ "publish-tool" => [:other_organisation, :username, :url, :user_agent, :additional]
}
@@in_subject = {"amend-content" => "Content change request",
@@ -32,7 +32,7 @@ def initialize(client, params, from_route)
#author information
@name = params[:name]
@email = params[:email]
- @department = params[:department]
+ @organisation = params[:organisation]
@job = params[:job]
if has_value(params[:phone])
@@ -86,7 +86,7 @@ def format_comment(from_route, params)
else
comment = @@in_comments[from_route].map do |comment_param|
if params[comment_param] && !params[comment_param].empty?
- "[" + comment_param.to_s.capitalize + "]\n" + params[comment_param]
+ "[" + comment_param.to_s.capitalize.gsub(/_/, " ") + "]\n" + params[comment_param]
end
end
@@ -102,7 +102,7 @@ def format_comment_for_tech_issues(from_route, params)
all_comments = @@in_comments[from_route].map do |comment_param|
comment = ""
if params[comment_param] && !params[comment_param].empty?
- comment = "[" + comment_param.to_s.capitalize + "]\n"
+ comment = "[" + comment_param.to_s.capitalize.gsub(/_/, " ") + "]\n"
if :url == comment_param
comment += build_full_url_path(params[:url])
else
View
10 spec/content_form_spec.rb
@@ -24,7 +24,7 @@ def teardown
def test_page_contain_required_fields
#Given
- ZendeskRequest.expects(:get_departments).returns([{"key1" => "value1"}, {"key2" => "value2"}])
+ ZendeskRequest.expects(:get_organisations).returns([{"key1" => "value1"}, {"key2" => "value2"}])
#When
get '/amend-content'
@@ -34,12 +34,12 @@ def test_page_contain_required_fields
assert last_response.body.include?('Email')
assert last_response.body.include?('Job title')
assert last_response.body.include?('Phone number')
- assert last_response.body.include?('Department')
+ assert last_response.body.include?('Organisation')
end
- def test_departments_list_shown_on_page
+ def test_organisations_list_shown_on_page
#Given
- ZendeskRequest.expects(:get_departments).returns([{"key1" => "value1"}, {"key2" => "value2"}])
+ ZendeskRequest.expects(:get_organisations).returns([{"key1" => "value1"}, {"key2" => "value2"}])
#When
get '/amend-content'
@@ -51,7 +51,7 @@ def test_departments_list_shown_on_page
def test_zendesk_create_ticket_triggered_by_post_request
form_parameters = PageHelper.fill_content_form
- ZendeskRequest.expects(:get_departments).returns([{"key1" => "value1"}, {"key2" => "value2"}])
+ ZendeskRequest.expects(:get_organisations).returns([{"key1" => "value1"}, {"key2" => "value2"}])
Guard.expects(:validationsForCreateUser).returns({});
ZendeskRequest.expects(:raise_zendesk_request).returns("fake ticket")
View
2  spec/page_helper.rb
@@ -11,7 +11,7 @@ def self.fill_content_form
:not_before_year => '2012',
:name => 'tester',
:email => 'tester@digital.cabinet-office.gov.uk',
- :department => 'test department',
+ :organisation => 'test organisation',
:job => 'job',
:phone => '123456'
}
View
2  spec/tech_issues_spec.rb
@@ -16,7 +16,7 @@ def app
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
- ZendeskRequest.expects(:get_departments).returns([{"key1" => "value1"}, {"key2" => "value2"}])
+ ZendeskRequest.expects(:get_organisations).returns([{"key1" => "value1"}, {"key2" => "value2"}])
end
# Called after every test method runs. Can be used to tear
Please sign in to comment.
Something went wrong with that request. Please try again.