This repository has been archived on 2019-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/spec/models/favourite_spec.rb

30 lines
946 B
Ruby
Raw Normal View History

require 'rails_helper'
RSpec.describe Favourite, type: :model do
2017-06-18 23:38:50 +00:00
let(:account) { Fabricate(:account) }
2016-02-26 14:28:08 +00:00
2017-06-18 23:38:50 +00: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)
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