1 require "application_system_test_case"
3 class UserMutingTest < ApplicationSystemTestCase
4 # NB: loads helpers to verify mailer-related behaviour e.g. via assert_no_emails
5 include ActionMailer::TestHelper
7 test "users can mute and unmute other users" do
9 other_user = create(:user)
12 visit user_path(other_user)
13 click_on "Mute this User"
14 assert_content "You muted #{other_user.display_name}"
16 visit edit_account_path
17 assert_content "Muted Users"
18 click_on "Muted Users"
19 assert_content "You have muted 1 User"
22 assert_content "You unmuted #{other_user.display_name}"
23 refute_content "Muted Users"
24 assert_current_path edit_account_path
27 test "messages sent by muted users are set `muted` and do not cause notification emails" do
29 muted_user = create(:user)
30 create(:user_mute, :owner => user, :subject => muted_user)
31 sign_in_as(muted_user)
33 visit new_message_path(user)
34 fill_in "Subject", :with => "Hey Hey"
35 fill_in "Body", :with => "some message"
41 message = Message.find_by(:sender => muted_user, :recipient => user)
42 assert_predicate message, :muted?