slimmer 3.8.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ module Slimmer
9
9
  format: "Format",
10
10
  need_id: "Need-ID",
11
11
  proposition: "Proposition",
12
+ organisations: "Organisations",
12
13
  remove_meta_viewport: "Remove-Meta-Viewport",
13
14
  result_count: "Result-Count",
14
15
  section: "Section",
@@ -12,12 +12,13 @@ module Slimmer::Processors
12
12
  def filter(src, dest)
13
13
  custom_vars = []
14
14
  if @artefact
15
- custom_vars << set_custom_var(1, "Section", @artefact.primary_root_section["title"]) if @artefact.primary_root_section
16
- custom_vars << set_custom_var(3, "NeedID", @artefact.need_id)
15
+ custom_vars << set_custom_var(1, "Section", @artefact.primary_root_section["title"].downcase) if @artefact.primary_root_section
16
+ custom_vars << set_custom_var(3, "NeedID", @artefact.need_id.downcase)
17
17
  custom_vars << set_custom_var(4, "Proposition", (@artefact.business_proposition ? 'business' : 'citizen')) unless @artefact.business_proposition.nil?
18
+ custom_vars << set_custom_var(9, "Organisations", @artefact.organisations) unless @artefact.organisations.nil?
18
19
  end
19
- custom_vars << set_custom_var(2, "Format", @headers[Slimmer::Headers::FORMAT_HEADER])
20
- custom_vars << set_custom_var(5, "ResultCount", @headers[Slimmer::Headers::RESULT_COUNT_HEADER])
20
+ custom_vars << set_custom_var(2, "Format", @headers[Slimmer::Headers::FORMAT_HEADER].downcase)
21
+ custom_vars << set_custom_var(5, "ResultCount", @headers[Slimmer::Headers::RESULT_COUNT_HEADER].downcase)
21
22
 
22
23
  if dest.at_css("#ga-params")
23
24
  dest.at_css("#ga-params").content += custom_vars.compact.join("\n")
@@ -27,8 +28,8 @@ module Slimmer::Processors
27
28
  private
28
29
  def set_custom_var(slot, name, value)
29
30
  return nil unless value
30
- response = "_gaq.push(#{JSON.dump([ "_setCustomVar", slot, name, value.downcase, PAGE_LEVEL_EVENT])});\n"
31
- response + "GOVUK.Analytics.#{name} = \"#{value.downcase}\";"
31
+ response = "_gaq.push(#{JSON.dump([ "_setCustomVar", slot, name, value, PAGE_LEVEL_EVENT])});\n"
32
+ response + "GOVUK.Analytics.#{name} = \"#{value}\";"
32
33
  end
33
34
  end
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '3.8.0'
2
+ VERSION = '3.9.0'
3
3
  end
data/test/headers_test.rb CHANGED
@@ -29,6 +29,11 @@ class HeadersTest < MiniTest::Unit::TestCase
29
29
  assert_equal "rhubarb", headers["X-Slimmer-Proposition"]
30
30
  end
31
31
 
32
+ def test_should_set_organisations_header
33
+ set_slimmer_headers organisations: "<D123><P1>"
34
+ assert_equal "<D123><P1>", headers["X-Slimmer-Organisations"]
35
+ end
36
+
32
37
  def test_should_set_result_count_header
33
38
  set_slimmer_headers result_count: 3
34
39
  assert_equal "3", headers["X-Slimmer-Result-Count"]
@@ -57,7 +57,8 @@ module GoogleAnalyticsTest
57
57
  artefact = artefact_for_slug_in_a_subsection("something", "rhubarb/in-puddings")
58
58
  artefact["details"].merge!(
59
59
  "need_id" => "42",
60
- "business_proposition" => true
60
+ "business_proposition" => true,
61
+ "organisations" => "<P1><D422>"
61
62
  )
62
63
  headers = {
63
64
  Slimmer::Headers::FORMAT_HEADER => "custard",
@@ -96,6 +97,10 @@ module GoogleAnalyticsTest
96
97
  assert_custom_var 4, "Proposition", "business", PAGE_LEVEL_EVENT
97
98
  end
98
99
 
100
+ def test_should_pass_proposition_to_GA
101
+ assert_custom_var 9, "Organisations", "<P1><D422>", PAGE_LEVEL_EVENT
102
+ end
103
+
99
104
  def test_should_set_section_in_GOVUK_object
100
105
  assert_set_var "Proposition", "trifle", govuk
101
106
  end
@@ -130,6 +135,10 @@ module GoogleAnalyticsTest
130
135
  refute_custom_var "Proposition"
131
136
  end
132
137
 
138
+ def test_should_omit_organisations
139
+ refute_custom_var "Organisations"
140
+ end
141
+
133
142
  def test_should_omit_result_count
134
143
  refute_custom_var "ResultCount"
135
144
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.8.0
5
+ version: 3.9.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Griffiths
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-10-15 00:00:00 Z
14
+ date: 2012-11-12 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nokogiri
@@ -246,7 +246,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
246
  requirements:
247
247
  - - ">="
248
248
  - !ruby/object:Gem::Version
249
- hash: 4023505413084510363
249
+ hash: -2824424653822310108
250
250
  segments:
251
251
  - 0
252
252
  version: "0"
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - ">="
257
257
  - !ruby/object:Gem::Version
258
- hash: 4023505413084510363
258
+ hash: -2824424653822310108
259
259
  segments:
260
260
  - 0
261
261
  version: "0"