slimmer 2.1.0 → 3.0.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 3.0.0
2
+
3
+ Backwards-incompatible changes:
4
+ * Artefact is expected to follow the format emitted by the Content API
5
+
1
6
  # 2.0.0
2
7
 
3
8
  Backwards-incompatible changes:
data/lib/slimmer.rb CHANGED
@@ -1,7 +1,7 @@
1
- #########################################
2
- ####### Look, Rounded corners.... It's 2.0 #####
3
- #####################################################
4
- #######################################################
1
+ #.....................................................
2
+ #"""""" Look, Gradiented-Rounded corners.... It's 3.0 """""
3
+ #////////////////////////////////////////////////////////////////
4
+ ###################################################################
5
5
 
6
6
  require 'nokogiri'
7
7
  require 'erb'
@@ -21,6 +21,7 @@ module Slimmer
21
21
  autoload :Template, 'slimmer/template'
22
22
  autoload :App, 'slimmer/app'
23
23
  autoload :Headers, 'slimmer/headers'
24
+ autoload :Artefact, 'slimmer/artefact'
24
25
 
25
26
  module Processors
26
27
  autoload :AdminTitleInserter, 'slimmer/processors/admin_title_inserter'
@@ -43,7 +44,7 @@ module Slimmer
43
44
  class CouldNotRetrieveTemplate < StandardError; end
44
45
  end
45
46
 
46
- #######################################################
47
- #####################################################
48
- #################################################
49
- #########################################
47
+ ######################################################################
48
+ #///////////////////////////////////////////////////////////////////
49
+ #"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
50
+ #.......................................................
@@ -0,0 +1,39 @@
1
+ class Slimmer::Artefact
2
+ def initialize(artefact_data)
3
+ @data = artefact_data
4
+ end
5
+
6
+ def slug
7
+ id_to_slug(@data["id"])
8
+ end
9
+
10
+ def tags_of_type(type)
11
+ return [] unless @data.has_key?("tags")
12
+ @data["tags"].select do |t|
13
+ t["details"]["type"] == type
14
+ end
15
+ end
16
+
17
+ def legacy_sources
18
+ tags_of_type('legacy_source').map do |t|
19
+ id_to_slug(t["id"])
20
+ end
21
+ end
22
+
23
+ def related_artefacts
24
+ return [] unless @data.has_key?("related")
25
+ @data["related"].map do |r|
26
+ self.class.new(r)
27
+ end
28
+ end
29
+
30
+ def method_missing(name, *args)
31
+ @data[name.to_s] || @data["details"][name.to_s]
32
+ end
33
+
34
+ private
35
+
36
+ def id_to_slug(id)
37
+ id.split('/').last.chomp('.json')
38
+ end
39
+ end
@@ -28,26 +28,7 @@ module Slimmer
28
28
  end
29
29
 
30
30
  def set_slimmer_artefact(artefact_input)
31
- if artefact_input.is_a?(Hash) or artefact_input.is_a?(OpenStruct)
32
- artefact = artefact_input.dup
33
- elsif artefact_input.respond_to?(:to_hash) # e.g. GdsApi::Response
34
- artefact = artefact_input.to_hash.dup
35
- end
36
-
37
- if artefact.is_a?(Hash)
38
- # Temporary deletions until the actions are removed from the API.
39
- # The actions increase the size of the artefact significantly, and will
40
- # only grow over time.
41
- #
42
- # We skip this when given an OpenStruct as they won't have actions etc...
43
- artefact.delete("actions")
44
- if artefact["related_items"]
45
- artefact["related_items"].each do |ri|
46
- ri["artefact"].delete("actions") if ri["artefact"]
47
- end
48
- end
49
- end
50
-
31
+ artefact = artefact_input.dup
51
32
  headers[ARTEFACT_HEADER] = artefact.to_json
52
33
  end
53
34
  end
@@ -28,9 +28,8 @@ module Slimmer::Processors
28
28
  private
29
29
  def set_custom_var(slot, name, value)
30
30
  return nil unless value
31
- value.downcase!
32
- response = "_gaq.push(#{JSON.dump([ "_setCustomVar", slot, name, value, PAGE_LEVEL_EVENT])});\n"
33
- response + "GOVUK.Analytics.#{name} = \"#{value}\";"
31
+ response = "_gaq.push(#{JSON.dump([ "_setCustomVar", slot, name, value.downcase, PAGE_LEVEL_EVENT])});\n"
32
+ response + "GOVUK.Analytics.#{name} = \"#{value.downcase}\";"
34
33
  end
35
34
  end
36
35
  end
@@ -8,13 +8,23 @@ module Slimmer
8
8
  end
9
9
 
10
10
  def filter(source, dest)
11
- return unless @artefact and @artefact["tag_ids"]
12
- logo_classes = LOGO_CLASSES & @artefact["tag_ids"]
11
+ return unless @artefact and @artefact["tags"]
12
+ classes_to_use = LOGO_CLASSES & legacy_sources
13
13
  wrapper = dest.css('#wrapper')
14
- logo_classes.each do |klass|
14
+ classes_to_use.each do |klass|
15
15
  wrapper.add_class(klass)
16
16
  end
17
17
  end
18
+
19
+ def legacy_sources
20
+ legacy_source_tags = @artefact["tags"].select do |tag|
21
+ tag["details"]["type"] == "legacy_source"
22
+ end
23
+ legacy_sources = legacy_source_tags.map do |tag|
24
+ tag["id"].split("/").last.chomp(".json")
25
+ end
26
+ legacy_sources
27
+ end
18
28
  end
19
29
  end
20
30
  end
@@ -14,8 +14,27 @@ class Slimmer::Processors::RelatedItemsInserter
14
14
 
15
15
  def related_item_block
16
16
  artefact = @artefact
17
+ root_primary_section = root_primary_section(artefact)
17
18
  related_block_template = @skin.template('related.raw')
18
19
  html = ERB.new(related_block_template).result(binding)
19
20
  Nokogiri::HTML.fragment(html)
20
21
  end
22
+
23
+ # Duplicated in Frontend
24
+ def root_primary_section(artefact)
25
+ primary_section = artefact["tags"].detect do |tag|
26
+ tag["details"]["type"] == "section"
27
+ end
28
+
29
+ if primary_section.nil?
30
+ nil
31
+ else
32
+ if primary_section["parent"]
33
+ primary_section["parent"]
34
+ else
35
+ primary_section
36
+ end
37
+ end
38
+ end
39
+
21
40
  end
@@ -13,6 +13,10 @@ module Slimmer::TestTemplate
13
13
  <script src="http://static.preview.alphagov.co.uk/static/popup.js" defer></script>
14
14
  <script src="http://static.preview.alphagov.co.uk/static/geo-locator.js" defer></script>
15
15
  <script src="http://static.preview.alphagov.co.uk/static/customisation-settings.js" defer></script>
16
+ <script src="http://static.preview.alphagov.co.uk/static/welcome.js" defer></script>
17
+ <script src="http://static.preview.alphagov.co.uk/static/browse.js" defer></script>
18
+ <script src="http://static.preview.alphagov.co.uk/static/jquery.history.js" defer></script>
19
+ <script src="http://static.preview.alphagov.co.uk/static/jquery.tabs.js" defer></script>
16
20
  </head>
17
21
  <body>
18
22
  <nav role="navigation" class="header-context">
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '2.1.0'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -0,0 +1,78 @@
1
+ require_relative "test_helper"
2
+ require 'gds_api/test_helpers/content_api'
3
+
4
+ describe Slimmer::Artefact do
5
+ include GdsApi::TestHelpers::ContentApi
6
+
7
+ it "should pull the slug out of the id" do
8
+ a = Slimmer::Artefact.new(artefact_for_slug('vat-rates'))
9
+ assert_equal 'vat-rates', a.slug
10
+ end
11
+
12
+ describe "Related artefacts" do
13
+ before do
14
+ @data = artefact_for_slug('something')
15
+ end
16
+
17
+ it "should return an array of corresponding artefact instances" do
18
+ @data["related"] << artefact_for_slug('vat')
19
+ @data["related"] << artefact_for_slug('something-else')
20
+ a = Slimmer::Artefact.new(@data)
21
+ related = a.related_artefacts
22
+ assert_equal [Slimmer::Artefact, Slimmer::Artefact], related.map(&:class)
23
+ assert_equal %w(vat something-else), related.map(&:slug)
24
+ end
25
+
26
+ it "should return empty array if there is no 'related' element" do
27
+ @data.delete("related")
28
+ assert_equal [], Slimmer::Artefact.new(@data).related_artefacts
29
+ end
30
+ end
31
+
32
+ describe "Legacy sources" do
33
+ before do
34
+ @data = artefact_for_slug('something')
35
+ end
36
+
37
+ it "should return the slugs of all legacy_source tags" do
38
+ @data["tags"] << tag_for_slug('businesslink', 'legacy_source')
39
+ @data["tags"] << tag_for_slug('directgov', 'legacy_source')
40
+ assert_equal ['businesslink', 'directgov'], Slimmer::Artefact.new(@data).legacy_sources.sort
41
+ end
42
+
43
+ it "should not include other tags" do
44
+ @data["tags"] << tag_for_slug('businesslink', 'legacy_source')
45
+ @data["tags"] << tag_for_slug('business', 'proposition')
46
+ @data["tags"] << tag_for_slug('directgov', 'legacy_source')
47
+ assert_equal ['businesslink', 'directgov'], Slimmer::Artefact.new(@data).legacy_sources.sort
48
+ end
49
+
50
+ it "should return empty array if the data hs no tags element" do
51
+ @data.delete("tags")
52
+ assert_equal [], Slimmer::Artefact.new(@data).legacy_sources
53
+ end
54
+ end
55
+
56
+ describe "method_missing accessing artefact fields" do
57
+ before do
58
+ @data = artefact_for_slug('something')
59
+ @data["foo"] = "bar"
60
+ @a = Slimmer::Artefact.new(@data)
61
+ end
62
+
63
+ it "should return corresponding field" do
64
+ assert_equal @data["title"], @a.title
65
+ assert_equal "bar", @a.foo
66
+ end
67
+
68
+ it "should return the corresponding field from details if it doesn't exist at the top level" do
69
+ @data["details"]["foo"] = "baz"
70
+ assert_equal @data["details"]["need_id"], @a.need_id
71
+ assert_equal "bar", @a.foo
72
+ end
73
+
74
+ it "should return nil if the field doesn't exist" do
75
+ assert_equal nil, @a.non_existent
76
+ end
77
+ end
78
+ end
@@ -1,3 +1,4 @@
1
+ <!-- Whilst they are both in use, this and the copy in static should be kept in sync -->
1
2
  <% if artefact %>
2
3
 
3
4
  <!-- related -->
@@ -6,27 +7,50 @@
6
7
 
7
8
  <div class="related">
8
9
  <div class="inner group">
9
- <h2>Related topics</h2>
10
+ <h2>More like this:</h2>
10
11
  <nav role="navigation">
11
12
  <ul>
12
- <% if artefact["related_items"].any? %>
13
- <% artefact["related_items"].each do |item| %>
14
- <% if item["artefact"] %>
15
- <li class="<%= h item["artefact"]["kind"] %>">
16
- <a href="/<%= h item["artefact"]["slug"] %>"><%= h item["artefact"]["name"] %></a>
17
- </li>
13
+ <!-- Content API style Artefact -->
14
+ <% if artefact["related"] %>
15
+ <% if artefact["related"].any? %>
16
+ <% artefact["related"].each do |item| %>
17
+
18
+ <li>
19
+ <a href="<%= h item["web_url"] %>"><%= h item["title"] %></a>
20
+ </li>
21
+ <% end %>
22
+ <% end %>
23
+ <% if root_primary_section %>
24
+ <li class="related-topic"><a href="<%= root_primary_section["content_with_tag"]["web_url"] %>"
25
+ >More from the <span><%= h root_primary_section["title"] %></span> category</a></li>
26
+ <% end %>
27
+ <% else %> <!-- Panopticon API style Artefact (deprecated) -->
28
+ <% if artefact["related_items"].any? %>
29
+ <% artefact["related_items"].each do |item| %>
30
+ <% if item["artefact"] %>
31
+ <li class="<%= h item["artefact"]["kind"] %>">
32
+ <a href="/<%= h item["artefact"]["slug"] %>"><%= h item["artefact"]["name"] %></a>
33
+ </li>
34
+ <% end %>
18
35
  <% end %>
19
36
  <% end %>
20
- <% end %>
21
37
 
22
- <% if artefact["section"] %>
23
- <% section, subsection = artefact["section"].split(':', 2) %>
24
- <li class="related-topic"><a href="/browse/<%= h section.parameterize %>"
25
- >More from the <span><%= h section %></span> section</a></li>
38
+ <% if artefact["section"] and artefact["section"] != "" %>
39
+ <% section, subsection = artefact["section"].split(':', 2) %>
40
+ <li class="related-topic"><a href="/browse/<%= h section.parameterize %>"
41
+ >More from the <span><%= h section %></span> category</a></li>
42
+ <% end %>
26
43
  <% end %>
27
44
  </ul>
28
45
  </nav>
29
46
  </div>
47
+ <div id="legacy-sources">
48
+ <p>Information from</p>
49
+ <ul>
50
+ <li class="directgov">Directgov</li>
51
+ <li class="businesslink">BusinessLink</li>
52
+ </ul>
53
+ </div>
30
54
  </div>
31
55
 
32
56
  </div>
data/test/headers_test.rb CHANGED
@@ -65,41 +65,16 @@ describe Slimmer::Headers do
65
65
  end
66
66
 
67
67
  describe "setting the artefact header" do
68
-
69
68
  it "should convert a hash to JSON and insert into the header" do
70
- artefact = {"foo" => "bar", "slug" => "vat-rates"}
71
- self.set_slimmer_artefact(artefact)
72
- assert_equal artefact.to_json, headers[Slimmer::Headers::ARTEFACT_HEADER]
73
- end
74
-
75
- it "should convert an OpenStruct to JSON and insert into the header" do
76
- artefact = OpenStruct.new(section: 'missing', need_id: 'missing', kind: 'missing')
69
+ artefact = {"foo" => "bar"}
77
70
  self.set_slimmer_artefact(artefact)
78
71
  assert_equal artefact.to_json, headers[Slimmer::Headers::ARTEFACT_HEADER]
79
72
  end
80
73
 
81
- it "should handle an object that responds to :to_hash" do
82
- hash = {"foo" => "bar", "slug" => "vat-rates"}
83
- artefact = stub("Response", :to_hash => hash)
84
- self.set_slimmer_artefact(artefact)
85
- assert_equal hash.to_json, headers[Slimmer::Headers::ARTEFACT_HEADER]
86
- end
87
-
88
- it "should strip the actions from the artefact" do
89
- artefact = {"foo" => "bar", "slug" => "vat-rates", "actions" => "some_actions"}
90
- self.set_slimmer_artefact(artefact)
91
- assert_equal ({"foo" => "bar", "slug" => "vat-rates"}).to_json, headers[Slimmer::Headers::ARTEFACT_HEADER]
92
- end
93
-
94
- it "should strip the actions from any related items" do
95
- artefact = {"slug" => "vat-rates", "related_items" => [
96
- {"artefact" => {"slug" => 'a-thing', "actions" => "something"}},
97
- {"artefact" => {"slug" => 'another-thing', "actions" => "something else"}}
98
- ]}
74
+ it "should convert an OpenStruct to JSON" do
75
+ artefact = OpenStruct.new("foo" => "bar")
99
76
  self.set_slimmer_artefact(artefact)
100
- assert_equal ({"slug" => "vat-rates", "related_items" => [
101
- {"artefact" => {"slug" => 'a-thing'}}, {"artefact" => {"slug" => 'another-thing'}}
102
- ]}).to_json, headers[Slimmer::Headers::ARTEFACT_HEADER]
77
+ assert_equal({"foo" => "bar"}.to_json, headers[Slimmer::Headers::ARTEFACT_HEADER])
103
78
  end
104
79
 
105
80
  it "should not have side-effects on the passed in hash" do
@@ -1,55 +1,81 @@
1
1
  require_relative "../test_helper.rb"
2
+ require 'gds_api/test_helpers/content_api'
2
3
 
3
4
  describe Slimmer::Processors::LogoClassInserter do
5
+ include GdsApi::TestHelpers::ContentApi
4
6
 
5
- before do
6
- @artefact = {
7
- "slug" => "vat",
8
- "tag_ids" => ['businesslink']
9
- }
10
- @processor = Slimmer::Processors::LogoClassInserter.new(@artefact)
11
- @template = as_nokogiri %{
7
+ def artefact_with_legacy_source_tags(legacy_sources)
8
+ artefact = artefact_for_slug("vat")
9
+ legacy_sources.each do |legacy_source|
10
+ artefact["tags"] << tag_for_slug(legacy_source, "legacy_source")
11
+ end
12
+ artefact
13
+ end
14
+
15
+ def business_link_artefact
16
+ artefact_with_legacy_source_tags(["businesslink"])
17
+ end
18
+
19
+ def directgov_artefact
20
+ artefact_with_legacy_source_tags(["directgov"])
21
+ end
22
+
23
+ def business_link_and_directgov_artefact
24
+ artefact_with_legacy_source_tags(["directgov", "businesslink"])
25
+ end
26
+
27
+ def process(artefact, template)
28
+ Slimmer::Processors::LogoClassInserter.new(artefact).filter(:any_source, template)
29
+ end
30
+
31
+ def example_template
32
+ as_nokogiri %{
12
33
  <html><body><div><div id="wrapper"></div></div></body></html>
13
34
  }
14
35
  end
15
36
 
16
37
  it "should add businesslink class to the wrapper" do
17
- @processor.filter(:any_source, @template)
18
- assert_in @template, "div#wrapper.businesslink"
38
+ template = example_template
39
+ process(business_link_artefact, template)
40
+ assert_in template, "div#wrapper.businesslink"
19
41
  end
20
42
 
21
43
  it "should add multiple classes to the wrapper" do
22
- @artefact["tag_ids"] = ['businesslink', 'directgov']
23
- @processor.filter(:any_source, @template)
24
- assert_in @template, "div#wrapper.businesslink.directgov"
44
+ template = example_template
45
+ artefact = business_link_and_directgov_artefact
46
+ process(artefact, template)
47
+ assert_in template, "div#wrapper.businesslink.directgov"
25
48
  end
26
49
 
27
50
  it "should ignore non-known tags" do
28
- @artefact["tag_ids"] = ['businesslink', 'business', 'fooey']
29
- @processor.filter(:any_source, @template)
30
- assert_in @template, "div#wrapper.businesslink"
31
- assert_not_in @template, "div#wrapper.business"
32
- assert_not_in @template, "div#wrapper.fooey"
51
+ template = example_template
52
+ artefact = artefact_with_legacy_source_tags(["businesslink", "business", "fooey"])
53
+ process(artefact, template)
54
+ assert_in template, "div#wrapper.businesslink"
55
+ assert_not_in template, "div#wrapper.business"
56
+ assert_not_in template, "div#wrapper.fooey"
33
57
  end
34
58
 
35
59
  it "should do nothing if the #wrapper element doesn't exist" do
36
- @template = as_nokogiri %{
60
+ artefact = directgov_artefact
61
+ template = as_nokogiri %{
37
62
  <html><body><div><div id="not_wrapper"></div></div></body></html>
38
63
  }
39
- @processor.filter(:any_source, @template)
40
- assert_in @template, "div#not_wrapper"
41
- assert_not_in @template, "div#wrapper"
64
+ process(artefact, template)
65
+ assert_in template, "div#not_wrapper"
66
+ assert_not_in template, "div#wrapper"
42
67
  end
43
68
 
44
69
  it "should do nothing if the artefact has no tag_ids" do
45
- @artefact.delete("tag_ids")
46
- @processor.filter(:any_source, @template)
47
- assert_in @template, "div#wrapper"
70
+ template = example_template
71
+ artefact = artefact_for_slug("vat")
72
+ process(artefact, template)
73
+ assert_in template, "div#wrapper"
48
74
  end
49
75
 
50
76
  it "should not blow up without an artefact" do
77
+ template = example_template
51
78
  processor = Slimmer::Processors::LogoClassInserter.new(nil)
52
- # assert_nothing_raised
53
- processor.filter(:any_source, @template)
79
+ processor.filter(:any_source, template)
54
80
  end
55
81
  end
@@ -1,19 +1,14 @@
1
1
  require_relative '../test_helper'
2
+ require 'gds_api/test_helpers/content_api'
2
3
 
3
4
  class RelatedItemsInserterTest < MiniTest::Unit::TestCase
5
+ include GdsApi::TestHelpers::ContentApi
4
6
 
5
7
  def setup
6
8
  super
7
9
  @related_template = File.read( File.dirname(__FILE__) + "/../fixtures/related.raw.html.erb" )
8
10
  @skin = stub("Skin", :template => @related_template)
9
- @artefact = {
10
- 'slug' => 'vat',
11
- 'title' => 'VAT',
12
- 'related_items' => [
13
- { 'artefact' => { 'kind' => 'answer', 'name' => 'VAT rates', 'slug' => 'vat-rates' } },
14
- { 'artefact' => { 'kind' => 'guide', 'name' => 'Starting to import', 'slug' => 'starting-to-import' } },
15
- ]
16
- }
11
+ @artefact = artefact_for_slug_with_related_artefacts("vat", ["vat-rates", "starting-to-import"])
17
12
  end
18
13
 
19
14
  def test_should_add_related_items
@@ -34,9 +29,9 @@ class RelatedItemsInserterTest < MiniTest::Unit::TestCase
34
29
  }
35
30
 
36
31
  Slimmer::Processors::RelatedItemsInserter.new(@skin, @artefact).filter(source, template)
37
- assert_in template, "div.related h2", "Related topics"
38
- assert_in template, "div.related nav[role=navigation] ul li.answer:nth-child(1) a[href='/vat-rates']", "VAT rates"
39
- assert_in template, "div.related nav[role=navigation] ul li.guide:nth-child(2) a[href='/starting-to-import']", "Starting to import"
32
+ assert_in template, "div.related h2", "More like this:"
33
+ assert_in template, "div.related nav[role=navigation] ul li:nth-child(1) a[href='https://www.test.gov.uk/vat-rates']", "Vat rates"
34
+ assert_in template, "div.related nav[role=navigation] ul li:nth-child(2) a[href='https://www.test.gov.uk/starting-to-import']", "Starting to import"
40
35
  end
41
36
 
42
37
  def test_should_not_add_related_items_for_non_mainstream_source
data/test/test_helper.rb CHANGED
@@ -6,6 +6,7 @@ require 'webmock/minitest'
6
6
  require 'json'
7
7
  require 'logger'
8
8
  require 'mocha'
9
+ require 'gds_api/test_helpers/content_api'
9
10
 
10
11
  WebMock.disable_net_connect!
11
12
  ENV['FACTER_govuk_platform'] = 'test'
@@ -39,6 +40,7 @@ end
39
40
 
40
41
  class SlimmerIntegrationTest < MiniTest::Unit::TestCase
41
42
  include Rack::Test::Methods
43
+ include GdsApi::TestHelpers::ContentApi
42
44
 
43
45
  # given_response can either be called from a setup method, or in the class scope.
44
46
  # The setup method variant is necessary if you want to pass variables into the call that
@@ -31,8 +31,8 @@ module TypicalUsage
31
31
  assert_rendered_in_template '#unskinned', "Unskinned"
32
32
  end
33
33
 
34
- def test_not_skip_slimmer_in_production
35
- with_rails_env('production') do
34
+ def test_not_skip_slimmer_in_test
35
+ with_rails_env('test') do
36
36
  get "/some-slug?skip_slimmer=1"
37
37
  end
38
38
  assert_rendered_in_template '#wrapper', "Don't template me"
@@ -72,25 +72,8 @@ module TypicalUsage
72
72
  class NormalResponseTest < SlimmerIntegrationTest
73
73
  def setup
74
74
  super
75
- @artefact = {
76
- 'slug' => 'some-slug',
77
- 'title' => 'Example document',
78
- 'primary_section' => 'this_section',
79
- 'related_items' => [
80
- {
81
- 'artefact' => {
82
- 'kind' => 'guide',
83
- 'name' => 'How to test computer software automatically & ensure that 2>1',
84
- 'slug' => 'how-to-test-computer-software-automatically',
85
- }
86
- }
87
- ],
88
- 'tag_ids' => ['this_section', 'directgov'],
89
- 'tags' => [
90
- {"id" => "this_section", "title" => 'This section'},
91
- {"id" => "directgov", "title" => 'Directgov'},
92
- ]
93
- }
75
+ @artefact = artefact_for_slug("some-slug")
76
+ @artefact["tags"] << tag_for_slug("directgov", "legacy_source")
94
77
  given_response 200, %{
95
78
  <html>
96
79
  <head><title>The title of the page</title>
@@ -173,19 +156,7 @@ module TypicalUsage
173
156
 
174
157
  def setup
175
158
  super
176
- @artefact = {
177
- 'slug' => 'some-slug',
178
- 'title' => 'Example document',
179
- 'related_items' => [
180
- {
181
- 'artefact' => {
182
- 'kind' => 'guide',
183
- 'name' => 'How to test computer software automatically & ensure that 2>1',
184
- 'slug' => 'how-to-test-computer-software-automatically',
185
- }
186
- }
187
- ]
188
- }
159
+ @artefact = artefact_for_slug_with_related_artefacts("some-slug", ["how-to-test-computer-software-automatically"])
189
160
  end
190
161
  end
191
162
 
@@ -202,8 +173,8 @@ module TypicalUsage
202
173
  end
203
174
 
204
175
  def test_should_insert_related_items_block
205
- assert_rendered_in_template "div.related nav li.guide a", "How to test computer software automatically &amp; ensure that 2&gt;1"
206
- assert_rendered_in_template "div.related nav li.guide", %r{href="/how-to-test-computer-software-automatically"}
176
+ assert_rendered_in_template "div.related nav li a", "How to test computer software automatically"
177
+ assert_rendered_in_template "div.related nav li", %r{href="https://www.test.gov.uk/how-to-test-computer-software-automatically"}
207
178
  end
208
179
  end
209
180
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.0
5
+ version: 3.0.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-09-10 00:00:00 Z
14
+ date: 2012-09-12 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nokogiri
@@ -134,6 +134,17 @@ dependencies:
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: *id011
137
+ - !ruby/object:Gem::Dependency
138
+ name: gds-api-adapters
139
+ requirement: &id012 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - "="
143
+ - !ruby/object:Gem::Version
144
+ version: 1.9.1
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: *id012
137
148
  description: Rack middleware for skinning pages using a specific template
138
149
  email:
139
150
  - bengriffiths@gmail.com
@@ -171,8 +182,10 @@ files:
171
182
  - lib/slimmer/processors/footer_remover.rb
172
183
  - lib/slimmer/headers.rb
173
184
  - lib/slimmer/version.rb
185
+ - lib/slimmer/artefact.rb
174
186
  - Rakefile
175
187
  - test/headers_test.rb
188
+ - test/artefact_test.rb
176
189
  - test/fixtures/related.raw.html.erb
177
190
  - test/fixtures/500.html.erb
178
191
  - test/fixtures/404.html.erb
@@ -204,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
217
  requirements:
205
218
  - - ">="
206
219
  - !ruby/object:Gem::Version
207
- hash: -2259214820452961452
220
+ hash: -2567614616492657902
208
221
  segments:
209
222
  - 0
210
223
  version: "0"
@@ -213,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
226
  requirements:
214
227
  - - ">="
215
228
  - !ruby/object:Gem::Version
216
- hash: -2259214820452961452
229
+ hash: -2567614616492657902
217
230
  segments:
218
231
  - 0
219
232
  version: "0"
@@ -226,6 +239,7 @@ specification_version: 3
226
239
  summary: Thinner than the skinner
227
240
  test_files:
228
241
  - test/headers_test.rb
242
+ - test/artefact_test.rb
229
243
  - test/fixtures/related.raw.html.erb
230
244
  - test/fixtures/500.html.erb
231
245
  - test/fixtures/404.html.erb