high_voltage 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -3
- data/.travis.yml +7 -14
- data/Appraisals +3 -10
- data/CONTRIBUTING.md +4 -1
- data/Gemfile.lock +61 -42
- data/MIT-LICENSE +1 -1
- data/NEWS.md +5 -0
- data/README.md +71 -10
- data/app/controllers/concerns/high_voltage/static_page.rb +7 -1
- data/gemfiles/{rails3.1.gemfile → rails4.2.gemfile} +3 -1
- data/high_voltage.gemspec +1 -1
- 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/{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/fixtures/config/database.yml +3 -0
- data/spec/{dummy → fixtures}/config/routes.rb +0 -0
- data/spec/{dummy → fixtures}/public/pages/exists.html +0 -0
- data/spec/high_voltage/page_finder_spec.rb +30 -14
- data/spec/spec_helper.rb +14 -8
- data/spec/{dummy → support}/app/controllers/alternative_finder_controller.rb +0 -0
- data/spec/{dummy → support}/app/controllers/subclassed_pages_controller.rb +0 -0
- metadata +46 -105
- data/gemfiles/rails3.1.gemfile.lock +0 -121
- data/gemfiles/rails3.2.gemfile +0 -8
- data/gemfiles/rails3.2.gemfile.lock +0 -119
- data/gemfiles/rails4.0.gemfile.lock +0 -118
- data/gemfiles/rails4.1.gemfile.lock +0 -124
- 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
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,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.
|
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
|
-
|
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.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
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
|
+
![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
|
-
|
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
|
@@ -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
@@ -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
|
@@ -1,108 +1,113 @@
|
|
1
|
-
|
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
|
7
|
-
describe
|
8
|
-
before { get :show, :
|
8
|
+
context "using default configuration" do
|
9
|
+
describe "on GET to /pages/exists" do
|
10
|
+
before { get :show, id: "exists" }
|
9
11
|
|
10
|
-
it
|
12
|
+
it "responds with success and render template" do
|
11
13
|
expect(response).to be_success
|
12
|
-
expect(response).to render_template(
|
14
|
+
expect(response).to render_template("exists")
|
13
15
|
end
|
14
16
|
|
15
|
-
it
|
16
|
-
expect(response).to render_template(
|
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
|
21
|
-
before { get :show, :
|
22
|
+
describe "on GET to /pages/dir/nested" do
|
23
|
+
before { get :show, id: "dir/nested" }
|
22
24
|
|
23
|
-
it
|
25
|
+
it "responds with success and render template" do
|
24
26
|
expect(response).to be_success
|
25
|
-
expect(response).to render_template(
|
27
|
+
expect(response).to render_template("pages/dir/nested")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
it
|
30
|
-
expect { get :show, id:
|
31
|
-
|
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
|
35
|
-
expect { get :show, id:
|
36
|
-
|
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
|
40
|
-
expect { get :show, id:
|
41
|
-
|
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
|
47
|
+
context "using custom layout" do
|
46
48
|
before(:each) do
|
47
|
-
HighVoltage.layout =
|
49
|
+
HighVoltage.layout = "alternate"
|
48
50
|
end
|
49
51
|
|
50
|
-
describe
|
51
|
-
before { get :show, :
|
52
|
+
describe "on GET to /pages/exists" do
|
53
|
+
before { get :show, id: "exists" }
|
52
54
|
|
53
|
-
it
|
54
|
-
expect(response).not_to render_template(
|
55
|
-
expect(response).to render_template(
|
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
|
62
|
+
context "using custom content path" do
|
61
63
|
before(:each) do
|
62
|
-
HighVoltage.content_path =
|
64
|
+
HighVoltage.content_path = "other_pages/"
|
63
65
|
Rails.application.reload_routes!
|
64
66
|
end
|
65
67
|
|
66
|
-
describe
|
67
|
-
before { get :show, :
|
68
|
+
describe "on GET to /other_pages/also_exists" do
|
69
|
+
before { get :show, id: "also_exists" }
|
68
70
|
|
69
|
-
it
|
71
|
+
it "responds with success and render template" do
|
70
72
|
expect(response).to be_success
|
71
|
-
expect(response).to render_template(
|
73
|
+
expect(response).to render_template("other_pages/also_exists")
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
|
-
describe
|
76
|
-
before { get :show, :
|
77
|
+
describe "on GET to /other_pages/also_dir/nested" do
|
78
|
+
before { get :show, id: "also_dir/also_nested" }
|
77
79
|
|
78
|
-
it
|
80
|
+
it "responds with success and render template" do
|
79
81
|
expect(response).to be_success
|
80
|
-
expect(response).to render_template(
|
82
|
+
expect(response).to render_template("other_pages/also_dir/also_nested")
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
|
-
it
|
85
|
-
expect { get :show, id:
|
86
|
-
|
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
|
90
|
-
it
|
91
|
-
expect { get :show, id:
|
92
|
-
|
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
|
96
|
-
expect { get :show, id:
|
97
|
-
|
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
|
102
|
-
id =
|
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
|
-
|
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!
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/{dummy → fixtures}/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb
RENAMED
File without changes
|
File without changes
|
File without changes
|