Skip to content
Extraits de code Groupes Projets
Valider 238de58e rédigé par Yamagishi Kazutoshi's avatar Yamagishi Kazutoshi Validation de Eugen Rochko
Parcourir les fichiers

Change belongs_to_required_by_default to true (#5888)

parent 7233ac07
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 47 ajouts et 48 suppressions
...@@ -102,7 +102,7 @@ class Account < ApplicationRecord ...@@ -102,7 +102,7 @@ class Account < ApplicationRecord
has_many :lists, through: :list_accounts has_many :lists, through: :list_accounts
# Account migrations # Account migrations
belongs_to :moved_to_account, class_name: 'Account' belongs_to :moved_to_account, class_name: 'Account', optional: true
scope :remote, -> { where.not(domain: nil) } scope :remote, -> { where.not(domain: nil) }
scope :local, -> { where(domain: nil) } scope :local, -> { where(domain: nil) }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class AccountDomainBlock < ApplicationRecord class AccountDomainBlock < ApplicationRecord
include Paginable include Paginable
belongs_to :account, required: true belongs_to :account
validates :domain, presence: true, uniqueness: { scope: :account_id } validates :domain, presence: true, uniqueness: { scope: :account_id }
after_create :remove_blocking_cache after_create :remove_blocking_cache
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
class Admin::ActionLog < ApplicationRecord class Admin::ActionLog < ApplicationRecord
serialize :recorded_changes serialize :recorded_changes
belongs_to :account, required: true belongs_to :account
belongs_to :target, required: true, polymorphic: true belongs_to :target, polymorphic: true
default_scope -> { order('id desc') } default_scope -> { order('id desc') }
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
class Block < ApplicationRecord class Block < ApplicationRecord
include Paginable include Paginable
belongs_to :account, required: true belongs_to :account
belongs_to :target_account, class_name: 'Account', required: true belongs_to :target_account, class_name: 'Account'
validates :account_id, uniqueness: { scope: :target_account_id } validates :account_id, uniqueness: { scope: :target_account_id }
......
...@@ -9,6 +9,6 @@ ...@@ -9,6 +9,6 @@
# #
class ConversationMute < ApplicationRecord class ConversationMute < ApplicationRecord
belongs_to :account, required: true belongs_to :account
belongs_to :conversation, required: true belongs_to :conversation
end end
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
class Favourite < ApplicationRecord class Favourite < ApplicationRecord
include Paginable include Paginable
belongs_to :account, inverse_of: :favourites, required: true belongs_to :account, inverse_of: :favourites
belongs_to :status, inverse_of: :favourites, counter_cache: true, required: true belongs_to :status, inverse_of: :favourites, counter_cache: true
has_one :notification, as: :activity, dependent: :destroy has_one :notification, as: :activity, dependent: :destroy
......
...@@ -14,12 +14,11 @@ ...@@ -14,12 +14,11 @@
class Follow < ApplicationRecord class Follow < ApplicationRecord
include Paginable include Paginable
belongs_to :account, counter_cache: :following_count, required: true belongs_to :account, counter_cache: :following_count
belongs_to :target_account, belongs_to :target_account,
class_name: 'Account', class_name: 'Account',
counter_cache: :followers_count, counter_cache: :followers_count
required: true
has_one :notification, as: :activity, dependent: :destroy has_one :notification, as: :activity, dependent: :destroy
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
class FollowRequest < ApplicationRecord class FollowRequest < ApplicationRecord
include Paginable include Paginable
belongs_to :account, required: true belongs_to :account
belongs_to :target_account, class_name: 'Account', required: true belongs_to :target_account, class_name: 'Account'
has_one :notification, as: :activity, dependent: :destroy has_one :notification, as: :activity, dependent: :destroy
......
...@@ -20,7 +20,7 @@ class Import < ApplicationRecord ...@@ -20,7 +20,7 @@ class Import < ApplicationRecord
self.inheritance_column = false self.inheritance_column = false
belongs_to :account, required: true belongs_to :account
enum type: [:following, :blocking, :muting] enum type: [:following, :blocking, :muting]
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# #
class Invite < ApplicationRecord class Invite < ApplicationRecord
belongs_to :user, required: true belongs_to :user
has_many :users, inverse_of: :invite has_many :users, inverse_of: :invite
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) } scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
......
...@@ -15,7 +15,7 @@ class List < ApplicationRecord ...@@ -15,7 +15,7 @@ class List < ApplicationRecord
PER_ACCOUNT_LIMIT = 50 PER_ACCOUNT_LIMIT = 50
belongs_to :account belongs_to :account, optional: true
has_many :list_accounts, inverse_of: :list, dependent: :destroy has_many :list_accounts, inverse_of: :list, dependent: :destroy
has_many :accounts, through: :list_accounts has_many :accounts, through: :list_accounts
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
# #
class ListAccount < ApplicationRecord class ListAccount < ApplicationRecord
belongs_to :list, required: true belongs_to :list
belongs_to :account, required: true belongs_to :account
belongs_to :follow, required: true belongs_to :follow
validates :account_id, uniqueness: { scope: :list_id } validates :account_id, uniqueness: { scope: :list_id }
......
...@@ -45,8 +45,8 @@ class MediaAttachment < ApplicationRecord ...@@ -45,8 +45,8 @@ class MediaAttachment < ApplicationRecord
}, },
}.freeze }.freeze
belongs_to :account, inverse_of: :media_attachments belongs_to :account, inverse_of: :media_attachments, optional: true
belongs_to :status, inverse_of: :media_attachments belongs_to :status, inverse_of: :media_attachments, optional: true
has_attached_file :file, has_attached_file :file,
styles: ->(f) { file_styles f }, styles: ->(f) { file_styles f },
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
# #
class Mention < ApplicationRecord class Mention < ApplicationRecord
belongs_to :account, inverse_of: :mentions, required: true belongs_to :account, inverse_of: :mentions
belongs_to :status, required: true belongs_to :status
has_one :notification, as: :activity, dependent: :destroy has_one :notification, as: :activity, dependent: :destroy
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
class Mute < ApplicationRecord class Mute < ApplicationRecord
include Paginable include Paginable
belongs_to :account, required: true belongs_to :account
belongs_to :target_account, class_name: 'Account', required: true belongs_to :target_account, class_name: 'Account'
validates :account_id, uniqueness: { scope: :target_account_id } validates :account_id, uniqueness: { scope: :target_account_id }
......
...@@ -26,15 +26,15 @@ class Notification < ApplicationRecord ...@@ -26,15 +26,15 @@ class Notification < ApplicationRecord
STATUS_INCLUDES = [:account, :application, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :application, :media_attachments, :tags, mentions: :account]].freeze STATUS_INCLUDES = [:account, :application, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :application, :media_attachments, :tags, mentions: :account]].freeze
belongs_to :account belongs_to :account, optional: true
belongs_to :from_account, class_name: 'Account' belongs_to :from_account, class_name: 'Account', optional: true
belongs_to :activity, polymorphic: true belongs_to :activity, polymorphic: true, optional: true
belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id' belongs_to :mention, foreign_type: 'Mention', foreign_key: 'activity_id', optional: true
belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id' belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id', optional: true
belongs_to :follow, foreign_type: 'Follow', foreign_key: 'activity_id' belongs_to :follow, foreign_type: 'Follow', foreign_key: 'activity_id', optional: true
belongs_to :follow_request, foreign_type: 'FollowRequest', foreign_key: 'activity_id' belongs_to :follow_request, foreign_type: 'FollowRequest', foreign_key: 'activity_id', optional: true
belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id' belongs_to :favourite, foreign_type: 'Favourite', foreign_key: 'activity_id', optional: true
validates :account_id, uniqueness: { scope: [:activity_type, :activity_id] } validates :account_id, uniqueness: { scope: [:activity_type, :activity_id] }
validates :activity_type, inclusion: { in: TYPE_CLASS_MAP.values } validates :activity_type, inclusion: { in: TYPE_CLASS_MAP.values }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
class Report < ApplicationRecord class Report < ApplicationRecord
belongs_to :account belongs_to :account
belongs_to :target_account, class_name: 'Account' belongs_to :target_account, class_name: 'Account'
belongs_to :action_taken_by_account, class_name: 'Account' belongs_to :action_taken_by_account, class_name: 'Account', optional: true
scope :unresolved, -> { where(action_taken: false) } scope :unresolved, -> { where(action_taken: false) }
scope :resolved, -> { where(action_taken: true) } scope :resolved, -> { where(action_taken: true) }
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
# #
class SessionActivation < ApplicationRecord class SessionActivation < ApplicationRecord
belongs_to :user, inverse_of: :session_activations, required: true belongs_to :user, inverse_of: :session_activations
belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', dependent: :destroy belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', dependent: :destroy, optional: true
belongs_to :web_push_subscription, class_name: 'Web::PushSubscription', dependent: :destroy belongs_to :web_push_subscription, class_name: 'Web::PushSubscription', dependent: :destroy, optional: true
delegate :token, delegate :token,
to: :access_token, to: :access_token,
......
...@@ -33,14 +33,14 @@ class Status < ApplicationRecord ...@@ -33,14 +33,14 @@ class Status < ApplicationRecord
enum visibility: [:public, :unlisted, :private, :direct], _suffix: :visibility enum visibility: [:public, :unlisted, :private, :direct], _suffix: :visibility
belongs_to :application, class_name: 'Doorkeeper::Application' belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
belongs_to :account, inverse_of: :statuses, counter_cache: true, required: true belongs_to :account, inverse_of: :statuses, counter_cache: true
belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account' belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account', optional: true
belongs_to :conversation belongs_to :conversation, optional: true
belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies, optional: true
belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, counter_cache: :reblogs_count belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, counter_cache: :reblogs_count, optional: true
has_many :favourites, inverse_of: :status, dependent: :destroy has_many :favourites, inverse_of: :status, dependent: :destroy
has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
# #
class StatusPin < ApplicationRecord class StatusPin < ApplicationRecord
belongs_to :account, required: true belongs_to :account
belongs_to :status, required: true belongs_to :status
validates_with StatusPinValidator validates_with StatusPinValidator
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter