1 require "application_system_test_case"
3 class ChangesetCommentsTest < ApplicationSystemTestCase
4 test "open changeset has a still open notice" do
5 changeset = create(:changeset)
6 sign_in_as(create(:user))
7 visit changeset_path(changeset)
10 assert_no_button "Comment"
11 assert_text "Changeset still open"
15 test "changeset has a login notice" do
16 changeset = create(:changeset, :closed)
17 visit changeset_path(changeset)
20 assert_no_button "Subscribe"
21 assert_no_button "Comment"
22 assert_link "Log in to join the discussion", :href => login_path(:referer => changeset_path(changeset))
26 test "can add a comment to a changeset" do
27 changeset = create(:changeset, :closed)
30 visit changeset_path(changeset)
33 assert_no_content "Comment from #{user.display_name}"
34 assert_no_content "Some newly added changeset comment"
35 assert_button "Comment", :disabled => true
37 fill_in "text", :with => "Some newly added changeset comment"
39 assert_button "Comment", :disabled => false
43 assert_content "Comment from #{user.display_name}"
44 assert_content "Some newly added changeset comment"
48 test "regular users can't hide comments" do
49 changeset = create(:changeset, :closed)
50 create(:changeset_comment, :changeset => changeset, :body => "Unwanted comment")
51 sign_in_as(create(:user))
52 visit changeset_path(changeset)
55 assert_text "Unwanted comment"
56 assert_no_button "hide"
60 test "moderators can hide comments" do
61 changeset = create(:changeset, :closed)
62 create(:changeset_comment, :changeset => changeset, :body => "Unwanted comment")
64 visit changeset_path(changeset)
67 assert_text "Unwanted comment"
70 sign_in_as(create(:moderator_user))
71 visit changeset_path(changeset)
74 assert_text "Unwanted comment"
75 assert_button "hide", :exact => true
76 assert_no_button "unhide", :exact => true
78 click_on "hide", :exact => true
80 assert_text "Unwanted comment"
81 assert_no_button "hide", :exact => true
82 assert_button "unhide", :exact => true
86 visit changeset_path(changeset)
89 assert_no_text "Unwanted comment"
93 test "moderators can unhide comments" do
94 changeset = create(:changeset, :closed)
95 create(:changeset_comment, :changeset => changeset, :body => "Wanted comment", :visible => false)
97 visit changeset_path(changeset)
100 assert_no_text "Wanted comment"
103 sign_in_as(create(:moderator_user))
104 visit changeset_path(changeset)
107 assert_text "Wanted comment"
108 assert_no_button "hide", :exact => true
109 assert_button "unhide", :exact => true
111 click_on "unhide", :exact => true
113 assert_text "Wanted comment"
114 assert_button "hide", :exact => true
115 assert_no_button "unhide", :exact => true
119 visit changeset_path(changeset)
122 assert_text "Wanted comment"