slimmer 10.0.0 → 10.1.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +6 -31
  4. data/Rakefile +0 -6
  5. data/lib/slimmer.rb +12 -2
  6. data/lib/slimmer/app.rb +1 -4
  7. data/lib/slimmer/component_resolver.rb +2 -6
  8. data/lib/slimmer/govuk_components.rb +12 -0
  9. data/lib/slimmer/govuk_request_id.rb +0 -5
  10. data/lib/slimmer/headers.rb +42 -0
  11. data/lib/slimmer/http_client.rb +16 -0
  12. data/lib/slimmer/i18n_backend.rb +3 -10
  13. data/lib/slimmer/skin.rb +3 -7
  14. data/lib/slimmer/version.rb +1 -1
  15. metadata +20 -72
  16. data/lib/slimmer/cache.rb +0 -46
  17. data/test/cache_test.rb +0 -53
  18. data/test/changelog_test.rb +0 -10
  19. data/test/component_resolver_test.rb +0 -41
  20. data/test/fixtures/404.html.erb +0 -13
  21. data/test/fixtures/410.html.erb +0 -13
  22. data/test/fixtures/500.html.erb +0 -13
  23. data/test/fixtures/core_layout.html.erb +0 -19
  24. data/test/fixtures/proposition_menu.html.erb +0 -7
  25. data/test/fixtures/report_a_problem.raw.html.erb +0 -23
  26. data/test/headers_test.rb +0 -57
  27. data/test/processors/body_inserter_test.rb +0 -43
  28. data/test/processors/header_context_inserter_test.rb +0 -51
  29. data/test/processors/inside_header_inserter_test.rb +0 -35
  30. data/test/processors/metadata_inserter_test.rb +0 -86
  31. data/test/processors/navigation_mover_test.rb +0 -53
  32. data/test/processors/report_a_problem_inserter_test.rb +0 -75
  33. data/test/processors/search_parameter_inserter_test.rb +0 -39
  34. data/test/processors/search_path_setter_test.rb +0 -39
  35. data/test/processors/search_remover_test.rb +0 -62
  36. data/test/processors/tag_mover_test.rb +0 -95
  37. data/test/skin_test.rb +0 -99
  38. data/test/test_helper.rb +0 -136
  39. data/test/test_helpers/govuk_components_test.rb +0 -19
  40. data/test/test_template_dependency_on_static_test.rb +0 -25
  41. data/test/typical_usage_test.rb +0 -358
data/test/skin_test.rb DELETED
@@ -1,99 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- describe Slimmer::Skin do
4
-
5
- describe "loading templates" do
6
- it "should be able to load the template" do
7
- skin = Slimmer::Skin.new asset_host: "http://example.local/", cache: Slimmer::Cache.instance
8
-
9
- expected_url = "http://example.local/templates/example.html.erb"
10
- stub_request(:get, expected_url).to_return :body => "<foo />"
11
-
12
- template = skin.template 'example'
13
-
14
- assert_requested :get, expected_url
15
- assert_equal "<foo />", template
16
- end
17
-
18
- describe "should pass the GOVUK-Request-Id header when requesting the template" do
19
- before do
20
- @skin = Slimmer::Skin.new asset_host: "http://example.local/", cache: Slimmer::Cache.instance
21
-
22
- @expected_url = "http://example.local/templates/example.html.erb"
23
- stub_request(:get, @expected_url).to_return :body => "<foo />"
24
- end
25
-
26
- it "should pass the value from the original request if set" do
27
- Slimmer::GovukRequestId.value = '12345'
28
- template = @skin.template('example')
29
-
30
- assert_requested :get, @expected_url do |request|
31
- request.headers['Govuk-Request-Id'] == '12345'
32
- end
33
- assert_equal "<foo />", template
34
- end
35
-
36
- it "shouldnot set the header if the value is not set" do
37
- Slimmer::GovukRequestId.value = ''
38
- template = @skin.template('example')
39
-
40
- assert_requested :get, @expected_url do |request|
41
- ! request.headers.has_key?('Govuk-Request-Id')
42
- end
43
- assert_equal "<foo />", template
44
- end
45
- end
46
-
47
- it "should try and load templates from the cache" do
48
- skin = Slimmer::Skin.new asset_host: "http://example.local/", cache: Slimmer::Cache.instance
49
-
50
- Slimmer::Cache.instance.expects(:fetch).with('example-template').returns('cache data')
51
- template = skin.template 'example-template'
52
- assert_equal 'cache data', template
53
- end
54
-
55
- it "should raise appropriate exception when template not found" do
56
- skin = Slimmer::Skin.new asset_host: "http://example.local/", cache: Slimmer::Cache.instance
57
-
58
- expected_url = "http://example.local/templates/example.html.erb"
59
- stub_request(:get, expected_url).to_return(:status => '404')
60
-
61
- assert_raises(Slimmer::TemplateNotFoundException) do
62
- skin.template 'example'
63
- end
64
- end
65
-
66
- it "should raise appropriate exception when cant reach template host" do
67
- skin = Slimmer::Skin.new asset_host: "http://example.local/", cache: Slimmer::Cache.instance
68
-
69
- expected_url = "http://example.local/templates/example.html.erb"
70
- stub_request(:get, expected_url).to_raise(Errno::ECONNREFUSED)
71
-
72
- assert_raises(Slimmer::CouldNotRetrieveTemplate) do
73
- skin.template 'example'
74
- end
75
- end
76
-
77
- it "should raise appropriate exception when hostname cannot be resolved" do
78
- skin = Slimmer::Skin.new asset_host: "http://non-existent.domain/", cache: Slimmer::Cache.instance
79
-
80
- expected_url = "http://non-existent.domain/templates/example.html.erb"
81
- stub_request(:get, expected_url).to_raise(SocketError)
82
-
83
- assert_raises(Slimmer::CouldNotRetrieveTemplate) do
84
- skin.template 'example'
85
- end
86
- end
87
-
88
- it "should raise appropriate exception when encountering an SSL error" do
89
- skin = Slimmer::Skin.new asset_host: "https://bad-ssl.domain/", cache: Slimmer::Cache.instance
90
-
91
- expected_url = "https://bad-ssl.domain/templates/example.html.erb"
92
- stub_request(:get, expected_url).to_raise(OpenSSL::SSL::SSLError)
93
-
94
- assert_raises(Slimmer::CouldNotRetrieveTemplate) do
95
- skin.template 'example'
96
- end
97
- end
98
- end
99
- end
data/test/test_helper.rb DELETED
@@ -1,136 +0,0 @@
1
- require_relative '../lib/slimmer'
2
- require 'minitest/autorun'
3
- require 'rack/test'
4
- require 'json'
5
- require 'logger'
6
- require 'mocha/setup'
7
- require 'timecop'
8
-
9
- MiniTest::Test.class_eval do
10
- def as_nokogiri(html_string)
11
- Nokogiri::HTML.parse(html_string.strip)
12
- end
13
-
14
- def assert_in(template, selector, content=nil, message=nil)
15
- message ||= "Expected to find #{content ? "#{content.inspect} at " : ""}#{selector.inspect} in the output template"
16
-
17
- assert template.at_css(selector), message + ", but selector not found."
18
-
19
- if content
20
- assert_equal content, template.at_css(selector).inner_html.to_s, message
21
- end
22
- end
23
-
24
- def assert_not_in(template, selector, message="didn't expect to find #{selector}")
25
- refute template.at_css(selector), message
26
- end
27
-
28
- def allowing_real_web_connections(&block)
29
- WebMock.allow_net_connect!
30
- result = yield
31
- WebMock.disable_net_connect!
32
- result
33
- end
34
-
35
- def teardown
36
- Timecop.return
37
- end
38
- end
39
-
40
- require 'webmock/minitest'
41
- WebMock.disable_net_connect!
42
-
43
- # Including action_view is dificualt because it depends on rails and internal
44
- # ~*magic*~. To avoid depending on the whole of rails mock out the method we
45
- # need so we can tests the internal implementations which don't depend on rails
46
- module ActionView
47
- class Resolver
48
- end
49
- class Template
50
- attr_reader :args
51
- def initialize(*args)
52
- @args = args
53
- end
54
- def self.registered_template_handler(*args)
55
- args
56
- end
57
- end
58
- end
59
-
60
- class SlimmerIntegrationTest < MiniTest::Test
61
- include Rack::Test::Methods
62
-
63
- # given_response can either be called from a setup method, or in the class scope.
64
- # The setup method variant is necessary if you want to pass variables into the call that
65
- # are created in higher setup methods.
66
- def self.given_response(code, body, headers={}, app_options={})
67
- define_method(:setup) do
68
- super()
69
- given_response(code, body, headers, app_options)
70
- end
71
- end
72
-
73
- def given_response(code, body, headers={}, app_options={})
74
- self.class.class_eval do
75
- define_method(:app) do
76
- inner_app = proc { |env|
77
- [code, {"Content-Type" => "text/html"}.merge(headers), body]
78
- }
79
- Slimmer::App.new inner_app, {asset_host: "http://template.local"}.merge(app_options)
80
- end
81
- end
82
-
83
- template_name = case code
84
- when 200 then 'core_layout'
85
- when 404 then '404'
86
- when 410 then '410'
87
- else '500'
88
- end
89
-
90
- use_template(template_name)
91
- use_template('report_a_problem.raw')
92
-
93
- fetch_page
94
- end
95
-
96
- def fetch_page
97
- get "/"
98
- end
99
-
100
- def use_template(template_name)
101
- template = File.read File.dirname(__FILE__) + "/fixtures/#{template_name}.html.erb"
102
- stub_request(:get, "http://template.local/templates/#{template_name}.html.erb").
103
- to_return(:body => template)
104
- end
105
-
106
- private
107
-
108
- def assert_not_rendered_in_template(content)
109
- refute_match /#{Regexp.escape(content)}/, last_response.body
110
- end
111
-
112
- # content can be a string or a Regexp
113
- def assert_rendered_in_template(selector, content=nil, message=nil)
114
- unless message
115
- if content
116
- message = "Expected to find #{content.inspect} at #{selector.inspect} in the output template"
117
- else
118
- message = "Expected to find #{selector.inspect} in the output template"
119
- end
120
- end
121
-
122
- matched_elements = Nokogiri::HTML.parse(last_response.body).css(selector)
123
- assert matched_elements.length > 0, message + ", but selector not found."
124
-
125
- if content
126
- inner_htmls = matched_elements.map(&:inner_html)
127
- found_match = inner_htmls.grep(content).any? # grep matches strings or Regexps
128
- assert found_match, message + ". The selector was found but with different content: \"#{inner_htmls.join('", ')}\""
129
- end
130
- end
131
-
132
- def assert_no_selector(selector, message=nil)
133
- message ||= "Expected not to find #{selector.inspect}, but did"
134
- assert_nil Nokogiri::HTML.parse(last_response.body).at_css(selector), message
135
- end
136
- end
@@ -1,19 +0,0 @@
1
- require_relative "../test_helper"
2
- require_relative "../../lib/slimmer/test_helpers/govuk_components"
3
-
4
- describe Slimmer::TestHelpers::GovukComponents do
5
- let(:subject) {
6
- class Dummy
7
- include Slimmer::TestHelpers::GovukComponents
8
- end
9
- }
10
-
11
- describe '#shared_component_selector' do
12
- it 'generates a selector for components' do
13
- outcome = subject.new.shared_component_selector('flux_capacitor')
14
-
15
- expected = "test-govuk-component[data-template='govuk_component-flux_capacitor']"
16
- assert_equal expected, outcome
17
- end
18
- end
19
- end
@@ -1,25 +0,0 @@
1
- require "test_helper"
2
-
3
- class TestTemplateDependencyOnStaticTest < MiniTest::Test
4
- def test_scripts_on_static_referenced_in_test_templates_exist
5
- template_path = File.dirname(__FILE__).gsub('/test', '/lib/slimmer/test_templates')
6
- Dir.foreach(template_path) do | template_file_name |
7
- next if ['.','..'].include? template_file_name
8
- doc = Nokogiri::HTML.fragment(File.read(File.join(template_path, template_file_name)))
9
- scripts = doc.search("script").map { |node| node.attributes["src"].value }
10
- failing_scripts = allowing_real_web_connections do
11
- scripts.select do |script_src|
12
- uri = URI.parse(script_src)
13
- http = Net::HTTP.new(uri.host, uri.port)
14
- if uri.scheme == "https"
15
- http.use_ssl = true
16
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
17
- end
18
- response = http.get(uri.request_uri)
19
- response.code != "200"
20
- end
21
- end
22
- assert failing_scripts.empty?, "Some scripts could not be loaded: #{failing_scripts.inspect}"
23
- end
24
- end
25
- end
@@ -1,358 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- module TypicalUsage
4
-
5
- class SkippingSlimmerTest < SlimmerIntegrationTest
6
- given_response 200, %{Don't template me}, {"X-Slimmer-Skip" => "true"}
7
-
8
- def test_should_return_the_response_as_is
9
- assert_equal "Don't template me", last_response.body
10
- end
11
- end
12
-
13
- class SkipUsingQueryParamTest < SlimmerIntegrationTest
14
- given_response 200, %{<html><body><div id='unskinned'>Unskinned</div><div id="wrapper">Don't template me</div></body></html>}, {}
15
-
16
- def fetch_page; end
17
-
18
- def with_rails_env(new_env, &block)
19
- old_env, ENV['RAILS_ENV'] = ENV['RAILS_ENV'], new_env
20
- begin
21
- yield
22
- ensure
23
- ENV['RAILS_ENV'] = old_env
24
- end
25
- end
26
-
27
- def test_should_return_the_response_as_is_in_development
28
- with_rails_env('development') do
29
- get "/some-slug?skip_slimmer=1"
30
- end
31
- assert_rendered_in_template '#unskinned', "Unskinned"
32
- end
33
-
34
- def test_not_skip_slimmer_in_test
35
- with_rails_env('test') do
36
- get "/some-slug?skip_slimmer=1"
37
- end
38
- assert_rendered_in_template '#wrapper', /^Don't template me/
39
- end
40
- end
41
-
42
- class SkipNonHtmlResponse < SlimmerIntegrationTest
43
- given_response 200, '{ "json" : "document" }', {'Content-Type' => 'application/json'}
44
-
45
- def test_should_pass_through_non_html_response
46
- assert_equal '{ "json" : "document" }', last_response.body
47
- end
48
- end
49
-
50
- class SkipDoesntInteractWithNonHtmlBodies < SlimmerIntegrationTest
51
- def test_non_html_response_bodies_are_passed_through_untouched
52
- # Rack::SendFile doesn't work if to_s, to_str or each are called on the
53
- # response body (as happens when building a Rack::Response)
54
- body = stub('body')
55
- inner_app = proc { |env|
56
- [200, {"Content-Type" => "application/json"}, body]
57
- }
58
- app = Slimmer::App.new inner_app, {asset_host: "http://template.local"}
59
-
60
- body.expects(:to_s).never
61
- body.expects(:to_str).never
62
- body.expects(:each).never
63
- Rack::Response.expects(:new).never
64
-
65
- app.call({})
66
- end
67
- end
68
-
69
- class ContentLengthTest < SlimmerIntegrationTest
70
- given_response 200, %{
71
- <html>
72
- <head><title>The title of the page</title>
73
- <meta name="something" content="yes">
74
- <script src="blah.js"></script>
75
- <link href="app.css" rel="stylesheet" type="text/css">
76
- </head>
77
- <body class="body_class">
78
- <div id="wrapper">The body of the page</div>
79
- </body>
80
- </html>
81
- }
82
-
83
- def test_should_set_correct_content_length_header
84
- expected = last_response.body.bytesize
85
- assert_equal expected.to_s, last_response.headers['Content-Length']
86
- end
87
- end
88
-
89
- class NormalResponseTest < SlimmerIntegrationTest
90
- def setup
91
- super
92
- given_response 200, %{
93
- <html>
94
- <head><title>The title of the page</title>
95
- <meta name="something" content="yes">
96
- <script src="blah.js"></script>
97
- <link href="app.css" rel="stylesheet" type="text/css">
98
- </head>
99
- <body class="body_class">
100
- <div id="wrapper">The body of the page</div>
101
- </body>
102
- </html>
103
- }, {}
104
- end
105
-
106
- def test_should_replace_the_wrapper_using_the_app_response
107
- assert_rendered_in_template "#wrapper", /^The body of the page/
108
- end
109
-
110
- def test_should_replace_the_title_using_the_app_response
111
- assert_rendered_in_template "head title", "The title of the page"
112
- end
113
-
114
- def test_should_move_script_tags_into_the_body
115
- assert_rendered_in_template "body script[src='blah.js']"
116
- end
117
-
118
- def test_should_move_meta_tags_into_the_head
119
- assert_rendered_in_template "head meta[name='something']"
120
- end
121
-
122
- def test_should_move_stylesheet_tags_into_the_head
123
- assert_rendered_in_template "head link[href='app.css']"
124
- end
125
-
126
- def test_should_copy_the_class_of_the_body_element
127
- assert_rendered_in_template "body.body_class"
128
- end
129
- end
130
-
131
- class ConditionalCommentTest < SlimmerIntegrationTest
132
- given_response 200, %{
133
- <html>
134
- <head><title>The title of the page</title>
135
- <!--[if lt IE 9]><link href="app-ie.css" rel="stylesheet" type="text/css"><![endif]-->
136
- </head>
137
- <body class="body_class"><div id="wrapper"></div></body>
138
- </html>
139
- }
140
- def test_should_find_conditional_comments_copied_into_the_head
141
- element = Nokogiri::HTML.parse(last_response.body).at_xpath('//comment()')
142
- assert_match /app-ie\.css/, element.to_s, 'Not found conditional comment in output'
143
- end
144
- end
145
-
146
- class WrapTagTest < SlimmerIntegrationTest
147
- given_response 200, %{
148
- <html>
149
- <head>
150
- <!--[if gt IE 8]><!--><link href="app.css" rel="stylesheet" type="text/css"><!--<![endif]-->
151
- </head>
152
- <body class="body_class"><div id="wrapper"></div></body>
153
- </html>
154
- }
155
- def test_should_find_stylesheet_wrapped_with_conditional_comments
156
- assert_rendered_in_template "head link[href='app.css']"
157
- element = Nokogiri::HTML.parse(last_response.body).at_xpath('/html/head')
158
- assert_match /<!--\[if gt IE 8\]><!-->.*app\.css.*<!--<!\[endif\]-->/m, element.to_s, 'Not found conditional comment in output'
159
- end
160
- end
161
-
162
- class HeaderContextResponseTest < SlimmerIntegrationTest
163
- given_response 200, %{
164
- <html>
165
- <head><title>The title of the page</title>
166
- <meta name="something" content="yes">
167
- <script src="blah.js"></script>
168
- <link href="app.css" rel="stylesheet" type="text/css">
169
- </head>
170
- <body class="body_class">
171
- <div class="header-context custom-class">app-specific header context</div>
172
- <div id="wrapper">The body of the page</div>
173
- </body>
174
- </html>
175
- }
176
-
177
- def test_should_replace_the_header_context_using_the_app_response
178
- assert_rendered_in_template ".header-context.custom-class", "app-specific header context"
179
- end
180
- end
181
-
182
- class ReportAProblemTest < SlimmerIntegrationTest
183
- given_response 200, %{
184
- <html>
185
- <body>
186
- <div id="wrapper">The body of the page</div>
187
- </body>
188
- </html>
189
- }
190
-
191
- def test_should_insert_the_report_a_problem_form
192
- assert_rendered_in_template "#wrapper .report-a-problem-container"
193
- end
194
-
195
- def test_should_add_the_current_url_to_the_form
196
- assert_rendered_in_template ".report-a-problem-container input[name=url][value='http://example.org/']"
197
- end
198
- end
199
-
200
- class Error500ResponseTest < SlimmerIntegrationTest
201
- given_response 500, %{
202
- <html>
203
- <head><title>500 Error</title>
204
- <meta name="something" content="yes">
205
- <script src="blah.js"></script>
206
- <link href="app.css" rel="stylesheet" type="text/css">
207
- </head>
208
- <body class="body_class">
209
- <div id="wrapper"><p class='message'>Something bad happened</p></div>
210
- </body>
211
- </html>
212
- }
213
-
214
- def test_should_not_replace_the_wrapper_using_the_app_response
215
- assert_not_rendered_in_template "Something bad happened"
216
- end
217
-
218
- def test_should_include_default_500_error_message
219
- assert_rendered_in_template "body .content header h1", "We seem to be having a problem."
220
- end
221
-
222
- def test_should_replace_the_title_using_the_app_response
223
- assert_rendered_in_template "head title", "500 Error"
224
- end
225
- end
226
-
227
- class Error404ResponseTest < SlimmerIntegrationTest
228
- given_response 404, %{
229
- <html>
230
- <head><title>404 Missing</title>
231
- <meta name="something" content="yes">
232
- <script src="blah.js"></script>
233
- <link href="app.css" rel="stylesheet" type="text/css">
234
- </head>
235
- <body class="body_class">
236
- <div id="wrapper"><p class='message'>Something bad happened</p></div>
237
- </body>
238
- </html>
239
- }
240
-
241
- def test_should_not_replace_the_wrapper_using_the_app_response
242
- assert_not_rendered_in_template "Something bad happened"
243
- end
244
-
245
- def test_should_include_default_404_error_message
246
- assert_rendered_in_template "body .content header h1", "Oops! We can't find what you're looking for."
247
- end
248
-
249
- def test_should_replace_the_title_using_the_app_response
250
- assert_rendered_in_template "head title", "404 Missing"
251
- end
252
- end
253
-
254
- class Error406ResponseTest < SlimmerIntegrationTest
255
- given_response 406, %{
256
- <html>
257
- <head><title>406 Not Acceptable</title>
258
- <meta name="something" content="yes">
259
- <script src="blah.js"></script>
260
- <link href="app.css" rel="stylesheet" type="text/css">
261
- </head>
262
- <body class="body_class">
263
- <div id="wrapper"><p class='message'>Something bad happened</p></div>
264
- </body>
265
- </html>
266
- }
267
-
268
- def test_should_not_replace_the_wrapper_using_the_app_response
269
- assert_not_rendered_in_template "Something bad happened"
270
- end
271
-
272
- def test_should_include_default_non_404_error_message
273
- assert_rendered_in_template "body .content header h1", "We seem to be having a problem."
274
- end
275
-
276
- def test_should_replace_the_title_using_the_app_response
277
- assert_rendered_in_template "head title", "406 Not Acceptable"
278
- end
279
- end
280
-
281
- class Error410ResponseTest < SlimmerIntegrationTest
282
- given_response 410, %{
283
- <html>
284
- <head><title>410 Gone</title>
285
- <meta name="something" content="yes">
286
- <script src="blah.js"></script>
287
- <link href="app.css" rel="stylesheet" type="text/css">
288
- </head>
289
- <body class="body_class">
290
- <div id="wrapper"><p class='message'>Something bad happened</p></div>
291
- </body>
292
- </html>
293
- }
294
-
295
- def test_should_not_replace_the_wrapper_using_the_app_response
296
- assert_not_rendered_in_template "Something bad happened"
297
- end
298
-
299
- def test_should_include_default_410_error_message
300
- assert_rendered_in_template "body .content header h1", "That's gone now, sorry."
301
- end
302
-
303
- def test_should_replace_the_title_using_the_app_response
304
- assert_rendered_in_template "head title", "410 Gone"
305
- end
306
- end
307
-
308
- class ArbitraryWrapperIdTest < SlimmerIntegrationTest
309
-
310
- given_response 200, %{
311
- <html>
312
- <body>
313
- <div id="custom_wrapper">The body of the page</div>
314
- </body>
315
- </html>
316
- }, {}, {wrapper_id: "custom_wrapper"}
317
-
318
- def test_should_replace_wrapper_with_custom_wrapper
319
- assert_rendered_in_template "body #custom_wrapper", /^The body of the page/
320
- assert_no_selector "#wrapper"
321
- end
322
- end
323
-
324
- class StrippingHeadersTest < SlimmerIntegrationTest
325
- def test_should_strip_all_slimmer_headers_from_final_response
326
- given_response 200, %{
327
- <html>
328
- <body>
329
- <div id="wrapper">The body of the page</div>
330
- </body>
331
- </html>
332
- }, {
333
- "#{Slimmer::Headers::HEADER_PREFIX}-Foo" => "Something",
334
- "X-Custom-Header" => "Something else"
335
- }
336
-
337
- refute last_response.headers.has_key?("#{Slimmer::Headers::HEADER_PREFIX}-Foo")
338
- assert_equal "Something else", last_response.headers["X-Custom-Header"]
339
- end
340
-
341
- def test_should_strip_slimmer_headers_even_when_skipping_slimmer
342
- given_response 200, %{
343
- <html>
344
- <body>
345
- <div id="wrapper">The body of the page</div>
346
- </body>
347
- </html>
348
- }, {
349
- "#{Slimmer::Headers::HEADER_PREFIX}-Foo" => "Something",
350
- "X-Custom-Header" => "Something else",
351
- Slimmer::Headers::SKIP_HEADER => "1"
352
- }
353
-
354
- refute last_response.headers.has_key?("#{Slimmer::Headers::HEADER_PREFIX}-Foo")
355
- assert_equal "Something else", last_response.headers["X-Custom-Header"]
356
- end
357
- end
358
- end