mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
Add test for Account#save_with_optional_media! (#5603)
There was a test when some of the properties are invalid, but none when all of them are valid.
This commit is contained in:
parent
d48779cf7b
commit
cf01326cc1
@ -93,23 +93,46 @@ RSpec.describe Account, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#save_with_optional_media!' do
|
describe '#save_with_optional_media!' do
|
||||||
it 'sets default avatar, header, avatar_remote_url, and header_remote_url if some of them are invalid' do
|
before do
|
||||||
stub_request(:get, 'https://remote/valid_avatar').to_return(request_fixture('avatar.txt'))
|
stub_request(:get, 'https://remote/valid_avatar').to_return(request_fixture('avatar.txt'))
|
||||||
stub_request(:get, 'https://remote/invalid_avatar').to_return(request_fixture('feed.txt'))
|
stub_request(:get, 'https://remote/invalid_avatar').to_return(request_fixture('feed.txt'))
|
||||||
account = Fabricate(:account,
|
end
|
||||||
|
|
||||||
|
let(:account) do
|
||||||
|
Fabricate(:account,
|
||||||
avatar_remote_url: 'https://remote/valid_avatar',
|
avatar_remote_url: 'https://remote/valid_avatar',
|
||||||
header_remote_url: 'https://remote/valid_avatar')
|
header_remote_url: 'https://remote/valid_avatar')
|
||||||
|
end
|
||||||
|
|
||||||
|
let!(:expectation) { account.dup }
|
||||||
|
|
||||||
|
context 'with valid properties' do
|
||||||
|
before do
|
||||||
|
account.save_with_optional_media!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'unchanges avatar, header, avatar_remote_url, and header_remote_url' do
|
||||||
|
expect(account.avatar_remote_url).to eq expectation.avatar_remote_url
|
||||||
|
expect(account.header_remote_url).to eq expectation.header_remote_url
|
||||||
|
expect(account.avatar_file_name).to eq expectation.avatar_file_name
|
||||||
|
expect(account.header_file_name).to eq expectation.header_file_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with invalid properties' do
|
||||||
|
before do
|
||||||
account.avatar_remote_url = 'https://remote/invalid_avatar'
|
account.avatar_remote_url = 'https://remote/invalid_avatar'
|
||||||
account.save_with_optional_media!
|
account.save_with_optional_media!
|
||||||
|
end
|
||||||
|
|
||||||
account.reload
|
it 'sets default avatar, header, avatar_remote_url, and header_remote_url' do
|
||||||
expect(account.avatar_remote_url).to eq ''
|
expect(account.avatar_remote_url).to eq ''
|
||||||
expect(account.header_remote_url).to eq ''
|
expect(account.header_remote_url).to eq ''
|
||||||
expect(account.avatar_file_name).to eq nil
|
expect(account.avatar_file_name).to eq nil
|
||||||
expect(account.header_file_name).to eq nil
|
expect(account.header_file_name).to eq nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#subscribed?' do
|
describe '#subscribed?' do
|
||||||
it 'returns false when no subscription expiration information is present' do
|
it 'returns false when no subscription expiration information is present' do
|
||||||
|
Loading…
Reference in New Issue
Block a user