3 class UserMutesControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/user/username/mute", :method => :post },
7 { :controller => "user_mutes", :action => "create", :display_name => "username" }
10 { :path => "/user/username/mute", :method => :delete },
11 { :controller => "user_mutes", :action => "destroy", :display_name => "username" }
14 { :path => "/user_mutes", :method => :get },
15 { :controller => "user_mutes", :action => "index" }
21 muted_user = create(:user)
22 user.mutes.create(:subject => muted_user)
26 assert_match "You have muted 1 User", @response.body
27 assert_dom "tr a[href='#{user_path muted_user}']", :text => muted_user.display_name
34 assert_equal 0, user.muted_users.count
35 subject = create(:user, :display_name => "Bob")
36 post user_mute_path(subject)
37 assert_match "You muted Bob", flash[:notice]
39 assert_equal 1, user.muted_users.count
40 assert_equal subject, user.muted_users.first
42 post user_mute_path(subject)
43 assert_match "Bob could not be muted. Is already muted", flash[:error]
44 assert_equal 1, user.muted_users.count
51 subject = create(:user, :display_name => "Bob")
52 user.mutes.create(:subject => subject)
53 assert_equal 1, user.muted_users.count
55 delete user_mute_path(subject)
56 assert_match "You unmuted Bob", flash[:notice]
57 assert_equal 0, user.muted_users.count
59 delete user_mute_path(subject)
60 assert_response :not_found