2009-11-18 12:45:35 -05:00
|
|
|
require 'rubygems'
|
2011-02-11 06:45:35 -05:00
|
|
|
require 'bundler/setup'
|
2009-11-18 18:50:43 -05:00
|
|
|
|
2010-07-06 08:07:24 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require 'mocha'
|
2010-06-01 17:37:53 -04:00
|
|
|
|
2010-02-06 14:41:35 -05:00
|
|
|
require 'active_model'
|
2009-11-18 18:50:43 -05:00
|
|
|
require 'action_controller'
|
2010-03-19 08:29:24 -04:00
|
|
|
require 'action_view'
|
|
|
|
require 'action_view/template'
|
2011-02-11 06:45:35 -05:00
|
|
|
|
|
|
|
# Rails 3.0.4 is missing this "deprecation" require.
|
|
|
|
require 'active_support/core_ext/module/deprecation'
|
2009-11-18 18:50:43 -05:00
|
|
|
require 'action_view/test_case'
|
|
|
|
|
2011-04-27 14:55:03 -04:00
|
|
|
module Rails
|
|
|
|
def self.env
|
|
|
|
ActiveSupport::StringInquirer.new("test")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-07-06 08:07:24 -04:00
|
|
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
|
|
require 'simple_form'
|
2009-12-09 18:18:29 -05:00
|
|
|
|
2012-01-24 13:23:50 -05:00
|
|
|
require "rails/generators/test_case"
|
|
|
|
require 'generators/simple_form/install_generator'
|
|
|
|
|
2012-02-16 19:53:17 -05:00
|
|
|
Dir["#{File.dirname(__FILE__)}/support/*.rb"].each do |file|
|
|
|
|
require file unless file.end_with?('discovery_inputs.rb')
|
|
|
|
end
|
2009-12-08 08:48:31 -05:00
|
|
|
I18n.default_locale = :en
|
2009-11-18 18:50:43 -05:00
|
|
|
|
2012-01-30 13:14:58 -05:00
|
|
|
require 'country_select'
|
2009-12-11 08:53:18 -05:00
|
|
|
|
2012-03-03 12:36:02 -05:00
|
|
|
ActionDispatch::Assertions::NO_STRIP << "label"
|
|
|
|
|
2009-12-08 08:48:31 -05:00
|
|
|
class ActionView::TestCase
|
2009-12-09 20:57:05 -05:00
|
|
|
include MiscHelpers
|
2010-06-07 01:30:58 -04:00
|
|
|
include SimpleForm::ActionViewExtensions::FormHelper
|
2009-11-19 16:26:16 -05:00
|
|
|
|
|
|
|
setup :set_controller
|
2009-12-08 08:48:31 -05:00
|
|
|
setup :setup_new_user
|
2009-11-19 16:26:16 -05:00
|
|
|
|
|
|
|
def set_controller
|
|
|
|
@controller = MockController.new
|
|
|
|
end
|
|
|
|
|
2009-12-09 21:22:53 -05:00
|
|
|
def setup_new_user(options={})
|
|
|
|
@user = User.new({
|
|
|
|
:id => 1,
|
2012-02-17 16:31:36 -05:00
|
|
|
:name => 'New in SimpleForm!',
|
2009-12-08 08:48:31 -05:00
|
|
|
:description => 'Hello!',
|
2011-03-25 09:25:09 -04:00
|
|
|
:created_at => Time.now
|
2009-12-09 21:22:53 -05:00
|
|
|
}.merge(options))
|
2010-06-17 18:12:36 -04:00
|
|
|
|
2010-05-14 17:58:36 -04:00
|
|
|
@validating_user = ValidatingUser.new({
|
|
|
|
:id => 1,
|
2012-02-17 16:31:36 -05:00
|
|
|
:name => 'New in SimpleForm!',
|
2010-05-14 17:58:36 -04:00
|
|
|
:description => 'Hello!',
|
2012-01-03 13:10:50 -05:00
|
|
|
:home_picture => 'Home picture',
|
2010-08-06 13:52:19 -04:00
|
|
|
:created_at => Time.now,
|
2010-09-05 11:19:45 -04:00
|
|
|
:age => 19,
|
2011-03-10 21:54:59 -05:00
|
|
|
:amount => 15,
|
2011-03-11 23:12:01 -05:00
|
|
|
:attempts => 1,
|
2011-04-29 15:23:42 -04:00
|
|
|
:company => [1]
|
2010-05-14 17:58:36 -04:00
|
|
|
}.merge(options))
|
2010-09-05 12:46:02 -04:00
|
|
|
|
|
|
|
@other_validating_user = OtherValidatingUser.new({
|
|
|
|
:id => 1,
|
2012-02-17 16:31:36 -05:00
|
|
|
:name => 'New in SimpleForm!',
|
2010-09-05 12:46:02 -04:00
|
|
|
:description => 'Hello!',
|
|
|
|
:created_at => Time.now,
|
|
|
|
:age => 19,
|
|
|
|
:company => 1
|
|
|
|
}.merge(options))
|
2009-12-08 08:48:31 -05:00
|
|
|
end
|
|
|
|
|
2009-11-19 16:26:16 -05:00
|
|
|
def protect_against_forgery?
|
|
|
|
false
|
|
|
|
end
|
2009-12-08 08:48:31 -05:00
|
|
|
|
|
|
|
def user_path(*args)
|
|
|
|
'/users'
|
|
|
|
end
|
2009-12-10 15:03:27 -05:00
|
|
|
alias :users_path :user_path
|
2009-12-08 08:48:31 -05:00
|
|
|
alias :super_user_path :user_path
|
2010-05-14 17:58:36 -04:00
|
|
|
alias :validating_user_path :user_path
|
2011-09-03 06:00:23 -04:00
|
|
|
alias :validating_users_path :user_path
|
2010-09-05 12:46:02 -04:00
|
|
|
alias :other_validating_user_path :user_path
|
2009-11-19 16:26:16 -05:00
|
|
|
end
|