high_voltage 3.1.1 → 3.1.2
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/CHANGELOG.md +8 -0
- data/lib/high_voltage/version.rb +1 -1
- metadata +4 -99
- data/.gitignore +0 -7
- data/.travis.yml +0 -25
- data/Appraisals +0 -15
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -114
- data/Rakefile +0 -24
- data/bin/setup +0 -12
- data/gemfiles/rails_4.2.gemfile +0 -7
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_5.1.gemfile +0 -8
- data/gemfiles/rails_5.2.gemfile +0 -8
- data/high_voltage.gemspec +0 -24
- data/spec/constraints/root_route_spec.rb +0 -29
- data/spec/controllers/alternative_finder_controller_spec.rb +0 -12
- data/spec/controllers/pages_controller_spec.rb +0 -113
- data/spec/controllers/subclassed_pages_controller_spec.rb +0 -34
- data/spec/fake_app.rb +0 -16
- data/spec/features/current_page_helper_spec.rb +0 -9
- data/spec/features/view_page_spec.rb +0 -9
- data/spec/fixtures/app/views/layouts/alternate.html.erb +0 -14
- data/spec/fixtures/app/views/layouts/application.html.erb +0 -14
- data/spec/fixtures/app/views/other/wrong.html.erb +0 -1
- data/spec/fixtures/app/views/other_pages/also_dir/also_nested.html.erb +0 -1
- data/spec/fixtures/app/views/other_pages/also_exists.html.erb +0 -1
- data/spec/fixtures/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -2
- data/spec/fixtures/app/views/pages/_partial.html.erb +0 -1
- data/spec/fixtures/app/views/pages/about.html.erb +0 -1
- data/spec/fixtures/app/views/pages/also_dir/also_nested.html.erb +0 -1
- data/spec/fixtures/app/views/pages/also_exists.html.erb +0 -1
- data/spec/fixtures/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -2
- data/spec/fixtures/app/views/pages/current_page_helper.html.erb +0 -1
- data/spec/fixtures/app/views/pages/dir/nested.html.erb +0 -1
- data/spec/fixtures/app/views/pages/exists.html.erb +0 -1
- data/spec/fixtures/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -2
- data/spec/fixtures/app/views/pages/exists_without_html_extension.erb +0 -1
- data/spec/fixtures/app/views/pages/rot13.html.erb +0 -1
- data/spec/fixtures/app/views/pages/text.txt.erb +0 -1
- data/spec/fixtures/config/database.yml +0 -3
- data/spec/fixtures/config/routes.rb +0 -4
- data/spec/fixtures/public/pages/exists.html +0 -0
- data/spec/high_voltage/configuration_spec.rb +0 -31
- data/spec/high_voltage/page_collector_spec.rb +0 -40
- data/spec/high_voltage/page_finder_spec.rb +0 -98
- data/spec/high_voltage/page_spec.rb +0 -65
- data/spec/high_voltage_spec.rb +0 -11
- data/spec/integration/navigation_spec.rb +0 -7
- data/spec/minimal_spec_helper.rb +0 -5
- data/spec/requests/home_page_spec.rb +0 -13
- data/spec/routing/routes_spec.rb +0 -140
- data/spec/spec_helper.rb +0 -39
- data/spec/support/app/controllers/alternative_finder_controller.rb +0 -14
- data/spec/support/app/controllers/subclassed_pages_controller.rb +0 -3
- data/spec/support/http_method_shim.rb +0 -19
@@ -1,65 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe HighVoltage::Page do
|
4
|
-
it "produces the id for a page" do
|
5
|
-
page = page(full_file_path("exists.html.erb"))
|
6
|
-
|
7
|
-
expect(page.id).to eq "exists"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "produces the id for a page in a subdirectory" do
|
11
|
-
page = page(full_file_path("dir/nested.html.erb"))
|
12
|
-
|
13
|
-
expect(page.id).to eq "dir/nested"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "is valid for a page" do
|
17
|
-
page = page(full_file_path("exists.html.erb"))
|
18
|
-
|
19
|
-
expect(page).to be_valid
|
20
|
-
end
|
21
|
-
|
22
|
-
it "is valid for a page in a subdirectory" do
|
23
|
-
page = page(full_file_path("dir/nested.html.erb"))
|
24
|
-
|
25
|
-
expect(page).to be_valid
|
26
|
-
end
|
27
|
-
|
28
|
-
it "is invalid for a directory" do
|
29
|
-
page = page(full_file_path("dir"))
|
30
|
-
|
31
|
-
expect(page).to_not be_valid
|
32
|
-
end
|
33
|
-
|
34
|
-
it "is invalid for a partial" do
|
35
|
-
page = page(full_file_path("_partial.html.erb"))
|
36
|
-
|
37
|
-
expect(page).to_not be_valid
|
38
|
-
end
|
39
|
-
|
40
|
-
it "is invalid for a non-existent page" do
|
41
|
-
page = page(full_file_path("nonexistent.html.erb"))
|
42
|
-
|
43
|
-
expect(page).to_not be_valid
|
44
|
-
end
|
45
|
-
|
46
|
-
it "is valid for files without a format present" do
|
47
|
-
page = page(full_file_path("exists_without_html_extension.erb"))
|
48
|
-
|
49
|
-
expect(page).to be_valid
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def full_content_path
|
55
|
-
HighVoltage.full_path.to_s
|
56
|
-
end
|
57
|
-
|
58
|
-
def page(file_path)
|
59
|
-
HighVoltage::Page.new(full_content_path, file_path)
|
60
|
-
end
|
61
|
-
|
62
|
-
def full_file_path(file_path)
|
63
|
-
"#{full_content_path}#{file_path}"
|
64
|
-
end
|
65
|
-
end
|
data/spec/high_voltage_spec.rb
DELETED
data/spec/minimal_spec_helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Home page route' do
|
4
|
-
before(:each) do
|
5
|
-
HighVoltage.home_page = 'home'
|
6
|
-
Rails.application.reload_routes!
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'redirects the duplicate content to root' do
|
10
|
-
get '/home'
|
11
|
-
expect(response.headers['Location']).to eq 'http://www.example.com/'
|
12
|
-
end
|
13
|
-
end
|
data/spec/routing/routes_spec.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'routes' do
|
4
|
-
context 'default configuration' do
|
5
|
-
it 'generates a route' do
|
6
|
-
expect(page_path('one')).to eq '/pages/one'
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'generates a nested route' do
|
10
|
-
expect(page_path('one/two')).to eq '/pages/one/two'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'recognizes a route' do
|
14
|
-
assert_recognizes(
|
15
|
-
{
|
16
|
-
:controller => 'high_voltage/pages',
|
17
|
-
:action => 'show',
|
18
|
-
:id => 'one'
|
19
|
-
},
|
20
|
-
'/pages/one'
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'recognizes a nested route' do
|
25
|
-
assert_recognizes(
|
26
|
-
{
|
27
|
-
:controller => 'high_voltage/pages',
|
28
|
-
:action => 'show',
|
29
|
-
:id => 'one/two'
|
30
|
-
},
|
31
|
-
'/pages/one/two'
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'recognizes a route with dots' do
|
36
|
-
assert_recognizes(
|
37
|
-
{
|
38
|
-
:controller => 'high_voltage/pages',
|
39
|
-
:action => 'show',
|
40
|
-
:id => 'one.two.three'
|
41
|
-
},
|
42
|
-
'/pages/one.two.three'
|
43
|
-
)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'using top-level routing configuration' do
|
48
|
-
before(:each) do
|
49
|
-
HighVoltage.route_drawer = HighVoltage::RouteDrawers::Root
|
50
|
-
Rails.application.reload_routes!
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'generates a route' do
|
54
|
-
expect(page_path('one')).to eq '/one'
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'generates a nested route' do
|
58
|
-
expect(page_path('one/two')).to eq '/one/two'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'custom content path' do
|
63
|
-
before(:each) do
|
64
|
-
HighVoltage.content_path = 'other_pages/'
|
65
|
-
Rails.application.reload_routes!
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'generates a route' do
|
69
|
-
expect(page_path('one')).to eq '/other_pages/one'
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'generates a nested route' do
|
73
|
-
expect(page_path('one/two')).to eq '/other_pages/one/two'
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'recognizes a route' do
|
77
|
-
assert_recognizes(
|
78
|
-
{
|
79
|
-
:controller => 'high_voltage/pages',
|
80
|
-
:action => 'show',
|
81
|
-
:id => 'one'
|
82
|
-
},
|
83
|
-
'/other_pages/one'
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'recognizes a nested route' do
|
88
|
-
assert_recognizes(
|
89
|
-
{
|
90
|
-
:controller => 'high_voltage/pages',
|
91
|
-
:action => 'show',
|
92
|
-
:id => 'one/two'
|
93
|
-
},
|
94
|
-
'/other_pages/one/two'
|
95
|
-
)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'recognizes a route with dots' do
|
99
|
-
assert_recognizes(
|
100
|
-
{
|
101
|
-
:controller => 'high_voltage/pages',
|
102
|
-
:action => 'show',
|
103
|
-
:id => 'one.two.three'
|
104
|
-
},
|
105
|
-
'/other_pages/one.two.three'
|
106
|
-
)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'home page route' do
|
111
|
-
it 'recognizes the root route' do
|
112
|
-
HighVoltage.home_page = 'home'
|
113
|
-
Rails.application.reload_routes!
|
114
|
-
|
115
|
-
assert_recognizes(
|
116
|
-
{
|
117
|
-
:controller => 'high_voltage/pages',
|
118
|
-
:action => 'show',
|
119
|
-
:id => 'home'
|
120
|
-
},
|
121
|
-
'/'
|
122
|
-
)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'no home page route' do
|
127
|
-
it 'does generate a home page route' do
|
128
|
-
expect(get: '/').not_to be_routable
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context 'disabled routes' do
|
133
|
-
it 'does not recognize routes' do
|
134
|
-
HighVoltage.routes = false
|
135
|
-
Rails.application.reload_routes!
|
136
|
-
|
137
|
-
expect(get: '/pages/one/two').not_to be_routable
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
3
|
-
require "pry"
|
4
|
-
require "active_model/railtie"
|
5
|
-
require "action_controller/railtie"
|
6
|
-
require "action_view/railtie"
|
7
|
-
require "high_voltage"
|
8
|
-
require "fake_app"
|
9
|
-
require "rspec/rails"
|
10
|
-
|
11
|
-
Rails.backtrace_cleaner.remove_silencers!
|
12
|
-
|
13
|
-
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |file| require file }
|
14
|
-
|
15
|
-
RSpec.configure do |config|
|
16
|
-
config.infer_spec_type_from_file_location!
|
17
|
-
|
18
|
-
config.after(:each) do
|
19
|
-
HighVoltage.set_default_configuration
|
20
|
-
Rails.application.reload_routes!
|
21
|
-
end
|
22
|
-
|
23
|
-
config.expect_with :rspec do |c|
|
24
|
-
c.syntax = :expect
|
25
|
-
end
|
26
|
-
|
27
|
-
config.include RSpec::Matchers
|
28
|
-
config.mock_with :rspec
|
29
|
-
config.order = "random"
|
30
|
-
|
31
|
-
if Rails::VERSION::MAJOR >= 5
|
32
|
-
require "rails-controller-testing"
|
33
|
-
|
34
|
-
config.include(
|
35
|
-
Rails::Controller::Testing::TemplateAssertions,
|
36
|
-
type: :controller,
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class AlternativeFinderController < HighVoltage::PagesController
|
2
|
-
private
|
3
|
-
|
4
|
-
def page_finder_factory
|
5
|
-
Rot13PageFinder
|
6
|
-
end
|
7
|
-
|
8
|
-
class Rot13PageFinder < HighVoltage::PageFinder
|
9
|
-
def find
|
10
|
-
paths = super.split('/')
|
11
|
-
"#{paths[0..-2].join('/')}/#{paths[-1].tr('a-z','n-za-m')}"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,19 +0,0 @@
|
|
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, *args)
|
7
|
-
if args.any?
|
8
|
-
raise ArgumentError, "Unexpected arguments passed to shim: #{args.inspect}"
|
9
|
-
else
|
10
|
-
super(path, params: params)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
if Rails::VERSION::MAJOR >= 5
|
16
|
-
RSpec.configure do |config|
|
17
|
-
config.include HTTPMethodShim, type: :controller
|
18
|
-
end
|
19
|
-
end
|