2023-02-21 19:55:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-23 13:17:37 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Favourite, type: :model do
|
2017-06-18 19:38:50 -04:00
|
|
|
let(:account) { Fabricate(:account) }
|
2016-02-26 09:28:08 -05:00
|
|
|
|
2017-06-18 19:38:50 -04:00
|
|
|
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)
|
2023-02-20 00:14:50 -05:00
|
|
|
expect(Favourite.new(account: account, status: status).valid?).to be false
|
2017-06-18 19:38:50 -04:00
|
|
|
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
|
2016-02-23 13:17:37 -05:00
|
|
|
end
|