]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/notes_controller_test.rb
Add history changesets layer module
[rails.git] / test / controllers / notes_controller_test.rb
index 71dfa42baefafa63bbfbe42a5b42555fbc3d832b..b672a3a3e2aef4de057ab199adf0bc06f8acb4f0 100644 (file)
@@ -129,12 +129,12 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
     end
 
     sidebar_browse_check :note_path, note_with_hidden_comment.id, "notes/show"
-    assert_select "div.note-comments ul li", :count => 1
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 1
 
     session_for(create(:moderator_user))
 
     sidebar_browse_check :note_path, note_with_hidden_comment.id, "notes/show"
-    assert_select "div.note-comments ul li", :count => 2
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 2
   end
 
   def test_read_note_hidden_user_comment
@@ -144,12 +144,30 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
     end
 
     sidebar_browse_check :note_path, note_with_hidden_user_comment.id, "notes/show"
-    assert_select "div.note-comments ul li", :count => 1
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 1
 
     session_for(create(:moderator_user))
 
     sidebar_browse_check :note_path, note_with_hidden_user_comment.id, "notes/show"
-    assert_select "div.note-comments ul li", :count => 1
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 1
+  end
+
+  def test_read_note_hidden_opener
+    hidden_user = create(:user, :deleted)
+    note_with_hidden_opener = create(:note)
+    create(:note_comment, :author => hidden_user, :note => note_with_hidden_opener)
+
+    sidebar_browse_check :note_path, note_with_hidden_opener.id, "notes/show"
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 0
+  end
+
+  def test_read_note_suspended_opener_and_comment
+    note = create(:note)
+    create(:note_comment, :note => note, :author => create(:user, :suspended))
+    create(:note_comment, :note => note, :event => "commented")
+
+    sidebar_browse_check :note_path, note.id, "notes/show"
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 1
   end
 
   def test_read_closed_note
@@ -157,16 +175,16 @@ class NotesControllerTest < ActionDispatch::IntegrationTest
     closed_note = create(:note_with_comments, :closed, :closed_by => user, :comments_count => 2)
 
     sidebar_browse_check :note_path, closed_note.id, "notes/show"
-    assert_select "div.note-comments ul li", :count => 2
-    assert_select "div.details", /Resolved by #{user.display_name}/
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 2
+    assert_dom "div.details", /Resolved by #{user.display_name}/
 
     user.soft_destroy!
 
     reset!
 
     sidebar_browse_check :note_path, closed_note.id, "notes/show"
-    assert_select "div.note-comments ul li", :count => 1
-    assert_select "div.details", /Resolved by deleted/
+    assert_dom "article:match('id', ?)", /^c\d+$/, :count => 1
+    assert_dom "div.details", /Resolved by deleted/
   end
 
   def test_new_note_anonymous