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
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validation' do
|
describe 'Validations' do
|
||||||
it 'disallow empty uri for remote status' do
|
context 'with a remote account' do
|
||||||
alice.update(domain: 'example.com')
|
subject { Fabricate.build :status, account: remote_account }
|
||||||
status = Fabricate.build(:status, uri: '', account: alice)
|
|
||||||
expect(status).to model_have_error_on_field(:uri)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user