high_voltage 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/high_voltage/version.rb +1 -1
  4. metadata +4 -99
  5. data/.gitignore +0 -7
  6. data/.travis.yml +0 -25
  7. data/Appraisals +0 -15
  8. data/Gemfile +0 -3
  9. data/Gemfile.lock +0 -114
  10. data/Rakefile +0 -24
  11. data/bin/setup +0 -12
  12. data/gemfiles/rails_4.2.gemfile +0 -7
  13. data/gemfiles/rails_5.0.gemfile +0 -8
  14. data/gemfiles/rails_5.1.gemfile +0 -8
  15. data/gemfiles/rails_5.2.gemfile +0 -8
  16. data/high_voltage.gemspec +0 -24
  17. data/spec/constraints/root_route_spec.rb +0 -29
  18. data/spec/controllers/alternative_finder_controller_spec.rb +0 -12
  19. data/spec/controllers/pages_controller_spec.rb +0 -113
  20. data/spec/controllers/subclassed_pages_controller_spec.rb +0 -34
  21. data/spec/fake_app.rb +0 -16
  22. data/spec/features/current_page_helper_spec.rb +0 -9
  23. data/spec/features/view_page_spec.rb +0 -9
  24. data/spec/fixtures/app/views/layouts/alternate.html.erb +0 -14
  25. data/spec/fixtures/app/views/layouts/application.html.erb +0 -14
  26. data/spec/fixtures/app/views/other/wrong.html.erb +0 -1
  27. data/spec/fixtures/app/views/other_pages/also_dir/also_nested.html.erb +0 -1
  28. data/spec/fixtures/app/views/other_pages/also_exists.html.erb +0 -1
  29. data/spec/fixtures/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -2
  30. data/spec/fixtures/app/views/pages/_partial.html.erb +0 -1
  31. data/spec/fixtures/app/views/pages/about.html.erb +0 -1
  32. data/spec/fixtures/app/views/pages/also_dir/also_nested.html.erb +0 -1
  33. data/spec/fixtures/app/views/pages/also_exists.html.erb +0 -1
  34. data/spec/fixtures/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -2
  35. data/spec/fixtures/app/views/pages/current_page_helper.html.erb +0 -1
  36. data/spec/fixtures/app/views/pages/dir/nested.html.erb +0 -1
  37. data/spec/fixtures/app/views/pages/exists.html.erb +0 -1
  38. data/spec/fixtures/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -2
  39. data/spec/fixtures/app/views/pages/exists_without_html_extension.erb +0 -1
  40. data/spec/fixtures/app/views/pages/rot13.html.erb +0 -1
  41. data/spec/fixtures/app/views/pages/text.txt.erb +0 -1
  42. data/spec/fixtures/config/database.yml +0 -3
  43. data/spec/fixtures/config/routes.rb +0 -4
  44. data/spec/fixtures/public/pages/exists.html +0 -0
  45. data/spec/high_voltage/configuration_spec.rb +0 -31
  46. data/spec/high_voltage/page_collector_spec.rb +0 -40
  47. data/spec/high_voltage/page_finder_spec.rb +0 -98
  48. data/spec/high_voltage/page_spec.rb +0 -65
  49. data/spec/high_voltage_spec.rb +0 -11
  50. data/spec/integration/navigation_spec.rb +0 -7
  51. data/spec/minimal_spec_helper.rb +0 -5
  52. data/spec/requests/home_page_spec.rb +0 -13
  53. data/spec/routing/routes_spec.rb +0 -140
  54. data/spec/spec_helper.rb +0 -39
  55. data/spec/support/app/controllers/alternative_finder_controller.rb +0 -14
  56. data/spec/support/app/controllers/subclassed_pages_controller.rb +0 -3
  57. data/spec/support/http_method_shim.rb +0 -19
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe HighVoltage::Constraints::RootRoute do
4
- describe "#matches?" do
5
- it "returns true when the view file exists" do
6
- request = double(path: "exists")
7
-
8
- result = described_class.new.matches?(request)
9
-
10
- expect(result).to be true
11
- end
12
-
13
- it "returns true when the view file exists and url ends with .html" do
14
- request = double(path: "exists.html")
15
-
16
- result = described_class.new.matches?(request)
17
-
18
- expect(result).to be true
19
- end
20
-
21
- it "returns false when the view files does not exist" do
22
- request = double(path: "index")
23
-
24
- result = described_class.new.matches?(request)
25
-
26
- expect(result).to be false
27
- end
28
- end
29
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AlternativeFinderController do
4
- render_views
5
-
6
- it 'renders the file from the alternative directory' do
7
- get :show, :id => 'ebg13'
8
-
9
- expect(response).to be_successful
10
- expect(response).to render_template('rot13')
11
- end
12
- end
@@ -1,113 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "spec_helper"
4
-
5
- describe HighVoltage::PagesController do
6
- render_views
7
-
8
- context "using default configuration" do
9
- describe "on GET to /pages/exists" do
10
- before { get :show, id: "exists" }
11
-
12
- it "responds with success and render template" do
13
- expect(response).to be_successful
14
- expect(response).to render_template("exists")
15
- end
16
-
17
- it "uses the default layout used by ApplicationController" do
18
- expect(response).to render_template("layouts/application")
19
- end
20
- end
21
-
22
- describe "on GET to /pages/dir/nested" do
23
- before { get :show, id: "dir/nested" }
24
-
25
- it "responds with success and render template" do
26
- expect(response).to be_successful
27
- expect(response).to render_template("pages/dir/nested")
28
- end
29
- end
30
-
31
- it "raises a routing error for an invalid page" do
32
- expect { get :show, id: "invalid" }.
33
- to raise_error(ActionController::RoutingError)
34
- end
35
-
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)
39
- end
40
-
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)
44
- end
45
- end
46
-
47
- context "using custom layout" do
48
- before(:each) do
49
- HighVoltage.layout = "alternate"
50
- end
51
-
52
- describe "on GET to /pages/exists" do
53
- before { get :show, id: "exists" }
54
-
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")
58
- end
59
- end
60
- end
61
-
62
- context "using custom content path" do
63
- before(:each) do
64
- HighVoltage.content_path = "other_pages/"
65
- Rails.application.reload_routes!
66
- end
67
-
68
- describe "on GET to /other_pages/also_exists" do
69
- before { get :show, id: "also_exists" }
70
-
71
- it "responds with success and render template" do
72
- expect(response).to be_successful
73
- expect(response).to render_template("other_pages/also_exists")
74
- end
75
- end
76
-
77
- describe "on GET to /other_pages/also_dir/nested" do
78
- before { get :show, id: "also_dir/also_nested" }
79
-
80
- it "responds with success and render template" do
81
- expect(response).to be_successful
82
- expect(response).to render_template("other_pages/also_dir/also_nested")
83
- end
84
- end
85
-
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)
92
- end
93
-
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)
98
- end
99
-
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)
103
- end
104
- end
105
-
106
- it "raises a missing template error for valid page with invalid partial" do
107
- id = "also_exists_but_references_nonexistent_partial"
108
-
109
- expect { get :show, id: id }.
110
- to raise_error(ActionView::MissingTemplate)
111
- end
112
- end
113
- end
@@ -1,34 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SubclassedPagesController do
4
- render_views
5
-
6
- describe "on GET to /subclassed_pages/also_exists" do
7
- before { get :show, id: "also_exists" }
8
-
9
- it "responds with success and render template" do
10
- expect(response).to be_successful
11
- expect(response).to render_template("also_exists")
12
- end
13
-
14
- it "uses the custom configured layout" do
15
- expect(response).not_to render_template("layouts/application")
16
- expect(response).to render_template("layouts/alternate")
17
- end
18
- end
19
-
20
- it 'raises a routing error for an invalid page' do
21
- expect { get :show, id: "invalid" }.
22
- to raise_error(ActionController::RoutingError)
23
- end
24
-
25
- it 'raises a routing error for a page in another directory' do
26
- expect { get :show, id: "../other/wrong" }.
27
- to raise_error(ActionController::RoutingError)
28
- end
29
-
30
- it 'raises a missing template error for valid page with invalid partial' do
31
- expect { get :show, id: "also_exists_but_references_nonexistent_partial" }.
32
- to raise_error(ActionView::MissingTemplate)
33
- end
34
- end
@@ -1,16 +0,0 @@
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.eager_load = false
10
- config.action_controller.perform_caching = true
11
- config.action_controller.cache_store = :memory_store
12
- config.root = "spec/fixtures"
13
- config.paths["app/views"] << "spec/fixtures/app/views"
14
- end
15
- end
16
- Dummy::Application.initialize!
@@ -1,9 +0,0 @@
1
- require "spec_helper"
2
-
3
- feature "current page helper" do
4
- scenario "is available in view" do
5
- visit page_path(id: "current_page_helper")
6
-
7
- expect(page).to have_content "Current Page: pages/current_page_helper"
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require "spec_helper"
2
-
3
- feature "view page" do
4
- scenario "successfully" do
5
- visit page_path(id: "about")
6
-
7
- expect(page).to have_content "About Us"
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy - Alternate Layout</title>
5
- <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
7
- <%= csrf_meta_tag %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
7
- <%= csrf_meta_tag %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1 +0,0 @@
1
- cant get here from pages
@@ -1 +0,0 @@
1
- hello <%= 'world' %> from a nested dir
@@ -1 +0,0 @@
1
- hello <%= 'world' %>
@@ -1,2 +0,0 @@
1
- hello <%= 'world' %>
2
- <%= render 'nonexistent' %>
@@ -1 +0,0 @@
1
- <h1>About Us</h1>
@@ -1 +0,0 @@
1
- hello <%= 'world' %> from a nested dir
@@ -1 +0,0 @@
1
- hello <%= 'world' %>
@@ -1,2 +0,0 @@
1
- hello <%= 'world' %>
2
- <%= render 'nonexistent' %>
@@ -1 +0,0 @@
1
- <h1>Current Page: <%= current_page %></h1>
@@ -1 +0,0 @@
1
- hello <%= 'world' %> from a nested dir
@@ -1 +0,0 @@
1
- hello <%= 'world' %>
@@ -1,2 +0,0 @@
1
- hello <%= 'world' %>
2
- <%= render 'nonexistent' %>
@@ -1 +0,0 @@
1
- <h1>Exists without html extension</h1>
@@ -1 +0,0 @@
1
- alternative
@@ -1 +0,0 @@
1
- text page
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: ":memory:"
@@ -1,4 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- get "/subclassed_pages/*id" => 'subclassed_pages#show', :format => false
3
- get "/alternative_finder/*id" => 'alternative_finder#show', :format => false
4
- end
File without changes
@@ -1,31 +0,0 @@
1
- require 'minimal_spec_helper'
2
-
3
- describe HighVoltage::Configuration do
4
- describe 'basic config assignment' do
5
- let(:config_value) { 'fake_config_value' }
6
-
7
- before(:each) do
8
- HighVoltage.configure do |config|
9
- ActiveSupport::Deprecation.silence do
10
- config.content_path = config_value
11
- config.layout = config_value
12
- config.parent_engine = config_value
13
- config.route_drawer = config_value
14
- config.routes = config_value
15
- end
16
- end
17
- end
18
-
19
- after(:each) do
20
- HighVoltage.configure do |config|
21
- config.parent_engine = Rails.application
22
- end
23
- end
24
-
25
- it { expect(HighVoltage.content_path).to eq config_value }
26
- it { expect(HighVoltage.layout).to eq config_value }
27
- it { expect(HighVoltage.parent_engine).to eq config_value }
28
- it { expect(HighVoltage.route_drawer).to eq config_value }
29
- it { expect(HighVoltage.routes).to eq config_value }
30
- end
31
- end
@@ -1,40 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe HighVoltage::PageCollector do
4
- it "produces an array of all page_ids under pages/" do
5
- expect(HighVoltage.page_ids).to match_array [
6
- "about",
7
- "also_dir/also_nested",
8
- "also_exists",
9
- "also_exists_but_references_nonexistent_partial",
10
- "current_page_helper",
11
- "dir/nested",
12
- "exists",
13
- "exists_but_references_nonexistent_partial",
14
- "rot13",
15
- "exists_without_html_extension",
16
- "text",
17
- ]
18
- end
19
-
20
- it "produces an array of all page_ids under other_pages/" do
21
- with_content_path("other_pages/") do
22
- expect(HighVoltage.page_ids).to eq [
23
- "also_dir/also_nested",
24
- "also_exists",
25
- "also_exists_but_references_nonexistent_partial",
26
- ]
27
- end
28
- end
29
-
30
- private
31
-
32
- def with_content_path(path)
33
- original_content_path = HighVoltage.content_path
34
- HighVoltage.content_path = path
35
-
36
- yield
37
-
38
- HighVoltage.content_path = original_content_path
39
- end
40
- end
@@ -1,98 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "spec_helper"
4
-
5
- describe HighVoltage::PageFinder do
6
- it "produces the name of an existing template" do
7
- expect(find("existing")).to eq "pages/existing"
8
- end
9
-
10
- it "produces the name of a nested template" do
11
- expect(find("dir/nested")).to eq "pages/dir/nested"
12
- end
13
-
14
- it "produces the name of a dotfile" do
15
- expect(find(".file")).to eq "pages/.file"
16
- end
17
-
18
- it "supports non-ASCII characters" do
19
- expect(find("résumé")).to eq "pages/résumé"
20
- end
21
-
22
- it "uses a custom content path" do
23
- with_content_path("other_pages/") do
24
- expect(find("also_exists")).to eq "other_pages/also_exists"
25
- end
26
- end
27
-
28
- it "allows the trailing slash to be omitted from the content path" do
29
- with_content_path("forgot_slash") do
30
- expect(find("thing")).to eq "forgot_slash/thing"
31
- end
32
- end
33
-
34
- it "exposes the content path" do
35
- with_content_path("another_thing/") do
36
- expect(page_finder.content_path).to eq "another_thing/"
37
- end
38
- end
39
-
40
- it "provides the page_id" do
41
- subclass = Class.new(HighVoltage::PageFinder) do
42
- def page_name
43
- "the page is #{page_id}"
44
- end
45
- end
46
-
47
- expect(subclass.new("sweet page").page_name).to eq "the page is sweet page"
48
- end
49
-
50
- context "bad page_id" do
51
- it "throws an exception if page_id resolves to empty" do
52
- expect { find("") }.to raise_error HighVoltage::InvalidPageIdError
53
- expect { find("/") }.to raise_error HighVoltage::InvalidPageIdError
54
- expect { find(".") }.to raise_error HighVoltage::InvalidPageIdError
55
- expect { find("\\.") }.to raise_error HighVoltage::InvalidPageIdError
56
- expect { find("/\\.") }.to raise_error HighVoltage::InvalidPageIdError
57
- expect { find("dummy/..") }.to raise_error HighVoltage::InvalidPageIdError
58
- end
59
-
60
- it "throws an exception if page_id resolves to outside the content path" do
61
- expect { find("..") }.to raise_error HighVoltage::InvalidPageIdError
62
- expect { find("\\..") }.to raise_error HighVoltage::InvalidPageIdError
63
- expect { find("/\\..") }.to raise_error HighVoltage::InvalidPageIdError
64
- expect { find("../secret") }.
65
- to raise_error HighVoltage::InvalidPageIdError
66
- expect { find("\\../secret") }.
67
- to raise_error HighVoltage::InvalidPageIdError
68
- expect { find("/\\../secret") }.
69
- to raise_error HighVoltage::InvalidPageIdError
70
- expect { find("dummy/../../secret") }.
71
- to raise_error HighVoltage::InvalidPageIdError
72
- end
73
-
74
- it "throws an exception if invalid byte sequence in page_id" do
75
- expect { find("\xD0½\xA8\xCEļ\xFE\xBC\xD0.zip") }.
76
- to raise_error HighVoltage::InvalidPageIdError
77
- end
78
- end
79
-
80
- private
81
-
82
- def find(page_id)
83
- page_finder(page_id).find
84
- end
85
-
86
- def page_finder(page_id = "whatever")
87
- HighVoltage::PageFinder.new(page_id)
88
- end
89
-
90
- def with_content_path(path)
91
- original_content_path = HighVoltage.content_path
92
- HighVoltage.content_path = path
93
-
94
- yield
95
-
96
- HighVoltage.content_path = original_content_path
97
- end
98
- end