high_voltage 2.2.0 → 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 -4
  3. data/.travis.yml +13 -4
  4. data/Appraisals +3 -10
  5. data/CONTRIBUTING.md +4 -1
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +61 -42
  8. data/MIT-LICENSE +1 -1
  9. data/NEWS.md +8 -0
  10. data/README.md +71 -10
  11. data/Rakefile +9 -4
  12. data/app/controllers/concerns/high_voltage/static_page.rb +7 -1
  13. data/gemfiles/rails4.0.gemfile +10 -0
  14. data/gemfiles/rails4.1.gemfile +10 -0
  15. data/gemfiles/rails4.2.gemfile +10 -0
  16. data/high_voltage.gemspec +1 -2
  17. data/lib/high_voltage/engine.rb +10 -3
  18. data/lib/high_voltage/page_finder.rb +11 -1
  19. data/lib/high_voltage/version.rb +1 -1
  20. data/spec/constraints/root_route_spec.rb +4 -4
  21. data/spec/controllers/pages_controller_spec.rb +57 -52
  22. data/spec/fake_app.rb +18 -0
  23. data/spec/fixtures/config/database.yml +3 -0
  24. data/spec/high_voltage/page_finder_spec.rb +30 -14
  25. data/spec/spec_helper.rb +14 -8
  26. metadata +48 -113
  27. data/spec/dummy/Rakefile +0 -7
  28. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  29. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  30. data/spec/dummy/config/application.rb +0 -43
  31. data/spec/dummy/config/boot.rb +0 -10
  32. data/spec/dummy/config/environment.rb +0 -5
  33. data/spec/dummy/config/environments/development.rb +0 -25
  34. data/spec/dummy/config/environments/production.rb +0 -49
  35. data/spec/dummy/config/environments/test.rb +0 -30
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/spec/dummy/config/initializers/inflections.rb +0 -10
  38. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  39. data/spec/dummy/config/initializers/secret_key_base.rb +0 -1
  40. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  41. data/spec/dummy/config/initializers/session_store.rb +0 -8
  42. data/spec/dummy/config/locales/en.yml +0 -5
  43. data/spec/dummy/config.ru +0 -4
  44. data/spec/dummy/public/404.html +0 -26
  45. data/spec/dummy/public/422.html +0 -26
  46. data/spec/dummy/public/500.html +0 -26
  47. data/spec/dummy/public/favicon.ico +0 -0
  48. data/spec/dummy/public/javascripts/application.js +0 -2
  49. data/spec/dummy/public/javascripts/controls.js +0 -965
  50. data/spec/dummy/public/javascripts/dragdrop.js +0 -974
  51. data/spec/dummy/public/javascripts/effects.js +0 -1123
  52. data/spec/dummy/public/javascripts/prototype.js +0 -6001
  53. data/spec/dummy/public/javascripts/rails.js +0 -191
  54. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  55. data/spec/dummy/script/rails +0 -6
  56. /data/spec/{dummy → fixtures}/app/views/layouts/alternate.html.erb +0 -0
  57. /data/spec/{dummy → fixtures}/app/views/layouts/application.html.erb +0 -0
  58. /data/spec/{dummy → fixtures}/app/views/other/wrong.html.erb +0 -0
  59. /data/spec/{dummy → fixtures}/app/views/other_pages/also_dir/also_nested.html.erb +0 -0
  60. /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists.html.erb +0 -0
  61. /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
  62. /data/spec/{dummy → fixtures}/app/views/pages/also_dir/also_nested.html.erb +0 -0
  63. /data/spec/{dummy → fixtures}/app/views/pages/also_exists.html.erb +0 -0
  64. /data/spec/{dummy → fixtures}/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
  65. /data/spec/{dummy → fixtures}/app/views/pages/dir/nested.html.erb +0 -0
  66. /data/spec/{dummy → fixtures}/app/views/pages/exists.html.erb +0 -0
  67. /data/spec/{dummy → fixtures}/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -0
  68. /data/spec/{dummy → fixtures}/app/views/pages/rot13.html.erb +0 -0
  69. /data/spec/{dummy → fixtures}/config/routes.rb +0 -0
  70. /data/spec/{dummy → fixtures}/public/pages/exists.html +0 -0
  71. /data/spec/{dummy → support}/app/controllers/alternative_finder_controller.rb +0 -0
  72. /data/spec/{dummy → support}/app/controllers/subclassed_pages_controller.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f93b914b6966f7141851a562ce82ffe1e218e01
4
- data.tar.gz: d6456e304488fec82214e584d9dbd8f261151d69
3
+ metadata.gz: dfdb165dc9944d13d14ccfcfab0358c2d575b688
4
+ data.tar.gz: 769e4a05d918743c86ce21f58b4ab2ea3d8bc838
5
5
  SHA512:
6
- metadata.gz: eabead4dde04710b58c97047ca3d0b18af4694696b0e800af9ad0618d08d37c358071999f2fb4a56455857c501d1204a1df73c91c85f58e1fe4d9c71a915d93d
7
- data.tar.gz: 8a0b9a4dabe052d01a1b2f4edc91cc7bd15a36eff75ab49d7db3e4c18fe9509203edc214fc2a5d2767022cdfac32c384b94af8023583a5e39944fd94830be8ba
6
+ metadata.gz: e036c73851faf23320d6b5fccbd8c65cacdb73e736422e0df062cdea64ea8c6a88d26bfc084403a979955eeb695e82d4bc89fdcdd6905516dd7adf85734425b7
7
+ data.tar.gz: 29b92c7a8e76d78f6084bfbc6987d5022af4a048461eaff10192d32e94bdd217b41ca27e9ac1c42a38e70fae0603519075cba4e7d2f0a9cc78dc5b4ddaf11206
data/.gitignore CHANGED
@@ -1,9 +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
- gemfiles/
9
5
  *.gem
6
+ gemfiles/*.lock
data/.travis.yml CHANGED
@@ -1,8 +1,17 @@
1
- language:
2
- - ruby
1
+ gemfile:
2
+ - gemfiles/rails4.0.gemfile
3
+ - gemfiles/rails4.1.gemfile
4
+ - gemfiles/rails4.2.gemfile
3
5
  install:
4
6
  - 'travis_retry bundle install'
7
+ language:
8
+ - ruby
5
9
  rvm:
6
- - 1.9.3
7
10
  - 2.0.0
8
- - 2.1.2
11
+ - 2.1.5
12
+ - 2.2.0
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 CHANGED
@@ -1,3 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem 'appraisal'
4
+
3
5
  gemspec
data/Gemfile.lock CHANGED
@@ -1,30 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_voltage (2.2.0)
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,11 @@
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
+
6
+ New for 2.2.1:
7
+ + Resolve issue with require statements for Rails 3.x projects
8
+
1
9
  New for 2.2.0:
2
10
  + Deprecate caching because page and action caching was removed in Rails 4
3
11
  + Refactor test suite to use rspec `expect` syntax consistently.
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.0'
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
data/Rakefile CHANGED
@@ -11,9 +11,14 @@ require 'appraisal'
11
11
  RSpec::Core::RakeTask.new(:spec)
12
12
 
13
13
  desc 'Default'
14
- task :default => [:all]
14
+ task :default do
15
+ if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
16
+ Rake::Task['spec'].invoke
17
+ else
18
+ Rake::Task['appraise'].invoke
19
+ end
20
+ end
15
21
 
16
- desc 'Test the engine under all supported Rails versions'
17
- task all: ['appraisal:install'] do |t|
18
- exec 'rake appraisal spec'
22
+ task :appraise do
23
+ exec 'appraisal install && appraisal rake'
19
24
  end
@@ -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
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 4.0.0"
7
+ gem "actionpack-action_caching"
8
+ gem "actionpack-page_caching"
9
+
10
+ gemspec :path => "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 4.1.0"
7
+ gem "actionpack-action_caching"
8
+ gem "actionpack-page_caching"
9
+
10
+ gemspec :path => "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 4.2.0"
7
+ gem "actionpack-action_caching"
8
+ gem "actionpack-page_caching"
9
+
10
+ gemspec :path => "../"
data/high_voltage.gemspec CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_development_dependency("activesupport", ">= 3.1.0")
20
- s.add_development_dependency("appraisal")
21
20
  s.add_development_dependency("pry")
22
- s.add_development_dependency("rspec-rails")
21
+ s.add_development_dependency("rspec-rails", "~> 3.2.0")
23
22
  end
@@ -1,15 +1,22 @@
1
1
  module HighVoltage
2
2
  class Engine < Rails::Engine
3
- initializer 'Set up default parent engine' do |app|
3
+ initializer "Set up default parent engine" do |app|
4
4
  HighVoltage.parent_engine ||= Rails.application
5
5
  end
6
6
 
7
- initializer 'Require concerns path' do |app|
8
- concerns_path = 'app/controllers/concerns'
7
+ initializer "Require concerns path" do |app|
8
+ concerns_path = "app/controllers/concerns"
9
9
 
10
10
  unless app.paths.keys.include?(concerns_path)
11
11
  app.paths.add(concerns_path)
12
12
  end
13
13
  end
14
+
15
+ initializer "Require for Rails 3" do |app|
16
+ if defined?(Rails) && Rails::VERSION::MAJOR == 3
17
+ require "concerns/high_voltage/static_page"
18
+ require "high_voltage/pages_controller"
19
+ end
20
+ end
14
21
  end
15
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.0'.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