Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.prettierignore`: Upstream added a line at the end of the file, while glitch-soc had its own extra lines. Took upstream's change. - `CONTRIBUTING.md`: We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes. Ported upstream changes. - `app/controllers/application_controller.rb`: Upstream made code style changes in a method that is entirely replaced in glitch-soc. Ignored the change. - `app/models/account.rb`: Code style changes textually close to glitch-soc-specific changes. Ported upstream changes. - `lib/sanitize_ext/sanitize_config.rb`: Upstream code style changes. Ignored them.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account::Field, type: :model do
|
||||
describe '#verified?' do
|
||||
let(:account) { double('Account', local?: true) }
|
||||
|
||||
subject { described_class.new(account, 'name' => 'Foo', 'value' => 'Bar', 'verified_at' => verified_at) }
|
||||
|
||||
let(:account) { double('Account', local?: true) }
|
||||
|
||||
context 'when verified_at is set' do
|
||||
let(:verified_at) { Time.now.utc.iso8601 }
|
||||
|
||||
@@ -24,11 +26,11 @@ RSpec.describe Account::Field, type: :model do
|
||||
end
|
||||
|
||||
describe '#mark_verified!' do
|
||||
subject { described_class.new(account, original_hash) }
|
||||
|
||||
let(:account) { double('Account', local?: true) }
|
||||
let(:original_hash) { { 'name' => 'Foo', 'value' => 'Bar' } }
|
||||
|
||||
subject { described_class.new(account, original_hash) }
|
||||
|
||||
before do
|
||||
subject.mark_verified!
|
||||
end
|
||||
@@ -43,10 +45,10 @@ RSpec.describe Account::Field, type: :model do
|
||||
end
|
||||
|
||||
describe '#verifiable?' do
|
||||
let(:account) { double('Account', local?: local) }
|
||||
|
||||
subject { described_class.new(account, 'name' => 'Foo', 'value' => value) }
|
||||
|
||||
let(:account) { double('Account', local?: local) }
|
||||
|
||||
context 'for local accounts' do
|
||||
let(:local) { true }
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountAlias, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountConversation, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountDeletionRequest, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountDomainBlock, type: :model do
|
||||
@@ -7,7 +9,7 @@ RSpec.describe AccountDomainBlock, type: :model do
|
||||
|
||||
AccountDomainBlock.create!(account: account, domain: 'a.domain.blocked.later')
|
||||
|
||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
||||
end
|
||||
|
||||
it 'removes blocking cache after destruction' do
|
||||
@@ -17,6 +19,6 @@ RSpec.describe AccountDomainBlock, type: :model do
|
||||
|
||||
block.destroy!
|
||||
|
||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountFilter do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountMigration, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountModerationNote, type: :model do
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account, type: :model do
|
||||
context do
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
describe '#suspend!' do
|
||||
it 'marks the account as suspended' do
|
||||
subject.suspend!
|
||||
@@ -31,7 +33,7 @@ RSpec.describe Account, type: :model do
|
||||
end
|
||||
|
||||
it 'does not raise an error' do
|
||||
expect { subject.suspend! }.not_to raise_error
|
||||
expect { subject.suspend! }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -87,14 +89,14 @@ RSpec.describe Account, type: :model do
|
||||
end
|
||||
|
||||
describe 'Local domain user methods' do
|
||||
subject { Fabricate(:account, domain: nil, username: 'alice') }
|
||||
|
||||
around do |example|
|
||||
before = Rails.configuration.x.local_domain
|
||||
example.run
|
||||
Rails.configuration.x.local_domain = before
|
||||
end
|
||||
|
||||
subject { Fabricate(:account, domain: nil, username: 'alice') }
|
||||
|
||||
describe '#to_webfinger_s' do
|
||||
it 'returns a webfinger string for the account' do
|
||||
Rails.configuration.x.local_domain = 'example.com'
|
||||
@@ -160,7 +162,7 @@ RSpec.describe Account, type: :model do
|
||||
it 'sets default avatar, header, avatar_remote_url, and header_remote_url' do
|
||||
expect(account.avatar_remote_url).to eq 'https://remote.test/invalid_avatar'
|
||||
expect(account.header_remote_url).to eq expectation.header_remote_url
|
||||
expect(account.avatar_file_name).to eq nil
|
||||
expect(account.avatar_file_name).to be_nil
|
||||
expect(account.header_file_name).to eq expectation.header_file_name
|
||||
end
|
||||
end
|
||||
@@ -206,7 +208,7 @@ RSpec.describe Account, type: :model do
|
||||
end
|
||||
|
||||
it 'calls not ResolveAccountService#call' do
|
||||
expect_any_instance_of(ResolveAccountService).not_to receive(:call).with(acct)
|
||||
expect_any_instance_of(ResolveAccountService).to_not receive(:call).with(acct)
|
||||
account.refresh!
|
||||
end
|
||||
end
|
||||
@@ -243,13 +245,13 @@ RSpec.describe Account, type: :model do
|
||||
end
|
||||
|
||||
describe '#favourited?' do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
let(:original_status) do
|
||||
author = Fabricate(:account, username: 'original')
|
||||
Fabricate(:status, account: author)
|
||||
end
|
||||
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
context 'when the status is a reblog of another status' do
|
||||
let(:original_reblog) do
|
||||
author = Fabricate(:account, username: 'original_reblogger')
|
||||
@@ -259,11 +261,11 @@ RSpec.describe Account, type: :model do
|
||||
it 'is true when this account has favourited it' do
|
||||
Fabricate(:favourite, status: original_reblog, account: subject)
|
||||
|
||||
expect(subject.favourited?(original_status)).to eq true
|
||||
expect(subject.favourited?(original_status)).to be true
|
||||
end
|
||||
|
||||
it 'is false when this account has not favourited it' do
|
||||
expect(subject.favourited?(original_status)).to eq false
|
||||
expect(subject.favourited?(original_status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -271,23 +273,23 @@ RSpec.describe Account, type: :model do
|
||||
it 'is true when this account has favourited it' do
|
||||
Fabricate(:favourite, status: original_status, account: subject)
|
||||
|
||||
expect(subject.favourited?(original_status)).to eq true
|
||||
expect(subject.favourited?(original_status)).to be true
|
||||
end
|
||||
|
||||
it 'is false when this account has not favourited it' do
|
||||
expect(subject.favourited?(original_status)).to eq false
|
||||
expect(subject.favourited?(original_status)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reblogged?' do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
let(:original_status) do
|
||||
author = Fabricate(:account, username: 'original')
|
||||
Fabricate(:status, account: author)
|
||||
end
|
||||
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
context 'when the status is a reblog of another status' do
|
||||
let(:original_reblog) do
|
||||
author = Fabricate(:account, username: 'original_reblogger')
|
||||
@@ -297,11 +299,11 @@ RSpec.describe Account, type: :model do
|
||||
it 'is true when this account has reblogged it' do
|
||||
Fabricate(:status, reblog: original_reblog, account: subject)
|
||||
|
||||
expect(subject.reblogged?(original_reblog)).to eq true
|
||||
expect(subject.reblogged?(original_reblog)).to be true
|
||||
end
|
||||
|
||||
it 'is false when this account has not reblogged it' do
|
||||
expect(subject.reblogged?(original_reblog)).to eq false
|
||||
expect(subject.reblogged?(original_reblog)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -309,11 +311,11 @@ RSpec.describe Account, type: :model do
|
||||
it 'is true when this account has reblogged it' do
|
||||
Fabricate(:status, reblog: original_status, account: subject)
|
||||
|
||||
expect(subject.reblogged?(original_status)).to eq true
|
||||
expect(subject.reblogged?(original_status)).to be true
|
||||
end
|
||||
|
||||
it 'is false when this account has not reblogged it' do
|
||||
expect(subject.reblogged?(original_status)).to eq false
|
||||
expect(subject.reblogged?(original_status)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -811,19 +813,19 @@ RSpec.describe Account, type: :model do
|
||||
it 'is valid even if the username is longer than 30 characters' do
|
||||
account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(number: 31))
|
||||
account.valid?
|
||||
expect(account).not_to model_have_error_on_field(:username)
|
||||
expect(account).to_not model_have_error_on_field(:username)
|
||||
end
|
||||
|
||||
it 'is valid even if the display name is longer than 30 characters' do
|
||||
account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(number: 31))
|
||||
account.valid?
|
||||
expect(account).not_to model_have_error_on_field(:display_name)
|
||||
expect(account).to_not model_have_error_on_field(:display_name)
|
||||
end
|
||||
|
||||
it 'is valid even if the note is longer than 500 characters' do
|
||||
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501))
|
||||
account.valid?
|
||||
expect(account).not_to model_have_error_on_field(:note)
|
||||
expect(account).to_not model_have_error_on_field(:note)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -895,7 +897,7 @@ RSpec.describe Account, type: :model do
|
||||
|
||||
describe 'partitioned' do
|
||||
it 'returns a relation of accounts partitioned by domain' do
|
||||
matches = ['a', 'b', 'a', 'b']
|
||||
matches = %w(a b a b)
|
||||
matches.size.times.to_a.shuffle.each do |index|
|
||||
matches[index] = Fabricate(:account, domain: matches[index])
|
||||
end
|
||||
@@ -958,7 +960,7 @@ RSpec.describe Account, type: :model do
|
||||
# Test disabled because test environment omits autogenerating keys for performance
|
||||
xit 'generates keys' do
|
||||
account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_']))
|
||||
expect(account.keypair.private?).to eq true
|
||||
expect(account.keypair.private?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
@@ -132,11 +134,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
end
|
||||
|
||||
describe '#invalidate_last_inspected' do
|
||||
subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) }
|
||||
|
||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||
let(:status) { Fabricate(:status, id: 10, account: account) }
|
||||
|
||||
subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) }
|
||||
|
||||
before do
|
||||
account_statuses_cleanup_policy.record_last_inspected(42)
|
||||
end
|
||||
@@ -231,11 +233,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
end
|
||||
|
||||
describe '#compute_cutoff_id' do
|
||||
subject { account_statuses_cleanup_policy.compute_cutoff_id }
|
||||
|
||||
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
|
||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||
|
||||
subject { account_statuses_cleanup_policy.compute_cutoff_id }
|
||||
|
||||
context 'when the account has posted multiple toots' do
|
||||
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
|
||||
let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) }
|
||||
@@ -254,13 +256,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
end
|
||||
|
||||
describe '#statuses_to_delete' do
|
||||
subject { account_statuses_cleanup_policy.statuses_to_delete }
|
||||
|
||||
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
|
||||
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
|
||||
let!(:pinned_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:direct_message) { Fabricate(:status, created_at: 1.year.ago, account: account, visibility: :direct) }
|
||||
let!(:self_faved) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:self_bookmarked) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:status_with_poll) { Fabricate(:status, created_at: 1.year.ago, account: account, poll_attributes: { account: account, voters_count: 0, options: ['a', 'b'], expires_in: 2.days }) }
|
||||
let!(:status_with_poll) { Fabricate(:status, created_at: 1.year.ago, account: account, poll_attributes: { account: account, voters_count: 0, options: %w(a b), expires_in: 2.days }) }
|
||||
let!(:status_with_media) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:faved4) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:faved5) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
@@ -275,8 +279,6 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
|
||||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||
|
||||
subject { account_statuses_cleanup_policy.statuses_to_delete }
|
||||
|
||||
before do
|
||||
4.times { faved4.increment_count!(:favourites_count) }
|
||||
5.times { faved5.increment_count!(:favourites_count) }
|
||||
@@ -285,11 +287,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
end
|
||||
|
||||
context 'when passed a max_id' do
|
||||
subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) }
|
||||
|
||||
let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) }
|
||||
|
||||
subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) }
|
||||
|
||||
it 'returns statuses including max_id' do
|
||||
expect(subject).to include(old_status.id)
|
||||
end
|
||||
@@ -304,11 +306,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
|
||||
end
|
||||
|
||||
context 'when passed a min_id' do
|
||||
subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) }
|
||||
|
||||
let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) }
|
||||
|
||||
subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) }
|
||||
|
||||
it 'returns statuses including min_id' do
|
||||
expect(subject).to include(old_status.id)
|
||||
end
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountStatusesFilter do
|
||||
subject { described_class.new(account, current_account, params) }
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:current_account) { nil }
|
||||
let(:params) { {} }
|
||||
|
||||
subject { described_class.new(account, current_account, params) }
|
||||
|
||||
def status!(visibility)
|
||||
Fabricate(:status, account: account, visibility: visibility)
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::AccountAction, type: :model do
|
||||
@@ -5,15 +7,16 @@ RSpec.describe Admin::AccountAction, type: :model do
|
||||
|
||||
describe '#save!' do
|
||||
subject { account_action.save! }
|
||||
|
||||
let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:target_account) { Fabricate(:account) }
|
||||
let(:type) { 'disable' }
|
||||
|
||||
before do
|
||||
account_action.assign_attributes(
|
||||
type: type,
|
||||
type: type,
|
||||
current_account: account,
|
||||
target_account: target_account
|
||||
target_account: target_account
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AnnouncementMute, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AnnouncementReaction, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Announcement, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Appeal, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Backup, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Block, type: :model do
|
||||
@@ -28,8 +30,8 @@ RSpec.describe Block, type: :model do
|
||||
|
||||
Block.create!(account: account, target_account: target_account)
|
||||
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false
|
||||
end
|
||||
|
||||
it 'removes blocking cache after destruction' do
|
||||
@@ -41,7 +43,7 @@ RSpec.describe Block, type: :model do
|
||||
|
||||
block.destroy!
|
||||
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CanonicalEmailBlock, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountCounters do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountInteractions do
|
||||
@@ -14,7 +16,7 @@ describe AccountInteractions do
|
||||
context 'account with Follow' do
|
||||
it 'returns { target_account_id => { reblogs: true } }' do
|
||||
Fabricate(:follow, account: account, target_account: target_account)
|
||||
is_expected.to eq(target_account_id => { reblogs: true, notify: false, languages: nil })
|
||||
expect(subject).to eq(target_account_id => { reblogs: true, notify: false, languages: nil })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +29,7 @@ describe AccountInteractions do
|
||||
|
||||
context 'account without Follow' do
|
||||
it 'returns {}' do
|
||||
is_expected.to eq({})
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -38,13 +40,13 @@ describe AccountInteractions do
|
||||
context 'account with Follow' do
|
||||
it 'returns { target_account_id => true }' do
|
||||
Fabricate(:follow, account: target_account, target_account: account)
|
||||
is_expected.to eq(target_account_id => true)
|
||||
expect(subject).to eq(target_account_id => true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'account without Follow' do
|
||||
it 'returns {}' do
|
||||
is_expected.to eq({})
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -55,13 +57,13 @@ describe AccountInteractions do
|
||||
context 'account with Block' do
|
||||
it 'returns { target_account_id => true }' do
|
||||
Fabricate(:block, account: account, target_account: target_account)
|
||||
is_expected.to eq(target_account_id => true)
|
||||
expect(subject).to eq(target_account_id => true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'account without Block' do
|
||||
it 'returns {}' do
|
||||
is_expected.to eq({})
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -78,7 +80,7 @@ describe AccountInteractions do
|
||||
let(:hide) { true }
|
||||
|
||||
it 'returns { target_account_id => { notifications: true } }' do
|
||||
is_expected.to eq(target_account_id => { notifications: true })
|
||||
expect(subject).to eq(target_account_id => { notifications: true })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,14 +88,14 @@ describe AccountInteractions do
|
||||
let(:hide) { false }
|
||||
|
||||
it 'returns { target_account_id => { notifications: false } }' do
|
||||
is_expected.to eq(target_account_id => { notifications: false })
|
||||
expect(subject).to eq(target_account_id => { notifications: false })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'account without Mute' do
|
||||
it 'returns {}' do
|
||||
is_expected.to eq({})
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -156,8 +158,8 @@ describe AccountInteractions do
|
||||
|
||||
let(:mute) do
|
||||
Fabricate(:mute,
|
||||
account: account,
|
||||
target_account: target_account,
|
||||
account: account,
|
||||
target_account: target_account,
|
||||
hide_notifications: hide_notifications)
|
||||
end
|
||||
|
||||
@@ -170,7 +172,7 @@ describe AccountInteractions do
|
||||
it 'returns Mute without updating mute.hide_notifications' do
|
||||
expect do
|
||||
expect(subject).to be_a Mute
|
||||
end.not_to change { mute.reload.hide_notifications? }.from(true)
|
||||
end.to_not change { mute.reload.hide_notifications? }.from(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,7 +192,7 @@ describe AccountInteractions do
|
||||
it 'returns Mute without updating mute.hide_notifications' do
|
||||
expect do
|
||||
expect(subject).to be_a Mute
|
||||
end.not_to change { mute.reload.hide_notifications? }.from(true)
|
||||
end.to_not change { mute.reload.hide_notifications? }.from(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -214,7 +216,7 @@ describe AccountInteractions do
|
||||
it 'returns Mute without updating mute.hide_notifications' do
|
||||
expect do
|
||||
expect(subject).to be_a Mute
|
||||
end.not_to change { mute.reload.hide_notifications? }.from(false)
|
||||
end.to_not change { mute.reload.hide_notifications? }.from(false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -232,25 +234,25 @@ describe AccountInteractions do
|
||||
end
|
||||
|
||||
describe '#mute_conversation!' do
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
subject { account.mute_conversation!(conversation) }
|
||||
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
it 'creates and returns ConversationMute' do
|
||||
expect do
|
||||
is_expected.to be_a ConversationMute
|
||||
expect(subject).to be_a ConversationMute
|
||||
end.to change { account.conversation_mutes.count }.by 1
|
||||
end
|
||||
end
|
||||
|
||||
describe '#block_domain!' do
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
subject { account.block_domain!(domain) }
|
||||
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
it 'creates and returns AccountDomainBlock' do
|
||||
expect do
|
||||
is_expected.to be_a AccountDomainBlock
|
||||
expect(subject).to be_a AccountDomainBlock
|
||||
end.to change { account.domain_blocks.count }.by 1
|
||||
end
|
||||
end
|
||||
@@ -261,14 +263,14 @@ describe AccountInteractions do
|
||||
context 'following target_account' do
|
||||
it 'returns destroyed Follow' do
|
||||
account.active_relationships.create(target_account: target_account)
|
||||
is_expected.to be_a Follow
|
||||
expect(subject).to be_a Follow
|
||||
expect(subject).to be_destroyed
|
||||
end
|
||||
end
|
||||
|
||||
context 'not following target_account' do
|
||||
it 'returns nil' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -279,14 +281,14 @@ describe AccountInteractions do
|
||||
context 'blocking target_account' do
|
||||
it 'returns destroyed Block' do
|
||||
account.block_relationships.create(target_account: target_account)
|
||||
is_expected.to be_a Block
|
||||
expect(subject).to be_a Block
|
||||
expect(subject).to be_destroyed
|
||||
end
|
||||
end
|
||||
|
||||
context 'not blocking target_account' do
|
||||
it 'returns nil' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -297,55 +299,55 @@ describe AccountInteractions do
|
||||
context 'muting target_account' do
|
||||
it 'returns destroyed Mute' do
|
||||
account.mute_relationships.create(target_account: target_account)
|
||||
is_expected.to be_a Mute
|
||||
expect(subject).to be_a Mute
|
||||
expect(subject).to be_destroyed
|
||||
end
|
||||
end
|
||||
|
||||
context 'not muting target_account' do
|
||||
it 'returns nil' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unmute_conversation!' do
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
subject { account.unmute_conversation!(conversation) }
|
||||
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
context 'muting the conversation' do
|
||||
it 'returns destroyed ConversationMute' do
|
||||
account.conversation_mutes.create(conversation: conversation)
|
||||
is_expected.to be_a ConversationMute
|
||||
expect(subject).to be_a ConversationMute
|
||||
expect(subject).to be_destroyed
|
||||
end
|
||||
end
|
||||
|
||||
context 'not muting the conversation' do
|
||||
it 'returns nil' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unblock_domain!' do
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
subject { account.unblock_domain!(domain) }
|
||||
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
context 'blocking the domain' do
|
||||
it 'returns destroyed AccountDomainBlock' do
|
||||
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
||||
account.domain_blocks << account_domain_block
|
||||
is_expected.to be_a AccountDomainBlock
|
||||
expect(subject).to be_a AccountDomainBlock
|
||||
expect(subject).to be_destroyed
|
||||
end
|
||||
end
|
||||
|
||||
context 'unblocking the domain' do
|
||||
it 'returns nil' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -356,13 +358,13 @@ describe AccountInteractions do
|
||||
context 'following target_account' do
|
||||
it 'returns true' do
|
||||
account.active_relationships.create(target_account: target_account)
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not following target_account' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -373,13 +375,13 @@ describe AccountInteractions do
|
||||
context 'followed by target_account' do
|
||||
it 'returns true' do
|
||||
account.passive_relationships.create(account: target_account)
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not followed by target_account' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -390,33 +392,33 @@ describe AccountInteractions do
|
||||
context 'blocking target_account' do
|
||||
it 'returns true' do
|
||||
account.block_relationships.create(target_account: target_account)
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not blocking target_account' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#domain_blocking?' do
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
subject { account.domain_blocking?(domain) }
|
||||
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
context 'blocking the domain' do
|
||||
it 'returns true' do
|
||||
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
||||
account.domain_blocks << account_domain_block
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not blocking the domain' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -428,49 +430,49 @@ describe AccountInteractions do
|
||||
it 'returns true' do
|
||||
mute = Fabricate(:mute, account: account, target_account: target_account)
|
||||
account.mute_relationships << mute
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not muting target_account' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#muting_conversation?' do
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
subject { account.muting_conversation?(conversation) }
|
||||
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
context 'muting the conversation' do
|
||||
it 'returns true' do
|
||||
account.conversation_mutes.create(conversation: conversation)
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not muting the conversation' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#muting_notifications?' do
|
||||
subject { account.muting_notifications?(target_account) }
|
||||
|
||||
before do
|
||||
mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
|
||||
account.mute_relationships << mute
|
||||
end
|
||||
|
||||
subject { account.muting_notifications?(target_account) }
|
||||
|
||||
context 'muting notifications of target_account' do
|
||||
let(:hide) { true }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -478,7 +480,7 @@ describe AccountInteractions do
|
||||
let(:hide) { false }
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -489,27 +491,27 @@ describe AccountInteractions do
|
||||
context 'requested by target_account' do
|
||||
it 'returns true' do
|
||||
Fabricate(:follow_request, account: account, target_account: target_account)
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not requested by target_account' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#favourited?' do
|
||||
let(:status) { Fabricate(:status, account: account, favourites: favourites) }
|
||||
|
||||
subject { account.favourited?(status) }
|
||||
|
||||
let(:status) { Fabricate(:status, account: account, favourites: favourites) }
|
||||
|
||||
context 'favorited' do
|
||||
let(:favourites) { [Fabricate(:favourite, account: account)] }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -517,21 +519,21 @@ describe AccountInteractions do
|
||||
let(:favourites) { [] }
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reblogged?' do
|
||||
let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
|
||||
|
||||
subject { account.reblogged?(status) }
|
||||
|
||||
let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
|
||||
|
||||
context 'reblogged' do
|
||||
let(:reblogs) { [Fabricate(:status, account: account)] }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -539,26 +541,26 @@ describe AccountInteractions do
|
||||
let(:reblogs) { [] }
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pinned?' do
|
||||
let(:status) { Fabricate(:status, account: account) }
|
||||
|
||||
subject { account.pinned?(status) }
|
||||
|
||||
let(:status) { Fabricate(:status, account: account) }
|
||||
|
||||
context 'pinned' do
|
||||
it 'returns true' do
|
||||
Fabricate(:status_pin, account: account, status: status)
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not pinned' do
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -147,8 +147,8 @@ RSpec.describe Remotable do
|
||||
let(:code) { 500 }
|
||||
|
||||
it 'does not assign file' do
|
||||
expect(foo).not_to receive(:public_send).with("#{hoge}=", any_args)
|
||||
expect(foo).not_to receive(:public_send).with("#{hoge}_file_name=", any_args)
|
||||
expect(foo).to_not receive(:public_send).with("#{hoge}=", any_args)
|
||||
expect(foo).to_not receive(:public_send).with("#{hoge}_file_name=", any_args)
|
||||
|
||||
foo.hoge_remote_url = url
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ConversationMute, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Conversation, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomEmojiCategory, type: :model do
|
||||
|
||||
@@ -4,12 +4,12 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomEmojiFilter do
|
||||
describe '#results' do
|
||||
subject { described_class.new(params).results }
|
||||
|
||||
let!(:custom_emoji_0) { Fabricate(:custom_emoji, domain: 'a') }
|
||||
let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') }
|
||||
let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') }
|
||||
|
||||
subject { described_class.new(params).results }
|
||||
|
||||
context 'params have values' do
|
||||
context 'local' do
|
||||
let(:params) { { local: true } }
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomEmoji, type: :model do
|
||||
describe '#search' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
|
||||
|
||||
subject { described_class.search(search_term) }
|
||||
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
|
||||
|
||||
context 'shortcode is exact' do
|
||||
let(:shortcode) { 'blobpats' }
|
||||
let(:search_term) { 'blobpats' }
|
||||
|
||||
it 'finds emoji' do
|
||||
is_expected.to include(custom_emoji)
|
||||
expect(subject).to include(custom_emoji)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,21 +22,21 @@ RSpec.describe CustomEmoji, type: :model do
|
||||
let(:search_term) { 'blob' }
|
||||
|
||||
it 'finds emoji' do
|
||||
is_expected.to include(custom_emoji)
|
||||
expect(subject).to include(custom_emoji)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#local?' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
|
||||
|
||||
subject { custom_emoji.local? }
|
||||
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
|
||||
|
||||
context 'domain is nil' do
|
||||
let(:domain) { nil }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,7 +44,7 @@ RSpec.describe CustomEmoji, type: :model do
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -55,15 +57,15 @@ RSpec.describe CustomEmoji, type: :model do
|
||||
end
|
||||
|
||||
describe '.from_text' do
|
||||
let!(:emojo) { Fabricate(:custom_emoji) }
|
||||
|
||||
subject { described_class.from_text(text, nil) }
|
||||
|
||||
let!(:emojo) { Fabricate(:custom_emoji) }
|
||||
|
||||
context 'with plain text' do
|
||||
let(:text) { 'Hello :coolcat:' }
|
||||
|
||||
it 'returns records used via shortcodes in text' do
|
||||
is_expected.to include(emojo)
|
||||
expect(subject).to include(emojo)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,7 +73,7 @@ RSpec.describe CustomEmoji, type: :model do
|
||||
let(:text) { '<p>Hello :coolcat:</p>' }
|
||||
|
||||
it 'returns records used via shortcodes in text' do
|
||||
is_expected.to include(emojo)
|
||||
expect(subject).to include(emojo)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomFilterKeyword, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomFilter, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Device, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainAllow, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DomainBlock, type: :model do
|
||||
@@ -24,16 +26,16 @@ RSpec.describe DomainBlock, type: :model do
|
||||
describe '.blocked?' do
|
||||
it 'returns true if the domain is suspended' do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
|
||||
expect(DomainBlock.blocked?('example.com')).to eq true
|
||||
expect(DomainBlock.blocked?('example.com')).to be true
|
||||
end
|
||||
|
||||
it 'returns false even if the domain is silenced' do
|
||||
Fabricate(:domain_block, domain: 'example.com', severity: :silence)
|
||||
expect(DomainBlock.blocked?('example.com')).to eq false
|
||||
expect(DomainBlock.blocked?('example.com')).to be false
|
||||
end
|
||||
|
||||
it 'returns false if the domain is not suspended nor silenced' do
|
||||
expect(DomainBlock.blocked?('example.com')).to eq false
|
||||
expect(DomainBlock.blocked?('example.com')).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EmailDomainBlock, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EncryptedMessage, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Export do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Favourite, type: :model do
|
||||
@@ -9,7 +11,7 @@ RSpec.describe Favourite, type: :model do
|
||||
|
||||
it 'invalidates if the reblogged status is already a favourite' do
|
||||
Favourite.create!(account: account, status: reblog)
|
||||
expect(Favourite.new(account: account, status: status).valid?).to eq false
|
||||
expect(Favourite.new(account: account, status: status).valid?).to be false
|
||||
end
|
||||
|
||||
it 'replaces status with the reblogged one if it is a reblog' do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FeaturedTag, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FollowRecommendationSuppression, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FollowRequest, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Follow, type: :model do
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe HomeFeed, type: :model do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { described_class.new(account) }
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe '#get' do
|
||||
before do
|
||||
Fabricate(:status, account: account, id: 1)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Identity, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Import, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Invite, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe IpBlock, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ListAccount, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe List, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe LoginActivity, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Marker, type: :model do
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe MediaAttachment, type: :model do
|
||||
describe 'local?' do
|
||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) }
|
||||
|
||||
subject { media_attachment.local? }
|
||||
|
||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) }
|
||||
|
||||
context 'remote_url is blank' do
|
||||
let(:remote_url) { '' }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,16 +20,16 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
let(:remote_url) { 'remote_url' }
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'needs_redownload?' do
|
||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) }
|
||||
|
||||
subject { media_attachment.needs_redownload? }
|
||||
|
||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) }
|
||||
|
||||
context 'file is blank' do
|
||||
let(:file) { nil }
|
||||
|
||||
@@ -35,7 +37,7 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
let(:remote_url) { 'remote_url' }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,7 +49,7 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
let(:remote_url) { '' }
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,7 +57,7 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
let(:remote_url) { 'remote_url' }
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -138,7 +140,7 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
end
|
||||
|
||||
it 'extracts thumbnail' do
|
||||
expect(media.thumbnail.present?).to eq true
|
||||
expect(media.thumbnail.present?).to be true
|
||||
end
|
||||
|
||||
it 'extracts colors from thumbnail' do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mention, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mute, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Notification, type: :model do
|
||||
@@ -68,7 +70,7 @@ RSpec.describe Notification, type: :model do
|
||||
let(:notifications) { [] }
|
||||
|
||||
it 'returns []' do
|
||||
is_expected.to eq []
|
||||
expect(subject).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OneTimeKey, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Poll, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PreviewCard, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PreviewCardTrend, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PublicFeed, type: :model do
|
||||
@@ -11,7 +13,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
private_status = Fabricate(:status, visibility: :private)
|
||||
|
||||
expect(subject).to include(public_status.id)
|
||||
expect(subject).not_to include(private_status.id)
|
||||
expect(subject).to_not include(private_status.id)
|
||||
end
|
||||
|
||||
it 'does not include replies' do
|
||||
@@ -19,7 +21,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
reply = Fabricate(:status, in_reply_to_id: status.id)
|
||||
|
||||
expect(subject).to include(status.id)
|
||||
expect(subject).not_to include(reply.id)
|
||||
expect(subject).to_not include(reply.id)
|
||||
end
|
||||
|
||||
it 'does not include boosts' do
|
||||
@@ -27,7 +29,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
boost = Fabricate(:status, reblog_of_id: status.id)
|
||||
|
||||
expect(subject).to include(status.id)
|
||||
expect(subject).not_to include(boost.id)
|
||||
expect(subject).to_not include(boost.id)
|
||||
end
|
||||
|
||||
it 'filters out silenced accounts' do
|
||||
@@ -36,10 +38,12 @@ RSpec.describe PublicFeed, type: :model do
|
||||
silenced_status = Fabricate(:status, account: silenced_account)
|
||||
|
||||
expect(subject).to include(status.id)
|
||||
expect(subject).not_to include(silenced_status.id)
|
||||
expect(subject).to_not include(silenced_status.id)
|
||||
end
|
||||
|
||||
context 'without local_only option' do
|
||||
subject { described_class.new(viewer).get(20).map(&:id) }
|
||||
|
||||
let(:viewer) { nil }
|
||||
|
||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||
@@ -48,8 +52,6 @@ RSpec.describe PublicFeed, type: :model do
|
||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||
let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
|
||||
|
||||
subject { described_class.new(viewer).get(20).map(&:id) }
|
||||
|
||||
context 'without a viewer' do
|
||||
let(:viewer) { nil }
|
||||
|
||||
@@ -128,20 +130,20 @@ RSpec.describe PublicFeed, type: :model do
|
||||
end
|
||||
|
||||
context 'with a local_only option set' do
|
||||
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
|
||||
|
||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
||||
let!(:local_status) { Fabricate(:status, account: local_account) }
|
||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||
let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
|
||||
|
||||
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
|
||||
|
||||
context 'without a viewer' do
|
||||
let(:viewer) { nil }
|
||||
|
||||
it 'does not include remote instances statuses' do
|
||||
expect(subject).to include(local_status.id)
|
||||
expect(subject).not_to include(remote_status.id)
|
||||
expect(subject).to_not include(remote_status.id)
|
||||
end
|
||||
|
||||
it 'does not include local-only statuses' do
|
||||
@@ -154,13 +156,13 @@ RSpec.describe PublicFeed, type: :model do
|
||||
|
||||
it 'does not include remote instances statuses' do
|
||||
expect(subject).to include(local_status.id)
|
||||
expect(subject).not_to include(remote_status.id)
|
||||
expect(subject).to_not include(remote_status.id)
|
||||
end
|
||||
|
||||
it 'is not affected by personal domain blocks' do
|
||||
viewer.block_domain!('test.com')
|
||||
expect(subject).to include(local_status.id)
|
||||
expect(subject).not_to include(remote_status.id)
|
||||
expect(subject).to_not include(remote_status.id)
|
||||
end
|
||||
|
||||
it 'includes local-only statuses' do
|
||||
@@ -170,18 +172,18 @@ RSpec.describe PublicFeed, type: :model do
|
||||
end
|
||||
|
||||
context 'with a remote_only option set' do
|
||||
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
|
||||
|
||||
let!(:local_account) { Fabricate(:account, domain: nil) }
|
||||
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
|
||||
let!(:local_status) { Fabricate(:status, account: local_account) }
|
||||
let!(:remote_status) { Fabricate(:status, account: remote_account) }
|
||||
|
||||
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
|
||||
|
||||
context 'without a viewer' do
|
||||
let(:viewer) { nil }
|
||||
|
||||
it 'does not include local instances statuses' do
|
||||
expect(subject).not_to include(local_status.id)
|
||||
expect(subject).to_not include(local_status.id)
|
||||
expect(subject).to include(remote_status.id)
|
||||
end
|
||||
end
|
||||
@@ -190,25 +192,25 @@ RSpec.describe PublicFeed, type: :model do
|
||||
let(:viewer) { Fabricate(:account, username: 'viewer') }
|
||||
|
||||
it 'does not include local instances statuses' do
|
||||
expect(subject).not_to include(local_status.id)
|
||||
expect(subject).to_not include(local_status.id)
|
||||
expect(subject).to include(remote_status.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with an account passed in' do
|
||||
subject { described_class.new(@account).get(20).map(&:id) }
|
||||
|
||||
before do
|
||||
@account = Fabricate(:account)
|
||||
end
|
||||
|
||||
subject { described_class.new(@account).get(20).map(&:id) }
|
||||
|
||||
it 'excludes statuses from accounts blocked by the account' do
|
||||
blocked = Fabricate(:account)
|
||||
@account.block!(blocked)
|
||||
blocked_status = Fabricate(:status, account: blocked)
|
||||
|
||||
expect(subject).not_to include(blocked_status.id)
|
||||
expect(subject).to_not include(blocked_status.id)
|
||||
end
|
||||
|
||||
it 'excludes statuses from accounts who have blocked the account' do
|
||||
@@ -216,7 +218,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
blocker.block!(@account)
|
||||
blocked_status = Fabricate(:status, account: blocker)
|
||||
|
||||
expect(subject).not_to include(blocked_status.id)
|
||||
expect(subject).to_not include(blocked_status.id)
|
||||
end
|
||||
|
||||
it 'excludes statuses from accounts muted by the account' do
|
||||
@@ -224,7 +226,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
@account.mute!(muted)
|
||||
muted_status = Fabricate(:status, account: muted)
|
||||
|
||||
expect(subject).not_to include(muted_status.id)
|
||||
expect(subject).to_not include(muted_status.id)
|
||||
end
|
||||
|
||||
it 'excludes statuses from accounts from personally blocked domains' do
|
||||
@@ -232,7 +234,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
@account.block_domain!(blocked.domain)
|
||||
blocked_status = Fabricate(:status, account: blocked)
|
||||
|
||||
expect(subject).not_to include(blocked_status.id)
|
||||
expect(subject).to_not include(blocked_status.id)
|
||||
end
|
||||
|
||||
context 'with language preferences' do
|
||||
@@ -244,7 +246,7 @@ RSpec.describe PublicFeed, type: :model do
|
||||
|
||||
expect(subject).to include(en_status.id)
|
||||
expect(subject).to include(es_status.id)
|
||||
expect(subject).not_to include(fr_status.id)
|
||||
expect(subject).to_not include(fr_status.id)
|
||||
end
|
||||
|
||||
it 'includes all languages when user does not have a setting' do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Relay, type: :model do
|
||||
|
||||
@@ -17,7 +17,7 @@ RSpec.describe RemoteFollow do
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||
|
||||
it 'returns acct' do
|
||||
is_expected.to eq 'gargron@quitter.no'
|
||||
expect(subject).to eq 'gargron@quitter.no'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ RSpec.describe RemoteFollow do
|
||||
let(:attrs) { {} }
|
||||
|
||||
it do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -37,7 +37,7 @@ RSpec.describe RemoteFollow do
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||
|
||||
it do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,12 +45,14 @@ RSpec.describe RemoteFollow do
|
||||
let(:attrs) { {} }
|
||||
|
||||
it do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#subscribe_address_for' do
|
||||
subject { remote_follow.subscribe_address_for(account) }
|
||||
|
||||
before do
|
||||
remote_follow.valid?
|
||||
end
|
||||
@@ -58,10 +60,8 @@ RSpec.describe RemoteFollow do
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { remote_follow.subscribe_address_for(account) }
|
||||
|
||||
it 'returns subscribe address' do
|
||||
is_expected.to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
|
||||
expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ReportFilter do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Report do
|
||||
@@ -33,7 +35,7 @@ describe Report do
|
||||
end
|
||||
|
||||
it 'assigns to a given account' do
|
||||
is_expected.to eq current_account.id
|
||||
expect(subject).to eq current_account.id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,7 +50,7 @@ describe Report do
|
||||
end
|
||||
|
||||
it 'unassigns' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Rule, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ScheduledStatus, type: :model do
|
||||
|
||||
@@ -44,7 +44,7 @@ RSpec.describe SessionActivation, type: :model do
|
||||
let(:id) { nil }
|
||||
|
||||
it 'returns nil' do
|
||||
is_expected.to be_nil
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ RSpec.describe SessionActivation, type: :model do
|
||||
|
||||
context 'id exists as session_id' do
|
||||
it 'returns true' do
|
||||
is_expected.to be true
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ RSpec.describe SessionActivation, type: :model do
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be false
|
||||
expect(subject).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ RSpec.describe Setting, type: :model do
|
||||
let(:cache_value) { 'cache-value' }
|
||||
|
||||
it 'calls not RailsSettings::Base#[]' do
|
||||
expect(RailsSettings::Base).not_to receive(:[]).with(key)
|
||||
expect(RailsSettings::Base).to_not receive(:[]).with(key)
|
||||
described_class[key]
|
||||
end
|
||||
|
||||
@@ -104,7 +104,7 @@ RSpec.describe Setting, type: :model do
|
||||
ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
|
||||
described_class[key]
|
||||
end
|
||||
expect(callback).not_to have_received(:call)
|
||||
expect(callback).to_not have_received(:call)
|
||||
end
|
||||
|
||||
it 'returns the cached value' do
|
||||
@@ -163,17 +163,17 @@ RSpec.describe Setting, type: :model do
|
||||
end
|
||||
|
||||
describe '.default_settings' do
|
||||
subject { described_class.default_settings }
|
||||
|
||||
before do
|
||||
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
|
||||
end
|
||||
|
||||
subject { described_class.default_settings }
|
||||
|
||||
context 'RailsSettings::Default.enabled? is false' do
|
||||
let(:enabled) { false }
|
||||
|
||||
it 'returns {}' do
|
||||
is_expected.to eq({})
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -181,7 +181,7 @@ RSpec.describe Setting, type: :model do
|
||||
let(:enabled) { true }
|
||||
|
||||
it 'returns instance of RailsSettings::Default' do
|
||||
is_expected.to be_a RailsSettings::Default
|
||||
expect(subject).to be_a RailsSettings::Default
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe StatusEdit, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe StatusPin, type: :model do
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Status, type: :model do
|
||||
subject { Fabricate(:status, account: alice) }
|
||||
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!') }
|
||||
|
||||
subject { Fabricate(:status, account: alice) }
|
||||
|
||||
describe '#local?' do
|
||||
it 'returns true when no remote URI is set' do
|
||||
expect(subject.local?).to be true
|
||||
@@ -241,11 +243,11 @@ RSpec.describe Status, type: :model do
|
||||
end
|
||||
|
||||
describe '.mutes_map' do
|
||||
subject { Status.mutes_map([status.conversation.id], account) }
|
||||
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { Status.mutes_map([status.conversation.id], account) }
|
||||
|
||||
it 'returns a hash' do
|
||||
expect(subject).to be_a Hash
|
||||
end
|
||||
@@ -257,11 +259,11 @@ RSpec.describe Status, type: :model do
|
||||
end
|
||||
|
||||
describe '.favourites_map' do
|
||||
subject { Status.favourites_map([status], account) }
|
||||
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { Status.favourites_map([status], account) }
|
||||
|
||||
it 'returns a hash' do
|
||||
expect(subject).to be_a Hash
|
||||
end
|
||||
@@ -273,11 +275,11 @@ RSpec.describe Status, type: :model do
|
||||
end
|
||||
|
||||
describe '.reblogs_map' do
|
||||
subject { Status.reblogs_map([status], account) }
|
||||
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { Status.reblogs_map([status], account) }
|
||||
|
||||
it 'returns a hash' do
|
||||
expect(subject).to be_a Hash
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe StatusStat, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe StatusTrend, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SystemKey, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe TagFeed, type: :service do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TagFollow, type: :model do
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Tag do
|
||||
describe 'validations' do
|
||||
it 'invalid with #' do
|
||||
expect(described_class.new(name: '#hello_world')).not_to be_valid
|
||||
expect(described_class.new(name: '#hello_world')).to_not be_valid
|
||||
end
|
||||
|
||||
it 'invalid with .' do
|
||||
expect(described_class.new(name: '.abcdef123')).not_to be_valid
|
||||
expect(described_class.new(name: '.abcdef123')).to_not be_valid
|
||||
end
|
||||
|
||||
it 'invalid with spaces' do
|
||||
expect(described_class.new(name: 'hello world')).not_to be_valid
|
||||
expect(described_class.new(name: 'hello world')).to_not be_valid
|
||||
end
|
||||
|
||||
it 'valid with aesthetic' do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Trends::Statuses do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Trends::Tags do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnavailableDomain, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UserInviteRequest, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UserRole, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require 'devise_two_factor/spec_helpers'
|
||||
|
||||
@@ -46,7 +48,7 @@ RSpec.describe User, type: :model do
|
||||
it 'cleans out empty string from languages' do
|
||||
user = Fabricate.build(:user, chosen_languages: [''])
|
||||
user.valid?
|
||||
expect(user.chosen_languages).to eq nil
|
||||
expect(user.chosen_languages).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,10 +144,10 @@ RSpec.describe User, type: :model do
|
||||
end
|
||||
|
||||
describe '#confirm' do
|
||||
let(:new_email) { 'new-email@example.com' }
|
||||
|
||||
subject { user.confirm }
|
||||
|
||||
let(:new_email) { 'new-email@example.com' }
|
||||
|
||||
before do
|
||||
allow(TriggerWebhookWorker).to receive(:perform_async)
|
||||
end
|
||||
@@ -159,7 +161,7 @@ RSpec.describe User, type: :model do
|
||||
|
||||
it 'does not trigger the account.approved Web Hook' do
|
||||
subject
|
||||
expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id)
|
||||
expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -270,7 +272,7 @@ RSpec.describe User, type: :model do
|
||||
|
||||
it 'does not trigger the account.approved Web Hook' do
|
||||
subject
|
||||
expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id)
|
||||
expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -409,6 +411,7 @@ RSpec.describe User, type: :model do
|
||||
|
||||
describe '#disable!' do
|
||||
subject(:user) { Fabricate(:user, disabled: false, current_sign_in_at: current_sign_in_at, last_sign_in_at: nil) }
|
||||
|
||||
let(:current_sign_in_at) { Time.zone.now }
|
||||
|
||||
before do
|
||||
@@ -497,6 +500,7 @@ RSpec.describe User, type: :model do
|
||||
|
||||
describe '#active_for_authentication?' do
|
||||
subject { user.active_for_authentication? }
|
||||
|
||||
let(:user) { Fabricate(:user, disabled: disabled, confirmed_at: confirmed_at) }
|
||||
|
||||
context 'when user is disabled' do
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Web::PushSubscription, type: :model do
|
||||
subject { described_class.new(data: data) }
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
let(:policy) { 'all' }
|
||||
@@ -19,8 +23,6 @@ RSpec.describe Web::PushSubscription, type: :model do
|
||||
}
|
||||
end
|
||||
|
||||
subject { described_class.new(data: data) }
|
||||
|
||||
describe '#pushable?' do
|
||||
let(:notification_type) { :mention }
|
||||
let(:notification) { Fabricate(:notification, account: account, type: notification_type) }
|
||||
@@ -39,7 +41,7 @@ RSpec.describe Web::PushSubscription, type: :model do
|
||||
let(:policy) { 'all' }
|
||||
|
||||
it 'returns true' do
|
||||
expect(subject.pushable?(notification)).to eq true
|
||||
expect(subject.pushable?(notification)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,7 +49,7 @@ RSpec.describe Web::PushSubscription, type: :model do
|
||||
let(:policy) { 'none' }
|
||||
|
||||
it 'returns false' do
|
||||
expect(subject.pushable?(notification)).to eq false
|
||||
expect(subject.pushable?(notification)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,13 +62,13 @@ RSpec.describe Web::PushSubscription, type: :model do
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
expect(subject.pushable?(notification)).to eq true
|
||||
expect(subject.pushable?(notification)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'and notification is not from someone you follow' do
|
||||
it 'returns false' do
|
||||
expect(subject.pushable?(notification)).to eq false
|
||||
expect(subject.pushable?(notification)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -80,13 +82,13 @@ RSpec.describe Web::PushSubscription, type: :model do
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
expect(subject.pushable?(notification)).to eq true
|
||||
expect(subject.pushable?(notification)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'and notification is not from someone who follows you' do
|
||||
it 'returns false' do
|
||||
expect(subject.pushable?(notification)).to eq false
|
||||
expect(subject.pushable?(notification)).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Web::Setting, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WebauthnCredential, type: :model do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Webhook, type: :model do
|
||||
|
||||
Reference in New Issue
Block a user