- ##
- # test hide comment succes
- def test_hide_comment_success
- comment = changeset_comments(:normal_comment_1)
-
- basic_authorization(users(:moderator_user).email, "test")
-
- assert("!comment.visible") do
- post :hide_comment, :id => comment.id
- end
- assert_response :success
- end
-
- ##
- # test unhide comment fail
- def test_unhide_comment_fail
- # unauthorized
- comment = changeset_comments(:normal_comment_1)
- assert("comment.visible") do
- post :unhide_comment, :id => comment.id
- assert_response :unauthorized
- end
-
- basic_authorization(users(:public_user).email, "test")
-
- # not a moderator
- assert("comment.visible") do
- post :unhide_comment, :id => comment.id
- assert_response :forbidden
- end
-
- basic_authorization(users(:moderator_user).email, "test")
-
- # bad comment id
- post :unhide_comment, :id => 999111
- assert_response :not_found
- end
-
- ##
- # test unhide comment succes
- def test_unhide_comment_success
- comment = changeset_comments(:normal_comment_1)
-
- basic_authorization(users(:moderator_user).email, "test")
-
- assert("!comment.visible") do
- post :unhide_comment, :id => comment.id
- end
- assert_response :success
- end
-
- ##
- # test comments feed
- def test_comments_feed
- get :comments_feed, :format => "rss"
- assert_response :success
- assert_equal "application/rss+xml", @response.content_type
- assert_select "rss", :count => 1 do
- assert_select "channel", :count => 1 do
- assert_select "item", :count => 3
- end
- end
-
- get :comments_feed, :id => changesets(:normal_user_closed_change), :format => "rss"
- assert_response :success
- assert_equal "application/rss+xml", @response.content_type
- assert_select "rss", :count => 1 do
- assert_select "channel", :count => 1 do
- assert_select "item", :count => 3
- end
- end
- end
-
- #------------------------------------------------------------
- # utility functions
- #------------------------------------------------------------