high_voltage 2.2.1 → 2.3.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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -3
  3. data/.travis.yml +7 -14
  4. data/Appraisals +3 -10
  5. data/CONTRIBUTING.md +4 -1
  6. data/Gemfile.lock +61 -42
  7. data/MIT-LICENSE +1 -1
  8. data/NEWS.md +5 -0
  9. data/README.md +71 -10
  10. data/app/controllers/concerns/high_voltage/static_page.rb +7 -1
  11. data/gemfiles/{rails3.1.gemfile → rails4.2.gemfile} +3 -1
  12. data/high_voltage.gemspec +1 -1
  13. data/lib/high_voltage/page_finder.rb +11 -1
  14. data/lib/high_voltage/version.rb +1 -1
  15. data/spec/constraints/root_route_spec.rb +4 -4
  16. data/spec/controllers/pages_controller_spec.rb +57 -52
  17. data/spec/fake_app.rb +18 -0
  18. data/spec/{dummy → fixtures}/app/views/layouts/alternate.html.erb +0 -0
  19. data/spec/{dummy → fixtures}/app/views/layouts/application.html.erb +0 -0
  20. data/spec/{dummy → fixtures}/app/views/other/wrong.html.erb +0 -0
  21. data/spec/{dummy → fixtures}/app/views/other_pages/also_dir/also_nested.html.erb +0 -0
  22. data/spec/{dummy → fixtures}/app/views/other_pages/also_exists.html.erb +0 -0
  23. data/spec/{dummy → fixtures}/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
  24. data/spec/{dummy → fixtures}/app/views/pages/also_dir/also_nested.html.erb +0 -0
  25. data/spec/{dummy → fixtures}/app/views/pages/also_exists.html.erb +0 -0
  26. data/spec/{dummy → fixtures}/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
  27. data/spec/{dummy → fixtures}/app/views/pages/dir/nested.html.erb +0 -0
  28. data/spec/{dummy → fixtures}/app/views/pages/exists.html.erb +0 -0
  29. data/spec/{dummy → fixtures}/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -0
  30. data/spec/{dummy → fixtures}/app/views/pages/rot13.html.erb +0 -0
  31. data/spec/fixtures/config/database.yml +3 -0
  32. data/spec/{dummy → fixtures}/config/routes.rb +0 -0
  33. data/spec/{dummy → fixtures}/public/pages/exists.html +0 -0
  34. data/spec/high_voltage/page_finder_spec.rb +30 -14
  35. data/spec/spec_helper.rb +14 -8
  36. data/spec/{dummy → support}/app/controllers/alternative_finder_controller.rb +0 -0
  37. data/spec/{dummy → support}/app/controllers/subclassed_pages_controller.rb +0 -0
  38. metadata +46 -105
  39. data/gemfiles/rails3.1.gemfile.lock +0 -121
  40. data/gemfiles/rails3.2.gemfile +0 -8
  41. data/gemfiles/rails3.2.gemfile.lock +0 -119
  42. data/gemfiles/rails4.0.gemfile.lock +0 -118
  43. data/gemfiles/rails4.1.gemfile.lock +0 -124
  44. data/spec/dummy/Rakefile +0 -7
  45. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  46. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  47. data/spec/dummy/config/application.rb +0 -43
  48. data/spec/dummy/config/boot.rb +0 -10
  49. data/spec/dummy/config/environment.rb +0 -5
  50. data/spec/dummy/config/environments/development.rb +0 -25
  51. data/spec/dummy/config/environments/production.rb +0 -49
  52. data/spec/dummy/config/environments/test.rb +0 -30
  53. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  54. data/spec/dummy/config/initializers/inflections.rb +0 -10
  55. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  56. data/spec/dummy/config/initializers/secret_key_base.rb +0 -1
  57. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  58. data/spec/dummy/config/initializers/session_store.rb +0 -8
  59. data/spec/dummy/config/locales/en.yml +0 -5
  60. data/spec/dummy/config.ru +0 -4
  61. data/spec/dummy/public/404.html +0 -26
  62. data/spec/dummy/public/422.html +0 -26
  63. data/spec/dummy/public/500.html +0 -26
  64. data/spec/dummy/public/favicon.ico +0 -0
  65. data/spec/dummy/public/javascripts/application.js +0 -2
  66. data/spec/dummy/public/javascripts/controls.js +0 -965
  67. data/spec/dummy/public/javascripts/dragdrop.js +0 -974
  68. data/spec/dummy/public/javascripts/effects.js +0 -1123
  69. data/spec/dummy/public/javascripts/prototype.js +0 -6001
  70. data/spec/dummy/public/javascripts/rails.js +0 -191
  71. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  72. data/spec/dummy/script/rails +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b872bfede94dc9cf0c80856bd435edd5c8014f65
4
- data.tar.gz: 742e628313897b06f7579d4c3098c2eab2717440
3
+ metadata.gz: dfdb165dc9944d13d14ccfcfab0358c2d575b688
4
+ data.tar.gz: 769e4a05d918743c86ce21f58b4ab2ea3d8bc838
5
5
  SHA512:
6
- metadata.gz: 181f409611c5c3e699f29d27416b55f5633fc1d1d9af772b5bbc2d8fc17a70fe1308c207698aba65aafc23d91ba515a599a7e95591a8ee4855a856db44374edc
7
- data.tar.gz: 8197ebd00469a8e6d1e77b58b26bfa02f2bfa5a32fdffaa13cd441e06448c26fdcb3ca39d3799da7b85be07aa94f454fee0fb6108678385527c464b7a8380e36
6
+ metadata.gz: e036c73851faf23320d6b5fccbd8c65cacdb73e736422e0df062cdea64ea8c6a88d26bfc084403a979955eeb695e82d4bc89fdcdd6905516dd7adf85734425b7
7
+ data.tar.gz: 29b92c7a8e76d78f6084bfbc6987d5022af4a048461eaff10192d32e94bdd217b41ca27e9ac1c42a38e70fae0603519075cba4e7d2f0a9cc78dc5b4ddaf11206
data/.gitignore CHANGED
@@ -1,8 +1,6 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
- spec/dummy/db/*.sqlite3
5
- spec/dummy/log/*.log
6
- spec/dummy/tmp/
7
4
  *.swp
8
5
  *.gem
6
+ gemfiles/*.lock
data/.travis.yml CHANGED
@@ -1,24 +1,17 @@
1
1
  gemfile:
2
- - gemfiles/rails3.1.gemfile
3
- - gemfiles/rails3.2.gemfile
4
2
  - gemfiles/rails4.0.gemfile
5
3
  - gemfiles/rails4.1.gemfile
4
+ - gemfiles/rails4.2.gemfile
6
5
  install:
7
6
  - 'travis_retry bundle install'
8
7
  language:
9
8
  - ruby
10
- matrix:
11
- exclude:
12
- - rvm: 1.9.3
13
- gemfile: gemfiles/rails4.0.gemfile
14
- - rvm: 1.9.3
15
- gemfile: gemfiles/rails4.1.gemfile
16
- - rvm: 2.0.0
17
- gemfile: gemfiles/rails3.1.gemfile
18
- - rvm: 2.1.2
19
- gemfile: gemfiles/rails3.1.gemfile
20
9
  rvm:
21
- - 1.9.3
22
10
  - 2.0.0
23
- - 2.1.2
11
+ - 2.1.5
12
+ - 2.2.0
24
13
  script: 'bundle exec rake spec'
14
+ notifications:
15
+ email: false
16
+ sudo: false
17
+ cache: bundler
data/Appraisals CHANGED
@@ -1,16 +1,9 @@
1
- if RUBY_VERSION >= '2.0'
2
- rails_versions = ['~> 3.2.13', '~> 4.0.0', '~> 4.1.0']
3
- else
4
- rails_versions = ['~> 3.1.12', '~> 3.2.13']
5
- end
1
+ rails_versions = ['~> 4.0.0', '~> 4.1.0', '~> 4.2.0']
6
2
 
7
3
  rails_versions.each do |rails_version|
8
4
  appraise "rails#{rails_version.slice(/\d+\.\d+/)}" do
9
5
  gem 'rails', rails_version
10
-
11
- if ['~> 4.0.0', '~> 4.1.0'].include? rails_version
12
- gem 'actionpack-action_caching'
13
- gem 'actionpack-page_caching'
14
- end
6
+ gem 'actionpack-action_caching'
7
+ gem 'actionpack-page_caching'
15
8
  end
16
9
  end
data/CONTRIBUTING.md CHANGED
@@ -1,4 +1,7 @@
1
- We love pull requests. Here's a quick guide:
1
+ We love pull requests from everyone. By participating in this project, you
2
+ agree to abide by the thoughtbot [code of conduct].
3
+
4
+ [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
2
5
 
3
6
  1. Fork the repo.
4
7
 
data/Gemfile.lock CHANGED
@@ -1,30 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_voltage (2.2.1)
4
+ high_voltage (2.3.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- actionpack (4.1.1)
10
- actionview (= 4.1.1)
11
- activesupport (= 4.1.1)
12
- rack (~> 1.5.2)
9
+ actionpack (4.2.0)
10
+ actionview (= 4.2.0)
11
+ activesupport (= 4.2.0)
12
+ rack (~> 1.6.0)
13
13
  rack-test (~> 0.6.2)
14
- actionview (4.1.1)
15
- activesupport (= 4.1.1)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
16
+ actionview (4.2.0)
17
+ activesupport (= 4.2.0)
16
18
  builder (~> 3.1)
17
19
  erubis (~> 2.7.0)
18
- activemodel (4.1.1)
19
- activesupport (= 4.1.1)
20
- builder (~> 3.1)
21
- activesupport (4.1.1)
22
- i18n (~> 0.6, >= 0.6.9)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
22
+ activesupport (4.2.0)
23
+ i18n (~> 0.7)
23
24
  json (~> 1.7, >= 1.7.7)
24
25
  minitest (~> 5.1)
25
- thread_safe (~> 0.1)
26
+ thread_safe (~> 0.3, >= 0.3.4)
26
27
  tzinfo (~> 1.1)
27
- appraisal (1.0.0)
28
+ appraisal (1.0.2)
28
29
  bundler
29
30
  rake
30
31
  thor (>= 0.14.0)
@@ -32,39 +33,57 @@ GEM
32
33
  coderay (1.1.0)
33
34
  diff-lcs (1.2.5)
34
35
  erubis (2.7.0)
35
- i18n (0.6.9)
36
- json (1.8.1)
36
+ i18n (0.7.0)
37
+ json (1.8.2)
38
+ loofah (2.0.1)
39
+ nokogiri (>= 1.5.9)
37
40
  method_source (0.8.2)
38
- minitest (5.3.3)
39
- pry (0.9.12.6)
40
- coderay (~> 1.0)
41
- method_source (~> 0.8)
41
+ mini_portile (0.6.2)
42
+ minitest (5.5.1)
43
+ nokogiri (1.6.6.2)
44
+ mini_portile (~> 0.6.0)
45
+ pry (0.10.1)
46
+ coderay (~> 1.1.0)
47
+ method_source (~> 0.8.1)
42
48
  slop (~> 3.4)
43
- rack (1.5.2)
44
- rack-test (0.6.2)
49
+ rack (1.6.0)
50
+ rack-test (0.6.3)
45
51
  rack (>= 1.0)
46
- railties (4.1.1)
47
- actionpack (= 4.1.1)
48
- activesupport (= 4.1.1)
52
+ rails-deprecated_sanitizer (1.0.3)
53
+ activesupport (>= 4.2.0.alpha)
54
+ rails-dom-testing (1.0.5)
55
+ activesupport (>= 4.2.0.beta, < 5.0)
56
+ nokogiri (~> 1.6.0)
57
+ rails-deprecated_sanitizer (>= 1.0.1)
58
+ rails-html-sanitizer (1.0.1)
59
+ loofah (~> 2.0)
60
+ railties (4.2.0)
61
+ actionpack (= 4.2.0)
62
+ activesupport (= 4.2.0)
49
63
  rake (>= 0.8.7)
50
64
  thor (>= 0.18.1, < 2.0)
51
- rake (10.3.1)
52
- rspec-core (2.14.8)
53
- rspec-expectations (2.14.5)
54
- diff-lcs (>= 1.1.3, < 2.0)
55
- rspec-mocks (2.14.6)
56
- rspec-rails (2.14.2)
57
- actionpack (>= 3.0)
58
- activemodel (>= 3.0)
59
- activesupport (>= 3.0)
60
- railties (>= 3.0)
61
- rspec-core (~> 2.14.0)
62
- rspec-expectations (~> 2.14.0)
63
- rspec-mocks (~> 2.14.0)
64
- slop (3.5.0)
65
+ rake (10.4.2)
66
+ rspec-core (3.2.1)
67
+ rspec-support (~> 3.2.0)
68
+ rspec-expectations (3.2.0)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.2.0)
71
+ rspec-mocks (3.2.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.2.0)
74
+ rspec-rails (3.2.1)
75
+ actionpack (>= 3.0, < 4.3)
76
+ activesupport (>= 3.0, < 4.3)
77
+ railties (>= 3.0, < 4.3)
78
+ rspec-core (~> 3.2.0)
79
+ rspec-expectations (~> 3.2.0)
80
+ rspec-mocks (~> 3.2.0)
81
+ rspec-support (~> 3.2.0)
82
+ rspec-support (3.2.2)
83
+ slop (3.6.0)
65
84
  thor (0.19.1)
66
- thread_safe (0.3.3)
67
- tzinfo (1.1.0)
85
+ thread_safe (0.3.4)
86
+ tzinfo (1.2.2)
68
87
  thread_safe (~> 0.1)
69
88
 
70
89
  PLATFORMS
@@ -75,4 +94,4 @@ DEPENDENCIES
75
94
  appraisal
76
95
  high_voltage!
77
96
  pry
78
- rspec-rails
97
+ rspec-rails (~> 3.2.0)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2010-2014 thoughtbot, inc.
1
+ Copyright 2010-2015 thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/NEWS.md CHANGED
@@ -1,3 +1,8 @@
1
+ New for 2.3.0:
2
+ + Ruby 2.2 and Rails 4.2 testing
3
+ + Raise InvalidPageIdError when visiting a page with invalid characters
4
+ + Code of Conduct added to Contributing guide
5
+
1
6
  New for 2.2.1:
2
7
  + Resolve issue with require statements for Rails 3.x projects
3
8
 
data/README.md CHANGED
@@ -15,7 +15,7 @@ Yeah, like "About us", "Directions", marketing pages, etc.
15
15
  Include in your Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'high_voltage', '~> 2.2.1'
18
+ gem 'high_voltage', '~> 2.3.0`
19
19
  ```
20
20
 
21
21
  For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
@@ -263,6 +263,58 @@ end
263
263
  Use this to create a custom file mapping, clean filenames for your file
264
264
  system, A/B test, and so on.
265
265
 
266
+ ## Localization
267
+
268
+ [Rails I18n guides](http://guides.rubyonrails.org/i18n.html).
269
+
270
+ Add a before filter to the Application controller
271
+
272
+ ```ruby
273
+ # app/controllers/application_controller.rb
274
+ before_action :set_locale
275
+
276
+ def set_locale
277
+ I18n.locale = params[:locale] || I18n.default_locale
278
+ end
279
+ ```
280
+
281
+ Disable the default High Voltage routes
282
+
283
+ ```ruby
284
+ # config/initializers/high_voltage.rb
285
+ HighVoltage.configure do |config|
286
+ config.routes = false
287
+ end
288
+ ```
289
+
290
+ ```ruby
291
+ # config/routes.rb
292
+ scope "/:locale", locale: /en|bn|hi/ do
293
+ get "/pages/:id" => "high_voltage/pages#show", :as => :page, :format => false
294
+ end
295
+ ```
296
+
297
+ Add a static page to the project
298
+
299
+ ```
300
+ # app/views/pages/about.html.erb
301
+ <%= t "hello" %>
302
+ ```
303
+
304
+ Make sure that there are corresponding locale files
305
+
306
+ ```
307
+ /config/locale/bn.yml
308
+ /config/locale/en.yml
309
+ /config/locale/hi.yml
310
+ ```
311
+
312
+ One last note is there is a [know
313
+ issue](https://github.com/thoughtbot/high_voltage/issues/59) with High Voltage.
314
+
315
+ You'll need to specify routes like this `<%= link_to "About Us", page_path(id:
316
+ "about") %>`
317
+
266
318
  ## Testing
267
319
 
268
320
  You can test your static pages using [RSpec](https://github.com/rspec/rspec-rails)
@@ -291,20 +343,29 @@ Enjoy!
291
343
 
292
344
  ## Contributing
293
345
 
294
- Please see [CONTRIBUTING.md](https://github.com/thoughtbot/high_voltage/blob/master/CONTRIBUTING.md)
295
- for details.
346
+ Please see [CONTRIBUTING.md].
347
+ Thank you, [contributors]!
296
348
 
297
- ## Credits
349
+ [CONTRIBUTING.md]: /CONTRIBUTING.md
350
+ [contributors]: https://github.com/thoughtbot/high_voltage/graphs/contributors
298
351
 
299
- ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
352
+ ## License
353
+
354
+ High Voltage is copyright © 2009-2015 thoughtbot. It is free software, and may
355
+ be redistributed under the terms specified in the [`LICENSE`] file.
300
356
 
301
- High Voltage is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
357
+ [`LICENSE`]: /MIT-LICENSE
302
358
 
303
- Thank you to all [the contributors](https://github.com/thoughtbot/high_voltage/contributors)!
359
+ ## About thoughtbot
304
360
 
361
+ ![thoughtbot](https://thoughtbot.com/logo.png)
362
+
363
+ High Voltage is maintained and funded by thoughtbot, inc.
305
364
  The names and logos for thoughtbot are trademarks of thoughtbot, inc.
306
365
 
307
- ## License
366
+ We love open source software!
367
+ See [our other projects][community].
368
+ We are [available for hire][hire].
308
369
 
309
- High Voltage is Copyright © 2009-2014 thoughtbot. It is free software, and may
310
- be redistributed under the terms specified in the MIT-LICENSE file.
370
+ [community]: https://thoughtbot.com/community?utm_source=github
371
+ [hire]: https://thoughtbot.com/hire-us?utm_source=github
@@ -6,12 +6,14 @@ module HighVoltage::StaticPage
6
6
 
7
7
  rescue_from ActionView::MissingTemplate do |exception|
8
8
  if exception.message =~ %r{Missing template #{page_finder.content_path}}
9
- raise ActionController::RoutingError, "No such page: #{params[:id]}"
9
+ invalid_page
10
10
  else
11
11
  raise exception
12
12
  end
13
13
  end
14
14
 
15
+ rescue_from HighVoltage::InvalidPageIdError, with: :invalid_page
16
+
15
17
  if respond_to?(:caches_action)
16
18
  caches_action :show, layout: HighVoltage.action_caching_layout,
17
19
  if: -> { HighVoltage.action_caching }
@@ -39,4 +41,8 @@ module HighVoltage::StaticPage
39
41
  def page_finder_factory
40
42
  HighVoltage::PageFinder
41
43
  end
44
+
45
+ def invalid_page
46
+ raise ActionController::RoutingError, "No such page: #{params[:id]}"
47
+ end
42
48
  end
@@ -3,6 +3,8 @@
3
3
  source "http://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "rails", "~> 3.1.12"
6
+ gem "rails", "~> 4.2.0"
7
+ gem "actionpack-action_caching"
8
+ gem "actionpack-page_caching"
7
9
 
8
10
  gemspec :path => "../"
data/high_voltage.gemspec CHANGED
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_development_dependency("activesupport", ">= 3.1.0")
20
20
  s.add_development_dependency("pry")
21
- s.add_development_dependency("rspec-rails")
21
+ s.add_development_dependency("rspec-rails", "~> 3.2.0")
22
22
  end
@@ -31,7 +31,17 @@ module HighVoltage
31
31
  end
32
32
 
33
33
  def clean_id
34
- @page_id.tr("^#{VALID_CHARACTERS}", '')
34
+ @page_id.tr("^#{VALID_CHARACTERS}", "").tap do |id|
35
+ if invalid_page_id?(id)
36
+ raise InvalidPageIdError.new "Invalid page id: #{@page_id}"
37
+ end
38
+ end
39
+ end
40
+
41
+ def invalid_page_id?(id)
42
+ id.blank? || (id.first == ".")
35
43
  end
36
44
  end
45
+
46
+ class InvalidPageIdError < StandardError; end
37
47
  end
@@ -1,3 +1,3 @@
1
1
  module HighVoltage
2
- VERSION = "2.2.1".freeze
2
+ VERSION = "2.3.0".freeze
3
3
  end
@@ -3,19 +3,19 @@ require 'spec_helper'
3
3
  describe HighVoltage::Constraints::RootRoute, '.matches?' do
4
4
  it 'returns true when the view file exists' do
5
5
  request = double(path: 'index')
6
- Dir.stub(:glob).and_return(['about.html.erb'])
6
+ allow(Dir).to receive(:glob).and_return(["about.html.erb"])
7
7
 
8
8
  result = HighVoltage::Constraints::RootRoute.matches?(request)
9
9
 
10
- expect(result).to be_true
10
+ expect(result).to be true
11
11
  end
12
12
 
13
13
  it 'returns false when the view files does not exist' do
14
14
  request = double(path: 'index')
15
- File.stub(:glob).and_return([])
15
+ allow(File).to receive(:glob).and_return([])
16
16
 
17
17
  result = HighVoltage::Constraints::RootRoute.matches?(request)
18
18
 
19
- expect(result).to be_false
19
+ expect(result).to be false
20
20
  end
21
21
  end
@@ -1,108 +1,113 @@
1
- require 'spec_helper'
1
+ # encoding: utf-8
2
+
3
+ require "spec_helper"
2
4
 
3
5
  describe HighVoltage::PagesController do
4
6
  render_views
5
7
 
6
- context 'using default configuration' do
7
- describe 'on GET to /pages/exists' do
8
- before { get :show, :id => 'exists' }
8
+ context "using default configuration" do
9
+ describe "on GET to /pages/exists" do
10
+ before { get :show, id: "exists" }
9
11
 
10
- it 'responds with success and render template' do
12
+ it "responds with success and render template" do
11
13
  expect(response).to be_success
12
- expect(response).to render_template('exists')
14
+ expect(response).to render_template("exists")
13
15
  end
14
16
 
15
- it 'uses the default layout used by ApplicationController' do
16
- expect(response).to render_template('layouts/application')
17
+ it "uses the default layout used by ApplicationController" do
18
+ expect(response).to render_template("layouts/application")
17
19
  end
18
20
  end
19
21
 
20
- describe 'on GET to /pages/dir/nested' do
21
- before { get :show, :id => 'dir/nested' }
22
+ describe "on GET to /pages/dir/nested" do
23
+ before { get :show, id: "dir/nested" }
22
24
 
23
- it 'responds with success and render template' do
25
+ it "responds with success and render template" do
24
26
  expect(response).to be_success
25
- expect(response).to render_template('pages/dir/nested')
27
+ expect(response).to render_template("pages/dir/nested")
26
28
  end
27
29
  end
28
30
 
29
- it 'raises a routing error for an invalid page' do
30
- expect { get :show, id: 'invalid' }
31
- .to raise_error(ActionController::RoutingError)
31
+ it "raises a routing error for an invalid page" do
32
+ expect { get :show, id: "invalid" }.
33
+ to raise_error(ActionController::RoutingError)
32
34
  end
33
35
 
34
- it 'raises a routing error for a page in another directory' do
35
- expect { get :show, id: '../other/wrong' }
36
- .to raise_error(ActionController::RoutingError)
36
+ it "raises a routing error for a page in another directory" do
37
+ expect { get :show, id: "../other/wrong" }.
38
+ to raise_error(ActionController::RoutingError)
37
39
  end
38
40
 
39
- it 'raises a missing template error for valid page with invalid partial' do
40
- expect { get :show, id: 'exists_but_references_nonexistent_partial' }
41
- .to raise_error(ActionView::MissingTemplate)
41
+ it "raises a missing template error for valid page with invalid partial" do
42
+ expect { get :show, id: "exists_but_references_nonexistent_partial" }.
43
+ to raise_error(ActionView::MissingTemplate)
42
44
  end
43
45
  end
44
46
 
45
- context 'using custom layout' do
47
+ context "using custom layout" do
46
48
  before(:each) do
47
- HighVoltage.layout = 'alternate'
49
+ HighVoltage.layout = "alternate"
48
50
  end
49
51
 
50
- describe 'on GET to /pages/exists' do
51
- before { get :show, :id => 'exists' }
52
+ describe "on GET to /pages/exists" do
53
+ before { get :show, id: "exists" }
52
54
 
53
- it 'uses the custom configured layout' do
54
- expect(response).not_to render_template('layouts/application')
55
- expect(response).to render_template('layouts/alternate')
55
+ it "uses the custom configured layout" do
56
+ expect(response).not_to render_template("layouts/application")
57
+ expect(response).to render_template("layouts/alternate")
56
58
  end
57
59
  end
58
60
  end
59
61
 
60
- context 'using custom content path' do
62
+ context "using custom content path" do
61
63
  before(:each) do
62
- HighVoltage.content_path = 'other_pages/'
64
+ HighVoltage.content_path = "other_pages/"
63
65
  Rails.application.reload_routes!
64
66
  end
65
67
 
66
- describe 'on GET to /other_pages/also_exists' do
67
- before { get :show, :id => 'also_exists' }
68
+ describe "on GET to /other_pages/also_exists" do
69
+ before { get :show, id: "also_exists" }
68
70
 
69
- it 'responds with success and render template' do
71
+ it "responds with success and render template" do
70
72
  expect(response).to be_success
71
- expect(response).to render_template('other_pages/also_exists')
73
+ expect(response).to render_template("other_pages/also_exists")
72
74
  end
73
75
  end
74
76
 
75
- describe 'on GET to /other_pages/also_dir/nested' do
76
- before { get :show, :id => 'also_dir/also_nested' }
77
+ describe "on GET to /other_pages/also_dir/nested" do
78
+ before { get :show, id: "also_dir/also_nested" }
77
79
 
78
- it 'responds with success and render template' do
80
+ it "responds with success and render template" do
79
81
  expect(response).to be_success
80
- expect(response).to render_template('other_pages/also_dir/also_nested')
82
+ expect(response).to render_template("other_pages/also_dir/also_nested")
81
83
  end
82
84
  end
83
85
 
84
- it 'raises a routing error for an invalid page' do
85
- expect { get :show, id: 'also_invalid' }
86
- .to raise_error(ActionController::RoutingError)
86
+ it "raises a routing error for an invalid page" do
87
+ expect { get :show, id: "also_invalid" }.
88
+ to raise_error(ActionController::RoutingError)
89
+
90
+ expect { get :show, id: "√®ø" }.
91
+ to raise_error(ActionController::RoutingError)
87
92
  end
88
93
 
89
- context 'page in another directory' do
90
- it 'raises a routing error' do
91
- expect { get :show, id: '../other_wrong' }
92
- .to raise_error(ActionController::RoutingError)
94
+ context "page in another directory" do
95
+ it "raises a routing error" do
96
+ expect { get :show, id: "../other_wrong" }.
97
+ to raise_error(ActionController::RoutingError)
93
98
  end
94
99
 
95
- it 'raises a routing error when using a Unicode exploit' do
96
- expect { get :show, id: '/\\../other/wrong' }
97
- .to raise_error(ActionController::RoutingError)
100
+ it "raises a routing error when using a Unicode exploit" do
101
+ expect { get :show, id: "/\\../other/wrong" }.
102
+ to raise_error(ActionController::RoutingError)
98
103
  end
99
104
  end
100
105
 
101
- it 'raises a missing template error for valid page with invalid partial' do
102
- id = 'also_exists_but_references_nonexistent_partial'
106
+ it "raises a missing template error for valid page with invalid partial" do
107
+ id = "also_exists_but_references_nonexistent_partial"
103
108
 
104
- expect { get :show, id: id }
105
- .to raise_error(ActionView::MissingTemplate)
109
+ expect { get :show, id: id }.
110
+ to raise_error(ActionView::MissingTemplate)
106
111
  end
107
112
  end
108
113
  end
data/spec/fake_app.rb ADDED
@@ -0,0 +1,18 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
4
+
5
+ # Create a rails app
6
+ module Dummy
7
+ class Application < Rails::Application
8
+ config.secret_key_base = "test"
9
+ config.paths["public"] = ["spec/fixtures/public"]
10
+ config.paths["config/routes.rb"] = ["spec/fixtures/config/routes.rb"]
11
+ config.paths["app/views"] = ["spec/fixtures/app/views"]
12
+ config.paths["app/controllers"] = ["spec/support/app/controllers"]
13
+ config.eager_load = false
14
+ config.action_controller.perform_caching = true
15
+ config.action_controller.cache_store = :memory_store
16
+ end
17
+ end
18
+ Dummy::Application.initialize!