Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix namescape

  • Loading branch information...
commit d192bf2ab25a99e5980f98a71fd536e3d63ecf21 1 parent cbd4fb8
@ZenCocoon authored
View
6 lib/routing_filter_locale_unless_api.rb
@@ -1,5 +1,3 @@
-module RoutingFilter
- module LocaleUnlessApi
- require 'routing_filter_locale_unless_api/locale_unless_api'
- end
+module RoutingFilterLocaleUnlessApi
+ require 'routing_filter_locale_unless_api/locale_unless_api'
end
View
2  lib/routing_filter_locale_unless_api/locale_unless_api.rb
@@ -30,7 +30,7 @@
require 'i18n'
module RoutingFilter
- class Locale < Filter
+ class LocaleUnlessApi < Filter
@@api_formats = %w( xml json )
cattr_writer :api_formats
View
6 lib/routing_filter_locale_unless_api/version.rb
@@ -1,5 +1,3 @@
-module RoutingFilter
- module LocaleUnlessApi
- VERSION = "0.0.1"
- end
+module RoutingFilterLocaleUnlessApi
+ VERSION = "0.0.1"
end
View
10 test/locale_unless_api_test.rb
@@ -8,13 +8,13 @@ def setup
I18n.default_locale = :en
I18n.available_locales = %w(fr en)
- RoutingFilter::Locale.api_formats = %w( xml json )
+ RoutingFilter::LocaleUnlessApi.api_formats = %w( xml json )
@root = { :controller => 'some', :action => 'index' }
@params = { :controller => 'some', :action => 'show', :id => '1' }
@routes = draw_routes do
- filter :locale
+ filter :locale_unless_api
match 'products/:id', :to => 'some#show'
root :to => 'some#index'
end
@@ -37,7 +37,7 @@ def setup
end
test 'recognizes the path /en' do
- assert_equal root.merge(:locale => 'en'), routes.recognize_path('/en')
+ assert_equal root.merge(:locale => 'en'), routes.recognize_path('/en/')
end
test 'recognizes the path /fr' do
@@ -86,7 +86,7 @@ def setup
test 'does not prepend the segments /:locale to the generated path if the format XLS is considered as api' do
I18n.locale = 'fr'
- RoutingFilter::Locale.api_formats = %w( xml json xls )
+ RoutingFilter::LocaleUnlessApi.api_formats = %w( xml json xls )
assert_equal '/products/1.xls', routes.generate(params.merge(:format => 'xls'))
end
@@ -120,7 +120,7 @@ def setup
end
test 'does not prepend the segments /:locale to the generated path if a given locale and the format XLS is considered as api' do
- RoutingFilter::Locale.api_formats = %w( xml json xls )
+ RoutingFilter::LocaleUnlessApi.api_formats = %w( xml json xls )
assert_equal '/products/1.xls', routes.generate(params.merge(:format => 'xls', :locale => 'fr'))
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.