Routes using i18n and tests, moving test helpers to support directory.
This commit is contained in:
parent
42d00a8dea
commit
1e2ffc4104
|
@ -24,6 +24,10 @@ en:
|
|||
sign_in: 'Sign in'
|
||||
new_password: 'Forgot password?'
|
||||
new_confirmation: "Didn't receive confirmation instructions?"
|
||||
routes:
|
||||
session: 'session'
|
||||
password: 'password'
|
||||
confirmation: 'confirmation'
|
||||
notifier:
|
||||
confirmation_instructions: 'Confirmation instructions'
|
||||
reset_password_instructions: 'Reset password instructions'
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
ActionController::Routing::Routes.draw do |map|
|
||||
map.resource :session, :only => [:new, :create, :destroy]
|
||||
map.resource :password, :only => [:new, :create, :edit, :update]
|
||||
map.resource :confirmation, :only => [:new, :create, :show]
|
||||
def t(route_name)
|
||||
I18n.t(route_name, :scope => [:devise, :routes], :default => route_name.to_s)
|
||||
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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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 'test_help'
|
||||
|
||||
require 'webrat'
|
||||
|
||||
require 'assertions_helper'
|
||||
require 'models_helper'
|
||||
require 'integration_tests_helper'
|
||||
|
||||
#ActiveSupport::Dependencies.load_paths << File.expand_path(File.dirname(__FILE__) + '/..')
|
||||
#require_dependency 'devise'
|
||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
|
|
Loading…
Reference in New Issue