More tests passing for Rails 3 compatibility. 369 tests, 788 assertions, 34 failures, 16 errors.
This commit is contained in:
parent
b3e11c5aca
commit
d466849c57
|
@ -122,7 +122,7 @@ module ActionDispatch::Routing
|
|||
end
|
||||
|
||||
def registerable(mapping)
|
||||
scope(mapping.raw_path, :name_prefix => mapping.name) do
|
||||
scope :name_prefix => mapping.name do
|
||||
resource :registration, :only => [:new, :create, :edit, :update, :destroy], :as => mapping.raw_path[1..-1],
|
||||
:path_names => { :new => mapping.path_names[:sign_up] }
|
||||
end
|
||||
|
|
|
@ -11,16 +11,29 @@ class MockController < ApplicationController
|
|||
def path
|
||||
''
|
||||
end
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def host_with_port
|
||||
"test.host:3000"
|
||||
end
|
||||
|
||||
def protocol
|
||||
"http"
|
||||
end
|
||||
|
||||
def symbolized_path_parameters
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
class ControllerAuthenticableTest < ActionController::TestCase
|
||||
tests MockController
|
||||
|
||||
def setup
|
||||
@controller = MockController.new
|
||||
@mock_warden = OpenStruct.new
|
||||
@controller.env = { 'warden' => @mock_warden }
|
||||
@controller.session = {}
|
||||
end
|
||||
|
||||
test 'setup warden' do
|
||||
|
|
|
@ -197,16 +197,16 @@ class AuthenticationTest < ActionController::IntegrationTest
|
|||
|
||||
test 'destroyed account is signed out' do
|
||||
sign_in_as_user
|
||||
visit 'users/index'
|
||||
get '/users'
|
||||
|
||||
User.destroy_all
|
||||
visit 'users/index'
|
||||
get '/users'
|
||||
assert_redirected_to '/users/sign_in?unauthenticated=true'
|
||||
end
|
||||
|
||||
test 'allows session to be set by a given scope' do
|
||||
sign_in_as_user
|
||||
visit 'users/index'
|
||||
get '/users'
|
||||
assert_equal "Cart", @controller.user_session[:cart]
|
||||
end
|
||||
|
||||
|
@ -250,20 +250,20 @@ class AuthenticationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'render 404 on roles without permission' do
|
||||
get 'admin_area/password/new'
|
||||
get '/admin_area/password/new'
|
||||
assert_response :not_found
|
||||
assert_not_contain 'Send me reset password instructions'
|
||||
end
|
||||
|
||||
test 'render 404 on roles without mapping' do
|
||||
get 'sign_in'
|
||||
get '/sign_in'
|
||||
assert_response :not_found
|
||||
assert_not_contain 'Sign in'
|
||||
end
|
||||
|
||||
test 'uses the mapping from the default scope if specified' do
|
||||
swap Devise, :use_default_scope => true do
|
||||
get 'sign_in'
|
||||
get '/sign_in'
|
||||
assert_response :ok
|
||||
assert_contain 'Sign in'
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'test/test_helper'
|
|||
class RegistrationTest < ActionController::IntegrationTest
|
||||
|
||||
test 'a guest admin should be able to sign in successfully' do
|
||||
visit new_admin_session_path
|
||||
get new_admin_session_path
|
||||
click_link 'Sign up'
|
||||
|
||||
assert_template 'registrations/new'
|
||||
|
@ -21,7 +21,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'a guest user should be able to sign up successfully and be blocked by confirmation' do
|
||||
visit new_user_registration_path
|
||||
get new_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'new_user@test.com'
|
||||
fill_in 'password', :with => 'new_user123'
|
||||
|
@ -46,7 +46,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'a guest user cannot sign up with invalid information' do
|
||||
visit new_user_registration_path
|
||||
get new_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'invalid_email'
|
||||
fill_in 'password', :with => 'new_user123'
|
||||
|
@ -64,7 +64,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
|
||||
test 'a guest should not sign up with email/password that already exists' do
|
||||
user = create_user
|
||||
visit new_user_registration_path
|
||||
get new_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'user@test.com'
|
||||
fill_in 'password', :with => '123456'
|
||||
|
@ -78,20 +78,20 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'a guest should not be able to change account' do
|
||||
visit edit_user_registration_path
|
||||
get edit_user_registration_path
|
||||
follow_redirect!
|
||||
assert_template 'sessions/new'
|
||||
end
|
||||
|
||||
test 'a signed in user should not be able to access sign up' do
|
||||
sign_in_as_user
|
||||
visit new_user_registration_path
|
||||
get new_user_registration_path
|
||||
assert_template 'home/index'
|
||||
end
|
||||
|
||||
test 'a signed in user should be able to edit his account' do
|
||||
sign_in_as_user
|
||||
visit edit_user_registration_path
|
||||
get edit_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'user.new@email.com'
|
||||
fill_in 'current password', :with => '123456'
|
||||
|
@ -105,7 +105,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
|
||||
test 'a signed in user should be able to edit his password' do
|
||||
sign_in_as_user
|
||||
visit edit_user_registration_path
|
||||
get edit_user_registration_path
|
||||
|
||||
fill_in 'password', :with => 'pas123'
|
||||
fill_in 'password confirmation', :with => 'pas123'
|
||||
|
@ -120,7 +120,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
|
||||
test 'a signed in user should be able to cancel his account' do
|
||||
sign_in_as_user
|
||||
visit edit_user_registration_path
|
||||
get edit_user_registration_path
|
||||
|
||||
click_link "Cancel my account"
|
||||
assert_contain "Bye! Your account was successfully cancelled. We hope to see you again soon."
|
||||
|
|
|
@ -16,8 +16,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest
|
|||
test 'signing in with valid authentication token - but improper authentication token key - return to sign in form with error message' do
|
||||
swap Devise, :token_authentication_key => :donald_duck_token do
|
||||
sign_in_as_new_user_with_token(:auth_token_key => :secret_token)
|
||||
assert_redirected_to new_user_session_path(:unauthenticated => true)
|
||||
follow_redirect!
|
||||
assert_current_path new_user_session_path(:unauthenticated => true)
|
||||
|
||||
assert_contain 'You need to sign in or sign up before continuing'
|
||||
assert_contain 'Sign in'
|
||||
|
@ -28,8 +27,7 @@ class TokenAuthenticationTest < ActionController::IntegrationTest
|
|||
test 'signing in with invalid authentication token should return to sign in form with error message' do
|
||||
store_translations :en, :devise => {:sessions => {:invalid_token => 'LOL, that was not a single character correct.'}} do
|
||||
sign_in_as_new_user_with_token(:auth_token => '*** INVALID TOKEN ***')
|
||||
assert_redirected_to new_user_session_path(:invalid_token => true)
|
||||
follow_redirect!
|
||||
assert_current_path new_user_session_path(:invalid_token => true)
|
||||
|
||||
assert_response :success
|
||||
assert_contain 'LOL, that was not a single character correct.'
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
Rails::Application.routes.draw do
|
||||
resources :users, :only => [:index] do
|
||||
get :expire, :on => :member
|
||||
end
|
||||
|
||||
devise_for :users
|
||||
devise_for :admin, :as => 'admin_area'
|
||||
devise_for :accounts, :scope => 'manager', :path_prefix => ':locale',
|
||||
|
@ -8,10 +12,6 @@ Rails::Application.routes.draw do
|
|||
:unlock => 'unblock', :sign_up => 'register'
|
||||
}
|
||||
|
||||
resources :users, :only => [:index] do
|
||||
get :expire, :on => :member
|
||||
end
|
||||
|
||||
resources :admins, :only => [:index]
|
||||
root :to => "home#index"
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class ActionController::IntegrationTest
|
|||
|
||||
def sign_in_as_user(options={}, &block)
|
||||
user = create_user(options)
|
||||
visit new_user_session_path unless options[:visit] == false
|
||||
get new_user_session_path unless options[:visit] == false
|
||||
fill_in 'email', :with => 'user@test.com'
|
||||
fill_in 'password', :with => '123456'
|
||||
check 'remember me' if options[:remember_me] == true
|
||||
|
@ -41,7 +41,7 @@ class ActionController::IntegrationTest
|
|||
|
||||
def sign_in_as_admin(options={}, &block)
|
||||
admin = create_admin(options)
|
||||
visit new_admin_session_path unless options[:visit] == false
|
||||
get new_admin_session_path unless options[:visit] == false
|
||||
fill_in 'email', :with => 'admin@test.com'
|
||||
fill_in 'password', :with => '123456'
|
||||
yield if block_given?
|
||||
|
@ -49,6 +49,10 @@ class ActionController::IntegrationTest
|
|||
admin
|
||||
end
|
||||
|
||||
def assert_current_path(path)
|
||||
assert_equal path, current_url
|
||||
end
|
||||
|
||||
# Fix assert_redirect_to in integration sessions because they don't take into
|
||||
# account Middleware redirects.
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue