Skip to content
This repository
Browse code

Merge pull request #14 from alphagov/remove_breadcrumb_title

reviewed by @daibach
  • Loading branch information...
commit fe77b802503521f5f19d9eab15ea0178632d98d0 2 parents 9a65d62 + 95e1d71
Alex Tomlins alext authored
8 lib/slimmer/processors/section_inserter.rb
@@ -10,7 +10,6 @@ def filter(src,dest)
10 10 append_tag(list, section["parent"]) if section["parent"]
11 11 append_tag(list, section)
12 12 end
13   - append_text(list, @artefact.title) if @artefact.title and @artefact.title !~ /\A\s*\z/
14 13 end
15 14 end
16 15
@@ -26,12 +25,5 @@ def append_tag(list, tag)
26 25
27 26 list.add_child(list_item)
28 27 end
29   -
30   - def append_text(list, text)
31   - list_item = Nokogiri::XML::Node.new('li', list)
32   - list_item.content = text
33   -
34   - list.add_child(list_item)
35   - end
36 28 end
37 29 end
49 test/processors/section_inserter_test.rb
@@ -19,8 +19,7 @@ def create_artefact(slug, attributes = {})
19 19
20 20 def test_should_add_section_link_and_title_to_breadcrumb
21 21 artefact = create_artefact("something",
22   - "section_slug" => "business",
23   - "title" => "Something gooey")
  22 + "section_slug" => "business")
24 23
25 24 template = as_nokogiri %{
26 25 <html>
@@ -40,14 +39,12 @@ def test_should_add_section_link_and_title_to_breadcrumb
40 39 list = template.at_css(".header-context nav[role=navigation] ol")
41 40 assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
42 41 assert_in list, "li:nth-child(2)", %{<a href="https://www.test.gov.uk/browse/business">Business</a>}
43   - assert_in list, "li:nth-child(3)", %{Something gooey}
44 42 end
45 43
46 44 def test_should_add_section_link_subsection_link_and_title_to_breadcrumb
47 45 artefact = create_artefact("something",
48 46 "section_slug" => "business",
49   - "subsection_slug" => "employing-people",
50   - "title" => "Something gooey")
  47 + "subsection_slug" => "employing-people")
51 48
52 49 template = as_nokogiri %{
53 50 <html>
@@ -66,47 +63,12 @@ def test_should_add_section_link_subsection_link_and_title_to_breadcrumb
66 63 assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
67 64 assert_in list, "li:nth-child(2)", %{<a href="https://www.test.gov.uk/browse/business">Business</a>}
68 65 assert_in list, "li:nth-child(3)", %{<a href="https://www.test.gov.uk/browse/business/employing-people">Employing people</a>}
69   - assert_in list, "li:nth-child(4)", %{Something gooey}
70   - end
71   -
72   - def test_should_not_append_title_if_its_blank
73   - artefact = create_artefact("something",
74   - "section_slug" => "business",
75   - "subsection_slug" => "employing-people",
76   - "title" => nil)
77   -
78   - template = as_nokogiri %{
79   - <html>
80   - <body>
81   - <div class="header-context">
82   - <nav role="navigation">
83   - <ol class="group"><li><a href="/">Home</a></li></ol>
84   - </nav>
85   - </div>
86   - </body>
87   - </html>
88   - }
89   -
90   - t = template.dup
91   - Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, t)
92   - list = t.at_css(".header-context nav[role=navigation] ol")
93   - assert_not_in list, "li:nth-child(4)"
94   -
95   - artefact = create_artefact("something",
96   - "section_slug" => "business",
97   - "subsection_slug" => "employing-people",
98   - "title" => "")
99   -
100   - Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
101   - list = template.at_css(".header-context nav[role=navigation] ol")
102   - assert_not_in list, "li:nth-child(4)"
103 66 end
104 67
105 68 def test_should_add_links_after_last_item_in_breadcrumb
106 69 artefact = create_artefact("something",
107 70 "section_slug" => "business",
108   - "subsection_slug" => "employing-people",
109   - "title" => "Something gooey")
  71 + "subsection_slug" => "employing-people")
110 72
111 73 template = as_nokogiri %{
112 74 <html>
@@ -129,7 +91,6 @@ def test_should_add_links_after_last_item_in_breadcrumb
129 91 assert_in list, "li:nth-child(2)", %{<a href="/browse">All Sections</a>}
130 92 assert_in list, "li:nth-child(3)", %{<a href="https://www.test.gov.uk/browse/business">Business</a>}
131 93 assert_in list, "li:nth-child(4)", %{<a href="https://www.test.gov.uk/browse/business/employing-people">Employing people</a>}
132   - assert_in list, "li:nth-child(5)", %{Something gooey}
133 94 end
134 95
135 96 def test_should_do_nothing_if_navigation_not_in_template
@@ -165,8 +126,7 @@ def test_should_do_nothing_with_no_artefact
165 126 end
166 127
167 128 def test_should_not_fail_with_no_sections
168   - artefact = create_artefact("something",
169   - "title" => "Something gooey")
  129 + artefact = create_artefact("something")
170 130
171 131 template = as_nokogiri %{
172 132 <html>
@@ -185,6 +145,5 @@ def test_should_not_fail_with_no_sections
185 145 Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
186 146 list = template.at_css(".header-context nav[role=navigation] ol")
187 147 assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
188   - assert_in list, "li:nth-child(2)", %{Something gooey}
189 148 end
190 149 end
1  test/typical_usage_test.rb
@@ -112,7 +112,6 @@ def test_should_copy_the_class_of_the_body_element
112 112
113 113 def test_should_insert_section_links_into_the_navigation
114 114 assert_rendered_in_template "nav[role=navigation] li a[href='https://www.test.gov.uk/browse/this-section']", "This section"
115   - assert_rendered_in_template "nav[role=navigation] li:last-child", "Some article"
116 115 end
117 116
118 117 def test_should_add_logo_classes_to_wrapper

0 comments on commit fe77b80

Please sign in to comment.
Something went wrong with that request. Please try again.