slimmer 3.23.0 → 3.24.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slimmer.rb +0 -1
- data/lib/slimmer/headers.rb +0 -2
- data/lib/slimmer/skin.rb +0 -1
- data/lib/slimmer/version.rb +1 -1
- data/test/headers_test.rb +0 -9
- data/test/test_helper.rb +0 -1
- data/test/typical_usage_test.rb +0 -17
- metadata +4 -10
- data/lib/slimmer/processors/campaign_notification_inserter.rb +0 -27
- data/lib/slimmer/test_templates/campaign.html +0 -1
- data/test/fixtures/campaign.html.erb +0 -1
- data/test/processors/campaign_notification_inserter_test.rb +0 -49
data/lib/slimmer.rb
CHANGED
@@ -29,7 +29,6 @@ module Slimmer
|
|
29
29
|
autoload :BodyClassCopier, 'slimmer/processors/body_class_copier'
|
30
30
|
autoload :BodyInserter, 'slimmer/processors/body_inserter'
|
31
31
|
autoload :ConditionalCommentMover, 'slimmer/processors/conditional_comment_mover'
|
32
|
-
autoload :CampaignNotificationInserter, 'slimmer/processors/campaign_notification_inserter'
|
33
32
|
autoload :FooterRemover, 'slimmer/processors/footer_remover'
|
34
33
|
autoload :GoogleAnalyticsConfigurator, 'slimmer/processors/google_analytics_configurator'
|
35
34
|
autoload :HeaderContextInserter, 'slimmer/processors/header_context_inserter'
|
data/lib/slimmer/headers.rb
CHANGED
@@ -7,7 +7,6 @@ module Slimmer
|
|
7
7
|
SLIMMER_HEADER_MAPPING = {
|
8
8
|
application_name: "Application-Name",
|
9
9
|
beta: "Beta",
|
10
|
-
campaign_notification:"Campaign-Notification",
|
11
10
|
format: "Format",
|
12
11
|
need_id: "Need-ID",
|
13
12
|
page_owner: "Page-Owner",
|
@@ -23,7 +22,6 @@ module Slimmer
|
|
23
22
|
APPLICATION_NAME_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:application_name]}"
|
24
23
|
ARTEFACT_HEADER = "#{HEADER_PREFIX}-Artefact"
|
25
24
|
BETA_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:beta]}"
|
26
|
-
CAMPAIGN_NOTIFICATION = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:campaign_notification]}"
|
27
25
|
FORMAT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:format]}"
|
28
26
|
ORGANISATIONS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:organisations]}"
|
29
27
|
PAGE_OWNER_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:page_owner]}"
|
data/lib/slimmer/skin.rb
CHANGED
@@ -130,7 +130,6 @@ module Slimmer
|
|
130
130
|
Processors::ReportAProblemInserter.new(self, source_request.url, response.headers),
|
131
131
|
Processors::SearchIndexSetter.new(response),
|
132
132
|
Processors::MetaViewportRemover.new(response),
|
133
|
-
Processors::CampaignNotificationInserter.new(self, response.headers),
|
134
133
|
Processors::BetaNoticeInserter.new(self, response.headers),
|
135
134
|
]
|
136
135
|
|
data/lib/slimmer/version.rb
CHANGED
data/test/headers_test.rb
CHANGED
@@ -73,15 +73,6 @@ class HeadersTest < MiniTest::Unit::TestCase
|
|
73
73
|
set_slimmer_headers remove_meta_viewport: true
|
74
74
|
assert_equal "true", headers["X-Slimmer-Remove-Meta-Viewport"]
|
75
75
|
end
|
76
|
-
|
77
|
-
def test_should_not_have_campaign_notification_set
|
78
|
-
assert_equal nil, headers["X-Slimmer-Campaign-Notification"]
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_should_set_campaign_notification_header
|
82
|
-
set_slimmer_headers campaign_notification: true
|
83
|
-
assert_equal "true", headers["X-Slimmer-Campaign-Notification"]
|
84
|
-
end
|
85
76
|
end
|
86
77
|
|
87
78
|
describe Slimmer::Headers do
|
data/test/test_helper.rb
CHANGED
data/test/typical_usage_test.rb
CHANGED
@@ -412,21 +412,4 @@ module TypicalUsage
|
|
412
412
|
assert_equal "Something else", last_response.headers["X-Custom-Header"]
|
413
413
|
end
|
414
414
|
end
|
415
|
-
|
416
|
-
class CampaignNotificationInserterTest < SlimmerIntegrationTest
|
417
|
-
def test_should_update_the_campaign_with_a_notification
|
418
|
-
given_response 200, %{
|
419
|
-
<html>
|
420
|
-
<body>
|
421
|
-
<div id="wrapper">
|
422
|
-
<section class="main-campaign group"><a href="/tour">A tour!</a></section>
|
423
|
-
</div>
|
424
|
-
</body>
|
425
|
-
</html>
|
426
|
-
},
|
427
|
-
{Slimmer::Headers::CAMPAIGN_NOTIFICATION => "true"}
|
428
|
-
|
429
|
-
assert_rendered_in_template "#campaign-notification", "<p>testing...</p>"
|
430
|
-
end
|
431
|
-
end
|
432
415
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.24.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -251,7 +251,6 @@ files:
|
|
251
251
|
- lib/slimmer/headers.rb
|
252
252
|
- lib/slimmer/skin.rb
|
253
253
|
- lib/slimmer/app.rb
|
254
|
-
- lib/slimmer/test_templates/campaign.html
|
255
254
|
- lib/slimmer/test_templates/header_footer_only.html
|
256
255
|
- lib/slimmer/test_templates/wrapper.html
|
257
256
|
- lib/slimmer/test_templates/beta_notice.html
|
@@ -259,7 +258,6 @@ files:
|
|
259
258
|
- lib/slimmer/version.rb
|
260
259
|
- lib/slimmer/artefact.rb
|
261
260
|
- lib/slimmer/template.rb
|
262
|
-
- lib/slimmer/processors/campaign_notification_inserter.rb
|
263
261
|
- lib/slimmer/processors/header_context_inserter.rb
|
264
262
|
- lib/slimmer/processors/navigation_mover.rb
|
265
263
|
- lib/slimmer/processors/google_analytics_configurator.rb
|
@@ -288,7 +286,6 @@ files:
|
|
288
286
|
- test/fixtures/proposition_menu.html.erb
|
289
287
|
- test/fixtures/404.html.erb
|
290
288
|
- test/fixtures/report_a_problem.raw.html.erb
|
291
|
-
- test/fixtures/campaign.html.erb
|
292
289
|
- test/fixtures/related.raw.html.erb
|
293
290
|
- test/fixtures/beta_notice.html.erb
|
294
291
|
- test/headers_test.rb
|
@@ -302,7 +299,6 @@ files:
|
|
302
299
|
- test/processors/search_path_setter_test.rb
|
303
300
|
- test/processors/google_analytics_test.rb
|
304
301
|
- test/processors/meta_viewport_remover_test.rb
|
305
|
-
- test/processors/campaign_notification_inserter_test.rb
|
306
302
|
- test/processors/section_inserter_test.rb
|
307
303
|
- test/processors/report_a_problem_inserter_test.rb
|
308
304
|
- test/processors/tag_mover_test.rb
|
@@ -322,7 +318,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
322
318
|
version: '0'
|
323
319
|
segments:
|
324
320
|
- 0
|
325
|
-
hash: -
|
321
|
+
hash: -3770913411525795405
|
326
322
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
327
323
|
none: false
|
328
324
|
requirements:
|
@@ -331,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
327
|
version: '0'
|
332
328
|
segments:
|
333
329
|
- 0
|
334
|
-
hash: -
|
330
|
+
hash: -3770913411525795405
|
335
331
|
requirements: []
|
336
332
|
rubyforge_project: slimmer
|
337
333
|
rubygems_version: 1.8.23
|
@@ -347,7 +343,6 @@ test_files:
|
|
347
343
|
- test/fixtures/proposition_menu.html.erb
|
348
344
|
- test/fixtures/404.html.erb
|
349
345
|
- test/fixtures/report_a_problem.raw.html.erb
|
350
|
-
- test/fixtures/campaign.html.erb
|
351
346
|
- test/fixtures/related.raw.html.erb
|
352
347
|
- test/fixtures/beta_notice.html.erb
|
353
348
|
- test/headers_test.rb
|
@@ -361,7 +356,6 @@ test_files:
|
|
361
356
|
- test/processors/search_path_setter_test.rb
|
362
357
|
- test/processors/google_analytics_test.rb
|
363
358
|
- test/processors/meta_viewport_remover_test.rb
|
364
|
-
- test/processors/campaign_notification_inserter_test.rb
|
365
359
|
- test/processors/section_inserter_test.rb
|
366
360
|
- test/processors/report_a_problem_inserter_test.rb
|
367
361
|
- test/processors/tag_mover_test.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Slimmer::Processors
|
2
|
-
class CampaignNotificationInserter
|
3
|
-
def initialize(skin, headers)
|
4
|
-
@headers = headers
|
5
|
-
@skin = skin
|
6
|
-
@old_campaign_selector = ".main-campaign"
|
7
|
-
@new_campaign_selector = "#campaign-notification"
|
8
|
-
end
|
9
|
-
|
10
|
-
def filter(content_document, page_template)
|
11
|
-
if @headers[Slimmer::Headers::CAMPAIGN_NOTIFICATION] == "true" &&
|
12
|
-
old_campaign = page_template.at_css(@old_campaign_selector)
|
13
|
-
new_campaign_block = campaign_notification_block
|
14
|
-
if new_campaign_block.at_css(@new_campaign_selector)
|
15
|
-
old_campaign.replace(new_campaign_block)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def campaign_notification_block
|
23
|
-
html = @skin.template('campaign')
|
24
|
-
Nokogiri::HTML.fragment(html)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<section class="black" id="campaign-notification"><div><p>Notifications!</p></div></section>
|
@@ -1 +0,0 @@
|
|
1
|
-
<section id="campaign-notification"><p>testing...</p></section>
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class CampaignNotificationInserterTest < MiniTest::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@skin = stub("Skin", :template => nil)
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_should_not_replace_campaign_if_header_not_set
|
9
|
-
@skin.expects(:template).with("campaign").never
|
10
|
-
campaign_inserter = Slimmer::Processors::CampaignNotificationInserter.new(@skin, {})
|
11
|
-
|
12
|
-
source = as_nokogiri %{
|
13
|
-
<html>
|
14
|
-
<body>
|
15
|
-
<section class="main-campaign group"><a href="/tour">A tour!</a></section>
|
16
|
-
</body>
|
17
|
-
</html>
|
18
|
-
}
|
19
|
-
expected = as_nokogiri %{
|
20
|
-
<html>
|
21
|
-
<body>
|
22
|
-
<section class="main-campaign group"><a href="/tour">A tour!</a></section>
|
23
|
-
</body>
|
24
|
-
</html>
|
25
|
-
}
|
26
|
-
|
27
|
-
campaign_inserter.filter(:any_source, source)
|
28
|
-
assert_equal expected.to_html, source.to_html
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_should_replace_campaign_with_notification_if_header_set
|
32
|
-
campaign = '<section id="campaign-notification"><p>testing...</p></section>'
|
33
|
-
@skin.expects(:template).with('campaign').returns(campaign)
|
34
|
-
|
35
|
-
headers = {Slimmer::Headers::CAMPAIGN_NOTIFICATION => "true"}
|
36
|
-
campaign_inserter = Slimmer::Processors::CampaignNotificationInserter.new(@skin, headers)
|
37
|
-
|
38
|
-
source = as_nokogiri %{
|
39
|
-
<html><body><section class="main-campaign group"><a href="/tour">A tour!</a></section></body></html>
|
40
|
-
}
|
41
|
-
|
42
|
-
expected = as_nokogiri %{
|
43
|
-
<html><body><section id="campaign-notification"><p>testing...</p></section></body></html>
|
44
|
-
}
|
45
|
-
|
46
|
-
campaign_inserter.filter(:any_source, source)
|
47
|
-
assert_equal expected.to_html.gsub(/\n/," ").strip, source.to_html.gsub(/\n/," ").strip
|
48
|
-
end
|
49
|
-
end
|