mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Routes using i18n and tests, moving test helpers to support directory.
This commit is contained in:
parent
42d00a8dea
commit
1e2ffc4104
10 changed files with 94 additions and 10 deletions
|
@ -24,6 +24,10 @@ en:
|
||||||
sign_in: 'Sign in'
|
sign_in: 'Sign in'
|
||||||
new_password: 'Forgot password?'
|
new_password: 'Forgot password?'
|
||||||
new_confirmation: "Didn't receive confirmation instructions?"
|
new_confirmation: "Didn't receive confirmation instructions?"
|
||||||
|
routes:
|
||||||
|
session: 'session'
|
||||||
|
password: 'password'
|
||||||
|
confirmation: 'confirmation'
|
||||||
notifier:
|
notifier:
|
||||||
confirmation_instructions: 'Confirmation instructions'
|
confirmation_instructions: 'Confirmation instructions'
|
||||||
reset_password_instructions: 'Reset password instructions'
|
reset_password_instructions: 'Reset password instructions'
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
ActionController::Routing::Routes.draw do |map|
|
ActionController::Routing::Routes.draw do |map|
|
||||||
map.resource :session, :only => [:new, :create, :destroy]
|
def t(route_name)
|
||||||
map.resource :password, :only => [:new, :create, :edit, :update]
|
I18n.t(route_name, :scope => [:devise, :routes], :default => route_name.to_s)
|
||||||
map.resource :confirmation, :only => [:new, :create, :show]
|
end
|
||||||
|
|
||||||
|
map.resource :session, :only => [:new, :create, :destroy], :as => t(:session)
|
||||||
|
map.resource :password, :only => [:new, :create, :edit, :update], :as => t(:password)
|
||||||
|
map.resource :confirmation, :only => [:new, :create, :show], :as => t(:confirmation)
|
||||||
end
|
end
|
||||||
|
|
22
test/routes/confirmation_routing_test.rb
Normal file
22
test/routes/confirmation_routing_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ConfirmationRoutingTest < ActionController::TestCase
|
||||||
|
|
||||||
|
test 'new session route' do
|
||||||
|
assert_routing('/confirmation/new', :controller => 'confirmations', :action => 'new')
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'create confirmation route' do
|
||||||
|
assert_routing({:path => '/confirmation', :method => :post}, {:controller => 'confirmations', :action => 'create'})
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'show confirmation route' do
|
||||||
|
assert_routing('/confirmation', :controller => 'confirmations', :action => 'show')
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'translated confirmation route' do
|
||||||
|
translated_route(:confirmation => 'confirmacao') do
|
||||||
|
assert_routing('/confirmacao/new', :controller => 'confirmations', :action => 'new')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
26
test/routes/password_routing_test.rb
Normal file
26
test/routes/password_routing_test.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PasswordRoutingTest < ActionController::TestCase
|
||||||
|
|
||||||
|
test 'new password route' do
|
||||||
|
assert_routing('/password/new', :controller => 'passwords', :action => 'new')
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'create password route' do
|
||||||
|
assert_routing({:path => '/password', :method => :post}, {:controller => 'passwords', :action => 'create'})
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'edit password route' do
|
||||||
|
assert_routing('/password/edit', :controller => 'passwords', :action => 'edit')
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'update password route' do
|
||||||
|
assert_routing({:path => '/password', :method => :put}, {:controller => 'passwords', :action => 'update'})
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'translated password route' do
|
||||||
|
translated_route(:password => 'senha') do
|
||||||
|
assert_routing('/senha/new', :controller => 'passwords', :action => 'new')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
22
test/routes/session_routing_test.rb
Normal file
22
test/routes/session_routing_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class SessionRoutingTest < ActionController::TestCase
|
||||||
|
|
||||||
|
test 'new session route' do
|
||||||
|
assert_routing('/session/new', :controller => 'sessions', :action => 'new')
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'create session route' do
|
||||||
|
assert_routing({:path => '/session', :method => :post}, {:controller => 'sessions', :action => 'create'})
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'destroy session route' do
|
||||||
|
assert_routing({:path => '/session', :method => :delete}, {:controller => 'sessions', :action => 'destroy'})
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'translate session route' do
|
||||||
|
translated_route(:session => 'sessao') do
|
||||||
|
assert_routing('/sessao/new', :controller => 'sessions', :action => 'new')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
12
test/support/controller_tests_helper.rb
Normal file
12
test/support/controller_tests_helper.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class ActionController::TestCase
|
||||||
|
|
||||||
|
def translated_route(translation={}, &block)
|
||||||
|
I18n.locale = :'pt-BR'
|
||||||
|
I18n.backend.store_translations(:'pt-BR', :devise => { :routes => translation })
|
||||||
|
ActionController::Routing::Routes.reload!
|
||||||
|
yield
|
||||||
|
I18n.locale = :en
|
||||||
|
I18n.reload!
|
||||||
|
ActionController::Routing::Routes.reload!
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,15 +2,9 @@ RAILS_ENV = ENV["RAILS_ENV"] = "test"
|
||||||
require File.join(File.dirname(__FILE__), 'rails_app', 'config', 'environment')
|
require File.join(File.dirname(__FILE__), 'rails_app', 'config', 'environment')
|
||||||
|
|
||||||
require 'test_help'
|
require 'test_help'
|
||||||
|
|
||||||
require 'webrat'
|
require 'webrat'
|
||||||
|
|
||||||
require 'assertions_helper'
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||||
require 'models_helper'
|
|
||||||
require 'integration_tests_helper'
|
|
||||||
|
|
||||||
#ActiveSupport::Dependencies.load_paths << File.expand_path(File.dirname(__FILE__) + '/..')
|
|
||||||
#require_dependency 'devise'
|
|
||||||
|
|
||||||
ActionMailer::Base.delivery_method = :test
|
ActionMailer::Base.delivery_method = :test
|
||||||
ActionMailer::Base.perform_deliveries = true
|
ActionMailer::Base.perform_deliveries = true
|
||||||
|
|
Loading…
Reference in a new issue