Merge remote-tracking branch 'parent/main' into upstream-20240918
This commit is contained in:
commit
4ce35dd837
188 changed files with 1994 additions and 980 deletions
|
@ -10,10 +10,39 @@ RSpec.describe Account do
|
|||
|
||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||
|
||||
describe '#suspended_locally?' do
|
||||
context 'when the account is not suspended' do
|
||||
it 'returns false' do
|
||||
expect(subject.suspended_locally?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the account is suspended locally' do
|
||||
before do
|
||||
subject.update!(suspended_at: 1.day.ago, suspension_origin: :local)
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
expect(subject.suspended_locally?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the account is suspended remotely' do
|
||||
before do
|
||||
subject.update!(suspended_at: 1.day.ago, suspension_origin: :remote)
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
expect(subject.suspended_locally?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#suspend!' do
|
||||
it 'marks the account as suspended and creates a deletion request' do
|
||||
expect { subject.suspend! }
|
||||
.to change(subject, :suspended?).from(false).to(true)
|
||||
.and change(subject, :suspended_locally?).from(false).to(true)
|
||||
.and(change { AccountDeletionRequest.exists?(account: subject) }.from(false).to(true))
|
||||
end
|
||||
|
||||
|
@ -986,6 +1015,34 @@ RSpec.describe Account do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#attribution_domains_as_text=' do
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
it 'sets attribution_domains accordingly' do
|
||||
subject.attribution_domains_as_text = "hoge.com\nexample.com"
|
||||
|
||||
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||
end
|
||||
|
||||
it 'strips leading "*."' do
|
||||
subject.attribution_domains_as_text = "hoge.com\n*.example.com"
|
||||
|
||||
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||
end
|
||||
|
||||
it 'strips the protocol if present' do
|
||||
subject.attribution_domains_as_text = "http://hoge.com\nhttps://example.com"
|
||||
|
||||
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||
end
|
||||
|
||||
it 'strips a combination of leading "*." and protocol' do
|
||||
subject.attribution_domains_as_text = "http://*.hoge.com\nhttps://*.example.com"
|
||||
|
||||
expect(subject.attribution_domains).to contain_exactly('hoge.com', 'example.com')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Normalizations' do
|
||||
describe 'username' do
|
||||
it { is_expected.to normalize(:username).from(" \u3000bob \t \u00a0 \n ").to('bob') }
|
||||
|
|
43
spec/models/bookmark_spec.rb
Normal file
43
spec/models/bookmark_spec.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Bookmark do
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:account).required }
|
||||
it { is_expected.to belong_to(:status).required }
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :bookmark }
|
||||
|
||||
it { is_expected.to validate_uniqueness_of(:status_id).scoped_to(:account_id) }
|
||||
end
|
||||
|
||||
describe 'Callbacks' do
|
||||
describe 'reblog statuses' do
|
||||
context 'when status is not a reblog' do
|
||||
let(:status) { Fabricate :status }
|
||||
|
||||
it 'keeps status set to assigned value' do
|
||||
bookmark = Fabricate.build :bookmark, status: status
|
||||
|
||||
expect { bookmark.valid? }
|
||||
.to_not change(bookmark, :status)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when status is a reblog' do
|
||||
let(:original) { Fabricate :status }
|
||||
let(:status) { Fabricate :status, reblog: original }
|
||||
|
||||
it 'keeps status set to assigned value' do
|
||||
bookmark = Fabricate.build :bookmark, status: status
|
||||
|
||||
expect { bookmark.valid? }
|
||||
.to change(bookmark, :status).to(original)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -130,4 +130,13 @@ RSpec.describe CustomEmoji, :attachment_processing do
|
|||
it { is_expected.to normalize(:domain).from(nil).to(nil) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :custom_emoji }
|
||||
|
||||
it { is_expected.to validate_uniqueness_of(:shortcode).scoped_to(:domain) }
|
||||
it { is_expected.to validate_length_of(:shortcode).is_at_least(described_class::MINIMUM_SHORTCODE_SIZE) }
|
||||
it { is_expected.to allow_values('cats').for(:shortcode) }
|
||||
it { is_expected.to_not allow_values('@#$@#$', 'X').for(:shortcode) }
|
||||
end
|
||||
end
|
||||
|
|
46
spec/models/list_account_spec.rb
Normal file
46
spec/models/list_account_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ListAccount do
|
||||
describe 'Callbacks to set follows' do
|
||||
context 'when list owner follows account' do
|
||||
let!(:follow) { Fabricate :follow }
|
||||
let(:list) { Fabricate :list, account: follow.account }
|
||||
|
||||
it 'finds and sets the follow with the list account' do
|
||||
list_account = Fabricate :list_account, list: list, account: follow.target_account
|
||||
expect(list_account)
|
||||
.to have_attributes(
|
||||
follow: eq(follow),
|
||||
follow_request: be_nil
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when list owner has a follow request for account' do
|
||||
let!(:follow_request) { Fabricate :follow_request }
|
||||
let(:list) { Fabricate :list, account: follow_request.account }
|
||||
|
||||
it 'finds and sets the follow request with the list account' do
|
||||
list_account = Fabricate :list_account, list: list, account: follow_request.target_account
|
||||
expect(list_account)
|
||||
.to have_attributes(
|
||||
follow: be_nil,
|
||||
follow_request: eq(follow_request)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when list owner is the account' do
|
||||
it 'does not set follow or follow request' do
|
||||
list_account = Fabricate :list_account
|
||||
expect(list_account)
|
||||
.to have_attributes(
|
||||
follow: be_nil,
|
||||
follow_request: be_nil
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PreviewCard do
|
||||
describe 'file size limit', :attachment_processing do
|
||||
it 'is set differently whether vips is enabled or not' do
|
||||
expect(described_class::LIMIT).to eq(Rails.configuration.x.use_vips ? 8.megabytes : 2.megabytes)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
describe 'urls' do
|
||||
it 'allows http schemes' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue