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

62 lines
1.1 KiB
Ruby
Raw Normal View History

2009-11-18 12:45:35 -05:00
require 'rubygems'
2009-11-18 18:50:43 -05:00
require 'test/unit'
require 'action_controller'
require 'action_view/test_case'
2009-12-09 18:18:29 -05:00
begin
require 'ruby-debug'
rescue LoadError
end
2009-12-09 15:09:00 -05:00
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib', 'simple_form')
require 'simple_form'
2009-11-18 18:50:43 -05:00
2009-12-09 15:09:00 -05:00
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
2009-12-08 08:48:31 -05:00
I18n.default_locale = :en
2009-11-18 18:50:43 -05:00
2009-12-10 08:01:44 -05:00
class SimpleForm::FormBuilder
attr_accessor :attribute, :column, :input_type, :options
2009-12-10 08:01:44 -05:00
end
2009-12-08 08:48:31 -05:00
class ActionView::TestCase
include MiscHelpers
2009-11-19 16:26:16 -05:00
2009-12-09 15:25:12 -05:00
tests SimpleForm::ActionViewExtensions::FormHelper
2009-11-19 16:26:16 -05:00
setup :set_controller
setup :set_response
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
def set_response
@response = MockResponse.new(self)
end
2009-12-09 21:22:53 -05:00
def setup_new_user(options={})
@user = User.new({
:id => 1,
2009-12-08 08:48:31 -05:00
:name => 'New in Simple Form!',
:description => 'Hello!',
:created_at => Time.now
2009-12-09 21:22:53 -05:00
}.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 params
@params ||= {}
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
2009-11-19 16:26:16 -05:00
end