diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index b60438b68..d183c687e 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -21,7 +21,8 @@ class TagsController < ApplicationController @tags = Tag.names_matches_with_aliases(params[:search][:name_matches]) end - respond_with(@tags, root: "tags") + # XXX + respond_with(@tags.map(&:attributes)) end def show diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 0307da882..9736022e6 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -235,6 +235,7 @@ class ApplicationRecord < ActiveRecord::Base end def serializable_hash(options = {}) + options ||= {} options[:only] ||= [] options[:include] ||= [] options[:methods] ||= [] diff --git a/test/functional/comment_votes_controller_test.rb b/test/functional/comment_votes_controller_test.rb index abad8c93d..3f7b4ef33 100644 --- a/test/functional/comment_votes_controller_test.rb +++ b/test/functional/comment_votes_controller_test.rb @@ -17,12 +17,11 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest context "#create.json" do should "create a vote" do assert_difference("CommentVote.count", 1) do - post_auth comment_votes_path(comment_id: @comment.id, score: "down", format: "json"), @user + post_auth comment_votes_path(comment_id: @comment.id, score: "down"), @user, as: :json assert_response :success - comment = JSON.parse(@response.body) - assert_equal(@comment.id, comment["id"]) - assert_equal(-1, comment["score"]) + assert_equal(@comment.id, response.parsed_body["id"]) + assert_equal(-1, response.parsed_body["score"]) end end diff --git a/test/functional/forum_topics_controller_test.rb b/test/functional/forum_topics_controller_test.rb index c448ec7c9..c6e33cfec 100644 --- a/test/functional/forum_topics_controller_test.rb +++ b/test/functional/forum_topics_controller_test.rb @@ -21,7 +21,7 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest should "not allow users to see the topic" do get_auth forum_topic_path(@forum_topic), @user - assert_redirected_to forum_topics_path + assert_response 403 end should "not bump the forum for users without access" do diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 07155057e..92f081f66 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -87,7 +87,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest get_auth profile_path, @user, as: :json assert_response :success - assert_equal(@user.upload_limit, response.parsed_body["upload_limit"]) + assert_equal(@user.comment_count, response.parsed_body["comment_count"]) end should "redirect anonymous users to the sign in page" do diff --git a/test/models/upload_service_test.rb b/test/models/upload_service_test.rb index 97fcc0e64..7625d9c40 100644 --- a/test/models/upload_service_test.rb +++ b/test/models/upload_service_test.rb @@ -875,6 +875,7 @@ class UploadServiceTest < ActiveSupport::TestCase should "not delete the original files" do begin skip unless PixivUgoiraConverter.enabled? + @post.unstub(:queue_delete_files) # this is called thrice to delete the file for 62247364 FileUtils.expects(:rm_f).times(3) @@ -891,9 +892,9 @@ class UploadServiceTest < ActiveSupport::TestCase assert_nothing_raised { @post.file(:original) } assert_nothing_raised { @post.file(:preview) } - travel_to((PostReplacement::DELETION_GRACE_PERIOD + 1).days.from_now) do - perform_enqueued_jobs - end + assert_enqueued_jobs 3, only: DeletePostFilesJob + travel PostReplacement::DELETION_GRACE_PERIOD + 1.day + assert_raise(Post::DeletionError) { perform_enqueued_jobs } assert_nothing_raised { @post.file(:original) } assert_nothing_raised { @post.file(:preview) }