mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Got tests running on Rails 3: 369 tests, 486 assertions, 45 failures, 124 errors.
This commit is contained in:
parent
6d29bcc467
commit
766316b5e7
54 changed files with 420 additions and 550 deletions
|
@ -1,3 +1,7 @@
|
|||
== 1.1.0
|
||||
|
||||
* Rails 3 compatibility
|
||||
|
||||
== 1.0.1
|
||||
|
||||
* enhancements
|
||||
|
|
8
Gemfile
Normal file
8
Gemfile
Normal file
|
@ -0,0 +1,8 @@
|
|||
source "http://gemcutter.org"
|
||||
|
||||
gem "rails", "3.0.0.beta"
|
||||
gem "warden", "0.9.2"
|
||||
gem "sqlite3-ruby", :require => "sqlite3"
|
||||
gem "webrat", "0.7"
|
||||
gem "mocha", :require => false
|
||||
gem "bcrypt-ruby", :require => "bcrypt"
|
|
@ -28,18 +28,20 @@ class DeviseMailer < ::ActionMailer::Base
|
|||
recipients record.email
|
||||
sent_on Time.now
|
||||
content_type 'text/html'
|
||||
body render_with_scope(key, mapping, mapping.name => record, :resource => record)
|
||||
|
||||
@resource = instance_variable_set("@#{mapping.name}", record)
|
||||
render_with_scope(key, mapping)
|
||||
end
|
||||
|
||||
def render_with_scope(key, mapping, assigns)
|
||||
def render_with_scope(key, mapping)
|
||||
if self.class.scoped_views
|
||||
begin
|
||||
render :file => "devise_mailer/#{mapping.as}/#{key}", :body => assigns
|
||||
render :file => "devise_mailer/#{mapping.as}/#{key}"
|
||||
rescue ActionView::MissingTemplate
|
||||
render :file => "devise_mailer/#{key}", :body => assigns
|
||||
render :file => "devise_mailer/#{key}"
|
||||
end
|
||||
else
|
||||
render :file => "devise_mailer/#{key}", :body => assigns
|
||||
render :file => "devise_mailer/#{key}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
2
init.rb
2
init.rb
|
@ -1,2 +0,0 @@
|
|||
# We need to load devise here to ensure routes extensions are loaded.
|
||||
require 'devise'
|
|
@ -1,4 +1,18 @@
|
|||
module Devise
|
||||
class Engine < ::Rails::Engine
|
||||
engine_name :devise
|
||||
|
||||
config.after_initialize do
|
||||
require "devise/orm/#{Devise.orm}"
|
||||
|
||||
# Adds Warden Manager to Rails middleware stack, configuring default devise
|
||||
# strategy and also the failure app.
|
||||
config.middleware.use Warden::Manager do |config|
|
||||
Devise.configure_warden(config)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
autoload :FailureApp, 'devise/failure_app'
|
||||
autoload :Schema, 'devise/schema'
|
||||
autoload :TestHelpers, 'devise/test_helpers'
|
||||
|
|
|
@ -13,6 +13,6 @@ Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
|
|||
record.sign_in_count ||= 0
|
||||
record.sign_in_count += 1
|
||||
|
||||
record.save(false)
|
||||
record.save(:validate => false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ module Devise
|
|||
# # is the modules included in the class
|
||||
#
|
||||
class Mapping #:nodoc:
|
||||
attr_reader :name, :as, :path_names, :path_prefix, :route_options
|
||||
attr_reader :name, :as, :path_names, :path_prefix
|
||||
|
||||
# Loop through all mappings looking for a map that matches with the requested
|
||||
# path (ie /users/sign_in). If a path prefix is given, it's taken into account.
|
||||
|
@ -66,10 +66,8 @@ module Devise
|
|||
@klass = (options.delete(:class_name) || name.to_s.classify).to_s
|
||||
@name = (options.delete(:scope) || name.to_s.singularize).to_sym
|
||||
|
||||
@path_prefix = "/#{options.delete(:path_prefix)}/".squeeze("/")
|
||||
@route_options = options || {}
|
||||
|
||||
@path_names = Hash.new { |h,k| h[k] = k.to_s }
|
||||
@path_prefix = "/#{options.delete(:path_prefix)}/".squeeze("/")
|
||||
@path_names = Hash.new { |h,k| h[k] = k.to_s }
|
||||
@path_names.merge!(options.delete(:path_names) || {})
|
||||
end
|
||||
|
||||
|
|
|
@ -36,12 +36,6 @@ module Devise
|
|||
end
|
||||
end
|
||||
|
||||
# TODO Remove me in next release
|
||||
def old_password
|
||||
ActiveSupport::Deprecation.warn "old_password is deprecated, please use current_password instead", caller
|
||||
@old_password
|
||||
end
|
||||
|
||||
# Regenerates password salt and encrypted password each time password is set,
|
||||
# and then trigger any "after_changed_password"-callbacks.
|
||||
def password=(new_password)
|
||||
|
@ -78,16 +72,11 @@ module Devise
|
|||
# error on :current_password. It also automatically rejects :password and
|
||||
# :password_confirmation if they are blank.
|
||||
def update_with_password(params={})
|
||||
# TODO Remove me in next release
|
||||
if params[:old_password].present?
|
||||
params[:current_password] ||= params[:old_password]
|
||||
ActiveSupport::Deprecation.warn "old_password is deprecated, please use current_password instead", caller
|
||||
end
|
||||
|
||||
params.delete(:password) if params[:password].blank?
|
||||
params.delete(:password_confirmation) if params[:password_confirmation].blank?
|
||||
current_password = params.delete(:current_password)
|
||||
|
||||
params.delete(:password) if params[:password].blank?
|
||||
params.delete(:password_confirmation) if params[:password_confirmation].blank?
|
||||
|
||||
result = if valid_password?(current_password)
|
||||
update_attributes(params)
|
||||
else
|
||||
|
|
|
@ -46,7 +46,7 @@ module Devise
|
|||
unless_confirmed do
|
||||
self.confirmation_token = nil
|
||||
self.confirmed_at = Time.now
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ module Devise
|
|||
|
||||
# Send confirmation instructions by email
|
||||
def send_confirmation_instructions
|
||||
::DeviseMailer.deliver_confirmation_instructions(self)
|
||||
::DeviseMailer.confirmation_instructions(self).deliver
|
||||
end
|
||||
|
||||
# Remove confirmation date and send confirmation instructions, to ensure
|
||||
|
@ -66,7 +66,7 @@ module Devise
|
|||
def resend_confirmation!
|
||||
unless_confirmed do
|
||||
generate_confirmation_token
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
send_confirmation_instructions
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ module Devise
|
|||
# Lock an user also saving the record.
|
||||
def lock!
|
||||
lock
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
end
|
||||
|
||||
# Unlock an user by cleaning locket_at and failed_attempts.
|
||||
|
@ -47,7 +47,7 @@ module Devise
|
|||
self.locked_at = nil
|
||||
self.failed_attempts = 0
|
||||
self.unlock_token = nil
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,14 +58,14 @@ module Devise
|
|||
|
||||
# Send unlock instructions by email
|
||||
def send_unlock_instructions
|
||||
::DeviseMailer.deliver_unlock_instructions(self)
|
||||
::DeviseMailer.unlock_instructions(self).deliver
|
||||
end
|
||||
|
||||
# Resend the unlock instructions if the user is locked.
|
||||
def resend_unlock!
|
||||
if_locked do
|
||||
generate_unlock_token unless unlock_token.present?
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
send_unlock_instructions
|
||||
end
|
||||
end
|
||||
|
@ -96,7 +96,7 @@ module Devise
|
|||
self.failed_attempts += 1
|
||||
lock if failed_attempts > self.class.maximum_attempts
|
||||
end
|
||||
save(false) if changed?
|
||||
save(:validate => false) if changed?
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module Devise
|
|||
# Resets reset password token and send reset password instructions by email
|
||||
def send_reset_password_instructions
|
||||
generate_reset_password_token!
|
||||
::DeviseMailer.deliver_reset_password_instructions(self)
|
||||
::DeviseMailer.reset_password_instructions(self).deliver
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -45,7 +45,7 @@ module Devise
|
|||
# Resets the reset password token with and save the record without
|
||||
# validating
|
||||
def generate_reset_password_token!
|
||||
generate_reset_password_token && save(false)
|
||||
generate_reset_password_token && save(:validate => false)
|
||||
end
|
||||
|
||||
# Removes reset_password token
|
||||
|
|
|
@ -44,7 +44,7 @@ module Devise
|
|||
def remember_me!
|
||||
self.remember_token = Devise.friendly_token
|
||||
self.remember_created_at = Time.now.utc
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
end
|
||||
|
||||
# Removes the remember token only if it exists, and save the record
|
||||
|
@ -53,7 +53,7 @@ module Devise
|
|||
if remember_token
|
||||
self.remember_token = nil
|
||||
self.remember_created_at = nil
|
||||
save(false)
|
||||
save(:validate => false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
module Devise
|
||||
module Orm
|
||||
module MongoMapper
|
||||
module InstanceMethods
|
||||
def save(options={})
|
||||
if options == false
|
||||
super(:validate => false)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.included_modules_hook(klass)
|
||||
klass.send :extend, self
|
||||
klass.send :include, InstanceMethods
|
||||
klass.send :extend, self
|
||||
yield
|
||||
|
||||
klass.devise_modules.each do |mod|
|
||||
|
|
|
@ -1,14 +1,2 @@
|
|||
require 'devise/rails/routes'
|
||||
require 'devise/rails/warden_compat'
|
||||
|
||||
Rails.configuration.after_initialize do
|
||||
require "devise/orm/#{Devise.orm}"
|
||||
|
||||
# Adds Warden Manager to Rails middleware stack, configuring default devise
|
||||
# strategy and also the failure app.
|
||||
Rails.configuration.middleware.use Warden::Manager do |config|
|
||||
Devise.configure_warden(config)
|
||||
end
|
||||
|
||||
I18n.load_path.unshift File.expand_path(File.join(File.dirname(__FILE__), 'locales', 'en.yml'))
|
||||
end
|
||||
require 'devise/rails/warden_compat'
|
|
@ -1,11 +1,12 @@
|
|||
module ActionController::Routing
|
||||
module ActionDispatch::Routing
|
||||
class RouteSet #:nodoc:
|
||||
|
||||
# Ensure Devise modules are included only after loading routes, because we
|
||||
# need devise_for mappings already declared to create magic filters and
|
||||
# helpers.
|
||||
def load_routes_with_devise!
|
||||
load_routes_without_devise!
|
||||
#
|
||||
# TODO Hook into initializers workflow
|
||||
def finalize_with_devise!
|
||||
finalize_without_devise!
|
||||
return if Devise.mappings.empty?
|
||||
|
||||
ActionController::Base.send :include, Devise::Controllers::Helpers
|
||||
|
@ -13,113 +14,118 @@ module ActionController::Routing
|
|||
|
||||
ActionView::Base.send :include, Devise::Controllers::UrlHelpers
|
||||
end
|
||||
alias_method_chain :load_routes!, :devise
|
||||
alias_method_chain :finalize!, :devise
|
||||
end
|
||||
|
||||
class Mapper #:doc:
|
||||
# Includes devise_for method for routes. This method is responsible to
|
||||
# generate all needed routes for devise, based on what modules you have
|
||||
# defined in your model.
|
||||
# Examples: Let's say you have an User model configured to use
|
||||
# authenticatable, confirmable and recoverable modules. After creating this
|
||||
# inside your routes:
|
||||
#
|
||||
# map.devise_for :users
|
||||
#
|
||||
# this method is going to look inside your User model and create the
|
||||
# needed routes:
|
||||
#
|
||||
# # Session routes for Authenticatable (default)
|
||||
# new_user_session GET /users/sign_in {:controller=>"sessions", :action=>"new"}
|
||||
# user_session POST /users/sign_in {:controller=>"sessions", :action=>"create"}
|
||||
# destroy_user_session GET /users/sign_out {:controller=>"sessions", :action=>"destroy"}
|
||||
#
|
||||
# # Password routes for Recoverable, if User model has :recoverable configured
|
||||
# new_user_password GET /users/password/new(.:format) {:controller=>"passwords", :action=>"new"}
|
||||
# edit_user_password GET /users/password/edit(.:format) {:controller=>"passwords", :action=>"edit"}
|
||||
# user_password PUT /users/password(.:format) {:controller=>"passwords", :action=>"update"}
|
||||
# POST /users/password(.:format) {:controller=>"passwords", :action=>"create"}
|
||||
#
|
||||
# # Confirmation routes for Confirmable, if User model has :confirmable configured
|
||||
# new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"confirmations", :action=>"new"}
|
||||
# user_confirmation GET /users/confirmation(.:format) {:controller=>"confirmations", :action=>"show"}
|
||||
# POST /users/confirmation(.:format) {:controller=>"confirmations", :action=>"create"}
|
||||
#
|
||||
# You can configure your routes with some options:
|
||||
#
|
||||
# * :class_name => setup a different class to be looked up by devise, if it cannot be correctly find by the route name.
|
||||
#
|
||||
# map.devise_for :users, :class_name => 'Account'
|
||||
#
|
||||
# * :as => allows you to setup path name that will be used, as rails routes does. The following route configuration would setup your route as /accounts instead of /users:
|
||||
#
|
||||
# map.devise_for :users, :as => 'accounts'
|
||||
#
|
||||
# * :scope => setup the scope name. This is used as the instance variable name in controller, as the name in routes and the scope given to warden. Defaults to the singular of the given name:
|
||||
#
|
||||
# map.devise_for :users, :scope => :account
|
||||
#
|
||||
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :password and :confirmation.
|
||||
#
|
||||
# map.devise_for :users, :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification' }
|
||||
#
|
||||
# * :path_prefix => the path prefix to be used in all routes.
|
||||
#
|
||||
# map.devise_for :users, :path_prefix => "/:locale"
|
||||
#
|
||||
# Any other options will be passed to route definition. If you need conditions for your routes, just map:
|
||||
#
|
||||
# map.devise_for :users, :conditions => { :subdomain => /.+/ }
|
||||
#
|
||||
# If you are using a dynamic prefix, like :locale above, you need to configure default_url_options through Devise. You can do that in config/initializers/devise.rb or setting a Devise.default_url_options:
|
||||
#
|
||||
# Devise.default_url_options do
|
||||
# { :locale => I18n.locale }
|
||||
# end
|
||||
#
|
||||
def devise_for(*resources)
|
||||
options = resources.extract_options!
|
||||
class Mapper
|
||||
# Includes devise_for method for routes. This method is responsible to
|
||||
# generate all needed routes for devise, based on what modules you have
|
||||
# defined in your model.
|
||||
# Examples: Let's say you have an User model configured to use
|
||||
# authenticatable, confirmable and recoverable modules. After creating this
|
||||
# inside your routes:
|
||||
#
|
||||
# devise_for :users
|
||||
#
|
||||
# this method is going to look inside your User model and create the
|
||||
# needed routes:
|
||||
#
|
||||
# # Session routes for Authenticatable (default)
|
||||
# new_user_session GET /users/sign_in {:controller=>"sessions", :action=>"new"}
|
||||
# user_session POST /users/sign_in {:controller=>"sessions", :action=>"create"}
|
||||
# destroy_user_session GET /users/sign_out {:controller=>"sessions", :action=>"destroy"}
|
||||
#
|
||||
# # Password routes for Recoverable, if User model has :recoverable configured
|
||||
# new_user_password GET /users/password/new(.:format) {:controller=>"passwords", :action=>"new"}
|
||||
# edit_user_password GET /users/password/edit(.:format) {:controller=>"passwords", :action=>"edit"}
|
||||
# user_password PUT /users/password(.:format) {:controller=>"passwords", :action=>"update"}
|
||||
# POST /users/password(.:format) {:controller=>"passwords", :action=>"create"}
|
||||
#
|
||||
# # Confirmation routes for Confirmable, if User model has :confirmable configured
|
||||
# new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"confirmations", :action=>"new"}
|
||||
# user_confirmation GET /users/confirmation(.:format) {:controller=>"confirmations", :action=>"show"}
|
||||
# POST /users/confirmation(.:format) {:controller=>"confirmations", :action=>"create"}
|
||||
#
|
||||
# You can configure your routes with some options:
|
||||
#
|
||||
# * :class_name => setup a different class to be looked up by devise, if it cannot be correctly find by the route name.
|
||||
#
|
||||
# devise_for :users, :class_name => 'Account'
|
||||
#
|
||||
# * :as => allows you to setup path name that will be used, as rails routes does. The following route configuration would setup your route as /accounts instead of /users:
|
||||
#
|
||||
# devise_for :users, :as => 'accounts'
|
||||
#
|
||||
# * :scope => setup the scope name. This is used as the instance variable name in controller, as the name in routes and the scope given to warden. Defaults to the singular of the given name:
|
||||
#
|
||||
# devise_for :users, :scope => :account
|
||||
#
|
||||
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :password and :confirmation.
|
||||
#
|
||||
# devise_for :users, :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification' }
|
||||
#
|
||||
# * :path_prefix => the path prefix to be used in all routes.
|
||||
#
|
||||
# devise_for :users, :path_prefix => "/:locale"
|
||||
#
|
||||
# Any other options will be passed to route definition. If you need conditions for your routes, just map:
|
||||
#
|
||||
# devise_for :users, :conditions => { :subdomain => /.+/ }
|
||||
#
|
||||
# If you are using a dynamic prefix, like :locale above, you need to configure default_url_options through Devise. You can do that in config/initializers/devise.rb or setting a Devise.default_url_options:
|
||||
#
|
||||
# Devise.default_url_options do
|
||||
# { :locale => I18n.locale }
|
||||
# end
|
||||
#
|
||||
def devise_for(*resources)
|
||||
options = resources.extract_options!
|
||||
|
||||
resources.map!(&:to_sym)
|
||||
resources.each do |resource|
|
||||
mapping = Devise::Mapping.new(resource, options.dup)
|
||||
Devise.default_scope ||= mapping.name
|
||||
Devise.mappings[mapping.name] = mapping
|
||||
resources.map!(&:to_sym)
|
||||
resources.each do |resource|
|
||||
mapping = Devise::Mapping.new(resource, options.dup)
|
||||
Devise.default_scope ||= mapping.name
|
||||
Devise.mappings[mapping.name] = mapping
|
||||
|
||||
route_options = mapping.route_options.merge(:path_prefix => mapping.raw_path, :name_prefix => "#{mapping.name}_")
|
||||
mapping.for.each do |mod|
|
||||
send(mod, mapping) if self.respond_to?(mod, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
with_options(route_options) do |routes|
|
||||
mapping.for.each do |mod|
|
||||
send(mod, routes, mapping) if self.respond_to?(mod, true)
|
||||
end
|
||||
end
|
||||
protected
|
||||
|
||||
def authenticatable(mapping)
|
||||
scope(mapping.raw_path) do
|
||||
get mapping.path_names[:sign_in], :to => "sessions#new", :as => :"new_#{mapping.name}_session"
|
||||
post mapping.path_names[:sign_in], :to => "sessions#create", :as => :"#{mapping.name}_session"
|
||||
get mapping.path_names[:sign_out], :to => "sessions#destroy", :as => :"destroy_#{mapping.name}_session"
|
||||
end
|
||||
end
|
||||
|
||||
def recoverable(mapping)
|
||||
scope(mapping.raw_path, :name_prefix => mapping.name) do
|
||||
resource :password, :only => [:new, :create, :edit, :update], :as => mapping.path_names[:password]
|
||||
end
|
||||
end
|
||||
|
||||
def confirmable(mapping)
|
||||
scope(mapping.raw_path, :name_prefix => mapping.name) do
|
||||
resource :confirmation, :only => [:new, :create, :show], :as => mapping.path_names[:confirmation]
|
||||
end
|
||||
end
|
||||
|
||||
def lockable(mapping)
|
||||
scope(mapping.raw_path, :name_prefix => mapping.name) do
|
||||
resource :unlock, :only => [:new, :create, :show], :as => mapping.path_names[:unlock]
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def authenticatable(routes, mapping)
|
||||
routes.with_options(:controller => 'sessions', :name_prefix => nil) do |session|
|
||||
session.send(:"new_#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'new', :conditions => { :method => :get })
|
||||
session.send(:"#{mapping.name}_session", mapping.path_names[:sign_in], :action => 'create', :conditions => { :method => :post })
|
||||
session.send(:"destroy_#{mapping.name}_session", mapping.path_names[:sign_out], :action => 'destroy', :conditions => { :method => :get })
|
||||
end
|
||||
def registerable(mapping)
|
||||
scope(mapping.raw_path, :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
|
||||
|
||||
def confirmable(routes, mapping)
|
||||
routes.resource :confirmation, :only => [:new, :create, :show], :as => mapping.path_names[:confirmation]
|
||||
end
|
||||
|
||||
def lockable(routes, mapping)
|
||||
routes.resource :unlock, :only => [:new, :create, :show], :as => mapping.path_names[:unlock]
|
||||
end
|
||||
|
||||
def recoverable(routes, mapping)
|
||||
routes.resource :password, :only => [:new, :create, :edit, :update], :as => mapping.path_names[:password]
|
||||
end
|
||||
|
||||
def registerable(routes, mapping)
|
||||
routes.resource :registration, :only => [:new, :create, :edit, :update, :destroy], :as => mapping.raw_path[1..-1], :path_prefix => nil, :path_names => { :new => mapping.path_names[:sign_up] }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
0
log/test.log
Normal file
0
log/test.log
Normal file
|
@ -1,7 +1,4 @@
|
|||
gem 'bcrypt-ruby'
|
||||
|
||||
class Encryptors < ActiveSupport::TestCase
|
||||
|
||||
test 'should match a password created by authlogic' do
|
||||
authlogic = "b623c3bc9c775b0eb8edb218a382453396fec4146422853e66ecc4b6bc32d7162ee42074dcb5f180a770dc38b5df15812f09bbf497a4a1b95fe5e7d2b8eb7eb4"
|
||||
encryptor = Devise::Encryptors::AuthlogicSha512.digest('123mudar', 20, 'usZK_z_EAaF61Gwkw-ed', '')
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
||||
require 'test_help'
|
||||
require File.expand_path('../../rails_app/config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
|
||||
ActiveRecord::Migration.verbose = false
|
||||
ActiveRecord::Base.logger = Logger.new(nil)
|
||||
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
||||
|
||||
ActiveRecord::Schema.define(:version => 1) do
|
||||
[:users, :admins, :accounts].each do |table|
|
||||
|
|
|
@ -2,8 +2,8 @@ require 'mongo_mapper'
|
|||
MongoMapper.database = "devise-test-suite"
|
||||
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
||||
|
||||
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
||||
require 'test_help'
|
||||
require File.expand_path('../../rails_app/config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
|
||||
module MongoMapper::Document
|
||||
# TODO This should not be required
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
|
||||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
require 'rake/rdoctask'
|
||||
|
||||
require 'tasks/rails'
|
||||
Rails::Application.load_tasks
|
||||
|
|
|
@ -2,9 +2,5 @@
|
|||
# Likewise, all the methods added will be available for all controllers.
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
helper :all # include all helpers, all the time
|
||||
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
||||
|
||||
# Scrub sensitive parameters from your log
|
||||
filter_parameter_logging :password
|
||||
protect_from_forgery
|
||||
end
|
||||
|
|
31
test/rails_app/config/application.rb
Normal file
31
test/rails_app/config/application.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
DEVISE_ORM = :active_record unless defined? DEVISE_ORM
|
||||
|
||||
require "active_record/railtie" if DEVISE_ORM == :active_record
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "active_resource/railtie"
|
||||
require "rails/test_unit/railtie"
|
||||
|
||||
Bundler.require
|
||||
require "devise"
|
||||
|
||||
module RailsApp
|
||||
class Application < Rails::Application
|
||||
config.root = File.expand_path("../..", __FILE__)
|
||||
|
||||
# Add additional load paths for your own custom dirs
|
||||
config.load_paths += [ "#{config.root}/app/#{DEVISE_ORM}/" ]
|
||||
|
||||
# Configure generators values. Many other options are available, be sure to check the documentation.
|
||||
# config.generators do |g|
|
||||
# g.orm :active_record
|
||||
# g.template_engine :erb
|
||||
# g.test_framework :test_unit, :fixture => true
|
||||
# end
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters << :password
|
||||
end
|
||||
end
|
|
@ -1,110 +1,9 @@
|
|||
# Don't change this file!
|
||||
# Configure your app in config/environment.rb and config/environments/*.rb
|
||||
|
||||
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
||||
|
||||
module Rails
|
||||
class << self
|
||||
def boot!
|
||||
unless booted?
|
||||
preinitialize
|
||||
pick_boot.run
|
||||
end
|
||||
end
|
||||
|
||||
def booted?
|
||||
defined? Rails::Initializer
|
||||
end
|
||||
|
||||
def pick_boot
|
||||
(vendor_rails? ? VendorBoot : GemBoot).new
|
||||
end
|
||||
|
||||
def vendor_rails?
|
||||
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
||||
end
|
||||
|
||||
def preinitialize
|
||||
load(preinitializer_path) if File.exist?(preinitializer_path)
|
||||
end
|
||||
|
||||
def preinitializer_path
|
||||
"#{RAILS_ROOT}/config/preinitializer.rb"
|
||||
end
|
||||
end
|
||||
|
||||
class Boot
|
||||
def run
|
||||
load_initializer
|
||||
Rails::Initializer.run(:set_load_path)
|
||||
end
|
||||
end
|
||||
|
||||
class VendorBoot < Boot
|
||||
def load_initializer
|
||||
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
||||
Rails::Initializer.run(:install_gem_spec_stubs)
|
||||
Rails::GemDependency.add_frozen_gem_path
|
||||
end
|
||||
end
|
||||
|
||||
class GemBoot < Boot
|
||||
def load_initializer
|
||||
self.class.load_rubygems
|
||||
load_rails_gem
|
||||
require 'initializer'
|
||||
end
|
||||
|
||||
def load_rails_gem
|
||||
if version = self.class.gem_version
|
||||
gem 'rails', version
|
||||
else
|
||||
gem 'rails'
|
||||
end
|
||||
rescue Gem::LoadError => load_error
|
||||
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
||||
exit 1
|
||||
end
|
||||
|
||||
class << self
|
||||
def rubygems_version
|
||||
Gem::RubyGemsVersion rescue nil
|
||||
end
|
||||
|
||||
def gem_version
|
||||
if defined? RAILS_GEM_VERSION
|
||||
RAILS_GEM_VERSION
|
||||
elsif ENV.include?('RAILS_GEM_VERSION')
|
||||
ENV['RAILS_GEM_VERSION']
|
||||
else
|
||||
parse_gem_version(read_environment_rb)
|
||||
end
|
||||
end
|
||||
|
||||
def load_rubygems
|
||||
min_version = '1.3.2'
|
||||
require 'rubygems'
|
||||
unless rubygems_version >= min_version
|
||||
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
||||
exit 1
|
||||
end
|
||||
|
||||
rescue LoadError
|
||||
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
||||
exit 1
|
||||
end
|
||||
|
||||
def parse_gem_version(text)
|
||||
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
||||
end
|
||||
|
||||
private
|
||||
def read_environment_rb
|
||||
File.read("#{RAILS_ROOT}/config/environment.rb")
|
||||
end
|
||||
end
|
||||
end
|
||||
begin
|
||||
require File.expand_path("../../../../.bundle/environment", __FILE__)
|
||||
rescue LoadError
|
||||
require 'rubygems'
|
||||
require 'bundler'
|
||||
Bundler.setup
|
||||
end
|
||||
|
||||
# All that for this:
|
||||
Rails.boot!
|
||||
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
|
@ -1,18 +1,16 @@
|
|||
# SQLite version 3.x
|
||||
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
||||
development:
|
||||
adapter: sqlite3
|
||||
database: db/development.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
database: ":memory:"
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
adapter: sqlite3
|
||||
database: db/test.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
database: ":memory:"
|
||||
|
||||
production:
|
||||
adapter: sqlite3
|
||||
database: db/production.sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
||||
database: ":memory:"
|
||||
|
|
|
@ -1,42 +1,5 @@
|
|||
# Be sure to restart your server when you modify this file
|
||||
# Load the rails application
|
||||
require File.expand_path('../application', __FILE__)
|
||||
|
||||
# Specifies gem version of Rails to use when vendor/rails is not present
|
||||
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
|
||||
DEVISE_ORM = :active_record unless defined? DEVISE_ORM
|
||||
|
||||
# Bootstrap the Rails environment, frameworks, and default configuration
|
||||
require File.join(File.dirname(__FILE__), 'boot')
|
||||
|
||||
Rails::Initializer.run do |config|
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
# Add additional load paths for your own custom dirs
|
||||
config.load_paths += [ "#{RAILS_ROOT}/app/#{DEVISE_ORM}/" ]
|
||||
|
||||
# Specify gems that this application depends on and have them installed with rake gems:install
|
||||
# config.gem "bj"
|
||||
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
||||
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
||||
# config.gem "aws-s3", :lib => "aws/s3"
|
||||
|
||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
||||
# :all can be used as a placeholder for all plugins not explicitly named
|
||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# Skip frameworks you're not going to use. To use Rails without a database,
|
||||
# you must remove the Active Record framework.
|
||||
config.frameworks -= [ :active_record ] unless DEVISE_ORM == :active_record
|
||||
|
||||
# Activate observers that should always be running
|
||||
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names.
|
||||
config.time_zone = 'UTC'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
||||
# config.i18n.default_locale = :en
|
||||
end
|
||||
# Initialize the rails application
|
||||
RailsApp::Application.initialize!
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
RailsApp::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the webserver when you make code changes.
|
||||
config.cache_classes = false
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the webserver when you make code changes.
|
||||
config.cache_classes = false
|
||||
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.action_controller.consider_all_requests_local = true
|
||||
config.action_view.debug_rjs = true
|
||||
config.action_controller.perform_caching = false
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_view.debug_rjs = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Don't care if the mailer can't send
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
# Don't care if the mailer can't send
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
end
|
||||
|
|
|
@ -1,28 +1,33 @@
|
|||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
RailsApp::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# The production environment is meant for finished, "live" apps.
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
# The production environment is meant for finished, "live" apps.
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on
|
||||
config.action_controller.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
config.action_view.cache_template_loading = true
|
||||
# Full error reports are disabled and caching is turned on
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
|
||||
# Use a different logger for distributed setups
|
||||
# config.logger = SyslogLogger.new
|
||||
# Use a different logger for distributed setups
|
||||
# config.logger = SyslogLogger.new
|
||||
|
||||
# Use a different cache store in production
|
||||
# config.cache_store = :mem_cache_store
|
||||
# Use a different cache store in production
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Enable serving of images, stylesheets, and javascripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
# Disable Rails's static asset server
|
||||
# In production, Apache or nginx will already do this
|
||||
config.serve_static_assets = false
|
||||
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
# Enable serving of images, stylesheets, and javascripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Enable threaded mode
|
||||
# config.threadsafe!
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable threaded mode
|
||||
# config.threadsafe!
|
||||
end
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
RailsApp::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.action_controller.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
config.action_view.cache_template_loading = true
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Disable request forgery protection in test environment
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
# Disable request forgery protection in test environment
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
||||
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
||||
# like if you have constraints or database-specific column types
|
||||
# config.active_record.schema_format = :sql
|
||||
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
||||
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
||||
# like if you have constraints or database-specific column types
|
||||
# config.active_record.schema_format = :sql
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
Rails.backtrace_cleaner.remove_silencers!
|
|
@ -0,0 +1,7 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
ActionController::Base.cookie_verifier_secret = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
|
|
@ -1,24 +0,0 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# These settings change the behavior of Rails 2 apps and will be defaults
|
||||
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
||||
|
||||
if defined?(ActiveRecord)
|
||||
# Include Active Record class name as root for JSON serialized output.
|
||||
ActiveRecord::Base.include_root_in_json = true
|
||||
|
||||
# Store the full class name (including module namespace) in STI type column.
|
||||
ActiveRecord::Base.store_full_sti_class = true
|
||||
end
|
||||
|
||||
ActionController::Routing.generate_best_match = false
|
||||
|
||||
# Use ISO 8601 format for JSON serialized times and dates.
|
||||
ActiveSupport.use_standard_json_time_format = true
|
||||
|
||||
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
||||
# if you're including raw json in an HTML page.
|
||||
ActiveSupport.escape_html_entities_in_json = false
|
||||
|
||||
# Clean up silencers
|
||||
Rails.backtrace_cleaner.remove_silencers!
|
|
@ -5,8 +5,8 @@
|
|||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
ActionController::Base.session = {
|
||||
:key => '_rails_app_session',
|
||||
:secret => '89e8147901a0d7c221ac130e0ded3eeab6dab4a97127255909f08fedaae371918b41dec9d4d75c5b27a55c3772d43c2b6a3cbac232c5cc2ce4b8ec22242f5e60'
|
||||
:key => '_rails_app_session',
|
||||
:secret => '0c31f123b2bd4424ac366a7976aaa0696f0c82337c4073a5816a3abc6553293ad14f70cf23acb391954a8ce8cf08aaca3fab21e7642aa52ea212aefa19b7439d'
|
||||
}
|
||||
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
ActionController::Routing::Routes.draw do |map|
|
||||
map.devise_for :users
|
||||
map.devise_for :admin, :as => 'admin_area'
|
||||
map.devise_for :accounts, :scope => 'manager', :path_prefix => ':locale',
|
||||
Rails::Application.routes.draw do
|
||||
devise_for :users
|
||||
devise_for :admin, :as => 'admin_area'
|
||||
devise_for :accounts, :scope => 'manager', :path_prefix => ':locale',
|
||||
:class_name => "User", :requirements => { :extra => 'value' }, :path_names => {
|
||||
:sign_in => 'login', :sign_out => 'logout',
|
||||
:password => 'secret', :confirmation => 'verification',
|
||||
:unlock => 'unblock', :sign_up => 'register'
|
||||
}
|
||||
|
||||
map.resources :users, :only => [:index], :member => { :expire => :get }
|
||||
map.resources :admins, :only => :index
|
||||
map.root :controller => :home
|
||||
resources :users, :only => [:index] do
|
||||
get :expire, :on => :member
|
||||
end
|
||||
|
||||
map.connect '/admin_area/password/new', :controller => "passwords", :action => "new"
|
||||
map.admin_root '/admin_area/home', :controller => "admins", :action => "index"
|
||||
resources :admins, :only => [:index]
|
||||
root :to => "home#index"
|
||||
|
||||
map.connect '/sign_in', :controller => "sessions", :action => "new"
|
||||
map.connect ':controller/:action/:id'
|
||||
map.connect ':controller/:action/:id.:format'
|
||||
match '/admin_area/password/new', :to => "passwords#new"
|
||||
match '/admin_area/home', :to => "admins#index", :as => :admin_root
|
||||
|
||||
match '/sign_in', :to => "sessions#new"
|
||||
end
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<title>The page you were looking for doesn't exist (404)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -27,4 +23,4 @@
|
|||
<p>You may have mistyped the address or the page may have moved.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<title>The change you wanted was rejected (422)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -27,4 +23,4 @@
|
|||
<p>Maybe you tried to change something you didn't have access to.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<title>We're sorry, but something went wrong (500)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 4em auto 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
border-right-color: #999;
|
||||
border-bottom-color: #999;
|
||||
}
|
||||
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
|
||||
require 'commands/about'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/console'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/dbconsole'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/destroy'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/generate'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../../config/boot', __FILE__)
|
||||
require 'commands/performance/benchmarker'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../../config/boot', __FILE__)
|
||||
require 'commands/performance/profiler'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/plugin'
|
10
test/rails_app/script/rails
Executable file
10
test/rails_app/script/rails
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
||||
|
||||
ENV_PATH = File.expand_path('../../config/environment', __FILE__)
|
||||
BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
ROOT_PATH = File.expand_path('../..', __FILE__)
|
||||
|
||||
require BOOT_PATH
|
||||
require 'rails/commands'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/runner'
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'commands/server'
|
1
test/rails_app/vendor/plugins/devise
vendored
1
test/rails_app/vendor/plugins/devise
vendored
|
@ -1 +0,0 @@
|
|||
../../../../
|
|
@ -19,19 +19,4 @@ class ActiveSupport::TestCase
|
|||
def assert_email_not_sent(&block)
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') { yield }
|
||||
end
|
||||
|
||||
# Execute the block setting the given values and restoring old values after
|
||||
# the block is executed.
|
||||
def swap(object, new_values)
|
||||
old_values = {}
|
||||
new_values.each do |key, value|
|
||||
old_values[key] = object.send key
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
old_values.each do |key, value|
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,15 +7,13 @@ class ActiveSupport::TestCase
|
|||
|
||||
def store_translations(locale, translations, &block)
|
||||
begin
|
||||
I18n.backend.store_translations locale, translations
|
||||
I18n.backend.store_translations(locale, translations)
|
||||
yield
|
||||
ensure
|
||||
I18n.reload!
|
||||
end
|
||||
end
|
||||
|
||||
# Helpers for creating new users
|
||||
#
|
||||
def generate_unique_email
|
||||
@@email_count ||= 0
|
||||
@@email_count += 1
|
||||
|
@ -36,4 +34,19 @@ class ActiveSupport::TestCase
|
|||
def create_user(attributes={})
|
||||
User.create!(valid_attributes(attributes))
|
||||
end
|
||||
|
||||
# Execute the block setting the given values and restoring old values after
|
||||
# the block is executed.
|
||||
def swap(object, new_values)
|
||||
old_values = {}
|
||||
new_values.each do |key, value|
|
||||
old_values[key] = object.send key
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
old_values.each do |key, value|
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
end
|
||||
end
|
31
test/support/webrat/integrations/rails.rb
Normal file
31
test/support/webrat/integrations/rails.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'webrat/core/elements/field'
|
||||
|
||||
module Webrat
|
||||
Field.class_eval do
|
||||
def parse_rails_request_params(params)
|
||||
Rack::Utils.parse_nested_query(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ActionController #:nodoc:
|
||||
IntegrationTest.class_eval do
|
||||
include Webrat::Methods
|
||||
include Webrat::Matchers
|
||||
|
||||
# The Rails version of within supports passing in a model and Webrat
|
||||
# will apply a scope based on Rails' dom_id for that model.
|
||||
#
|
||||
# Example:
|
||||
# within User.last do
|
||||
# click_link "Delete"
|
||||
# end
|
||||
def within(selector_or_object, &block)
|
||||
if selector_or_object.is_a?(String)
|
||||
super
|
||||
else
|
||||
super('#' + RecordIdentifier.dom_id(selector_or_object), &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +1,10 @@
|
|||
require 'rubygems'
|
||||
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
|
||||
|
||||
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
|
||||
require File.join(File.dirname(__FILE__), 'orm', DEVISE_ORM.to_s)
|
||||
require File.expand_path("../orm/#{DEVISE_ORM}", __FILE__)
|
||||
|
||||
require 'webrat'
|
||||
require 'mocha'
|
||||
|
||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||
require "mocha"
|
||||
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
|
@ -18,4 +13,6 @@ ActionMailer::Base.default_url_options[:host] = 'test.com'
|
|||
Webrat.configure do |config|
|
||||
config.mode = :rails
|
||||
config.open_error_files = false
|
||||
end
|
||||
end
|
||||
|
||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
Loading…
Reference in a new issue