Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `.github/dependabot.yml`:
  Upstream made changes while we have dropped this file.
  Keep the file deleted.
- `.prettierignore`:
  Upstream made changes at the end of the file, where we
  had our extra lines.
  Just moved our extra lines back at the end.
- `app/serializers/initial_state_serializer.rb`:
  Upstream code style changes.
  Applied them.
- `app/services/backup_service.rb`:
  Upstream code style changes.
  Applied them.
This commit is contained in:
Claire
2023-02-19 10:42:55 +01:00
391 changed files with 6713 additions and 3145 deletions

View File

@@ -97,7 +97,7 @@ RSpec.describe Account::Field, type: :model do
expect(subject.verifiable?).to be false
end
end
context 'for text which is blank' do
let(:value) { '' }
@@ -149,7 +149,7 @@ RSpec.describe Account::Field, type: :model do
expect(subject.verifiable?).to be false
end
end
context 'for text which is blank' do
let(:value) { '' }

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
RSpec.describe AccountAlias, type: :model do
end

View File

@@ -3,6 +3,7 @@ require 'rails_helper'
RSpec.describe Account, type: :model do
context do
let(:bob) { Fabricate(:account, username: 'bob') }
subject { Fabricate(:account) }
describe '#suspend!' do
@@ -344,9 +345,9 @@ RSpec.describe Account, type: :model do
before do
_missing = Fabricate(
:account,
display_name: "Missing",
username: "missing",
domain: "missing.com"
display_name: 'Missing',
username: 'missing',
domain: 'missing.com'
)
end
@@ -404,58 +405,58 @@ RSpec.describe Account, type: :model do
it 'finds accounts with matching display_name' do
match = Fabricate(
:account,
display_name: "Display Name",
username: "username",
domain: "example.com"
display_name: 'Display Name',
username: 'username',
domain: 'example.com'
)
results = Account.search_for("display")
results = Account.search_for('display')
expect(results).to eq [match]
end
it 'finds accounts with matching username' do
match = Fabricate(
:account,
display_name: "Display Name",
username: "username",
domain: "example.com"
display_name: 'Display Name',
username: 'username',
domain: 'example.com'
)
results = Account.search_for("username")
results = Account.search_for('username')
expect(results).to eq [match]
end
it 'finds accounts with matching domain' do
match = Fabricate(
:account,
display_name: "Display Name",
username: "username",
domain: "example.com"
display_name: 'Display Name',
username: 'username',
domain: 'example.com'
)
results = Account.search_for("example")
results = Account.search_for('example')
expect(results).to eq [match]
end
it 'limits by 10 by default' do
11.times.each { Fabricate(:account, display_name: "Display Name") }
results = Account.search_for("display")
11.times.each { Fabricate(:account, display_name: 'Display Name') }
results = Account.search_for('display')
expect(results.size).to eq 10
end
it 'accepts arbitrary limits' do
2.times.each { Fabricate(:account, display_name: "Display Name") }
results = Account.search_for("display", limit: 1)
2.times.each { Fabricate(:account, display_name: 'Display Name') }
results = Account.search_for('display', limit: 1)
expect(results.size).to eq 1
end
it 'ranks multiple matches higher' do
matches = [
{ username: "username", display_name: "username" },
{ display_name: "Display Name", username: "username", domain: "example.com" },
{ username: 'username', display_name: 'username' },
{ display_name: 'Display Name', username: 'username', domain: 'example.com' },
].map(&method(:Fabricate).curry(2).call(:account))
results = Account.search_for("username")
results = Account.search_for('username')
expect(results).to eq matches
end
end
@@ -581,23 +582,23 @@ RSpec.describe Account, type: :model do
end
it 'limits by 10 by default' do
11.times { Fabricate(:account, display_name: "Display Name") }
results = Account.advanced_search_for("display", account)
11.times { Fabricate(:account, display_name: 'Display Name') }
results = Account.advanced_search_for('display', account)
expect(results.size).to eq 10
end
it 'accepts arbitrary limits' do
2.times { Fabricate(:account, display_name: "Display Name") }
results = Account.advanced_search_for("display", account, limit: 1)
2.times { Fabricate(:account, display_name: 'Display Name') }
results = Account.advanced_search_for('display', account, limit: 1)
expect(results.size).to eq 1
end
it 'ranks followed accounts higher' do
match = Fabricate(:account, username: "Matching")
followed_match = Fabricate(:account, username: "Matcher")
match = Fabricate(:account, username: 'Matching')
followed_match = Fabricate(:account, username: 'Matcher')
Fabricate(:follow, account: account, target_account: followed_match)
results = Account.advanced_search_for("match", account)
results = Account.advanced_search_for('match', account)
expect(results).to eq [followed_match, match]
expect(results.first.rank).to be > results.last.rank
end

View File

@@ -16,16 +16,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
context 'when widening a policy' do
let!(:account_statuses_cleanup_policy) do
Fabricate(:account_statuses_cleanup_policy,
account: account,
keep_direct: true,
keep_pinned: true,
keep_polls: true,
keep_media: true,
keep_self_fav: true,
keep_self_bookmark: true,
min_favs: 1,
min_reblogs: 1
)
account: account,
keep_direct: true,
keep_pinned: true,
keep_polls: true,
keep_media: true,
keep_self_fav: true,
keep_self_bookmark: true,
min_favs: 1,
min_reblogs: 1)
end
before do
@@ -35,77 +34,76 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
it 'invalidates last_inspected when widened because of keep_direct' do
account_statuses_cleanup_policy.keep_direct = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_pinned' do
account_statuses_cleanup_policy.keep_pinned = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_polls' do
account_statuses_cleanup_policy.keep_polls = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_media' do
account_statuses_cleanup_policy.keep_media = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_self_fav' do
account_statuses_cleanup_policy.keep_self_fav = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of keep_self_bookmark' do
account_statuses_cleanup_policy.keep_self_bookmark = false
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of higher min_favs' do
account_statuses_cleanup_policy.min_favs = 5
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of disabled min_favs' do
account_statuses_cleanup_policy.min_favs = nil
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of higher min_reblogs' do
account_statuses_cleanup_policy.min_reblogs = 5
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
it 'invalidates last_inspected when widened because of disable min_reblogs' do
account_statuses_cleanup_policy.min_reblogs = nil
account_statuses_cleanup_policy.save
expect(account_statuses_cleanup_policy.last_inspected).to be nil
expect(account_statuses_cleanup_policy.last_inspected).to be_nil
end
end
context 'when narrowing a policy' do
let!(:account_statuses_cleanup_policy) do
Fabricate(:account_statuses_cleanup_policy,
account: account,
keep_direct: false,
keep_pinned: false,
keep_polls: false,
keep_media: false,
keep_self_fav: false,
keep_self_bookmark: false,
min_favs: nil,
min_reblogs: nil
)
account: account,
keep_direct: false,
keep_pinned: false,
keep_polls: false,
keep_media: false,
keep_self_fav: false,
keep_self_bookmark: false,
min_favs: nil,
min_reblogs: nil)
end
it 'does not unnecessarily invalidate last_inspected' do
@@ -136,6 +134,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
describe '#invalidate_last_inspected' do
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
@@ -232,7 +231,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
end
describe '#compute_cutoff_id' do
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
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 }

View File

@@ -101,7 +101,7 @@ describe AccountInteractions do
describe '#follow!' do
it 'creates and returns Follow' do
expect do
expect(account.follow!(target_account)).to be_kind_of Follow
expect(account.follow!(target_account)).to be_a Follow
end.to change { account.following.count }.by 1
end
end
@@ -109,7 +109,7 @@ describe AccountInteractions do
describe '#block' do
it 'creates and returns Block' do
expect do
expect(account.block!(target_account)).to be_kind_of Block
expect(account.block!(target_account)).to be_a Block
end.to change { account.block_relationships.count }.by 1
end
end
@@ -123,7 +123,7 @@ describe AccountInteractions do
it 'creates Mute, and returns Mute' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.to change { account.mute_relationships.count }.by 1
end
end
@@ -133,7 +133,7 @@ describe AccountInteractions do
it 'creates Mute, and returns Mute' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.to change { account.mute_relationships.count }.by 1
end
end
@@ -143,7 +143,7 @@ describe AccountInteractions do
it 'creates Mute, and returns Mute' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.to change { account.mute_relationships.count }.by 1
end
end
@@ -169,7 +169,7 @@ describe AccountInteractions do
it 'returns Mute without updating mute.hide_notifications' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.not_to change { mute.reload.hide_notifications? }.from(true)
end
end
@@ -179,7 +179,7 @@ describe AccountInteractions do
it 'returns Mute, and updates mute.hide_notifications false' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.to change { mute.reload.hide_notifications? }.from(true).to(false)
end
end
@@ -189,7 +189,7 @@ describe AccountInteractions do
it 'returns Mute without updating mute.hide_notifications' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.not_to change { mute.reload.hide_notifications? }.from(true)
end
end
@@ -203,7 +203,7 @@ describe AccountInteractions do
it 'returns Mute, and updates mute.hide_notifications true' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.to change { mute.reload.hide_notifications? }.from(false).to(true)
end
end
@@ -213,7 +213,7 @@ describe AccountInteractions do
it 'returns Mute without updating mute.hide_notifications' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.not_to change { mute.reload.hide_notifications? }.from(false)
end
end
@@ -223,7 +223,7 @@ describe AccountInteractions do
it 'returns Mute, and updates mute.hide_notifications true' do
expect do
expect(subject).to be_kind_of Mute
expect(subject).to be_a Mute
end.to change { mute.reload.hide_notifications? }.from(false).to(true)
end
end
@@ -238,7 +238,7 @@ describe AccountInteractions do
it 'creates and returns ConversationMute' do
expect do
is_expected.to be_kind_of ConversationMute
is_expected.to be_a ConversationMute
end.to change { account.conversation_mutes.count }.by 1
end
end
@@ -250,7 +250,7 @@ describe AccountInteractions do
it 'creates and returns AccountDomainBlock' do
expect do
is_expected.to be_kind_of AccountDomainBlock
is_expected.to be_a AccountDomainBlock
end.to change { account.domain_blocks.count }.by 1
end
end
@@ -261,7 +261,7 @@ 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_kind_of Follow
is_expected.to be_a Follow
expect(subject).to be_destroyed
end
end
@@ -279,7 +279,7 @@ 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_kind_of Block
is_expected.to be_a Block
expect(subject).to be_destroyed
end
end
@@ -297,7 +297,7 @@ 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_kind_of Mute
is_expected.to be_a Mute
expect(subject).to be_destroyed
end
end
@@ -317,14 +317,14 @@ describe AccountInteractions do
context 'muting the conversation' do
it 'returns destroyed ConversationMute' do
account.conversation_mutes.create(conversation: conversation)
is_expected.to be_kind_of ConversationMute
is_expected.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
is_expected.to be_nil
end
end
end
@@ -338,7 +338,7 @@ describe AccountInteractions 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_kind_of AccountDomainBlock
is_expected.to be_a AccountDomainBlock
expect(subject).to be_destroyed
end
end
@@ -407,7 +407,7 @@ describe AccountInteractions do
subject { account.domain_blocking?(domain) }
context 'blocking the domain' do
it' returns true' 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

View File

@@ -15,7 +15,7 @@ RSpec.describe CustomEmojiFilter do
let(:params) { { local: true } }
it 'returns ActiveRecord::Relation' do
expect(subject).to be_kind_of(ActiveRecord::Relation)
expect(subject).to be_a(ActiveRecord::Relation)
expect(subject).to match_array([custom_emoji_2])
end
end
@@ -24,7 +24,7 @@ RSpec.describe CustomEmojiFilter do
let(:params) { { remote: true } }
it 'returns ActiveRecord::Relation' do
expect(subject).to be_kind_of(ActiveRecord::Relation)
expect(subject).to be_a(ActiveRecord::Relation)
expect(subject).to match_array([custom_emoji_0, custom_emoji_1])
end
end
@@ -33,7 +33,7 @@ RSpec.describe CustomEmojiFilter do
let(:params) { { by_domain: 'a' } }
it 'returns ActiveRecord::Relation' do
expect(subject).to be_kind_of(ActiveRecord::Relation)
expect(subject).to be_a(ActiveRecord::Relation)
expect(subject).to match_array([custom_emoji_0])
end
end
@@ -42,7 +42,7 @@ RSpec.describe CustomEmojiFilter do
let(:params) { { shortcode: 'hoge' } }
it 'returns ActiveRecord::Relation' do
expect(subject).to be_kind_of(ActiveRecord::Relation)
expect(subject).to be_a(ActiveRecord::Relation)
expect(subject).to match_array([custom_emoji_2])
end
end
@@ -62,7 +62,7 @@ RSpec.describe CustomEmojiFilter do
let(:params) { { hoge: nil } }
it 'returns ActiveRecord::Relation' do
expect(subject).to be_kind_of(ActiveRecord::Relation)
expect(subject).to be_a(ActiveRecord::Relation)
expect(subject).to match_array([custom_emoji_0, custom_emoji_1, custom_emoji_2])
end
end

View File

@@ -79,7 +79,7 @@ RSpec.describe CustomEmoji, type: :model do
describe 'pre_validation' do
let(:custom_emoji) { Fabricate(:custom_emoji, domain: 'wWw.MaStOdOn.CoM') }
it 'should downcase' do
it 'downcases' do
custom_emoji.valid?
expect(custom_emoji.domain).to eq('www.mastodon.com')
end

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
RSpec.describe Device, type: :model do
end

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
RSpec.describe EncryptedMessage, type: :model do
end

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
describe Export do
let(:account) { Fabricate(:account) }
let(:target_accounts) do
[ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account))
[{}, { username: 'one', domain: 'local.host' }].map(&method(:Fabricate).curry(2).call(:account))
end
describe 'to_csv' do

View File

@@ -1,9 +1,9 @@
require 'rails_helper'
RSpec.describe Import, type: :model do
let (:account) { Fabricate(:account) }
let (:type) { 'following' }
let (:data) { attachment_fixture('imports.txt') }
let(:account) { Fabricate(:account) }
let(:type) { 'following' }
let(:data) { attachment_fixture('imports.txt') }
describe 'validations' do
it 'has a valid parameters' do

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
RSpec.describe LoginActivity, type: :model do
end

View File

@@ -94,8 +94,8 @@ RSpec.describe MediaAttachment, type: :model do
end
it 'sets meta' do
expect(media.file.meta["original"]["width"]).to eq 128
expect(media.file.meta["original"]["height"]).to eq 128
expect(media.file.meta['original']['width']).to eq 128
expect(media.file.meta['original']['height']).to eq 128
end
end
@@ -118,9 +118,9 @@ RSpec.describe MediaAttachment, type: :model do
end
it 'sets meta' do
expect(media.file.meta["original"]["width"]).to eq fixture[:width]
expect(media.file.meta["original"]["height"]).to eq fixture[:height]
expect(media.file.meta["original"]["aspect"]).to eq fixture[:aspect]
expect(media.file.meta['original']['width']).to eq fixture[:width]
expect(media.file.meta['original']['height']).to eq fixture[:height]
expect(media.file.meta['original']['aspect']).to eq fixture[:aspect]
end
end
end
@@ -154,12 +154,12 @@ RSpec.describe MediaAttachment, type: :model do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }
it 'sets meta for different style' do
expect(media.file.meta["original"]["width"]).to eq 600
expect(media.file.meta["original"]["height"]).to eq 400
expect(media.file.meta["original"]["aspect"]).to eq 1.5
expect(media.file.meta["small"]["width"]).to eq 588
expect(media.file.meta["small"]["height"]).to eq 392
expect(media.file.meta["small"]["aspect"]).to eq 1.5
expect(media.file.meta['original']['width']).to eq 600
expect(media.file.meta['original']['height']).to eq 400
expect(media.file.meta['original']['aspect']).to eq 1.5
expect(media.file.meta['small']['width']).to eq 588
expect(media.file.meta['small']['height']).to eq 392
expect(media.file.meta['small']['aspect']).to eq 1.5
end
it 'gives the file a random name' do

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
RSpec.describe OneTimeKey, type: :model do
end

View File

@@ -7,7 +7,7 @@ RSpec.describe SessionActivation, type: :model do
let(:session_activation) { Fabricate(:session_activation, user_agent: 'Chrome/62.0.3202.89') }
it 'sets a Browser instance as detection' do
expect(session_activation.detection).to be_kind_of Browser::Chrome
expect(session_activation.detection).to be_a Browser::Chrome
end
end
@@ -44,7 +44,7 @@ RSpec.describe SessionActivation, type: :model do
let(:id) { nil }
it 'returns nil' do
is_expected.to be nil
is_expected.to be_nil
end
end
@@ -80,7 +80,7 @@ RSpec.describe SessionActivation, type: :model do
end
it 'returns an instance of SessionActivation' do
expect(described_class.activate(**options)).to be_kind_of SessionActivation
expect(described_class.activate(**options)).to be_a SessionActivation
end
end
@@ -89,7 +89,7 @@ RSpec.describe SessionActivation, type: :model do
let(:id) { nil }
it 'returns nil' do
expect(described_class.deactivate(id)).to be nil
expect(described_class.deactivate(id)).to be_nil
end
end

View File

@@ -127,7 +127,7 @@ RSpec.describe Setting, type: :model do
let(:records) { [original_setting] }
it 'returns a Hash' do
expect(described_class.all_as_records).to be_kind_of Hash
expect(described_class.all_as_records).to be_a Hash
end
context 'records includes Setting with var as the key' do
@@ -146,7 +146,7 @@ RSpec.describe Setting, type: :model do
it 'includes Setting with value of default_value' do
setting = described_class.all_as_records[key]
expect(setting).to be_kind_of Setting
expect(setting).to be_a Setting
expect(setting).to have_attributes(var: key)
expect(setting).to have_attributes(value: 'default_value')
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_kind_of RailsSettings::Default
is_expected.to be_a RailsSettings::Default
end
end
end

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
RSpec.describe SystemKey, type: :model do
end

View File

@@ -76,7 +76,7 @@ RSpec.describe Trends::Statuses do
before do
13.times { reblog(status1, today) }
13.times { reblog(status2, today) }
4.times { reblog(status3, today) }
4.times { reblog(status3, today) }
end
context do

View File

@@ -58,7 +58,7 @@ RSpec.describe UserRole, type: :model do
end
describe '#permissions_as_keys=' do
let(:input) { }
let(:input) {}
before do
subject.permissions_as_keys = input
@@ -127,7 +127,7 @@ RSpec.describe UserRole, type: :model do
subject { described_class.everyone }
it 'returns a role' do
expect(subject).to be_kind_of(described_class)
expect(subject).to be_a(described_class)
end
it 'is identified as the everyone role' do
@@ -139,7 +139,7 @@ RSpec.describe UserRole, type: :model do
end
it 'has negative position' do
expect(subject.position).to eq -1
expect(subject.position).to eq(-1)
end
end
@@ -147,7 +147,7 @@ RSpec.describe UserRole, type: :model do
subject { described_class.nobody }
it 'returns a role' do
expect(subject).to be_kind_of(described_class)
expect(subject).to be_a(described_class)
end
it 'is identified as the nobody role' do
@@ -159,7 +159,7 @@ RSpec.describe UserRole, type: :model do
end
it 'has negative position' do
expect(subject.position).to eq -1
expect(subject.position).to eq(-1)
end
end

View File

@@ -2,6 +2,9 @@ require 'rails_helper'
require 'devise_two_factor/spec_helpers'
RSpec.describe User, type: :model do
let(:password) { 'abcd1234' }
let(:account) { Fabricate(:account, username: 'alice') }
it_behaves_like 'two_factor_backupable'
describe 'otp_secret' do
@@ -96,9 +99,6 @@ RSpec.describe User, type: :model do
end
end
let(:account) { Fabricate(:account, username: 'alice') }
let(:password) { 'abcd1234' }
describe 'blacklist' do
around(:each) do |example|
old_blacklist = Rails.configuration.x.email_blacklist
@@ -110,19 +110,19 @@ RSpec.describe User, type: :model do
Rails.configuration.x.email_domains_blacklist = old_blacklist
end
it 'should allow a non-blacklisted user to be created' do
it 'allows a non-blacklisted user to be created' do
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
expect(user.valid?).to be_truthy
end
it 'should not allow a blacklisted user to be created' do
it 'does not allow a blacklisted user to be created' do
user = User.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
expect(user.valid?).to be_falsey
end
it 'should not allow a subdomain blacklisted user to be created' do
it 'does not allow a subdomain blacklisted user to be created' do
user = User.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
expect(user.valid?).to be_falsey
@@ -285,7 +285,7 @@ RSpec.describe User, type: :model do
it 'saves nil for otp_secret' do
user = Fabricate.build(:user, otp_secret: 'oldotpcode')
user.disable_two_factor!
expect(user.reload.otp_secret).to be nil
expect(user.reload.otp_secret).to be_nil
end
it 'saves cleared otp_backup_codes' do
@@ -313,7 +313,7 @@ RSpec.describe User, type: :model do
describe 'settings' do
it 'is instance of Settings::ScopedSettings' do
user = Fabricate(:user)
expect(user.settings).to be_kind_of Settings::ScopedSettings
expect(user.settings).to be_a Settings::ScopedSettings
end
end
@@ -346,17 +346,17 @@ RSpec.describe User, type: :model do
Rails.configuration.x.email_domains_whitelist = old_whitelist
end
it 'should not allow a user to be created unless they are whitelisted' do
it 'does not allow a user to be created unless they are whitelisted' do
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
expect(user.valid?).to be_falsey
end
it 'should allow a user to be created if they are whitelisted' do
it 'allows a user to be created if they are whitelisted' do
user = User.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
expect(user.valid?).to be_truthy
end
it 'should not allow a user with a whitelisted top domain as subdomain in their email address to be created' do
it 'does not allow a user with a whitelisted top domain as subdomain in their email address to be created' do
user = User.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
expect(user.valid?).to be_falsey
end
@@ -368,7 +368,7 @@ RSpec.describe User, type: :model do
Rails.configuration.x.email_domains_blacklist = old_blacklist
end
it 'should not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do
it 'does not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do
Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space'
user = User.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)

View File

@@ -29,7 +29,7 @@ RSpec.describe Web::PushSubscription, type: :model do
context "when notification is a #{type}" do
let(:notification_type) { type }
it "returns boolean corresponding to alert setting" do
it 'returns boolean corresponding to alert setting' do
expect(subject.pushable?(notification)).to eq data[:alerts][type]
end
end

View File

@@ -35,8 +35,8 @@ RSpec.describe WebauthnCredential, type: :model do
end
it 'is invalid if already exist a webauthn credential with the same external id' do
existing_webauthn_credential = Fabricate(:webauthn_credential, external_id: "_Typ0ygudDnk9YUVWLQayw")
new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: "_Typ0ygudDnk9YUVWLQayw")
existing_webauthn_credential = Fabricate(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
new_webauthn_credential = Fabricate.build(:webauthn_credential, external_id: '_Typ0ygudDnk9YUVWLQayw')
new_webauthn_credential.valid?