mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Augment coverage for Status
model (#32468)
This commit is contained in:
parent
d8eab3d81f
commit
cc70acc11c
@ -472,11 +472,53 @@ RSpec.describe Status do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
it 'disallow empty uri for remote status' do
|
||||
alice.update(domain: 'example.com')
|
||||
status = Fabricate.build(:status, uri: '', account: alice)
|
||||
expect(status).to model_have_error_on_field(:uri)
|
||||
describe 'Validations' do
|
||||
context 'with a remote account' do
|
||||
subject { Fabricate.build :status, account: remote_account }
|
||||
|
||||
let(:remote_account) { Fabricate :account, domain: 'example.com' }
|
||||
|
||||
it { is_expected.to_not allow_value('').for(:uri) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Callbacks' do
|
||||
describe 'Stripping content when required' do
|
||||
context 'with a remote account' do
|
||||
subject { Fabricate.build :status, local: false, account:, text: ' text ', spoiler_text: ' spoiler ' }
|
||||
|
||||
let(:account) { Fabricate.build :account, domain: 'host.example' }
|
||||
|
||||
it 'preserves content' do
|
||||
expect { subject.valid? }
|
||||
.to not_change(subject, :text)
|
||||
.and not_change(subject, :spoiler_text)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a local account' do
|
||||
let(:account) { Fabricate.build :account, domain: nil }
|
||||
|
||||
context 'with populated fields' do
|
||||
subject { Fabricate.build :status, local: true, account:, text: ' text ', spoiler_text: ' spoiler ' }
|
||||
|
||||
it 'strips content' do
|
||||
expect { subject.valid? }
|
||||
.to change(subject, :text).to('text')
|
||||
.and change(subject, :spoiler_text).to('spoiler')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with empty fields' do
|
||||
subject { Fabricate.build :status, local: true, account:, text: nil, spoiler_text: nil }
|
||||
|
||||
it 'preserves content' do
|
||||
expect { subject.valid? }
|
||||
.to not_change(subject, :text)
|
||||
.and not_change(subject, :spoiler_text)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user