+ def test_unhidecomment
+ user = create(:user)
+ administrator_user = create(:administrator_user)
+ diary_entry = create(:diary_entry, :user => user)
+ diary_comment = create(:diary_comment, :diary_entry => diary_entry, :visible => false)
+ # Try without logging in
+ post :unhidecomment,
+ :params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }
+ assert_response :forbidden
+ assert_equal false, DiaryComment.find(diary_comment.id).visible
+
+ # Now try as a normal user
+ post :unhidecomment,
+ :params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id },
+ :session => { :user => user }
+ assert_response :redirect
+ assert_redirected_to :controller => :errors, :action => :forbidden
+ assert_equal false, DiaryComment.find(diary_comment.id).visible
+
+ # Finally try as an administrator
+ post :unhidecomment,
+ :params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id },
+ :session => { :user => administrator_user }
+ assert_response :redirect
+ assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
+ assert_equal true, DiaryComment.find(diary_comment.id).visible
+ end
+