routes_revealer 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38bf504deba5b0ef19a4ac783011b2e72c7ea704
|
4
|
+
data.tar.gz: 12b551cd56974368652737c7722edfa1bfb757d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6489103ca721d33b27c636d9f9296e6a4808b71412ee3e3e497c0e485d666f0570e7c45a97c32e6593b4f119d2bca7410cf9c5f552a77c11993aa10aa1eff56b
|
7
|
+
data.tar.gz: 46b80c06d9be4df50bf5a042785316cbfb2d1dc0a1bd0b8fe52ca540fdfc7e1c0a95c7eb5b053a32c57ccbd933ffa611bc14ef7940f5619d9fdf30bcc33c71c5
|
@@ -15,6 +15,7 @@ module RoutesRevealer
|
|
15
15
|
def index
|
16
16
|
output = []
|
17
17
|
output += [asset_route]
|
18
|
+
output += public_folder
|
18
19
|
output += map_routes(Rails.application.routes.routes).flatten
|
19
20
|
output.compact!.uniq!
|
20
21
|
output.sort! if output
|
@@ -31,6 +32,17 @@ module RoutesRevealer
|
|
31
32
|
Rails.application.class.config.assets.prefix
|
32
33
|
end
|
33
34
|
|
35
|
+
def public_folder
|
36
|
+
files = Dir.glob('public/**/*')
|
37
|
+
files.map! do |file|
|
38
|
+
file[6..-1]
|
39
|
+
end
|
40
|
+
files.reject! do |file|
|
41
|
+
file.starts_with?(asset_route) || file == '/system'
|
42
|
+
end
|
43
|
+
files
|
44
|
+
end
|
45
|
+
|
34
46
|
def map_routes(routes, prepend='')
|
35
47
|
prepend = '' if prepend == '/'
|
36
48
|
route_hash_array(routes).map do |route_hash|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
3
|
# you may not use this file except in compliance with the License.
|
4
4
|
# You may obtain a copy of the License at
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# http://www.apache.org/licenses/LICENSE-2.0
|
7
7
|
# Unless required by applicable law or agreed to in writing, software
|
8
8
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -12,36 +12,35 @@ require 'spec_helper'
|
|
12
12
|
|
13
13
|
describe RoutesRevealer::RoutesController do
|
14
14
|
describe '#index' do
|
15
|
+
let(:this_engine_string) { 'This::Engine' }
|
16
|
+
let(:that_engine_string) { 'That::Engine' }
|
15
17
|
|
16
|
-
let(:
|
17
|
-
let(:
|
18
|
+
let(:route1) { double('route1', path: '/1', verb: 'GET', reqs: 'controller#1') }
|
19
|
+
let(:route2) { double('route2', path: '/2', verb: 'POST', reqs: 'controller#2') }
|
20
|
+
let(:route3) { double('route3', path: '/3', verb: 'PUT', reqs: 'controller#3') }
|
21
|
+
let(:route4) { double('route4', path: '/4', verb: 'DELETE', reqs: 'controller#4') }
|
22
|
+
let(:route5) { double('route5', path: '/', verb: 'GET', reqs: this_engine_string) }
|
23
|
+
let(:route6) { double('route6', path: '/that', verb: 'GET', reqs: that_engine_string) }
|
24
|
+
let(:bad_route7) { double('bad_route7', path: '/routes', verb: 'HEAD', reqs: 'controller#route7') }
|
25
|
+
let(:bad_route8) { double('bad_route7', path: '/rails', verb: 'TRACE', reqs: 'controller#route8') }
|
18
26
|
|
19
|
-
let(:
|
20
|
-
let(:
|
21
|
-
let(:
|
22
|
-
let(:
|
23
|
-
let(:route5) { double("route5", path: "/", verb: "GET", reqs: this_engine_string) }
|
24
|
-
let(:route6) { double("route6", path: "/that", verb: "GET", reqs: that_engine_string) }
|
25
|
-
let(:bad_route7) { double("bad_route7", path: "/routes", verb: "HEAD", reqs: "controller#route7") }
|
26
|
-
let(:bad_route8) { double("bad_route7", path: "/rails", verb: "TRACE", reqs: "controller#route8") }
|
27
|
-
|
28
|
-
let(:this_route1) { double("this_route1", path: "/t1", verb: "RAMBO", reqs: "this_controller#1") }
|
29
|
-
let(:this_route2) { double("this_route2", path: "/t2", verb: "ALWAYS", reqs: "this_controller#2") }
|
30
|
-
let(:that_route1) { double("that_route1", path: "/1", verb: "SHOOTS", reqs: "that_controller#1") }
|
31
|
-
let(:that_route2) { double("that_route2", path: "/2", verb: "WALNUTS", reqs: "that_controller#2") }
|
27
|
+
let(:this_route1) { double('this_route1', path: '/t1', verb: 'RAMBO', reqs: 'this_controller#1') }
|
28
|
+
let(:this_route2) { double('this_route2', path: '/t2', verb: 'ALWAYS', reqs: 'this_controller#2') }
|
29
|
+
let(:that_route1) { double('that_route1', path: '/1', verb: 'SHOOTS', reqs: 'that_controller#1') }
|
30
|
+
let(:that_route2) { double('that_route2', path: '/2', verb: 'WALNUTS', reqs: 'that_controller#2') }
|
32
31
|
|
33
32
|
let(:routes) { [route1, route2, route3, route4, route5, route6, bad_route7, bad_route8] }
|
34
33
|
let(:this_routes) { [this_route1, this_route2] }
|
35
34
|
let(:that_routes) { [that_route1, that_route2] }
|
36
35
|
|
37
|
-
let(:this_engine) { double(
|
38
|
-
let(:that_engine) { double(
|
39
|
-
|
36
|
+
let(:this_engine) { double('this_engine', routes: double('routes', routes: this_routes)) }
|
37
|
+
let(:that_engine) { double('that_engine', routes: double('routes', routes: that_routes)) }
|
38
|
+
let(:public_folder) { ['public/zzz/public.txt','public/assets/example.otf','public/system'] }
|
40
39
|
let(:route_wrapper) { ActionDispatch::Routing::RouteWrapper }
|
41
40
|
|
42
41
|
before do
|
43
42
|
allow(Rails).to receive_message_chain(:application, :routes, :routes).and_return(routes)
|
44
|
-
allow(Rails).to receive_message_chain(:application, :class, :config, :assets, :prefix).and_return(
|
43
|
+
allow(Rails).to receive_message_chain(:application, :class, :config, :assets, :prefix).and_return('/assets')
|
45
44
|
|
46
45
|
allow(Module).to receive(:const_get).with(this_engine_string).and_return(this_engine)
|
47
46
|
allow(Module).to receive(:const_get).with(that_engine_string).and_return(that_engine)
|
@@ -60,21 +59,42 @@ describe RoutesRevealer::RoutesController do
|
|
60
59
|
|
61
60
|
allow(route_wrapper).to receive(:new).with(that_route1).and_return(that_route1)
|
62
61
|
allow(route_wrapper).to receive(:new).with(that_route2).and_return(that_route2)
|
62
|
+
allow(Dir).to receive(:glob).with('public/**/*').and_return(public_folder)
|
63
63
|
|
64
64
|
get :index
|
65
65
|
end
|
66
66
|
|
67
67
|
it { expect(response.status).to eq 200 }
|
68
|
-
it { expect(JSON.parse(response.body).length).to eq
|
69
|
-
it { expect(JSON.parse(response.body)[0]).to eq
|
70
|
-
it { expect(JSON.parse(response.body)[1]).to eq
|
71
|
-
it { expect(JSON.parse(response.body)[2]).to eq
|
72
|
-
it { expect(JSON.parse(response.body)[3]).to eq
|
73
|
-
it { expect(JSON.parse(response.body)[4]).to eq
|
74
|
-
it { expect(JSON.parse(response.body)[5]).to eq
|
75
|
-
it { expect(JSON.parse(response.body)[6]).to eq
|
76
|
-
it { expect(JSON.parse(response.body)[7]).to eq
|
77
|
-
it { expect(JSON.parse(response.body)[8]).to eq
|
68
|
+
it { expect(JSON.parse(response.body).length).to eq 10 }
|
69
|
+
it { expect(JSON.parse(response.body)[0]).to eq '/1' }
|
70
|
+
it { expect(JSON.parse(response.body)[1]).to eq '/2' }
|
71
|
+
it { expect(JSON.parse(response.body)[2]).to eq '/3' }
|
72
|
+
it { expect(JSON.parse(response.body)[3]).to eq '/4' }
|
73
|
+
it { expect(JSON.parse(response.body)[4]).to eq '/assets' }
|
74
|
+
it { expect(JSON.parse(response.body)[5]).to eq '/t1' }
|
75
|
+
it { expect(JSON.parse(response.body)[6]).to eq '/t2' }
|
76
|
+
it { expect(JSON.parse(response.body)[7]).to eq '/that/1' }
|
77
|
+
it { expect(JSON.parse(response.body)[8]).to eq '/that/2' }
|
78
|
+
it { expect(JSON.parse(response.body)[9]).to eq '/zzz/public.txt' }
|
79
|
+
|
80
|
+
context 'Rails app includes a public folder' do
|
81
|
+
let(:public_folder) do
|
82
|
+
['public/robots.txt','public/humans.txt','public/dir/something.txt', 'public/assets/boom.png']
|
83
|
+
end
|
84
|
+
it 'adds the contents of the public folder' do
|
85
|
+
expect(JSON.parse(response.body).length).to eq 12
|
86
|
+
end
|
87
|
+
it { expect(JSON.parse(response.body)[5]).to eq '/dir/something.txt' }
|
88
|
+
it { expect(JSON.parse(response.body)[6]).to eq '/humans.txt' }
|
89
|
+
it { expect(JSON.parse(response.body)[7]).to eq '/robots.txt' }
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'Rails app has an empty / non existant public folder' do
|
93
|
+
let(:public_folder) { [] }
|
78
94
|
|
95
|
+
it 'adds no additional entries' do
|
96
|
+
expect(JSON.parse(response.body).length).to eq 9
|
97
|
+
end
|
98
|
+
end
|
79
99
|
end
|
80
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routes_revealer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The CareerBuilder.com Consumer Development teams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|