mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-19 13:47:35 +00:00
54b42901df
* Add a test for FollowRequest#authorize! * Remove tests There is no need to test ActiveModel::Validations::ClassMethods#validates. * Make an alias of destroy! as reject! Instead of defining the method, make an alias of destroy! as reject! because of reducing test.
32 lines
805 B
Ruby
32 lines
805 B
Ruby
# frozen_string_literal: true
|
|
# == Schema Information
|
|
#
|
|
# Table name: follow_requests
|
|
#
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# account_id :integer not null
|
|
# id :integer not null, primary key
|
|
# target_account_id :integer not null
|
|
#
|
|
|
|
class FollowRequest < ApplicationRecord
|
|
include Paginable
|
|
|
|
belongs_to :account, required: true
|
|
belongs_to :target_account, class_name: 'Account', required: true
|
|
|
|
has_one :notification, as: :activity, dependent: :destroy
|
|
|
|
validates :account_id, uniqueness: { scope: :target_account_id }
|
|
|
|
def authorize!
|
|
account.follow!(target_account)
|
|
MergeWorker.perform_async(target_account.id, account.id)
|
|
|
|
destroy!
|
|
end
|
|
|
|
alias reject! destroy!
|
|
end
|