rails_legacy_mapper 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/CHANGELOG +3 -0
- data/LICENSE +20 -0
- data/README +25 -0
- data/Rakefile +27 -0
- data/lib/rails_legacy_mapper.rb +23 -0
- data/lib/rails_legacy_mapper/mapper.rb +488 -0
- data/lib/rails_legacy_mapper/route_set_extensions.rb +53 -0
- data/lib/rails_legacy_mapper/version.rb +3 -0
- data/rails_legacy_mapper.gemspec +55 -0
- data/test/fake_controllers.rb +66 -0
- data/test/legacy_route_set_test.rb +578 -0
- data/test/rack_mount_integration_test.rb +310 -0
- data/test/resources_test.rb +1395 -0
- data/test/route_set_test.rb +959 -0
- data/test/test_helper.rb +48 -0
- data/test/uri_reserved_characters_routing_test.rb +54 -0
- metadata +158 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha'
|
3
|
+
require 'action_controller'
|
4
|
+
require 'fake_controllers'
|
5
|
+
require 'rails_legacy_mapper'
|
6
|
+
|
7
|
+
ROUTING = ActionDispatch::Routing
|
8
|
+
|
9
|
+
class MockController
|
10
|
+
def self.build(helpers)
|
11
|
+
Class.new do
|
12
|
+
def url_for(options)
|
13
|
+
options[:protocol] ||= "http"
|
14
|
+
options[:host] ||= "test.host"
|
15
|
+
|
16
|
+
super(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
include helpers
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module RoutingTestHelpers
|
25
|
+
def extra_keys(options, recall = {})
|
26
|
+
set.extra_keys(options, recall)
|
27
|
+
end
|
28
|
+
|
29
|
+
def generate_extras(options, recall = {})
|
30
|
+
set.generate_extras(options, recall)
|
31
|
+
end
|
32
|
+
|
33
|
+
def recognize_path(path, env = {})
|
34
|
+
set.recognize_path(path, env)
|
35
|
+
end
|
36
|
+
|
37
|
+
def request
|
38
|
+
@request ||= ActionDispatch::TestRequest.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def set
|
42
|
+
@set ||= ROUTING::RouteSet.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def url_for(options, recall = nil)
|
46
|
+
set.send(:url_for, options.merge(:only_path => true, :_path_segments => recall))
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# See RFC 3986, section 3.3 for allowed path characters.
|
4
|
+
class UriReservedCharactersRoutingTest < Test::Unit::TestCase
|
5
|
+
include RoutingTestHelpers
|
6
|
+
|
7
|
+
def setup
|
8
|
+
set.draw { |map| map.connect ':controller/:action/:variable/*additional' }
|
9
|
+
|
10
|
+
safe, unsafe = %w(: @ & = + $ , ;), %w(^ ? # [ ])
|
11
|
+
hex = unsafe.map { |char| '%' + char.unpack('H2').first.upcase }
|
12
|
+
|
13
|
+
@segment = "#{safe.join}#{unsafe.join}".freeze
|
14
|
+
@escaped = "#{safe.join}#{hex.join}".freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_route_generation_escapes_unsafe_path_characters
|
18
|
+
url_for(
|
19
|
+
:controller => "content",
|
20
|
+
:action => "act#{@segment}ion",
|
21
|
+
:variable => "variable",
|
22
|
+
:additional => "foo"
|
23
|
+
)
|
24
|
+
|
25
|
+
assert_equal "/content/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2",
|
26
|
+
url_for(
|
27
|
+
:controller => "content",
|
28
|
+
:action => "act#{@segment}ion",
|
29
|
+
:variable => "var#{@segment}iable",
|
30
|
+
:additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"]
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_route_recognition_unescapes_path_components
|
35
|
+
options = {
|
36
|
+
:controller => "content",
|
37
|
+
:action => "act#{@segment}ion",
|
38
|
+
:variable => "var#{@segment}iable",
|
39
|
+
:additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"]
|
40
|
+
}
|
41
|
+
|
42
|
+
assert_equal options, recognize_path("/content/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2")
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_route_generation_allows_passing_non_string_values_to_generated_helper
|
46
|
+
assert_equal "/content/action/variable/1/2",
|
47
|
+
url_for(
|
48
|
+
:controller => "content",
|
49
|
+
:action => "action",
|
50
|
+
:variable => "variable",
|
51
|
+
:additional => [1, 2]
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_legacy_mapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andrew White
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-29 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 31098233
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- beta
|
33
|
+
version: 3.1.0.beta
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
requirement: *id001
|
37
|
+
name: rails
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
- 10
|
49
|
+
version: 1.0.10
|
50
|
+
prerelease: false
|
51
|
+
type: :development
|
52
|
+
requirement: *id002
|
53
|
+
name: bundler
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 43
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
- 9
|
64
|
+
- 8
|
65
|
+
version: 0.9.8
|
66
|
+
prerelease: false
|
67
|
+
type: :development
|
68
|
+
requirement: *id003
|
69
|
+
name: mocha
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 49
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
- 8
|
80
|
+
- 7
|
81
|
+
version: 0.8.7
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
|
+
requirement: *id004
|
85
|
+
name: rake
|
86
|
+
description: |
|
87
|
+
This gem provides an extraction of the DeprecatedMapper from Rails 3.0.
|
88
|
+
If you have a legacy application with an old style routes.rb file this
|
89
|
+
allows you to get your application running quickly in Rails 3.1.
|
90
|
+
|
91
|
+
email:
|
92
|
+
- andyw@pixeltrix.co.uk
|
93
|
+
executables: []
|
94
|
+
|
95
|
+
extensions: []
|
96
|
+
|
97
|
+
extra_rdoc_files: []
|
98
|
+
|
99
|
+
files:
|
100
|
+
- .gemtest
|
101
|
+
- CHANGELOG
|
102
|
+
- LICENSE
|
103
|
+
- README
|
104
|
+
- Rakefile
|
105
|
+
- lib/rails_legacy_mapper.rb
|
106
|
+
- lib/rails_legacy_mapper/mapper.rb
|
107
|
+
- lib/rails_legacy_mapper/route_set_extensions.rb
|
108
|
+
- lib/rails_legacy_mapper/version.rb
|
109
|
+
- rails_legacy_mapper.gemspec
|
110
|
+
- test/fake_controllers.rb
|
111
|
+
- test/legacy_route_set_test.rb
|
112
|
+
- test/rack_mount_integration_test.rb
|
113
|
+
- test/resources_test.rb
|
114
|
+
- test/route_set_test.rb
|
115
|
+
- test/test_helper.rb
|
116
|
+
- test/uri_reserved_characters_routing_test.rb
|
117
|
+
has_rdoc: true
|
118
|
+
homepage: https://github.com/pixeltrix/rails_legacy_mapper/
|
119
|
+
licenses: []
|
120
|
+
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
requirements: []
|
145
|
+
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 1.6.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 3
|
150
|
+
summary: Old style routes for Rails 3.1
|
151
|
+
test_files:
|
152
|
+
- test/fake_controllers.rb
|
153
|
+
- test/legacy_route_set_test.rb
|
154
|
+
- test/rack_mount_integration_test.rb
|
155
|
+
- test/resources_test.rb
|
156
|
+
- test/route_set_test.rb
|
157
|
+
- test/test_helper.rb
|
158
|
+
- test/uri_reserved_characters_routing_test.rb
|