$ git grep StatusPinValidator
app/models/status_pin.rb: validates_with StatusPinValidator
app/validators/status_pin_validator.rb:class StatusPinValidator < ActiveModel::Validator
spec/validators/status_pin_validator_spec.rb:RSpec.describe StatusPinValidator, type: :validator do
なのでたぶんこのコードがサーバで走るのはapp/models/status_pin.rbだけでこのファイルは
class StatusPin < ApplicationRecord
belongs_to :account
belongs_to :status
validates_with StatusPinValidator
end
という内容なので…validates_withはいつ走るんじゃ←
> Passes the record off to the class or classes specified and allows them to add errors based on more complex conditions.
うむわからんw
> Options:
>
> :on - Specifies the contexts where this validation is active. Runs in all validation contexts by default nil.
指定しない場合はすべてのコンテキストでバリデーションが走ります。すべてって誰よ!
> The following methods trigger validations, and will save the object to the database only if the object is valid:
>
> - create
> - create!
> - save
> - save!
> - update
> - update!
app/controllers/api/v1/statuses/pins_controller.rbではcreate!しか呼ばれてないから一度固定トゥートを作っちゃったらバリデーションは走らなさそうね。
$ git grep -o StatusPin\\.\\w\*
controllers/api/v1/statuses/pins_controller.rb:StatusPin.create
controllers/api/v1/statuses/pins_controller.rb:StatusPin.find_by
lib/activitypub/activity/add.rb:StatusPin.create
lib/activitypub/activity/remove.rb:StatusPin.find_by
models/status.rb:StatusPin.select
services/activitypub/fetch_featured_collection_service.rb:StatusPin.where
services/activitypub/fetch_featured_collection_service.rb:StatusPin.where
services/activitypub/fetch_featured_collection_service.rb:StatusPin.create
ういうい