OSDN Git Service

add Redmine trunk rev 3089
[redminele/redminele.git] / redmine / vendor / plugins / engines / test / lib / engines_test_helper.rb
1 module TestHelper
2   def self.report_location(path)
3     [RAILS_ROOT + '/', 'vendor/plugins/'].each { |part| path.sub! part, ''}
4     path = path.split('/')
5     location, subject = path.first, path.last
6     if subject.sub! '.rb', ''
7       subject = subject.classify
8     else 
9       subject.sub! '.html.erb', ''
10     end
11     "#{subject} (from #{location})"
12   end
13   
14   def self.view_path_for path
15     [RAILS_ROOT + '/', 'vendor/plugins/', '.html.erb'].each { |part| path.sub! part, ''}
16     parts = path.split('/')
17     parts[(parts.index('views')+1)..-1].join('/')
18   end
19 end
20
21 class Test::Unit::TestCase
22   # Add more helper methods to be used by all tests here...  
23   def get_action_on_controller(*args)
24     action = args.shift
25     with_controller *args
26     get action
27   end
28   
29   def with_controller(controller, namespace = nil)
30     classname = controller.to_s.classify + 'Controller'
31     classname = namespace.to_s.classify + '::' + classname unless namespace.nil?
32     @controller = classname.constantize.new
33   end
34   
35   def assert_response_body(expected)
36     assert_equal expected, @response.body
37   end
38 end
39
40 # Because we're testing this behaviour, we actually want these features on!
41 Engines.disable_application_view_loading = false
42 Engines.disable_application_code_loading = false