]> git.openstreetmap.org Git - rails.git/blob - test/controllers/issue_comments_controller_test.rb
Merge pull request #5932 from tomhughes/frozen-strings
[rails.git] / test / controllers / issue_comments_controller_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class IssueCommentsControllerTest < ActionDispatch::IntegrationTest
6   def test_comment_by_normal_user
7     issue = create(:issue)
8
9     # Login as normal user
10     session_for(create(:user))
11
12     post issue_comments_path(:issue_id => issue)
13     assert_redirected_to :controller => :errors, :action => :forbidden
14     assert_equal 0, issue.comments.length
15   end
16
17   def test_comment
18     issue = create(:issue)
19
20     # Login as administrator
21     session_for(create(:administrator_user))
22
23     post issue_comments_path(:issue_id => issue, :issue_comment => { :body => "test comment" })
24     assert_redirected_to issue
25     assert_equal 1, issue.comments.length
26   end
27 end