fix tests
This commit is contained in:
@@ -244,7 +244,7 @@ GEM
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (4.2.0)
|
||||
newrelic_rpm (5.0.0.342)
|
||||
nio4r (2.3.0)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.8.2)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
nokogiri (1.8.2-x64-mingw32)
|
||||
|
||||
@@ -54,6 +54,6 @@ class BansController < ApplicationController
|
||||
permitted_params = %i[reason duration expires_at]
|
||||
permitted_params += %i[user_id user_name] if context == :create
|
||||
|
||||
params.require(:ban).permit(permitted_params)
|
||||
params.fetch(:ban, {}).permit(permitted_params)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module DelayedJobsHelper
|
||||
def print_name(job)
|
||||
case job.name
|
||||
when "PostKeeperManager.check_and_update"
|
||||
when "PostKeeperManager.check_and_assign"
|
||||
"<strong>update post tagger</strong>"
|
||||
|
||||
when "Tag.increment_post_counts"
|
||||
@@ -71,7 +71,7 @@ module DelayedJobsHelper
|
||||
|
||||
def print_handler(job)
|
||||
case job.name
|
||||
when "PostKeeperManager.check_and_update"
|
||||
when "PostKeeperManager.check_and_assign"
|
||||
""
|
||||
|
||||
when "Tag.increment_post_counts", "Tag.decrement_post_counts"
|
||||
|
||||
@@ -15,6 +15,11 @@ class PostKeeperManager
|
||||
end
|
||||
|
||||
def self.check_and_update(post, updater_id = nil, increment_tags = nil)
|
||||
check_and_assign(post, updater_id, increment_tags)
|
||||
post.update_column(:keeper_data, post.keeper_data)
|
||||
end
|
||||
|
||||
def self.check_and_assign(post, updater_id = nil, increment_tags = nil)
|
||||
post = Post.find(post) unless post.is_a?(Post)
|
||||
keeper_id = check(post, updater_id, increment_tags)
|
||||
post.keeper_data = {uid: keeper_id}
|
||||
|
||||
@@ -255,8 +255,8 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def mark_as_read!
|
||||
update_column(:is_read, true)
|
||||
owner.dmails.unread.count.tap do |unread_count|
|
||||
update_column(:is_read, true)
|
||||
owner.update(has_mail: (unread_count > 0), unread_dmail_count: unread_count)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -564,7 +564,7 @@ class Post < ApplicationRecord
|
||||
|
||||
if PostKeeperManager.enabled? && persisted?
|
||||
# no need to do this check on the initial create
|
||||
PostKeeperManager.check_and_update(self, CurrentUser.id, increment_tags)
|
||||
PostKeeperManager.check_and_assign(self, CurrentUser.id, increment_tags)
|
||||
|
||||
# run this again async to check for race conditions
|
||||
PostKeeperManager.queue_check(self, CurrentUser.id)
|
||||
|
||||
@@ -44,6 +44,7 @@ class PoolElementsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "do nothing if the post is not a member of the pool" do
|
||||
@pool.reload
|
||||
as_user do
|
||||
@pool.remove!(@post)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
||||
class PostKeeperManagerTest < ActiveSupport::TestCase
|
||||
subject { PostKeeperManager }
|
||||
|
||||
context "#check_and_update" do
|
||||
context "#check_and_assign" do
|
||||
setup do
|
||||
Timecop.travel(1.month.ago) do
|
||||
@alice = FactoryBot.create(:user)
|
||||
@@ -17,19 +17,21 @@ class PostKeeperManagerTest < ActiveSupport::TestCase
|
||||
end
|
||||
CurrentUser.scoped(@bob) do
|
||||
Timecop.travel(2.hours.from_now) do
|
||||
@post.update_attributes(tag_string: "aaa bbb ccc")
|
||||
@post.reload
|
||||
@post.update(tag_string: "aaa bbb ccc")
|
||||
end
|
||||
end
|
||||
CurrentUser.scoped(@carol) do
|
||||
Timecop.travel(4.hours.from_now) do
|
||||
@post.update_attributes(tag_string: "ccc ddd eee fff ggg")
|
||||
@post.reload
|
||||
@post.update(tag_string: "ccc ddd eee fff ggg")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
should "update the post" do
|
||||
subject.check_and_update(@post.id)
|
||||
@post.reload
|
||||
assert_equal(3, @post.versions.count)
|
||||
subject.check_and_assign(@post)
|
||||
assert_equal({"uid" => @carol.id}, @post.keeper_data)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -191,7 +191,7 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
|
||||
context "when finding deviantart artists" do
|
||||
setup do
|
||||
skip "deviant art is not configured" unless Danbooru.config.deviantart_client_id.present?
|
||||
skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present?
|
||||
FactoryBot.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/")
|
||||
FactoryBot.create(:artist, :name => "trixia", :url_string => "http://trixdraws.deviantart.com/")
|
||||
end
|
||||
|
||||
@@ -4,6 +4,8 @@ module Downloads
|
||||
class DeviantArtTest < ActiveSupport::TestCase
|
||||
context "a download for a deviant art html page" do
|
||||
setup do
|
||||
skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present?
|
||||
|
||||
@source = "http://starbitt.deviantart.com/art/09271X-636962118"
|
||||
@download = Downloads::File.new(@source)
|
||||
@tempfile = @download.download!
|
||||
|
||||
@@ -11,6 +11,7 @@ module Moderator
|
||||
@comment = FactoryBot.create(:comment)
|
||||
PoolArchive.stubs(:enabled?).returns(false)
|
||||
PostArchive.stubs(:enabled?).returns(false)
|
||||
@user.reload
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
||||
@@ -73,19 +73,24 @@ class PoolTest < ActiveSupport::TestCase
|
||||
@p3 = FactoryBot.create(:post)
|
||||
CurrentUser.scoped(@user, "1.2.3.4") do
|
||||
@pool.add!(@p1)
|
||||
@pool.reload
|
||||
end
|
||||
CurrentUser.scoped(@user, "1.2.3.5") do
|
||||
@pool.add!(@p2)
|
||||
@pool.reload
|
||||
end
|
||||
CurrentUser.scoped(@user, "1.2.3.6") do
|
||||
@pool.add!(@p3)
|
||||
@pool.reload
|
||||
end
|
||||
CurrentUser.scoped(@user, "1.2.3.7") do
|
||||
@pool.remove!(@p1)
|
||||
@pool.reload
|
||||
end
|
||||
CurrentUser.scoped(@user, "1.2.3.8") do
|
||||
version = @pool.versions[1]
|
||||
@pool.revert_to!(version)
|
||||
@pool.reload
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,6 +2,11 @@ require 'test_helper'
|
||||
|
||||
module Sources
|
||||
class DeviantArtTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present?
|
||||
end
|
||||
|
||||
context "The source for a private DeviantArt image URL" do
|
||||
setup do
|
||||
@site = Sources::Site.new("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png")
|
||||
|
||||
Reference in New Issue
Block a user