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.
- checksums.yaml +4 -4
- data/.gitignore +1 -4
- data/.travis.yml +13 -4
- data/Appraisals +3 -10
- data/CONTRIBUTING.md +4 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +61 -42
- data/MIT-LICENSE +1 -1
- data/NEWS.md +8 -0
- data/README.md +71 -10
- data/Rakefile +9 -4
- data/app/controllers/concerns/high_voltage/static_page.rb +7 -1
- data/gemfiles/rails4.0.gemfile +10 -0
- data/gemfiles/rails4.1.gemfile +10 -0
- data/gemfiles/rails4.2.gemfile +10 -0
- data/high_voltage.gemspec +1 -2
- data/lib/high_voltage/engine.rb +10 -3
- data/lib/high_voltage/page_finder.rb +11 -1
- data/lib/high_voltage/version.rb +1 -1
- data/spec/constraints/root_route_spec.rb +4 -4
- data/spec/controllers/pages_controller_spec.rb +57 -52
- data/spec/fake_app.rb +18 -0
- data/spec/fixtures/config/database.yml +3 -0
- data/spec/high_voltage/page_finder_spec.rb +30 -14
- data/spec/spec_helper.rb +14 -8
- metadata +48 -113
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/config/application.rb +0 -43
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -25
- data/spec/dummy/config/environments/production.rb +0 -49
- data/spec/dummy/config/environments/test.rb +0 -30
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_key_base.rb +0 -1
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -191
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +0 -6
- /data/spec/{dummy → fixtures}/app/views/layouts/alternate.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/layouts/application.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other/wrong.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other_pages/also_dir/also_nested.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/also_dir/also_nested.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/also_exists.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/dir/nested.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/exists.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -0
- /data/spec/{dummy → fixtures}/app/views/pages/rot13.html.erb +0 -0
- /data/spec/{dummy → fixtures}/config/routes.rb +0 -0
- /data/spec/{dummy → fixtures}/public/pages/exists.html +0 -0
- /data/spec/{dummy → support}/app/controllers/alternative_finder_controller.rb +0 -0
- /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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dfdb165dc9944d13d14ccfcfab0358c2d575b688
|
|
4
|
+
data.tar.gz: 769e4a05d918743c86ce21f58b4ab2ea3d8bc838
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e036c73851faf23320d6b5fccbd8c65cacdb73e736422e0df062cdea64ea8c6a88d26bfc084403a979955eeb695e82d4bc89fdcdd6905516dd7adf85734425b7
|
|
7
|
+
data.tar.gz: 29b92c7a8e76d78f6084bfbc6987d5022af4a048461eaff10192d32e94bdd217b41ca27e9ac1c42a38e70fae0603519075cba4e7d2f0a9cc78dc5b4ddaf11206
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
data/Gemfile.lock
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
high_voltage (2.
|
|
4
|
+
high_voltage (2.3.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: http://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
actionpack (4.
|
|
10
|
-
actionview (= 4.
|
|
11
|
-
activesupport (= 4.
|
|
12
|
-
rack (~> 1.
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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.
|
|
26
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
26
27
|
tzinfo (~> 1.1)
|
|
27
|
-
appraisal (1.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.
|
|
36
|
-
json (1.8.
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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.
|
|
44
|
-
rack-test (0.6.
|
|
49
|
+
rack (1.6.0)
|
|
50
|
+
rack-test (0.6.3)
|
|
45
51
|
rack (>= 1.0)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
52
|
-
rspec-core (2.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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.
|
|
67
|
-
tzinfo (1.
|
|
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
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.
|
|
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]
|
|
295
|
-
|
|
346
|
+
Please see [CONTRIBUTING.md].
|
|
347
|
+
Thank you, [contributors]!
|
|
296
348
|
|
|
297
|
-
|
|
349
|
+
[CONTRIBUTING.md]: /CONTRIBUTING.md
|
|
350
|
+
[contributors]: https://github.com/thoughtbot/high_voltage/graphs/contributors
|
|
298
351
|
|
|
299
|
-
|
|
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
|
-
|
|
357
|
+
[`LICENSE`]: /MIT-LICENSE
|
|
302
358
|
|
|
303
|
-
|
|
359
|
+
## About thoughtbot
|
|
304
360
|
|
|
361
|
+

|
|
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
|
-
|
|
366
|
+
We love open source software!
|
|
367
|
+
See [our other projects][community].
|
|
368
|
+
We are [available for hire][hire].
|
|
308
369
|
|
|
309
|
-
|
|
310
|
-
|
|
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
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
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
|
data/lib/high_voltage/engine.rb
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
module HighVoltage
|
|
2
2
|
class Engine < Rails::Engine
|
|
3
|
-
initializer
|
|
3
|
+
initializer "Set up default parent engine" do |app|
|
|
4
4
|
HighVoltage.parent_engine ||= Rails.application
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
initializer
|
|
8
|
-
concerns_path =
|
|
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
|
data/lib/high_voltage/version.rb
CHANGED
|
@@ -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.
|
|
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
|
|
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.
|
|
15
|
+
allow(File).to receive(:glob).and_return([])
|
|
16
16
|
|
|
17
17
|
result = HighVoltage::Constraints::RootRoute.matches?(request)
|
|
18
18
|
|
|
19
|
-
expect(result).to
|
|
19
|
+
expect(result).to be false
|
|
20
20
|
end
|
|
21
21
|
end
|