Permalink
Browse files

added localization-related test using assert_generates

added test with implicit locale
  • Loading branch information...
1 parent f91ebdd commit 232a777be4d26c4ecd959ce3456b8f60a20ff0d1 GSI2014 committed Feb 8, 2014
Showing with 33 additions and 8 deletions.
  1. +3 −1 Gemfile
  2. +12 −6 Gemfile.lock
  3. +2 −0 config/locales/routes.yml
  4. +16 −1 test/controllers/users_controller_test.rb
View
@@ -45,6 +45,8 @@ end
# gem 'debugger', group: [:development, :test]
gem 'devise'
-gem 'route_translator', '~> 3.1.0'
+#gem 'route_translator', '~> 3.1.0'
#gem 'route_translator', :github => 'enriclluelles/route_translator'
#gem 'route_translator', :github => 'astjohn/route_translator'
+#gem 'route_translator', git: 'https://github.com/astjohn/route_translator.git', branch: 'fix_rendered_paths'
+gem 'route_translator', :github => 'mohamagdy/route_translator', :branch => 'unit_tests_routes_without_locale'
View
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/mohamagdy/route_translator.git
+ revision: d16446e7edb9983792ce71d65c279eab4eca0d7a
+ branch: unit_tests_routes_without_locale
+ specs:
+ route_translator (3.1.0)
+
GEM
remote: https://rubygems.org/
specs:
@@ -25,7 +32,7 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
- arel (4.0.1)
+ arel (4.0.2)
atomic (1.1.14)
bcrypt-ruby (3.1.2)
builder (3.1.4)
@@ -35,7 +42,7 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
- coffee-script-source (1.6.3)
+ coffee-script-source (1.7.0)
devise (3.2.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
@@ -49,7 +56,7 @@ GEM
jbuilder (1.5.3)
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
- jquery-rails (3.0.4)
+ jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
@@ -80,7 +87,6 @@ GEM
rake (10.1.1)
rdoc (4.1.1)
json (~> 1.4)
- route_translator (3.1.0)
sass (3.2.14)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
@@ -106,7 +112,7 @@ GEM
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
- turbolinks (2.2.0)
+ turbolinks (2.2.1)
coffee-rails
tzinfo (0.3.38)
uglifier (2.4.0)
@@ -124,7 +130,7 @@ DEPENDENCIES
jbuilder (~> 1.2)
jquery-rails
rails (= 4.0.2)
- route_translator (~> 3.1.0)
+ route_translator!
sass-rails (~> 4.0.0)
sdoc
sqlite3
@@ -6,8 +6,10 @@ es:
routes:
new: nuevo
users: usuario
+ sign_out: cerrar
de:
routes:
new: neu
users: benutzer
+ sign_out: abmelden
@@ -1,11 +1,26 @@
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
- test "should get new" do
+ test "should get new - explicit locale" do
users_path
get :new, locale: 'en'
assert_response :success
end
+ test "should get new - implicit locale" do
+ get :new
+ assert_response :success
+ end
+
+ test "devise-destroy-route: sign_out closes session in any available language" do
+ assert_generates '/en/users/sign_out',
+ { :locale => 'en', :controller => 'devise/sessions', :action => 'destroy' }
+
+ assert_generates '/de/benutzer/abmelden',
+ { :locale => 'de', :controller => 'devise/sessions', :action => 'destroy' }
+
+ assert_generates '/es/usuario/cerrar',
+ { :locale => 'es', :controller => 'devise/sessions', :action => 'destroy' }
+ end
end

0 comments on commit 232a777

Please sign in to comment.