1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/spec/models/favourite_spec.rb

32 lines
987 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Favourite do
2017-06-18 16:38:50 -07:00
let(:account) { Fabricate(:account) }
2016-02-26 06:28:08 -08:00
2017-06-18 16:38:50 -07: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
described_class.create!(account: account, status: reblog)
expect(described_class.new(account: account, status: status).valid?).to be false
2017-06-18 16:38:50 -07:00
end
it 'replaces status with the reblogged one if it is a reblog' do
favourite = described_class.create!(account: account, status: status)
2017-06-18 16:38:50 -07: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
favourite = described_class.create!(account: account, status: status)
2017-06-18 16:38:50 -07:00
expect(favourite.status).to eq status
end
end
end