fix tests, avatar job enqueues user page job
This commit is contained in:
@@ -26,7 +26,8 @@ class Domain::Fa::Job::UserAvatarJob < Domain::Fa::Job::Base
|
||||
user: @user,
|
||||
caused_by_entry: @caused_by_entry,
|
||||
})
|
||||
raise("no user page log entry found, enqueued user page scan")
|
||||
logger.error("no user page log entry found, enqueued user page scan")
|
||||
return
|
||||
end
|
||||
@caused_by_entry ||= log_entry
|
||||
parser = Domain::Fa::Parser::Page.new(log_entry.response.contents, require_logged_in: false)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class VpnOnlyRouteConstraint
|
||||
def matches?(request)
|
||||
return false if request.params[:force_vpn_off]
|
||||
return true if Rails.env.test?
|
||||
if Rails.env.development?
|
||||
request.ip == "127.0.0.1" || request.ip == "::1"
|
||||
else
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
class BlobEntry < ReduxApplicationRecord
|
||||
include ImmutableModel
|
||||
before_destroy { raise ActiveRecord::ReadOnlyRecord }
|
||||
|
||||
self.primary_key = :sha256
|
||||
EMPTY_FILE_SHA256 = HexUtil.hex2bin("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
||||
|
||||
|
||||
@@ -212,7 +212,10 @@ class Domain::Fa::Post < ReduxApplicationRecord
|
||||
::Domain::Fa::User.find_or_build_from_legacy(legacy_post.creator)
|
||||
elsif legacy_post.creator_name
|
||||
::Domain::Fa::User.find_by(url_name: ::Domain::Fa::User.name_to_url_name(legacy_post.creator_name)) ||
|
||||
::Domain::Fa::User.new(name: legacy_post.creator_name)
|
||||
::Domain::Fa::User.new({
|
||||
name: legacy_post.creator_name,
|
||||
url_name: ::Domain::Fa::User.name_to_url_name(legacy_post.creator_name),
|
||||
})
|
||||
else
|
||||
# post may have not been scanned or is marked as deleted
|
||||
nil
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class HttpLogEntry < ReduxApplicationRecord
|
||||
include ImmutableModel
|
||||
before_destroy { raise ActiveRecord::ReadOnlyRecord }
|
||||
|
||||
enum verb: %i[get post], _prefix: true
|
||||
enum performed_by: %i[
|
||||
|
||||
@@ -66,13 +66,11 @@ describe Domain::Fa::Job::UserAvatarJob do
|
||||
context "the user has not been page scanned yet" do
|
||||
it "enqueues a user page scan job" do
|
||||
ret = described_class.perform_now({ user: user })
|
||||
expect(ret).to be_a(Exception)
|
||||
expect(ret.message).to match(/no user page log entry/)
|
||||
expect(user.avatar.file_uri).to eq(nil)
|
||||
expect(SpecUtil.enqueued_jobs(Domain::Fa::Job::UserPageJob)).to match([
|
||||
including(args: [{
|
||||
user: user,
|
||||
caused_by_entry: "nil",
|
||||
caused_by_entry: nil,
|
||||
}]),
|
||||
])
|
||||
end
|
||||
|
||||
@@ -29,12 +29,7 @@ class Domain::E621::PostTest < ActiveSupport::TestCase
|
||||
post.reload
|
||||
check_update.call
|
||||
|
||||
# should not be able to violate FK constraint on versions table
|
||||
# in the future this may be relaxed with a cascade deletion
|
||||
# maybe implement soft-deletion for rows?
|
||||
assert_raises ActiveRecord::InvalidForeignKey do
|
||||
post.destroy
|
||||
end
|
||||
assert post.persisted?
|
||||
post.destroy
|
||||
assert post.destroyed?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,8 +50,10 @@ module TestUtil
|
||||
end
|
||||
|
||||
def self.build_fa_user
|
||||
str = random_string(8)
|
||||
user = ::Domain::Fa::User.new({
|
||||
name: "Test-User-#{random_string(8)}",
|
||||
name: "Test-User-#{str}",
|
||||
url_name: "test-user-#{str.downcase}",
|
||||
})
|
||||
user.valid? || raise(user.errors.full_messages.join(", "))
|
||||
user
|
||||
|
||||
Reference in New Issue
Block a user