1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-05 10:18:45 +09:00
YuruToot/spec/models/favourite_spec.rb
Akihiko Odaki (@fn_aki@pawoo.net) 05e4728de7 Cover Favourite more (#3841)
2017-06-19 01:38:50 +02:00

30 lines
946 B
Ruby

require 'rails_helper'
RSpec.describe Favourite, type: :model do
let(:account) { Fabricate(:account) }
context 'when status is a reblog' do
let(:reblog) { Fabricate(:status, reblog: nil) }
let(:status) { Fabricate(:status, reblog: reblog) }
it 'invalidates if the reblogged status is already a favourite' do
Favourite.create!(account: account, status: reblog)
expect(Favourite.new(account: account, status: status).valid?).to eq false
end
it 'replaces status with the reblogged one if it is a reblog' do
favourite = Favourite.create!(account: account, status: status)
expect(favourite.status).to eq reblog
end
end
context 'when status is not a reblog' do
let(:status) { Fabricate(:status, reblog: nil) }
it 'saves with the specified status' do
favourite = Favourite.create!(account: account, status: status)
expect(favourite.status).to eq status
end
end
end