slimmer 3.13.0 → 3.13.1
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/lib/slimmer/headers.rb +10 -9
- data/lib/slimmer/version.rb +1 -1
- data/test/headers_test.rb +20 -8
- metadata +49 -49
data/lib/slimmer/headers.rb
CHANGED
@@ -43,24 +43,25 @@ module Slimmer
|
|
43
43
|
elsif artefact_input.respond_to?(:to_hash)
|
44
44
|
artefact = artefact_input.to_hash
|
45
45
|
end
|
46
|
+
yield artefact if block_given?
|
46
47
|
headers[ARTEFACT_HEADER] = artefact.to_json
|
47
48
|
end
|
48
49
|
|
49
50
|
def set_slimmer_artefact_overriding_section(artefact_input, details = {})
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
set_slimmer_artefact(artefact_input) do |artefact|
|
52
|
+
if tag = slimmer_section_tag_for_details(details)
|
53
|
+
artefact["tags"] = [tag] + (artefact["tags"] || [])
|
54
|
+
end
|
53
55
|
end
|
54
|
-
set_slimmer_artefact(artefact_input)
|
55
56
|
end
|
56
57
|
|
57
58
|
def set_slimmer_dummy_artefact(details = {})
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
set_slimmer_artefact({}) do |artefact|
|
60
|
+
artefact["title"] = details[:title] if details[:title]
|
61
|
+
if tag = slimmer_section_tag_for_details(details)
|
62
|
+
artefact["tags"] = [tag]
|
63
|
+
end
|
62
64
|
end
|
63
|
-
set_slimmer_artefact(artefact)
|
64
65
|
end
|
65
66
|
|
66
67
|
def slimmer_section_tag_for_details(details)
|
data/lib/slimmer/version.rb
CHANGED
data/test/headers_test.rb
CHANGED
@@ -117,8 +117,8 @@ describe Slimmer::Headers do
|
|
117
117
|
|
118
118
|
describe "setting the artefact and adding a dummy section" do
|
119
119
|
it "should setup a section tag for the given name and link" do
|
120
|
-
|
121
|
-
self.set_slimmer_artefact_overriding_section(
|
120
|
+
artefact_input = {"foo" => "bar", "slug" => "vat-rates", "actions" => "some_actions"}
|
121
|
+
self.set_slimmer_artefact_overriding_section(artefact_input, :section_name => "Foo", :section_link => "/something/foo")
|
122
122
|
|
123
123
|
artefact = JSON.parse(headers[Slimmer::Headers::ARTEFACT_HEADER])
|
124
124
|
|
@@ -128,8 +128,8 @@ describe Slimmer::Headers do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should not overwrite existing tags" do
|
131
|
-
|
132
|
-
self.set_slimmer_artefact_overriding_section(
|
131
|
+
artefact_input = {"foo" => "bar", "slug" => "vat-rates", "actions" => "some_actions", "tags" => ["foo", "bar"]}
|
132
|
+
self.set_slimmer_artefact_overriding_section(artefact_input, :section_name => "Foo", :section_link => "/something/foo")
|
133
133
|
|
134
134
|
artefact = JSON.parse(headers[Slimmer::Headers::ARTEFACT_HEADER])
|
135
135
|
|
@@ -137,10 +137,22 @@ describe Slimmer::Headers do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should not have side-effects on the passed in hash" do
|
140
|
-
|
141
|
-
artefact_copy =
|
142
|
-
self.set_slimmer_artefact_overriding_section(
|
143
|
-
assert_equal artefact_copy,
|
140
|
+
artefact_input = {"foo" => "bar", "slug" => "vat-rates", "actions" => "some_actions"}
|
141
|
+
artefact_copy = artefact_input.dup
|
142
|
+
self.set_slimmer_artefact_overriding_section(artefact_input, :section_name => "Foo", :section_link => "/foo")
|
143
|
+
assert_equal artefact_copy, artefact_input
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should work correctly with a gds_api response object" do
|
147
|
+
input_artefact = {"foo" => "bar", "slug" => "vat-rates", "actions" => "some_actions"}
|
148
|
+
api_response = GdsApi::Response.new(stub("HTTP Response", :code => 200, :body => input_artefact.to_json))
|
149
|
+
self.set_slimmer_artefact_overriding_section(api_response, :section_name => "Foo", :section_link => "/something/foo")
|
150
|
+
|
151
|
+
artefact = JSON.parse(headers[Slimmer::Headers::ARTEFACT_HEADER])
|
152
|
+
|
153
|
+
assert_equal "Foo", artefact["tags"][0]["title"]
|
154
|
+
assert_equal "section", artefact["tags"][0]["details"]["type"]
|
155
|
+
assert_equal "/something/foo", artefact["tags"][0]["content_with_tag"]["web_url"]
|
144
156
|
end
|
145
157
|
end
|
146
158
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.13.
|
5
|
+
version: 3.13.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Griffiths
|
@@ -180,57 +180,57 @@ extra_rdoc_files: []
|
|
180
180
|
files:
|
181
181
|
- README.md
|
182
182
|
- CHANGELOG.md
|
183
|
-
- lib/
|
183
|
+
- lib/slimmer.rb
|
184
|
+
- lib/slimmer/app.rb
|
185
|
+
- lib/slimmer/test_template.rb
|
184
186
|
- lib/slimmer/version.rb
|
187
|
+
- lib/slimmer/railtie.rb
|
188
|
+
- lib/slimmer/processors/tag_mover.rb
|
185
189
|
- lib/slimmer/processors/body_class_copier.rb
|
186
|
-
- lib/slimmer/processors/google_analytics_configurator.rb
|
187
|
-
- lib/slimmer/processors/related_items_inserter.rb
|
188
|
-
- lib/slimmer/processors/body_inserter.rb
|
189
190
|
- lib/slimmer/processors/logo_class_inserter.rb
|
190
|
-
- lib/slimmer/processors/report_a_problem_inserter.rb
|
191
|
-
- lib/slimmer/processors/footer_remover.rb
|
192
|
-
- lib/slimmer/processors/campaign_notification_inserter.rb
|
193
|
-
- lib/slimmer/processors/conditional_comment_mover.rb
|
194
191
|
- lib/slimmer/processors/beta_notice_inserter.rb
|
195
|
-
- lib/slimmer/processors/section_inserter.rb
|
196
|
-
- lib/slimmer/processors/tag_mover.rb
|
197
|
-
- lib/slimmer/processors/title_inserter.rb
|
198
|
-
- lib/slimmer/processors/search_index_setter.rb
|
199
192
|
- lib/slimmer/processors/header_context_inserter.rb
|
200
193
|
- lib/slimmer/processors/meta_viewport_remover.rb
|
201
|
-
- lib/slimmer/
|
202
|
-
- lib/slimmer/
|
203
|
-
- lib/slimmer/
|
194
|
+
- lib/slimmer/processors/search_index_setter.rb
|
195
|
+
- lib/slimmer/processors/report_a_problem_inserter.rb
|
196
|
+
- lib/slimmer/processors/campaign_notification_inserter.rb
|
197
|
+
- lib/slimmer/processors/footer_remover.rb
|
198
|
+
- lib/slimmer/processors/google_analytics_configurator.rb
|
199
|
+
- lib/slimmer/processors/title_inserter.rb
|
200
|
+
- lib/slimmer/processors/related_items_inserter.rb
|
201
|
+
- lib/slimmer/processors/section_inserter.rb
|
202
|
+
- lib/slimmer/processors/conditional_comment_mover.rb
|
203
|
+
- lib/slimmer/processors/body_inserter.rb
|
204
204
|
- lib/slimmer/artefact.rb
|
205
205
|
- lib/slimmer/skin.rb
|
206
|
-
- lib/slimmer/app.rb
|
207
206
|
- lib/slimmer/headers.rb
|
208
|
-
- lib/slimmer/
|
209
|
-
- lib/slimmer.rb
|
207
|
+
- lib/slimmer/template.rb
|
208
|
+
- lib/slimmer/test.rb
|
209
|
+
- lib/tasks/slimmer.rake
|
210
210
|
- Rakefile
|
211
|
+
- test/processors/header_context_inserter_test.rb
|
212
|
+
- test/processors/google_analytics_test.rb
|
213
|
+
- test/processors/body_inserter_test.rb
|
214
|
+
- test/processors/search_index_setter_test.rb
|
211
215
|
- test/processors/meta_viewport_remover_test.rb
|
212
|
-
- test/processors/related_items_inserter_test.rb
|
213
216
|
- test/processors/report_a_problem_inserter_test.rb
|
214
217
|
- test/processors/section_inserter_test.rb
|
215
|
-
- test/processors/google_analytics_test.rb
|
216
|
-
- test/processors/search_index_setter_test.rb
|
217
|
-
- test/processors/header_context_inserter_test.rb
|
218
|
-
- test/processors/body_inserter_test.rb
|
219
|
-
- test/processors/logo_class_inserter_test.rb
|
220
218
|
- test/processors/campaign_notification_inserter_test.rb
|
221
|
-
- test/
|
222
|
-
- test/
|
223
|
-
- test/headers_test.rb
|
219
|
+
- test/processors/related_items_inserter_test.rb
|
220
|
+
- test/processors/logo_class_inserter_test.rb
|
224
221
|
- test/test_template_dependency_on_static_test.rb
|
222
|
+
- test/headers_test.rb
|
223
|
+
- test/test_helper.rb
|
225
224
|
- test/typical_usage_test.rb
|
226
|
-
- test/
|
225
|
+
- test/artefact_test.rb
|
226
|
+
- test/skin_test.rb
|
227
|
+
- test/fixtures/campaign.html.erb
|
227
228
|
- test/fixtures/404.html.erb
|
228
229
|
- test/fixtures/beta_notice.html.erb
|
229
|
-
- test/fixtures/
|
230
|
-
- test/fixtures/campaign.html.erb
|
231
|
-
- test/fixtures/related.raw.html.erb
|
230
|
+
- test/fixtures/500.html.erb
|
232
231
|
- test/fixtures/wrapper.html.erb
|
233
|
-
- test/
|
232
|
+
- test/fixtures/related.raw.html.erb
|
233
|
+
- test/fixtures/report_a_problem.raw.html.erb
|
234
234
|
- bin/render_slimmer_error
|
235
235
|
homepage: http://github.com/alphagov/slimmer
|
236
236
|
licenses: []
|
@@ -245,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
245
|
requirements:
|
246
246
|
- - ">="
|
247
247
|
- !ruby/object:Gem::Version
|
248
|
-
hash:
|
248
|
+
hash: -2221718135592804125
|
249
249
|
segments:
|
250
250
|
- 0
|
251
251
|
version: "0"
|
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
254
|
requirements:
|
255
255
|
- - ">="
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
hash:
|
257
|
+
hash: -2221718135592804125
|
258
258
|
segments:
|
259
259
|
- 0
|
260
260
|
version: "0"
|
@@ -266,26 +266,26 @@ signing_key:
|
|
266
266
|
specification_version: 3
|
267
267
|
summary: Thinner than the skinner
|
268
268
|
test_files:
|
269
|
+
- test/processors/header_context_inserter_test.rb
|
270
|
+
- test/processors/google_analytics_test.rb
|
271
|
+
- test/processors/body_inserter_test.rb
|
272
|
+
- test/processors/search_index_setter_test.rb
|
269
273
|
- test/processors/meta_viewport_remover_test.rb
|
270
|
-
- test/processors/related_items_inserter_test.rb
|
271
274
|
- test/processors/report_a_problem_inserter_test.rb
|
272
275
|
- test/processors/section_inserter_test.rb
|
273
|
-
- test/processors/google_analytics_test.rb
|
274
|
-
- test/processors/search_index_setter_test.rb
|
275
|
-
- test/processors/header_context_inserter_test.rb
|
276
|
-
- test/processors/body_inserter_test.rb
|
277
|
-
- test/processors/logo_class_inserter_test.rb
|
278
276
|
- test/processors/campaign_notification_inserter_test.rb
|
279
|
-
- test/
|
280
|
-
- test/
|
281
|
-
- test/headers_test.rb
|
277
|
+
- test/processors/related_items_inserter_test.rb
|
278
|
+
- test/processors/logo_class_inserter_test.rb
|
282
279
|
- test/test_template_dependency_on_static_test.rb
|
280
|
+
- test/headers_test.rb
|
281
|
+
- test/test_helper.rb
|
283
282
|
- test/typical_usage_test.rb
|
284
|
-
- test/
|
283
|
+
- test/artefact_test.rb
|
284
|
+
- test/skin_test.rb
|
285
|
+
- test/fixtures/campaign.html.erb
|
285
286
|
- test/fixtures/404.html.erb
|
286
287
|
- test/fixtures/beta_notice.html.erb
|
287
|
-
- test/fixtures/
|
288
|
-
- test/fixtures/campaign.html.erb
|
289
|
-
- test/fixtures/related.raw.html.erb
|
288
|
+
- test/fixtures/500.html.erb
|
290
289
|
- test/fixtures/wrapper.html.erb
|
291
|
-
- test/
|
290
|
+
- test/fixtures/related.raw.html.erb
|
291
|
+
- test/fixtures/report_a_problem.raw.html.erb
|