1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00
heartcombo--simple_form/test/test_helper.rb

81 lines
1.7 KiB
Ruby
Raw Normal View History

2011-02-11 06:45:35 -05:00
require 'bundler/setup'
2009-11-18 18:50:43 -05:00
2013-02-27 16:12:37 -05:00
require 'minitest/autorun'
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'
ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
2010-03-19 08:29:24 -04:00
require 'action_view/template'
2011-02-11 06:45:35 -05:00
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
require "rails/generators/test_case"
require 'generators/simple_form/install_generator'
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
require 'country_select'
ActionDispatch::Assertions::NO_STRIP << "label"
2009-12-08 08:48:31 -05:00
class ActionView::TestCase
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
2013-06-24 14:41:58 -04:00
setup :setup_users
2009-11-19 16:26:16 -05:00
def set_controller
@controller = MockController.new
end
2013-06-24 14:41:58 -04:00
def setup_users(extra_attributes = {})
@user = User.build(extra_attributes)
@validating_user = ValidatingUser.build({
2013-01-28 16:02:59 -05:00
home_picture: 'Home picture',
age: 19,
amount: 15,
attempts: 1,
company: [1]
2013-06-24 14:41:58 -04:00
}.merge!(extra_attributes))
2010-09-05 12:46:02 -04:00
2013-06-24 14:41:58 -04:00
@other_validating_user = OtherValidatingUser.build({
2013-01-28 16:02:59 -05:00
age: 19,
company: 1
2013-06-24 14:41:58 -04:00
}.merge!(extra_attributes))
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
def company_user_path(*args)
'/company/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
alias :validating_user_path :user_path
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