~cytrogen/masto-fe

ref: 67055b034300393bd9a345bc057e86baa848ae35 masto-fe/spec/models/favourite_spec.rb -rw-r--r-- 987 bytes
67055b03 — Claire Fix import order inconsistencies (#2289) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Favourite 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
      described_class.create!(account: account, status: reblog)
      expect(described_class.new(account: account, status: status).valid?).to be false
    end

    it 'replaces status with the reblogged one if it is a reblog' do
      favourite = described_class.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 = described_class.create!(account: account, status: status)
      expect(favourite.status).to eq status
    end
  end
end