high_voltage 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/Appraisals +6 -2
- data/Gemfile +4 -3
- data/Gemfile.lock +39 -39
- data/NEWS.md +5 -0
- data/README.md +6 -10
- data/app/controllers/concerns/high_voltage/static_page.rb +6 -15
- data/gemfiles/rails4.0.gemfile +2 -3
- data/gemfiles/rails4.1.gemfile +2 -3
- data/gemfiles/rails4.2.gemfile +2 -3
- data/gemfiles/rails50.gemfile +10 -0
- data/high_voltage.gemspec +0 -1
- data/lib/high_voltage/configuration.rb +0 -32
- data/lib/high_voltage/constraints/root_route.rb +17 -10
- data/lib/high_voltage/version.rb +1 -1
- data/spec/constraints/root_route_spec.rb +21 -6
- data/spec/high_voltage/configuration_spec.rb +0 -102
- data/spec/spec_helper.rb +9 -2
- data/spec/support/http_method_shim.rb +15 -0
- metadata +6 -21
- data/spec/controllers/action_caching_controller_spec.rb +0 -38
- data/spec/controllers/page_caching_controller_spec.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6fe8331cf7311ae941daea7a313a66e350a5565
|
4
|
+
data.tar.gz: d1f5bb5ec3984ce97f167a7e4b56c9936ff1a788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b5f88d3c1b88243befa89c0e1c8e1640b9b1556ea070dcbb7eff8bfeab51c88d6907e6746730d9318c4a276f026f45695eefc800e9aba078bc4ee48714860a8
|
7
|
+
data.tar.gz: 949ae450736d58557bc15ecdcd6f33098ae2ada670563b9440e8b65e7883d12154ddc170d3f42d1147133d4452ccabe7d771707eef320779113e32bdccc636a7
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -3,7 +3,11 @@ rails_versions = ['~> 4.0.0', '~> 4.1.0', '~> 4.2.0']
|
|
3
3
|
rails_versions.each do |rails_version|
|
4
4
|
appraise "rails#{rails_version.slice(/\d+\.\d+/)}" do
|
5
5
|
gem 'rails', rails_version
|
6
|
-
gem 'actionpack-action_caching'
|
7
|
-
gem 'actionpack-page_caching'
|
8
6
|
end
|
9
7
|
end
|
8
|
+
|
9
|
+
appraise "rails50" do
|
10
|
+
gem "rails", "~> 5.0.0.beta3"
|
11
|
+
gem "rspec-rails", "3.5.0.beta1"
|
12
|
+
gem "rails-controller-testing"
|
13
|
+
end
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
high_voltage (
|
4
|
+
high_voltage (3.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
|
-
remote:
|
7
|
+
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionpack (4.2.
|
10
|
-
actionview (= 4.2.
|
11
|
-
activesupport (= 4.2.
|
12
|
-
rack (~> 1.6
|
9
|
+
actionpack (4.2.5.2)
|
10
|
+
actionview (= 4.2.5.2)
|
11
|
+
activesupport (= 4.2.5.2)
|
12
|
+
rack (~> 1.6)
|
13
13
|
rack-test (~> 0.6.2)
|
14
14
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
15
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.
|
16
|
-
actionview (4.2.
|
17
|
-
activesupport (= 4.2.
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
16
|
+
actionview (4.2.5.2)
|
17
|
+
activesupport (= 4.2.5.2)
|
18
18
|
builder (~> 3.1)
|
19
19
|
erubis (~> 2.7.0)
|
20
20
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
21
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.
|
22
|
-
activesupport (4.2.
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
22
|
+
activesupport (4.2.5.2)
|
23
23
|
i18n (~> 0.7)
|
24
24
|
json (~> 1.7, >= 1.7.7)
|
25
25
|
minitest (~> 5.1)
|
@@ -34,55 +34,55 @@ GEM
|
|
34
34
|
diff-lcs (1.2.5)
|
35
35
|
erubis (2.7.0)
|
36
36
|
i18n (0.7.0)
|
37
|
-
json (1.8.
|
38
|
-
loofah (2.0.
|
37
|
+
json (1.8.3)
|
38
|
+
loofah (2.0.3)
|
39
39
|
nokogiri (>= 1.5.9)
|
40
40
|
method_source (0.8.2)
|
41
|
-
|
42
|
-
minitest (5.
|
43
|
-
nokogiri (1.6.
|
44
|
-
|
41
|
+
mini_portile2 (2.0.0)
|
42
|
+
minitest (5.8.4)
|
43
|
+
nokogiri (1.6.7.2)
|
44
|
+
mini_portile2 (~> 2.0.0.rc2)
|
45
45
|
pry (0.10.1)
|
46
46
|
coderay (~> 1.1.0)
|
47
47
|
method_source (~> 0.8.1)
|
48
48
|
slop (~> 3.4)
|
49
|
-
rack (1.6.
|
49
|
+
rack (1.6.4)
|
50
50
|
rack-test (0.6.3)
|
51
51
|
rack (>= 1.0)
|
52
52
|
rails-deprecated_sanitizer (1.0.3)
|
53
53
|
activesupport (>= 4.2.0.alpha)
|
54
|
-
rails-dom-testing (1.0.
|
54
|
+
rails-dom-testing (1.0.7)
|
55
55
|
activesupport (>= 4.2.0.beta, < 5.0)
|
56
56
|
nokogiri (~> 1.6.0)
|
57
57
|
rails-deprecated_sanitizer (>= 1.0.1)
|
58
|
-
rails-html-sanitizer (1.0.
|
58
|
+
rails-html-sanitizer (1.0.3)
|
59
59
|
loofah (~> 2.0)
|
60
|
-
railties (4.2.
|
61
|
-
actionpack (= 4.2.
|
62
|
-
activesupport (= 4.2.
|
60
|
+
railties (4.2.5.2)
|
61
|
+
actionpack (= 4.2.5.2)
|
62
|
+
activesupport (= 4.2.5.2)
|
63
63
|
rake (>= 0.8.7)
|
64
64
|
thor (>= 0.18.1, < 2.0)
|
65
|
-
rake (10.
|
66
|
-
rspec-core (3.
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-expectations (3.
|
65
|
+
rake (10.5.0)
|
66
|
+
rspec-core (3.4.3)
|
67
|
+
rspec-support (~> 3.4.0)
|
68
|
+
rspec-expectations (3.4.0)
|
69
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
-
rspec-support (~> 3.
|
71
|
-
rspec-mocks (3.
|
70
|
+
rspec-support (~> 3.4.0)
|
71
|
+
rspec-mocks (3.4.1)
|
72
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-rails (3.2
|
73
|
+
rspec-support (~> 3.4.0)
|
74
|
+
rspec-rails (3.4.2)
|
75
75
|
actionpack (>= 3.0, < 4.3)
|
76
76
|
activesupport (>= 3.0, < 4.3)
|
77
77
|
railties (>= 3.0, < 4.3)
|
78
|
-
rspec-core (~> 3.
|
79
|
-
rspec-expectations (~> 3.
|
80
|
-
rspec-mocks (~> 3.
|
81
|
-
rspec-support (~> 3.
|
82
|
-
rspec-support (3.
|
78
|
+
rspec-core (~> 3.4.0)
|
79
|
+
rspec-expectations (~> 3.4.0)
|
80
|
+
rspec-mocks (~> 3.4.0)
|
81
|
+
rspec-support (~> 3.4.0)
|
82
|
+
rspec-support (3.4.1)
|
83
83
|
slop (3.6.0)
|
84
84
|
thor (0.19.1)
|
85
|
-
thread_safe (0.3.
|
85
|
+
thread_safe (0.3.5)
|
86
86
|
tzinfo (1.2.2)
|
87
87
|
thread_safe (~> 0.1)
|
88
88
|
|
@@ -94,7 +94,7 @@ DEPENDENCIES
|
|
94
94
|
appraisal
|
95
95
|
high_voltage!
|
96
96
|
pry
|
97
|
-
rspec-rails (~> 3.2
|
97
|
+
rspec-rails (~> 3.2)
|
98
98
|
|
99
99
|
BUNDLED WITH
|
100
|
-
1.
|
100
|
+
1.11.2
|
data/NEWS.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
New for 3.0.0
|
2
|
+
+ HighVoltage now supports Rails 5.0.0.beta3 and up.
|
3
|
+
+ Properly handle extensions in root route constraint requests.
|
4
|
+
+ Removes caching in preparation for Rails 5.
|
5
|
+
|
1
6
|
New for 2.4.0
|
2
7
|
+ Retrieve a list of available static pages via `HighVoltage.page_ids`.
|
3
8
|
+ Properly handle page ids which are blank when being sanitized.
|
data/README.md
CHANGED
@@ -15,13 +15,9 @@ Yeah, like "About us", "Directions", marketing pages, etc.
|
|
15
15
|
Include in your Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'high_voltage', '~>
|
18
|
+
gem 'high_voltage', '~> 3.0.0'
|
19
19
|
```
|
20
20
|
|
21
|
-
For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
|
22
|
-
|
23
|
-
https://github.com/thoughtbot/high_voltage/tree/v0.9.2
|
24
|
-
|
25
21
|
## Usage
|
26
22
|
|
27
23
|
Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.
|
@@ -32,13 +28,13 @@ Write your static pages and put them in the RAILS_ROOT/app/views/pages directory
|
|
32
28
|
After putting something interesting there, you can link to it from anywhere in your app with:
|
33
29
|
|
34
30
|
```ruby
|
35
|
-
link_to 'About', page_path('about')
|
31
|
+
<%= link_to 'About', page_path('about') %>
|
36
32
|
```
|
37
33
|
|
38
34
|
You can nest pages in a directory structure, if that makes sense from a URL perspective for you:
|
39
35
|
|
40
36
|
```ruby
|
41
|
-
link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Quarter-Four')
|
37
|
+
<%= link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Quarter-Four') %>
|
42
38
|
```
|
43
39
|
|
44
40
|
Bam.
|
@@ -168,7 +164,7 @@ end
|
|
168
164
|
|
169
165
|
#### Caching
|
170
166
|
|
171
|
-
|
167
|
+
Built in caching support has been removed in HighVoltage. See [PR 221](https://github.com/thoughtbot/high_voltage/pull/221).
|
172
168
|
|
173
169
|
Page caching and action caching can be done via Rails. Visit the [Caching with
|
174
170
|
Rails: An overview](http://guides.rubyonrails.org/caching_with_rails.html) guide
|
@@ -335,7 +331,7 @@ and [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers):
|
|
335
331
|
# spec/controllers/pages_controller_spec.rb
|
336
332
|
describe PagesController, '#show' do
|
337
333
|
%w(earn_money screencast about contact).each do |page|
|
338
|
-
context
|
334
|
+
context "on GET to /pages/#{page}" do
|
339
335
|
before do
|
340
336
|
get :show, id: page
|
341
337
|
end
|
@@ -362,7 +358,7 @@ Thank you, [contributors]!
|
|
362
358
|
|
363
359
|
## License
|
364
360
|
|
365
|
-
High Voltage is copyright © 2009-
|
361
|
+
High Voltage is copyright © 2009-2016 thoughtbot. It is free software, and may
|
366
362
|
be redistributed under the terms specified in the [`LICENSE`] file.
|
367
363
|
|
368
364
|
[`LICENSE`]: /MIT-LICENSE
|
@@ -13,23 +13,18 @@ module HighVoltage::StaticPage
|
|
13
13
|
end
|
14
14
|
|
15
15
|
rescue_from HighVoltage::InvalidPageIdError, with: :invalid_page
|
16
|
-
|
17
|
-
if respond_to?(:caches_action)
|
18
|
-
caches_action :show, layout: HighVoltage.action_caching_layout,
|
19
|
-
if: -> { HighVoltage.action_caching }
|
20
|
-
end
|
21
|
-
|
22
|
-
if respond_to?(:caches_page)
|
23
|
-
caches_page :show, if: -> { HighVoltage.page_caching }
|
24
|
-
end
|
25
|
-
|
26
|
-
hide_action :current_page, :page_finder, :page_finder_factory
|
27
16
|
end
|
28
17
|
|
29
18
|
def show
|
30
19
|
render template: current_page
|
31
20
|
end
|
32
21
|
|
22
|
+
def invalid_page
|
23
|
+
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
33
28
|
def current_page
|
34
29
|
page_finder.find
|
35
30
|
end
|
@@ -41,8 +36,4 @@ module HighVoltage::StaticPage
|
|
41
36
|
def page_finder_factory
|
42
37
|
HighVoltage::PageFinder
|
43
38
|
end
|
44
|
-
|
45
|
-
def invalid_page
|
46
|
-
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
47
|
-
end
|
48
39
|
end
|
data/gemfiles/rails4.0.gemfile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "appraisal"
|
6
|
+
gem "rspec-rails", "~> 3.2"
|
6
7
|
gem "rails", "~> 4.0.0"
|
7
|
-
gem "actionpack-action_caching"
|
8
|
-
gem "actionpack-page_caching"
|
9
8
|
|
10
9
|
gemspec :path => "../"
|
data/gemfiles/rails4.1.gemfile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "appraisal"
|
6
|
+
gem "rspec-rails", "~> 3.2"
|
6
7
|
gem "rails", "~> 4.1.0"
|
7
|
-
gem "actionpack-action_caching"
|
8
|
-
gem "actionpack-page_caching"
|
9
8
|
|
10
9
|
gemspec :path => "../"
|
data/gemfiles/rails4.2.gemfile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "appraisal"
|
6
|
+
gem "rspec-rails", "~> 3.2"
|
6
7
|
gem "rails", "~> 4.2.0"
|
7
|
-
gem "actionpack-action_caching"
|
8
|
-
gem "actionpack-page_caching"
|
9
8
|
|
10
9
|
gemspec :path => "../"
|
data/high_voltage.gemspec
CHANGED
@@ -1,10 +1,5 @@
|
|
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
|
-
|
8
3
|
attr_accessor(
|
9
4
|
:content_path,
|
10
5
|
:home_page,
|
@@ -14,8 +9,6 @@ module HighVoltage
|
|
14
9
|
:routes,
|
15
10
|
)
|
16
11
|
|
17
|
-
attr_reader :action_caching, :action_caching_layout, :page_caching
|
18
|
-
|
19
12
|
def configure
|
20
13
|
yield self
|
21
14
|
end
|
@@ -24,27 +17,6 @@ module HighVoltage
|
|
24
17
|
base.set_default_configuration
|
25
18
|
end
|
26
19
|
|
27
|
-
def action_caching=(value)
|
28
|
-
unless value == false
|
29
|
-
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
30
|
-
end
|
31
|
-
@action_caching = value
|
32
|
-
end
|
33
|
-
|
34
|
-
def action_caching_layout=(value)
|
35
|
-
unless value == false
|
36
|
-
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
37
|
-
end
|
38
|
-
@action_caching_layout = value
|
39
|
-
end
|
40
|
-
|
41
|
-
def page_caching=(value)
|
42
|
-
unless value == false
|
43
|
-
ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
|
44
|
-
end
|
45
|
-
@page_caching = value
|
46
|
-
end
|
47
|
-
|
48
20
|
def page_ids
|
49
21
|
HighVoltage::PageCollector.new(HighVoltage.full_path).page_ids
|
50
22
|
end
|
@@ -54,10 +26,6 @@ module HighVoltage
|
|
54
26
|
end
|
55
27
|
|
56
28
|
def set_default_configuration
|
57
|
-
@action_caching = false
|
58
|
-
@action_caching_layout = true
|
59
|
-
@page_caching = false
|
60
|
-
|
61
29
|
self.content_path = 'pages/'
|
62
30
|
self.home_page = nil
|
63
31
|
self.layout = 'application'
|
@@ -2,20 +2,27 @@ module HighVoltage
|
|
2
2
|
module Constraints
|
3
3
|
# Routing constraint to validate request.path has a corresponding view
|
4
4
|
class RootRoute
|
5
|
-
|
6
|
-
|
5
|
+
class << self
|
6
|
+
def matches?(request)
|
7
|
+
page_id = clean_page_path(request.path)
|
8
|
+
pattern = file_pattern(page_id)
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
Dir.glob(pattern).any?
|
11
|
+
end
|
10
12
|
|
11
|
-
|
13
|
+
private
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
def clean_page_path(request_path)
|
16
|
+
request_path.sub(/\.html$/, "")
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_pattern(page_id)
|
20
|
+
"#{content_path}#{page_id}.html*"
|
21
|
+
end
|
16
22
|
|
17
|
-
|
18
|
-
|
23
|
+
def content_path
|
24
|
+
Rails.root.join("app", "views", HighVoltage.content_path).to_s
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
data/lib/high_voltage/version.rb
CHANGED
@@ -1,18 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
describe HighVoltage::Constraints::RootRoute,
|
4
|
-
it
|
3
|
+
describe HighVoltage::Constraints::RootRoute, ".matches?" do
|
4
|
+
it "returns true when the view file exists" do
|
5
5
|
request = double(path: 'index')
|
6
|
-
|
6
|
+
file_path = Rails.root.join("app", "views", "pages", "index.html*").to_s
|
7
|
+
|
8
|
+
allow(Dir).to receive(:glob).with(file_path).and_return(["about.html.erb"])
|
7
9
|
|
8
10
|
result = HighVoltage::Constraints::RootRoute.matches?(request)
|
9
11
|
|
10
12
|
expect(result).to be true
|
11
13
|
end
|
12
14
|
|
13
|
-
it
|
15
|
+
it "returns true when the view file exists and url ends with .html" do
|
16
|
+
request = double(path: "index.html")
|
17
|
+
file_path = Rails.root.join("app", "views", "pages", "index.html*").to_s
|
18
|
+
|
19
|
+
allow(Dir).to receive(:glob).with(file_path).and_return(["about.html.erb"])
|
20
|
+
|
21
|
+
result = HighVoltage::Constraints::RootRoute.matches?(request)
|
22
|
+
|
23
|
+
expect(result).to be true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns false when the view files does not exist" do
|
14
27
|
request = double(path: 'index')
|
15
|
-
|
28
|
+
file_path = Rails.root.join("app", "views", "pages", "index", ".html*").to_s
|
29
|
+
|
30
|
+
allow(File).to receive(:glob).with(file_path).and_return([])
|
16
31
|
|
17
32
|
result = HighVoltage::Constraints::RootRoute.matches?(request)
|
18
33
|
|
@@ -7,11 +7,8 @@ describe HighVoltage::Configuration do
|
|
7
7
|
before(:each) do
|
8
8
|
HighVoltage.configure do |config|
|
9
9
|
ActiveSupport::Deprecation.silence do
|
10
|
-
config.action_caching = config_value
|
11
|
-
config.action_caching_layout = config_value
|
12
10
|
config.content_path = config_value
|
13
11
|
config.layout = config_value
|
14
|
-
config.page_caching = config_value
|
15
12
|
config.parent_engine = config_value
|
16
13
|
config.route_drawer = config_value
|
17
14
|
config.routes = config_value
|
@@ -25,109 +22,10 @@ describe HighVoltage::Configuration do
|
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
28
|
-
it { expect(HighVoltage.action_caching).to eq config_value }
|
29
|
-
it { expect(HighVoltage.action_caching_layout).to eq config_value }
|
30
25
|
it { expect(HighVoltage.content_path).to eq config_value }
|
31
26
|
it { expect(HighVoltage.layout).to eq config_value }
|
32
|
-
it { expect(HighVoltage.page_caching).to eq config_value }
|
33
27
|
it { expect(HighVoltage.parent_engine).to eq config_value }
|
34
28
|
it { expect(HighVoltage.route_drawer).to eq config_value }
|
35
29
|
it { expect(HighVoltage.routes).to eq config_value }
|
36
30
|
end
|
37
|
-
|
38
|
-
describe "#action_caching" do
|
39
|
-
context "action caching is enabled" do
|
40
|
-
it 'displays a deprecation warning' do
|
41
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
42
|
-
|
43
|
-
HighVoltage.configure do |config|
|
44
|
-
config.action_caching = true
|
45
|
-
end
|
46
|
-
|
47
|
-
expect(ActiveSupport::Deprecation).to have_received(:warn)
|
48
|
-
.with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "action caching is disabled" do
|
53
|
-
it 'does not display a deprecation warning' do
|
54
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
55
|
-
|
56
|
-
HighVoltage.configure do |config|
|
57
|
-
config.action_caching = false
|
58
|
-
end
|
59
|
-
|
60
|
-
expect(ActiveSupport::Deprecation).not_to have_received(:warn)
|
61
|
-
.with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#action_caching_layout" do
|
67
|
-
context "action caching layout is enabled" do
|
68
|
-
it 'displays a deprecation warning' do
|
69
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
70
|
-
|
71
|
-
HighVoltage.configure do |config|
|
72
|
-
config.action_caching_layout = true
|
73
|
-
end
|
74
|
-
|
75
|
-
expect(ActiveSupport::Deprecation).to have_received(:warn)
|
76
|
-
.with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "action caching layout is disabled" do
|
81
|
-
it "does not display a deprecation warning" do
|
82
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
83
|
-
|
84
|
-
HighVoltage.configure do |config|
|
85
|
-
config.action_caching_layout = false
|
86
|
-
end
|
87
|
-
|
88
|
-
expect(ActiveSupport::Deprecation).not_to have_received(:warn)
|
89
|
-
.with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#page_caching" do
|
95
|
-
context "page caching is enabled" do
|
96
|
-
it "displays a deprecation warning" do
|
97
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
98
|
-
|
99
|
-
HighVoltage.configure do |config|
|
100
|
-
config.page_caching = true
|
101
|
-
end
|
102
|
-
|
103
|
-
expect(ActiveSupport::Deprecation).to have_received(:warn)
|
104
|
-
.with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "page caching is disbled" do
|
109
|
-
it "does not display a deprecation warning" do
|
110
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
111
|
-
|
112
|
-
HighVoltage.configure do |config|
|
113
|
-
config.page_caching = false
|
114
|
-
end
|
115
|
-
|
116
|
-
expect(ActiveSupport::Deprecation).not_to have_received(:warn)
|
117
|
-
.with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#set_default_configuration' do
|
123
|
-
it 'defaults caching without a deprecation warning' do
|
124
|
-
allow(ActiveSupport::Deprecation).to receive(:warn)
|
125
|
-
|
126
|
-
Class.new do
|
127
|
-
extend HighVoltage::Configuration
|
128
|
-
end
|
129
|
-
|
130
|
-
expect(ActiveSupport::Deprecation).not_to have_received(:warn)
|
131
|
-
end
|
132
|
-
end
|
133
31
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,6 @@ require "pry"
|
|
4
4
|
require "active_model/railtie"
|
5
5
|
require "action_controller/railtie"
|
6
6
|
require "action_view/railtie"
|
7
|
-
require "actionpack/action_caching/railtie"
|
8
|
-
require "actionpack/page_caching/railtie"
|
9
7
|
require "rspec/rails"
|
10
8
|
|
11
9
|
require "high_voltage"
|
@@ -30,4 +28,13 @@ RSpec.configure do |config|
|
|
30
28
|
config.include RSpec::Matchers
|
31
29
|
config.mock_with :rspec
|
32
30
|
config.order = "random"
|
31
|
+
|
32
|
+
if Rails::VERSION::MAJOR >= 5
|
33
|
+
require "rails-controller-testing"
|
34
|
+
|
35
|
+
config.include(
|
36
|
+
Rails::Controller::Testing::TemplateAssertions,
|
37
|
+
type: :controller,
|
38
|
+
)
|
39
|
+
end
|
33
40
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Rails 5 deprecates calling HTTP action methods with positional arguments
|
2
|
+
# in favor of keyword arguments. However, the keyword argument form is only
|
3
|
+
# supported in Rails 5+. Since we support back to 4, we need some sort of shim
|
4
|
+
# to avoid super noisy deprecations when running tests.
|
5
|
+
module HTTPMethodShim
|
6
|
+
def get(path, params = nil, headers = nil)
|
7
|
+
super(path, params: params, headers: headers)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
if Rails::VERSION::MAJOR >= 5
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.include HTTPMethodShim, type: :controller
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: high_voltage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Jankowski
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activesupport
|
@@ -46,20 +46,6 @@ dependencies:
|
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rspec-rails
|
51
|
-
requirement: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 3.2.0
|
56
|
-
type: :development
|
57
|
-
prerelease: false
|
58
|
-
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 3.2.0
|
63
49
|
description: Fire in the disco. Fire in the ... taco bell.
|
64
50
|
email:
|
65
51
|
- support@thoughtbot.com
|
@@ -83,6 +69,7 @@ files:
|
|
83
69
|
- gemfiles/rails4.0.gemfile
|
84
70
|
- gemfiles/rails4.1.gemfile
|
85
71
|
- gemfiles/rails4.2.gemfile
|
72
|
+
- gemfiles/rails50.gemfile
|
86
73
|
- high_voltage.gemspec
|
87
74
|
- lib/high_voltage.rb
|
88
75
|
- lib/high_voltage/configuration.rb
|
@@ -95,9 +82,7 @@ files:
|
|
95
82
|
- lib/high_voltage/route_drawers/root.rb
|
96
83
|
- lib/high_voltage/version.rb
|
97
84
|
- spec/constraints/root_route_spec.rb
|
98
|
-
- spec/controllers/action_caching_controller_spec.rb
|
99
85
|
- spec/controllers/alternative_finder_controller_spec.rb
|
100
|
-
- spec/controllers/page_caching_controller_spec.rb
|
101
86
|
- spec/controllers/pages_controller_spec.rb
|
102
87
|
- spec/controllers/subclassed_pages_controller_spec.rb
|
103
88
|
- spec/fake_app.rb
|
@@ -131,6 +116,7 @@ files:
|
|
131
116
|
- spec/spec_helper.rb
|
132
117
|
- spec/support/app/controllers/alternative_finder_controller.rb
|
133
118
|
- spec/support/app/controllers/subclassed_pages_controller.rb
|
119
|
+
- spec/support/http_method_shim.rb
|
134
120
|
homepage: http://github.com/thoughtbot/high_voltage
|
135
121
|
licenses:
|
136
122
|
- MIT
|
@@ -151,15 +137,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
137
|
version: '0'
|
152
138
|
requirements: []
|
153
139
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.5.1
|
155
141
|
signing_key:
|
156
142
|
specification_version: 4
|
157
143
|
summary: Simple static page rendering controller
|
158
144
|
test_files:
|
159
145
|
- spec/constraints/root_route_spec.rb
|
160
|
-
- spec/controllers/action_caching_controller_spec.rb
|
161
146
|
- spec/controllers/alternative_finder_controller_spec.rb
|
162
|
-
- spec/controllers/page_caching_controller_spec.rb
|
163
147
|
- spec/controllers/pages_controller_spec.rb
|
164
148
|
- spec/controllers/subclassed_pages_controller_spec.rb
|
165
149
|
- spec/fake_app.rb
|
@@ -193,3 +177,4 @@ test_files:
|
|
193
177
|
- spec/spec_helper.rb
|
194
178
|
- spec/support/app/controllers/alternative_finder_controller.rb
|
195
179
|
- spec/support/app/controllers/subclassed_pages_controller.rb
|
180
|
+
- spec/support/http_method_shim.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HighVoltage::PagesController, '#action_caching' do
|
4
|
-
let(:page_name) { :exists }
|
5
|
-
|
6
|
-
context 'action_caching set to true' do
|
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
|
16
|
-
|
17
|
-
expect(controller).to have_received(:_save_fragment)
|
18
|
-
.with("test.host#{page_path(page_name)}", {})
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'action_caching set to false' do
|
23
|
-
it 'does not cache the action' do
|
24
|
-
allow(controller).to receive(:_save_fragment)
|
25
|
-
set_action_caching_without_deprecation(false)
|
26
|
-
|
27
|
-
get :show, id: page_name
|
28
|
-
|
29
|
-
expect(controller).not_to have_received(:_save_fragment)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def set_action_caching_without_deprecation(value)
|
34
|
-
ActiveSupport::Deprecation.silence do
|
35
|
-
HighVoltage.action_caching = value
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HighVoltage::PagesController, '#cache_page' do
|
4
|
-
let(:page_name) { :exists }
|
5
|
-
|
6
|
-
context 'page_caching set to true' do
|
7
|
-
after do
|
8
|
-
set_page_caching_without_deprecation(false)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'caches the page' do
|
12
|
-
allow(controller).to receive(:cache_page)
|
13
|
-
set_page_caching_without_deprecation(true)
|
14
|
-
|
15
|
-
get :show, id: page_name
|
16
|
-
|
17
|
-
expect(controller).to have_received(:cache_page)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'page_caching set to false' do
|
22
|
-
it 'does not cache the page' do
|
23
|
-
allow(controller).to receive(:cache_page)
|
24
|
-
set_page_caching_without_deprecation(false)
|
25
|
-
|
26
|
-
get :show, id: page_name
|
27
|
-
|
28
|
-
expect(controller).not_to have_received(:cache_page)
|
29
|
-
end
|
30
|
-
end
|
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
|