Files
danbooru/test/functional/moderator/dashboards_controller_test.rb
evazion 9efb374ae5 comments: allow swapping votes.
Allow users to upvote a comment, then downvote it, without raising an
error or having to manually remove the upvote first. The upvote is
automatically removed and replaced by the downvote.

Changes to the /comment_votes API:

* `POST /comment_votes` and `DELETE /comment_votes` now return a comment
  vote instead of a comment.
* The `score` param in `POST /comment_votes` is now 1 or -1, not
  `up` or `down.`
2021-01-21 07:58:50 -06:00

139 lines
3.3 KiB
Ruby

require 'test_helper'
module Moderator
class DashboardsControllerTest < ActionDispatch::IntegrationTest
context "The moderator dashboards controller" do
setup do
travel_to(1.month.ago) do
@user = create(:gold_user)
end
@admin = create(:admin_user)
end
context "show action" do
context "for mod actions" do
setup do
as(@admin) do
@mod_action = create(:mod_action)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for user feedbacks" do
setup do
as(@user) do
@feedback = create(:user_feedback)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for wiki pages" do
setup do
as(@user) do
@wiki_page = create(:wiki_page)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for tags and uploads" do
setup do
as(@user) do
@post = create(:post)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for notes" do
setup do
as(@user) do
@post = create(:post)
@note = create(:note, :post_id => @post.id)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for comments" do
setup do
@users = (0..5).map {create(:user)}
CurrentUser.as(@users[0]) do
@comment = create(:comment)
end
@users.each do |user|
create(:comment_vote, score: -1, comment: @comment, user: user)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for artists" do
setup do
as(@user) do
@artist = create(:artist)
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for flags" do
setup do
as(@user) do
@post = create(:post)
@post.flag!("blah")
end
end
should "render" do
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
context "for appeals" do
should "render" do
@post = create(:post, is_deleted: true)
@appeal = create(:post_appeal, post: @post)
get_auth moderator_dashboard_path, @admin
assert_response :success
end
end
end
end
end
end