collection_spec.rb 728 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
require 'rails_helper'

RSpec.describe Collection, type: :model do
  describe 'creation' do
    let(:collection) { create(:collection) }

    it 'is possible to create a valid collection' do
      expect(collection.valid?).to be(true)
    end
  end

  describe 'scopes' do
13
14
    let(:collection_1) { create(:collection, is_shared: false) }
    let(:collection_2) { create(:collection, is_shared: true) }
15

16
    describe 'shared scope' do
17
18
19
20
      it 'returns shared collections' do
        expect(Collection.shared).to match_array [collection_2]
      end
    end
21
22
23
24
25
26

    describe 'unshared scope' do
      it 'returns unshared collections' do
        expect(Collection.unshared).to match_array [collection_1]
      end
    end
27
28
  end
end