2011-02-11 11:45:35 +00:00
|
|
|
require 'bundler/setup'
|
2009-11-18 23:50:43 +00:00
|
|
|
|
2013-02-27 21:12:37 +00:00
|
|
|
require 'minitest/autorun'
|
2010-06-01 21:37:53 +00:00
|
|
|
|
2010-02-06 19:41:35 +00:00
|
|
|
require 'active_model'
|
2009-11-18 23:50:43 +00:00
|
|
|
require 'action_controller'
|
2010-03-19 12:29:24 +00:00
|
|
|
require 'action_view'
|
2014-03-10 18:18:49 +00:00
|
|
|
ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
|
|
|
|
|
2010-03-19 12:29:24 +00:00
|
|
|
require 'action_view/template'
|
2011-02-11 11:45:35 +00:00
|
|
|
|
2009-11-18 23:50:43 +00:00
|
|
|
require 'action_view/test_case'
|
|
|
|
|
2011-04-27 18:55:03 +00:00
|
|
|
module Rails
|
|
|
|
def self.env
|
|
|
|
ActiveSupport::StringInquirer.new("test")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-07-06 12:07:24 +00:00
|
|
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
|
|
require 'simple_form'
|
2009-12-09 23:18:29 +00:00
|
|
|
|
2012-01-24 18:23:50 +00:00
|
|
|
require "rails/generators/test_case"
|
|
|
|
require 'generators/simple_form/install_generator'
|
|
|
|
|
2012-02-17 00:53:17 +00:00
|
|
|
Dir["#{File.dirname(__FILE__)}/support/*.rb"].each do |file|
|
|
|
|
require file unless file.end_with?('discovery_inputs.rb')
|
|
|
|
end
|
2009-12-08 13:48:31 +00:00
|
|
|
I18n.default_locale = :en
|
2009-11-18 23:50:43 +00:00
|
|
|
|
2012-01-30 18:14:58 +00:00
|
|
|
require 'country_select'
|
2009-12-11 13:53:18 +00:00
|
|
|
|
2014-09-08 20:26:58 +00:00
|
|
|
if defined?(HTMLSelector::NO_STRIP)
|
|
|
|
HTMLSelector::NO_STRIP << "label"
|
|
|
|
else
|
2014-09-08 19:29:23 +00:00
|
|
|
ActionDispatch::Assertions::NO_STRIP << "label"
|
|
|
|
end
|
2012-03-03 17:36:02 +00:00
|
|
|
|
2015-01-04 17:05:23 +00:00
|
|
|
if ActiveSupport::TestCase.respond_to?(:test_order=)
|
|
|
|
ActiveSupport::TestCase.test_order = :random
|
|
|
|
end
|
|
|
|
|
2009-12-08 13:48:31 +00:00
|
|
|
class ActionView::TestCase
|
2009-12-10 01:57:05 +00:00
|
|
|
include MiscHelpers
|
2010-06-07 05:30:58 +00:00
|
|
|
include SimpleForm::ActionViewExtensions::FormHelper
|
2009-11-19 21:26:16 +00:00
|
|
|
|
|
|
|
setup :set_controller
|
2013-06-24 18:41:58 +00:00
|
|
|
setup :setup_users
|
2009-11-19 21:26:16 +00:00
|
|
|
|
|
|
|
def set_controller
|
|
|
|
@controller = MockController.new
|
|
|
|
end
|
|
|
|
|
2013-06-24 18:41:58 +00:00
|
|
|
def setup_users(extra_attributes = {})
|
|
|
|
@user = User.build(extra_attributes)
|
|
|
|
|
|
|
|
@validating_user = ValidatingUser.build({
|
2013-01-28 21:02:59 +00:00
|
|
|
home_picture: 'Home picture',
|
|
|
|
age: 19,
|
|
|
|
amount: 15,
|
|
|
|
attempts: 1,
|
|
|
|
company: [1]
|
2013-06-24 18:41:58 +00:00
|
|
|
}.merge!(extra_attributes))
|
2010-09-05 16:46:02 +00:00
|
|
|
|
2013-06-24 18:41:58 +00:00
|
|
|
@other_validating_user = OtherValidatingUser.build({
|
2013-01-28 21:02:59 +00:00
|
|
|
age: 19,
|
|
|
|
company: 1
|
2013-06-24 18:41:58 +00:00
|
|
|
}.merge!(extra_attributes))
|
2009-12-08 13:48:31 +00:00
|
|
|
end
|
|
|
|
|
2009-11-19 21:26:16 +00:00
|
|
|
def protect_against_forgery?
|
|
|
|
false
|
|
|
|
end
|
2009-12-08 13:48:31 +00:00
|
|
|
|
|
|
|
def user_path(*args)
|
|
|
|
'/users'
|
|
|
|
end
|
2012-11-08 19:57:15 +00:00
|
|
|
|
|
|
|
def company_user_path(*args)
|
|
|
|
'/company/users'
|
|
|
|
end
|
|
|
|
|
2009-12-10 20:03:27 +00:00
|
|
|
alias :users_path :user_path
|
2009-12-08 13:48:31 +00:00
|
|
|
alias :super_user_path :user_path
|
2010-05-14 21:58:36 +00:00
|
|
|
alias :validating_user_path :user_path
|
2011-09-03 10:00:23 +00:00
|
|
|
alias :validating_users_path :user_path
|
2010-09-05 16:46:02 +00:00
|
|
|
alias :other_validating_user_path :user_path
|
2009-11-19 21:26:16 +00:00
|
|
|
end
|