slimmer 3.20.0 → 3.21.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/lib/slimmer/test.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'slimmer/skin'
2
- require 'slimmer/test_template'
3
2
 
4
3
  module Slimmer
5
4
  class Skin
@@ -7,12 +6,10 @@ module Slimmer
7
6
  logger.debug "Slimmer: TEST MODE - Loading fixture template from #{__FILE__}"
8
7
  if name =~ /\A(.*)\.raw\z/
9
8
  %{<div id="test-#{$1}"></div>}
10
- elsif name == "beta_notice"
11
- %{<div class="beta-notice"><p>This page is BETA.</p></div>}
12
- elsif name == "campaign"
13
- '<section class="black" id="campaign-notification"><div><p>Notifications!</p></div></section>'
9
+ elsif File.exist?(template_path = File.join(File.dirname(__FILE__), 'test_templates', "#{name}.html"))
10
+ File.read(template_path)
14
11
  else
15
- Slimmer::TestTemplate::TEMPLATE
12
+ File.read(File.join(File.dirname(__FILE__), 'test_templates', "wrapper.html"))
16
13
  end
17
14
  end
18
15
  end
@@ -0,0 +1 @@
1
+ <div class="beta-notice"><p>This page is BETA.</p></div>
@@ -0,0 +1 @@
1
+ <section class="black" id="campaign-notification"><div><p>Notifications!</p></div></section>
@@ -0,0 +1,27 @@
1
+ <html>
2
+ <head>
3
+ <title>Test Template</title>
4
+ </head>
5
+ <body>
6
+ <header id="global-header"></header>
7
+ <div id="global-breadcrumb" class="header-context">
8
+ <nav role="navigation">
9
+ <ol class="group">
10
+ <li><a href="/">Home</a></li>
11
+ </ol>
12
+ </nav>
13
+ </div>
14
+
15
+ <div id="wrapper"></div>
16
+
17
+ <footer id="footer"></footer>
18
+
19
+ <script src="https://static.preview.alphagov.co.uk/static/govuk-template.js" type="text/javascript"></script>
20
+ <script src="https://static.preview.alphagov.co.uk/static/libs/jquery/jquery-1.7.2.js" type="text/javascript"></script>
21
+ <script defer src="https://static.preview.alphagov.co.uk/static/libs/jquery/plugins/jquery.base64.js?body=1" type="text/javascript"></script>
22
+ <script defer src="https://static.preview.alphagov.co.uk/static/user-satisfaction-survey.js?body=1" type="text/javascript"></script>
23
+ <script defer src="https://static.preview.alphagov.co.uk/static/core.js?body=1" type="text/javascript"></script>
24
+ <script defer src="https://static.preview.alphagov.co.uk/static/report-a-problem.js?body=1" type="text/javascript"></script>
25
+ <script src="https://static.preview.alphagov.co.uk/static/header-footer-only.js" type="text/javascript"></script>
26
+ </body>
27
+ </html>
@@ -0,0 +1,23 @@
1
+ <html>
2
+ <head>
3
+ <title>Test Template</title>
4
+ </head>
5
+ <body>
6
+ <header id="global-header"></header>
7
+ <div id="global-breadcrumb" class="header-context">
8
+ <nav role="navigation">
9
+ <ol class="group">
10
+ <li><a href="/">Home</a></li>
11
+ </ol>
12
+ </nav>
13
+ </div>
14
+
15
+ <div id="wrapper"></div>
16
+
17
+ <footer id="footer"></footer>
18
+
19
+ <script src="https://static.preview.alphagov.co.uk/static/govuk-template.js" type="text/javascript"></script>
20
+ <script src="https://static.preview.alphagov.co.uk/static/libs/jquery/jquery-1.7.2.js" type="text/javascript"></script>
21
+ <script src="https://static.preview.alphagov.co.uk/static/application.js" type="text/javascript"></script>
22
+ </body>
23
+ </html>
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '3.20.0'
2
+ VERSION = '3.21.0'
3
3
  end
@@ -1,22 +1,25 @@
1
1
  require "test_helper"
2
- require "slimmer/test_template"
3
2
 
4
3
  class TestTemplateDependencyOnStaticTest < MiniTest::Unit::TestCase
5
- def test_test_template_static_asset_urls_should_be_valid
6
- doc = Nokogiri::HTML.fragment(Slimmer::TestTemplate::TEMPLATE)
7
- scripts = doc.search("script").map { |node| node.attributes["src"].value }
8
- failing_scripts = allowing_real_web_connections do
9
- scripts.select do |script_src|
10
- uri = URI.parse(script_src)
11
- http = Net::HTTP.new(uri.host, uri.port)
12
- if uri.scheme == "https"
13
- http.use_ssl = true
14
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
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"
15
20
  end
16
- response = http.get(uri.request_uri)
17
- response.code != "200"
18
21
  end
22
+ assert failing_scripts.empty?, "Some scripts could not be loaded: #{failing_scripts.inspect}"
19
23
  end
20
- assert failing_scripts.empty?, "Some scripts could not be loaded: #{failing_scripts.inspect}"
21
24
  end
22
25
  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.20.0
4
+ version: 3.21.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-09-26 00:00:00.000000000 Z
13
+ date: 2013-10-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -251,11 +251,14 @@ 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
+ - lib/slimmer/test_templates/header_footer_only.html
256
+ - lib/slimmer/test_templates/wrapper.html
257
+ - lib/slimmer/test_templates/beta_notice.html
254
258
  - lib/slimmer/test.rb
255
259
  - lib/slimmer/version.rb
256
260
  - lib/slimmer/artefact.rb
257
261
  - lib/slimmer/template.rb
258
- - lib/slimmer/test_template.rb
259
262
  - lib/slimmer/processors/campaign_notification_inserter.rb
260
263
  - lib/slimmer/processors/header_context_inserter.rb
261
264
  - lib/slimmer/processors/navigation_mover.rb
@@ -318,7 +321,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
318
321
  version: '0'
319
322
  segments:
320
323
  - 0
321
- hash: -3039332141406207246
324
+ hash: 1806523750546367185
322
325
  required_rubygems_version: !ruby/object:Gem::Requirement
323
326
  none: false
324
327
  requirements:
@@ -327,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
330
  version: '0'
328
331
  segments:
329
332
  - 0
330
- hash: -3039332141406207246
333
+ hash: 1806523750546367185
331
334
  requirements: []
332
335
  rubyforge_project: slimmer
333
336
  rubygems_version: 1.8.23
@@ -1,27 +0,0 @@
1
- module Slimmer::TestTemplate
2
- TEMPLATE = %q{
3
- <html>
4
- <head>
5
- <title>Test Template</title>
6
- </head>
7
- <body>
8
- <header id="global-header"></header>
9
- <div id="global-breadcrumb" class="header-context">
10
- <nav role="navigation">
11
- <ol class="group">
12
- <li><a href="/">Home</a></li>
13
- </ol>
14
- </nav>
15
- </div>
16
-
17
- <div id="wrapper"></div>
18
-
19
- <footer id="footer"></footer>
20
-
21
- <script src="https://static.preview.alphagov.co.uk/static/govuk-template.js" type="text/javascript"></script>
22
- <script src="https://static.preview.alphagov.co.uk/static/libs/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
23
- <script src="https://static.preview.alphagov.co.uk/static/application.js" type="text/javascript"></script>
24
- </body>
25
- </html>
26
- }
27
- end