1 require "application_system_test_case"
 
   3 class NoteCommentsTest < ApplicationSystemTestCase
 
   4   test "open note has login notice" do
 
   5     note = create(:note_with_comments)
 
   9       assert_no_button "Resolve"
 
  10       assert_no_button "Comment"
 
  11       assert_link "Log in to comment on this note", :href => login_path(:referer => note_path(note))
 
  15   test "closed note has no login notice" do
 
  16     note = create(:note_with_comments, :closed)
 
  20       assert_no_button "Reactivate"
 
  21       assert_no_link "Log in to comment on this note"
 
  25   test "can add comment" do
 
  26     note = create(:note_with_comments)
 
  32       assert_no_content "Comment from #{user.display_name}"
 
  33       assert_no_content "Some newly added note comment"
 
  34       assert_button "Resolve"
 
  35       assert_button "Comment", :disabled => true
 
  37       fill_in "text", :with => "Some newly added note comment"
 
  39       assert_button "Comment & Resolve"
 
  40       assert_button "Comment", :disabled => false
 
  44       assert_content "Comment from #{user.display_name}"
 
  45       assert_content "Some newly added note comment"
 
  49   test "can't add a comment when blocked" do
 
  50     note = create(:note_with_comments)
 
  54     block = create(:user_block, :user => user)
 
  57       fill_in "text", :with => "Comment that won't be added while blocked"
 
  59       assert_no_text "Comment from #{user.display_name}"
 
  60       assert_no_text "Comment that won't be added while blocked"
 
  61       assert_no_text "Your access to the API has been blocked"
 
  62       assert_button "Comment & Resolve", :disabled => false
 
  63       assert_button "Comment", :disabled => false
 
  67       assert_no_text "Comment from #{user.display_name}"
 
  68       assert_no_text "Comment that won't be added while blocked"
 
  69       assert_text "Your access to the API has been blocked"
 
  70       assert_button "Comment & Resolve", :disabled => false
 
  71       assert_button "Comment", :disabled => false
 
  73       block.revoke! block.creator
 
  77       assert_text "Comment from #{user.display_name}"
 
  78       assert_text "Comment that won't be added while blocked"
 
  79       assert_no_text "Your access to the API has been blocked"
 
  83   test "no subscribe button when not logged in" do
 
  84     note = create(:note_with_comments)
 
  88       assert_no_button "Subscribe"
 
  89       assert_no_button "Unsubscribe"
 
  93   test "can subscribe" do
 
  94     note = create(:note_with_comments)
 
 100       assert_button "Subscribe"
 
 101       assert_no_button "Unsubscribe"
 
 105       assert_no_button "Subscribe"
 
 106       assert_button "Unsubscribe"
 
 110   test "can unsubscribe" do
 
 111     note = create(:note_with_comments)
 
 113     create(:note_subscription, :note => note, :user => user)
 
 115     visit note_path(note)
 
 118       assert_no_button "Subscribe"
 
 119       assert_button "Unsubscribe"
 
 121       click_on "Unsubscribe"
 
 123       assert_button "Subscribe"
 
 124       assert_no_button "Unsubscribe"