| Class | CommentsControllerTest |
| In: |
test/functional/comments_controller_test.rb
|
| Parent: | Test::Unit::TestCase |
# File test/functional/comments_controller_test.rb, line 24
24: def setup
25: logger.debug "Test Case: #{name}"
26: @controller = CommentsController.new
27: @request = ActionController::TestRequest.new
28: @response = ActionController::TestResponse.new
29: @wiki = create_templates
30: @andy, @george, @tony = users(:andy), users(:george), users(:tony) # admin, cadmin, user
31: end
# File test/functional/comments_controller_test.rb, line 33
33: def teardown
34: [ENV['EPFWIKI_SITES_PATH'], ENV['EPFWIKI_WIKIS_PATH']].each do |p|
35: FileUtils.rm_r(p) if File.exists?(p)
36: File.makedirs(p)
37: end
38: end
Shows:
# File test/functional/comments_controller_test.rb, line 43
43: def test_edit_update_destroy
44: # 1
45: p = WikiPage.find_by_presentation_name('Toolmentor Template')
46: c = Comment.create(:text => 'Text of comment by user tony', :user => @tony, :version => p.current_version, :page => p, :site => p.site)
47: get :edit, :id => c.id
48: assert_response :success
49: session['user'] = @andy
50: get :edit, :id => c.id
51: assert_response :success
52: assert_match 'Text of comment by user tony', @response.body
53: # 2
54: post :destroy
55: assert_unot_cadmin_message
56: post :update
57: assert_unot_cadmin_message
58: session['user'] = @george
59: post :destroy, :id => c.id
60: assert_redirected_to :controller => 'sites', :action => 'comments', :id => p.site.id
61: # TODO test update
62: end