2023-02-22 11:55:31 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-24 05:17:37 +11:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 13:49:53 +10:00
|
|
|
RSpec.describe Favourite do
|
2017-06-19 09:38:50 +10:00
|
|
|
let(:account) { Fabricate(:account) }
|
2016-02-27 01:28:08 +11:00
|
|
|
|
2017-06-19 09:38:50 +10: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
|
2023-06-06 21:58:33 +10:00
|
|
|
described_class.create!(account: account, status: reblog)
|
|
|
|
expect(described_class.new(account: account, status: status).valid?).to be false
|
2017-06-19 09:38:50 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'replaces status with the reblogged one if it is a reblog' do
|
2023-06-06 21:58:33 +10:00
|
|
|
favourite = described_class.create!(account: account, status: status)
|
2017-06-19 09:38:50 +10:00
|
|
|
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
|
2023-06-06 21:58:33 +10:00
|
|
|
favourite = described_class.create!(account: account, status: status)
|
2017-06-19 09:38:50 +10:00
|
|
|
expect(favourite.status).to eq status
|
|
|
|
end
|
|
|
|
end
|
2016-02-24 05:17:37 +11:00
|
|
|
end
|