route_translator 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ module RouteTranslator
31
31
  new_defaults = defaults.merge(RouteTranslator.locale_param_key => locale.to_s)
32
32
  new_requirements = requirements.merge(RouteTranslator.locale_param_key => locale.to_s)
33
33
  new_route_name = translate_name(route_name, locale)
34
- new_route_name = nil if route_set.named_routes.routes[new_route_name.to_sym] #TODO: Investigate this :(
34
+ new_route_name = nil if new_route_name && route_set.named_routes.routes[new_route_name.to_sym] #TODO: Investigate this :(
35
35
  block.call(app, new_conditions, new_requirements, new_defaults, new_route_name, anchor)
36
36
  end
37
37
  block.call(app, conditions, requirements, defaults, route_name, anchor) if RouteTranslator.config.generate_unlocalized_routes
@@ -1,3 +1,3 @@
1
1
  module RouteTranslator
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
3
3
  end
@@ -1,6 +1,8 @@
1
1
  es:
2
- people: gente
3
- products: productos
2
+ routes:
3
+ people: gente
4
+ products: productos
5
+ tr_param: tr_parametro
4
6
 
5
7
  ru:
6
8
  people: люди
data/test/routing_test.rb CHANGED
@@ -1,3 +1,4 @@
1
+ #encoding: utf-8
1
2
  require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
3
  require 'route_translator'
3
4
 
@@ -33,6 +34,36 @@ class TranslateRoutesTest < ActionController::TestCase
33
34
  assert_routing '/es', :controller => 'people', :action => 'index', :locale => 'es'
34
35
  end
35
36
 
37
+ def test_params
38
+ draw_routes do
39
+ localized do
40
+ resources :products
41
+ end
42
+ end
43
+
44
+ assert_routing '/es/productos/product_slug', :controller => 'products', :action => 'show', :locale => 'es', :id => 'product_slug'
45
+ end
46
+
47
+ def test_optional_segments
48
+ draw_routes do
49
+ localized do
50
+ get 'products(/:optional_param)/:non_optional_param', :to => 'products#index'
51
+ end
52
+ end
53
+
54
+ assert_routing '/es/productos/a', :controller => 'products', :action => 'index', :locale => 'es', :non_optional_param => 'a'
55
+ assert_routing '/es/productos/a/b', :controller => 'products', :action => 'index', :locale => 'es', :non_optional_param => 'b', :optional_param => 'a'
56
+ end
57
+
58
+ def test_dynamic_segments_dont_get_translated
59
+ draw_routes do
60
+ localized do
61
+ get 'products/:tr_param', :to => 'products#index', :constraints => { :tr_param => /\w/ }
62
+ end
63
+ end
64
+ assert_routing '/es/productos/a', :controller => 'products', :action => 'index', :locale => 'es', :tr_param => 'a'
65
+ end
66
+
36
67
  def test_resources
37
68
  config_default_locale_settings 'es'
38
69
 
metadata CHANGED
@@ -1,63 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: route_translator
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.2
5
5
  prerelease:
6
- segments:
7
- - 3
8
- - 0
9
- - 1
10
- version: 3.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Raul Murciano
14
9
  - Enric Lluelles
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2013-05-03 00:00:00 +02:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2013-05-13 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: minitest
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
19
+ requirements:
28
20
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 35
31
- segments:
32
- - 4
33
- - 7
34
- - 0
21
+ - !ruby/object:Gem::Version
35
22
  version: 4.7.0
36
23
  type: :development
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: sinatra
40
24
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 4.7.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: sinatra
33
+ requirement: !ruby/object:Gem::Requirement
42
34
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
50
39
  type: :development
51
- version_requirements: *id002
52
- description: Translates the Rails routes of your application into the languages defined in your locale files
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: Translates the Rails routes of your application into the languages defined
48
+ in your locale files
53
49
  email: enric@lluell.es
54
50
  executables: []
55
-
56
51
  extensions: []
57
-
58
52
  extra_rdoc_files: []
59
-
60
- files:
53
+ files:
61
54
  - lib/route_translator.rb
62
55
  - lib/route_translator/extensions.rb
63
56
  - lib/route_translator/extensions/action_controller.rb
@@ -80,41 +73,31 @@ files:
80
73
  - test/locales/routes.yml
81
74
  - test/routing_test.rb
82
75
  - test/test_helper.rb
83
- has_rdoc: true
84
76
  homepage: http://github.com/enriclluelles/route_translator
85
77
  licenses: []
86
-
87
78
  post_install_message:
88
79
  rdoc_options: []
89
-
90
- require_paths:
80
+ require_paths:
91
81
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
93
83
  none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
- version: "0"
101
- required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
89
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
110
94
  requirements: []
111
-
112
95
  rubyforge_project:
113
- rubygems_version: 1.6.2
96
+ rubygems_version: 1.8.23
114
97
  signing_key:
115
98
  specification_version: 3
116
99
  summary: Translate your Rails routes in a simple manner
117
- test_files:
100
+ test_files:
118
101
  - test/dummy/app/controllers/dummy_controller.rb
119
102
  - test/dummy/config.ru
120
103
  - test/dummy/config/application.rb