high_voltage 2.1.0 → 2.2.1
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 +0 -1
- data/.travis.yml +19 -3
- data/Appraisals +2 -2
- data/Gemfile +2 -0
- data/Gemfile.lock +54 -46
- data/MIT-LICENSE +1 -1
- data/NEWS.md +11 -0
- data/README.md +28 -31
- data/Rakefile +9 -4
- data/config/routes.rb +1 -1
- data/gemfiles/rails3.1.gemfile +8 -0
- data/gemfiles/rails3.1.gemfile.lock +121 -0
- data/gemfiles/rails3.2.gemfile +8 -0
- data/gemfiles/rails3.2.gemfile.lock +119 -0
- data/gemfiles/rails4.0.gemfile +10 -0
- data/gemfiles/rails4.0.gemfile.lock +118 -0
- data/gemfiles/rails4.1.gemfile +10 -0
- data/gemfiles/rails4.1.gemfile.lock +124 -0
- data/high_voltage.gemspec +0 -2
- data/lib/high_voltage/configuration.rb +27 -6
- data/lib/high_voltage/engine.rb +12 -3
- data/lib/high_voltage/version.rb +1 -1
- data/lib/high_voltage.rb +1 -0
- data/spec/constraints/root_route_spec.rb +10 -14
- data/spec/controllers/action_caching_controller_spec.rb +21 -10
- data/spec/controllers/alternative_finder_controller_spec.rb +2 -2
- data/spec/controllers/page_caching_controller_spec.rb +19 -10
- data/spec/controllers/pages_controller_spec.rb +43 -53
- data/spec/controllers/subclassed_pages_controller_spec.rb +15 -21
- data/spec/dummy/config/environments/test.rb +2 -1
- data/spec/high_voltage/configuration_spec.rb +82 -19
- data/spec/high_voltage/page_finder_spec.rb +5 -5
- data/spec/high_voltage_spec.rb +3 -3
- data/spec/integration/navigation_spec.rb +2 -4
- data/spec/requests/home_page_spec.rb +1 -1
- data/spec/routing/routes_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -3
- metadata +11 -35
- data/spec/support/caching.rb +0 -15
- data/spec/support/concern_reload.rb +0 -11
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../
|
|
3
|
+
specs:
|
|
4
|
+
high_voltage (2.2.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: http://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
actionmailer (4.0.5)
|
|
10
|
+
actionpack (= 4.0.5)
|
|
11
|
+
mail (~> 2.5.4)
|
|
12
|
+
actionpack (4.0.5)
|
|
13
|
+
activesupport (= 4.0.5)
|
|
14
|
+
builder (~> 3.1.0)
|
|
15
|
+
erubis (~> 2.7.0)
|
|
16
|
+
rack (~> 1.5.2)
|
|
17
|
+
rack-test (~> 0.6.2)
|
|
18
|
+
actionpack-action_caching (1.1.1)
|
|
19
|
+
actionpack (>= 4.0.0, < 5.0)
|
|
20
|
+
actionpack-page_caching (1.0.2)
|
|
21
|
+
actionpack (>= 4.0.0, < 5)
|
|
22
|
+
activemodel (4.0.5)
|
|
23
|
+
activesupport (= 4.0.5)
|
|
24
|
+
builder (~> 3.1.0)
|
|
25
|
+
activerecord (4.0.5)
|
|
26
|
+
activemodel (= 4.0.5)
|
|
27
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
|
28
|
+
activesupport (= 4.0.5)
|
|
29
|
+
arel (~> 4.0.0)
|
|
30
|
+
activerecord-deprecated_finders (1.0.3)
|
|
31
|
+
activesupport (4.0.5)
|
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
33
|
+
minitest (~> 4.2)
|
|
34
|
+
multi_json (~> 1.3)
|
|
35
|
+
thread_safe (~> 0.1)
|
|
36
|
+
tzinfo (~> 0.3.37)
|
|
37
|
+
appraisal (1.0.0)
|
|
38
|
+
bundler
|
|
39
|
+
rake
|
|
40
|
+
thor (>= 0.14.0)
|
|
41
|
+
arel (4.0.2)
|
|
42
|
+
builder (3.1.4)
|
|
43
|
+
coderay (1.1.0)
|
|
44
|
+
diff-lcs (1.2.5)
|
|
45
|
+
erubis (2.7.0)
|
|
46
|
+
hike (1.2.3)
|
|
47
|
+
i18n (0.6.11)
|
|
48
|
+
mail (2.5.4)
|
|
49
|
+
mime-types (~> 1.16)
|
|
50
|
+
treetop (~> 1.4.8)
|
|
51
|
+
method_source (0.8.2)
|
|
52
|
+
mime-types (1.25.1)
|
|
53
|
+
minitest (4.7.5)
|
|
54
|
+
multi_json (1.10.1)
|
|
55
|
+
polyglot (0.3.5)
|
|
56
|
+
pry (0.10.0)
|
|
57
|
+
coderay (~> 1.1.0)
|
|
58
|
+
method_source (~> 0.8.1)
|
|
59
|
+
slop (~> 3.4)
|
|
60
|
+
rack (1.5.2)
|
|
61
|
+
rack-test (0.6.2)
|
|
62
|
+
rack (>= 1.0)
|
|
63
|
+
rails (4.0.5)
|
|
64
|
+
actionmailer (= 4.0.5)
|
|
65
|
+
actionpack (= 4.0.5)
|
|
66
|
+
activerecord (= 4.0.5)
|
|
67
|
+
activesupport (= 4.0.5)
|
|
68
|
+
bundler (>= 1.3.0, < 2.0)
|
|
69
|
+
railties (= 4.0.5)
|
|
70
|
+
sprockets-rails (~> 2.0.0)
|
|
71
|
+
railties (4.0.5)
|
|
72
|
+
actionpack (= 4.0.5)
|
|
73
|
+
activesupport (= 4.0.5)
|
|
74
|
+
rake (>= 0.8.7)
|
|
75
|
+
thor (>= 0.18.1, < 2.0)
|
|
76
|
+
rake (10.3.2)
|
|
77
|
+
rspec-core (2.14.8)
|
|
78
|
+
rspec-expectations (2.14.5)
|
|
79
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
80
|
+
rspec-mocks (2.14.6)
|
|
81
|
+
rspec-rails (2.14.2)
|
|
82
|
+
actionpack (>= 3.0)
|
|
83
|
+
activemodel (>= 3.0)
|
|
84
|
+
activesupport (>= 3.0)
|
|
85
|
+
railties (>= 3.0)
|
|
86
|
+
rspec-core (~> 2.14.0)
|
|
87
|
+
rspec-expectations (~> 2.14.0)
|
|
88
|
+
rspec-mocks (~> 2.14.0)
|
|
89
|
+
slop (3.5.0)
|
|
90
|
+
sprockets (2.12.0)
|
|
91
|
+
hike (~> 1.2)
|
|
92
|
+
multi_json (~> 1.0)
|
|
93
|
+
rack (~> 1.0)
|
|
94
|
+
tilt (~> 1.1, != 1.3.0)
|
|
95
|
+
sprockets-rails (2.0.1)
|
|
96
|
+
actionpack (>= 3.0)
|
|
97
|
+
activesupport (>= 3.0)
|
|
98
|
+
sprockets (~> 2.8)
|
|
99
|
+
thor (0.19.1)
|
|
100
|
+
thread_safe (0.3.4)
|
|
101
|
+
tilt (1.4.1)
|
|
102
|
+
treetop (1.4.15)
|
|
103
|
+
polyglot
|
|
104
|
+
polyglot (>= 0.3.1)
|
|
105
|
+
tzinfo (0.3.39)
|
|
106
|
+
|
|
107
|
+
PLATFORMS
|
|
108
|
+
ruby
|
|
109
|
+
|
|
110
|
+
DEPENDENCIES
|
|
111
|
+
actionpack-action_caching
|
|
112
|
+
actionpack-page_caching
|
|
113
|
+
activesupport (>= 3.1.0)
|
|
114
|
+
appraisal
|
|
115
|
+
high_voltage!
|
|
116
|
+
pry
|
|
117
|
+
rails (~> 4.0.0)
|
|
118
|
+
rspec-rails
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../
|
|
3
|
+
specs:
|
|
4
|
+
high_voltage (2.2.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: http://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
actionmailer (4.1.4)
|
|
10
|
+
actionpack (= 4.1.4)
|
|
11
|
+
actionview (= 4.1.4)
|
|
12
|
+
mail (~> 2.5.4)
|
|
13
|
+
actionpack (4.1.4)
|
|
14
|
+
actionview (= 4.1.4)
|
|
15
|
+
activesupport (= 4.1.4)
|
|
16
|
+
rack (~> 1.5.2)
|
|
17
|
+
rack-test (~> 0.6.2)
|
|
18
|
+
actionpack-action_caching (1.1.1)
|
|
19
|
+
actionpack (>= 4.0.0, < 5.0)
|
|
20
|
+
actionpack-page_caching (1.0.2)
|
|
21
|
+
actionpack (>= 4.0.0, < 5)
|
|
22
|
+
actionview (4.1.4)
|
|
23
|
+
activesupport (= 4.1.4)
|
|
24
|
+
builder (~> 3.1)
|
|
25
|
+
erubis (~> 2.7.0)
|
|
26
|
+
activemodel (4.1.4)
|
|
27
|
+
activesupport (= 4.1.4)
|
|
28
|
+
builder (~> 3.1)
|
|
29
|
+
activerecord (4.1.4)
|
|
30
|
+
activemodel (= 4.1.4)
|
|
31
|
+
activesupport (= 4.1.4)
|
|
32
|
+
arel (~> 5.0.0)
|
|
33
|
+
activesupport (4.1.4)
|
|
34
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
35
|
+
json (~> 1.7, >= 1.7.7)
|
|
36
|
+
minitest (~> 5.1)
|
|
37
|
+
thread_safe (~> 0.1)
|
|
38
|
+
tzinfo (~> 1.1)
|
|
39
|
+
appraisal (1.0.0)
|
|
40
|
+
bundler
|
|
41
|
+
rake
|
|
42
|
+
thor (>= 0.14.0)
|
|
43
|
+
arel (5.0.1.20140414130214)
|
|
44
|
+
builder (3.2.2)
|
|
45
|
+
coderay (1.1.0)
|
|
46
|
+
diff-lcs (1.2.5)
|
|
47
|
+
erubis (2.7.0)
|
|
48
|
+
hike (1.2.3)
|
|
49
|
+
i18n (0.6.11)
|
|
50
|
+
json (1.8.1)
|
|
51
|
+
mail (2.5.4)
|
|
52
|
+
mime-types (~> 1.16)
|
|
53
|
+
treetop (~> 1.4.8)
|
|
54
|
+
method_source (0.8.2)
|
|
55
|
+
mime-types (1.25.1)
|
|
56
|
+
minitest (5.4.0)
|
|
57
|
+
multi_json (1.10.1)
|
|
58
|
+
polyglot (0.3.5)
|
|
59
|
+
pry (0.10.0)
|
|
60
|
+
coderay (~> 1.1.0)
|
|
61
|
+
method_source (~> 0.8.1)
|
|
62
|
+
slop (~> 3.4)
|
|
63
|
+
rack (1.5.2)
|
|
64
|
+
rack-test (0.6.2)
|
|
65
|
+
rack (>= 1.0)
|
|
66
|
+
rails (4.1.4)
|
|
67
|
+
actionmailer (= 4.1.4)
|
|
68
|
+
actionpack (= 4.1.4)
|
|
69
|
+
actionview (= 4.1.4)
|
|
70
|
+
activemodel (= 4.1.4)
|
|
71
|
+
activerecord (= 4.1.4)
|
|
72
|
+
activesupport (= 4.1.4)
|
|
73
|
+
bundler (>= 1.3.0, < 2.0)
|
|
74
|
+
railties (= 4.1.4)
|
|
75
|
+
sprockets-rails (~> 2.0)
|
|
76
|
+
railties (4.1.4)
|
|
77
|
+
actionpack (= 4.1.4)
|
|
78
|
+
activesupport (= 4.1.4)
|
|
79
|
+
rake (>= 0.8.7)
|
|
80
|
+
thor (>= 0.18.1, < 2.0)
|
|
81
|
+
rake (10.3.2)
|
|
82
|
+
rspec-core (2.14.8)
|
|
83
|
+
rspec-expectations (2.14.5)
|
|
84
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
85
|
+
rspec-mocks (2.14.6)
|
|
86
|
+
rspec-rails (2.14.2)
|
|
87
|
+
actionpack (>= 3.0)
|
|
88
|
+
activemodel (>= 3.0)
|
|
89
|
+
activesupport (>= 3.0)
|
|
90
|
+
railties (>= 3.0)
|
|
91
|
+
rspec-core (~> 2.14.0)
|
|
92
|
+
rspec-expectations (~> 2.14.0)
|
|
93
|
+
rspec-mocks (~> 2.14.0)
|
|
94
|
+
slop (3.5.0)
|
|
95
|
+
sprockets (2.12.0)
|
|
96
|
+
hike (~> 1.2)
|
|
97
|
+
multi_json (~> 1.0)
|
|
98
|
+
rack (~> 1.0)
|
|
99
|
+
tilt (~> 1.1, != 1.3.0)
|
|
100
|
+
sprockets-rails (2.1.3)
|
|
101
|
+
actionpack (>= 3.0)
|
|
102
|
+
activesupport (>= 3.0)
|
|
103
|
+
sprockets (~> 2.8)
|
|
104
|
+
thor (0.19.1)
|
|
105
|
+
thread_safe (0.3.4)
|
|
106
|
+
tilt (1.4.1)
|
|
107
|
+
treetop (1.4.15)
|
|
108
|
+
polyglot
|
|
109
|
+
polyglot (>= 0.3.1)
|
|
110
|
+
tzinfo (1.2.1)
|
|
111
|
+
thread_safe (~> 0.1)
|
|
112
|
+
|
|
113
|
+
PLATFORMS
|
|
114
|
+
ruby
|
|
115
|
+
|
|
116
|
+
DEPENDENCIES
|
|
117
|
+
actionpack-action_caching
|
|
118
|
+
actionpack-page_caching
|
|
119
|
+
activesupport (>= 3.1.0)
|
|
120
|
+
appraisal
|
|
121
|
+
high_voltage!
|
|
122
|
+
pry
|
|
123
|
+
rails (~> 4.1.0)
|
|
124
|
+
rspec-rails
|
data/high_voltage.gemspec
CHANGED
|
@@ -17,8 +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
|
-
s.add_development_dependency("capybara", "= 2.0.3")
|
|
22
20
|
s.add_development_dependency("pry")
|
|
23
21
|
s.add_development_dependency("rspec-rails")
|
|
24
22
|
end
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
module HighVoltage
|
|
2
2
|
module Configuration
|
|
3
|
+
CACHING_DEPRECATION_WARNING = <<-WARNING.strip_heredoc.squish
|
|
4
|
+
Caching support has been deprecated and will be removed
|
|
5
|
+
in the next release.
|
|
6
|
+
WARNING
|
|
7
|
+
|
|
3
8
|
attr_accessor(
|
|
4
|
-
:action_caching,
|
|
5
|
-
:action_caching_layout,
|
|
6
9
|
:content_path,
|
|
7
10
|
:home_page,
|
|
8
11
|
:layout,
|
|
9
|
-
:
|
|
12
|
+
:parent_engine,
|
|
10
13
|
:route_drawer,
|
|
11
14
|
:routes,
|
|
12
15
|
)
|
|
13
16
|
|
|
17
|
+
attr_reader :action_caching, :action_caching_layout, :page_caching
|
|
18
|
+
|
|
14
19
|
def configure
|
|
15
20
|
yield self
|
|
16
21
|
end
|
|
@@ -19,13 +24,29 @@ module HighVoltage
|
|
|
19
24
|
base.set_default_configuration
|
|
20
25
|
end
|
|
21
26
|
|
|
27
|
+
def action_caching=(value)
|
|
28
|
+
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
|
29
|
+
@action_caching = value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def action_caching_layout=(value)
|
|
33
|
+
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
|
34
|
+
@action_caching_layout = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def page_caching=(value)
|
|
38
|
+
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
|
39
|
+
@page_caching = value
|
|
40
|
+
end
|
|
41
|
+
|
|
22
42
|
def set_default_configuration
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
@action_caching = false
|
|
44
|
+
@action_caching_layout = true
|
|
45
|
+
@page_caching = false
|
|
46
|
+
|
|
25
47
|
self.content_path = 'pages/'
|
|
26
48
|
self.home_page = nil
|
|
27
49
|
self.layout = 'application'
|
|
28
|
-
self.page_caching = false
|
|
29
50
|
self.route_drawer = HighVoltage::RouteDrawers::Default
|
|
30
51
|
self.routes = true
|
|
31
52
|
end
|
data/lib/high_voltage/engine.rb
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
module HighVoltage
|
|
2
2
|
class Engine < Rails::Engine
|
|
3
|
-
initializer
|
|
4
|
-
|
|
3
|
+
initializer "Set up default parent engine" do |app|
|
|
4
|
+
HighVoltage.parent_engine ||= Rails.application
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
initializer "Require concerns path" do |app|
|
|
8
|
+
concerns_path = "app/controllers/concerns"
|
|
5
9
|
|
|
6
10
|
unless app.paths.keys.include?(concerns_path)
|
|
7
11
|
app.paths.add(concerns_path)
|
|
8
12
|
end
|
|
13
|
+
end
|
|
9
14
|
|
|
10
|
-
|
|
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
|
|
11
20
|
end
|
|
12
21
|
end
|
|
13
22
|
end
|
data/lib/high_voltage/version.rb
CHANGED
data/lib/high_voltage.rb
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe HighVoltage::Constraints::RootRoute, '.matches?' do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Dir.stub(:glob).and_return(['about.html.erb'])
|
|
4
|
+
it 'returns true when the view file exists' do
|
|
5
|
+
request = double(path: 'index')
|
|
6
|
+
Dir.stub(:glob).and_return(['about.html.erb'])
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
result = HighVoltage::Constraints::RootRoute.matches?(request)
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
end
|
|
10
|
+
expect(result).to be_true
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
File.stub(:glob).and_return([])
|
|
13
|
+
it 'returns false when the view files does not exist' do
|
|
14
|
+
request = double(path: 'index')
|
|
15
|
+
File.stub(:glob).and_return([])
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
result = HighVoltage::Constraints::RootRoute.matches?(request)
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
end
|
|
19
|
+
expect(result).to be_false
|
|
24
20
|
end
|
|
25
21
|
end
|
|
@@ -4,24 +4,35 @@ describe HighVoltage::PagesController, '#action_caching' do
|
|
|
4
4
|
let(:page_name) { :exists }
|
|
5
5
|
|
|
6
6
|
context 'action_caching set to true' do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
after do
|
|
8
|
+
set_action_caching_without_deprecation(false)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'caches the action' do
|
|
12
|
+
allow(controller).to receive(:_save_fragment)
|
|
13
|
+
set_action_caching_without_deprecation(true)
|
|
14
|
+
|
|
15
|
+
get :show, id: page_name
|
|
10
16
|
|
|
11
|
-
expect
|
|
17
|
+
expect(controller).to have_received(:_save_fragment)
|
|
18
|
+
.with("test.host#{page_path(page_name)}", {})
|
|
12
19
|
end
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
context 'action_caching set to false' do
|
|
16
|
-
it 'does not cache the action'
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
it 'does not cache the action' do
|
|
24
|
+
allow(controller).to receive(:_save_fragment)
|
|
25
|
+
set_action_caching_without_deprecation(false)
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
get :show, id: page_name
|
|
28
|
+
|
|
29
|
+
expect(controller).not_to have_received(:_save_fragment)
|
|
21
30
|
end
|
|
22
31
|
end
|
|
23
32
|
|
|
24
|
-
def
|
|
25
|
-
|
|
33
|
+
def set_action_caching_without_deprecation(value)
|
|
34
|
+
ActiveSupport::Deprecation.silence do
|
|
35
|
+
HighVoltage.action_caching = value
|
|
36
|
+
end
|
|
26
37
|
end
|
|
27
38
|
end
|
|
@@ -6,7 +6,7 @@ describe AlternativeFinderController do
|
|
|
6
6
|
it 'renders the file from the alternative directory' do
|
|
7
7
|
get :show, :id => 'ebg13'
|
|
8
8
|
|
|
9
|
-
response.
|
|
10
|
-
response.
|
|
9
|
+
expect(response).to be_success
|
|
10
|
+
expect(response).to render_template('rot13')
|
|
11
11
|
end
|
|
12
12
|
end
|
|
@@ -4,25 +4,34 @@ describe HighVoltage::PagesController, '#cache_page' do
|
|
|
4
4
|
let(:page_name) { :exists }
|
|
5
5
|
|
|
6
6
|
context 'page_caching set to true' do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
after do
|
|
8
|
+
set_page_caching_without_deprecation(false)
|
|
9
|
+
end
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
it 'caches the page' do
|
|
12
|
+
allow(controller).to receive(:cache_page)
|
|
13
|
+
set_page_caching_without_deprecation(true)
|
|
12
14
|
|
|
13
15
|
get :show, id: page_name
|
|
16
|
+
|
|
17
|
+
expect(controller).to have_received(:cache_page)
|
|
14
18
|
end
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
context 'page_caching set to false' do
|
|
18
|
-
it 'does not cache the page'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
controller.should_receive(:cache_page).never
|
|
22
|
+
it 'does not cache the page' do
|
|
23
|
+
allow(controller).to receive(:cache_page)
|
|
24
|
+
set_page_caching_without_deprecation(false)
|
|
23
25
|
|
|
24
26
|
get :show, id: page_name
|
|
27
|
+
|
|
28
|
+
expect(controller).not_to have_received(:cache_page)
|
|
25
29
|
end
|
|
26
30
|
end
|
|
27
|
-
end
|
|
28
31
|
|
|
32
|
+
def set_page_caching_without_deprecation(value)
|
|
33
|
+
ActiveSupport::Deprecation.silence do
|
|
34
|
+
HighVoltage.page_caching = value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -7,44 +7,38 @@ describe HighVoltage::PagesController do
|
|
|
7
7
|
describe 'on GET to /pages/exists' do
|
|
8
8
|
before { get :show, :id => 'exists' }
|
|
9
9
|
|
|
10
|
-
it '
|
|
11
|
-
response.
|
|
12
|
-
response.
|
|
10
|
+
it 'responds with success and render template' do
|
|
11
|
+
expect(response).to be_success
|
|
12
|
+
expect(response).to render_template('exists')
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
it '
|
|
16
|
-
response.
|
|
15
|
+
it 'uses the default layout used by ApplicationController' do
|
|
16
|
+
expect(response).to render_template('layouts/application')
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe 'on GET to /pages/dir/nested' do
|
|
21
21
|
before { get :show, :id => 'dir/nested' }
|
|
22
22
|
|
|
23
|
-
it '
|
|
24
|
-
response.
|
|
25
|
-
response.
|
|
23
|
+
it 'responds with success and render template' do
|
|
24
|
+
expect(response).to be_success
|
|
25
|
+
expect(response).to render_template('pages/dir/nested')
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
it '
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
:id => 'invalid'
|
|
33
|
-
}.should raise_error(ActionController::RoutingError)
|
|
29
|
+
it 'raises a routing error for an invalid page' do
|
|
30
|
+
expect { get :show, id: 'invalid' }
|
|
31
|
+
.to raise_error(ActionController::RoutingError)
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
it '
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
:id => '../other/wrong'
|
|
40
|
-
}.should raise_error(ActionController::RoutingError)
|
|
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)
|
|
41
37
|
end
|
|
42
38
|
|
|
43
|
-
it '
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
:id => 'exists_but_references_nonexistent_partial'
|
|
47
|
-
}.should raise_error(ActionView::MissingTemplate)
|
|
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)
|
|
48
42
|
end
|
|
49
43
|
end
|
|
50
44
|
|
|
@@ -56,9 +50,9 @@ describe HighVoltage::PagesController do
|
|
|
56
50
|
describe 'on GET to /pages/exists' do
|
|
57
51
|
before { get :show, :id => 'exists' }
|
|
58
52
|
|
|
59
|
-
it '
|
|
60
|
-
response.
|
|
61
|
-
response.
|
|
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')
|
|
62
56
|
end
|
|
63
57
|
end
|
|
64
58
|
end
|
|
@@ -72,47 +66,43 @@ describe HighVoltage::PagesController do
|
|
|
72
66
|
describe 'on GET to /other_pages/also_exists' do
|
|
73
67
|
before { get :show, :id => 'also_exists' }
|
|
74
68
|
|
|
75
|
-
it '
|
|
76
|
-
response.
|
|
77
|
-
response.
|
|
69
|
+
it 'responds with success and render template' do
|
|
70
|
+
expect(response).to be_success
|
|
71
|
+
expect(response).to render_template('other_pages/also_exists')
|
|
78
72
|
end
|
|
79
73
|
end
|
|
80
74
|
|
|
81
75
|
describe 'on GET to /other_pages/also_dir/nested' do
|
|
82
76
|
before { get :show, :id => 'also_dir/also_nested' }
|
|
83
77
|
|
|
84
|
-
it '
|
|
85
|
-
response.
|
|
86
|
-
response.
|
|
78
|
+
it 'responds with success and render template' do
|
|
79
|
+
expect(response).to be_success
|
|
80
|
+
expect(response).to render_template('other_pages/also_dir/also_nested')
|
|
87
81
|
end
|
|
88
82
|
end
|
|
89
83
|
|
|
90
|
-
it '
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
:id => 'also_invalid'
|
|
94
|
-
}.should raise_error(ActionController::RoutingError)
|
|
84
|
+
it 'raises a routing error for an invalid page' do
|
|
85
|
+
expect { get :show, id: 'also_invalid' }
|
|
86
|
+
.to raise_error(ActionController::RoutingError)
|
|
95
87
|
end
|
|
96
88
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
get :show,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
end
|
|
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)
|
|
93
|
+
end
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}.should raise_error(ActionController::RoutingError)
|
|
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)
|
|
98
|
+
end
|
|
109
99
|
end
|
|
110
100
|
|
|
111
|
-
it '
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
it 'raises a missing template error for valid page with invalid partial' do
|
|
102
|
+
id = 'also_exists_but_references_nonexistent_partial'
|
|
103
|
+
|
|
104
|
+
expect { get :show, id: id }
|
|
105
|
+
.to raise_error(ActionView::MissingTemplate)
|
|
116
106
|
end
|
|
117
107
|
end
|
|
118
108
|
end
|