]> git.openstreetmap.org Git - rails.git/blob - test/system/issues_test.rb
9eb2fbbcb27925d047674fe55395dba573474b2f
[rails.git] / test / system / issues_test.rb
1 require "application_system_test_case"
2
3 class IssuesTest < ApplicationSystemTestCase
4   def test_view_issues_normal_user
5     sign_in_as(create(:user))
6
7     visit issues_path
8     assert page.has_content?(I18n.t("application.require_admin.not_an_admin"))
9   end
10
11   def test_view_no_issues
12     sign_in_as(create(:moderator_user))
13
14     visit issues_path
15     assert page.has_content?(I18n.t(".issues.index.search.issues_not_found"))
16   end
17
18   def test_view_issues
19     sign_in_as(create(:moderator_user))
20     issues = create_list(:issue, 3, :issue_type => "moderator")
21
22     visit issues_path
23     assert page.has_content?(issues.first.reported_user.display_name)
24   end
25
26   def test_search_issues_by_user
27     good_user = create(:user)
28     bad_user = create(:user)
29     create(:issue, :reportable => bad_user, :reported_user => bad_user, :issue_type => "administrator")
30
31     sign_in_as(create(:administrator_user))
32
33     # No issues against the user
34     visit issues_path
35     fill_in "search_by_user", :with => good_user.display_name
36     click_on "Search"
37     assert page.has_content?(I18n.t(".issues.index.search.issues_not_found"))
38
39     # User doesn't exist
40     visit issues_path
41     fill_in "search_by_user", :with => "Nonexistant User"
42     click_on "Search"
43     assert page.has_content?(I18n.t(".issues.index.search.user_not_found"))
44
45     # Find Issue against bad_user
46     visit issues_path
47     fill_in "search_by_user", :with => bad_user.display_name
48     click_on "Search"
49     assert !page.has_content?(I18n.t(".issues.index.search.issues_not_found"))
50   end
51
52   def test_commenting
53     issue = create(:issue)
54     sign_in_as(create(:moderator_user))
55
56     visit issue_path(issue)
57
58     fill_in :issue_comment_body, :with => "test comment"
59     click_on "Submit"
60     assert page.has_content?(I18n.t(".issues.comment.comment_created"))
61     assert page.has_content?("test comment")
62
63     issue.reload
64     assert_equal issue.comments.first.body, "test comment"
65   end
66 end