…lines 1–43 unchanged (43 lines)
44 context 'when the collection item is inlined' do
45 let(:object) { featured_item_json }
46
47 it_behaves_like 'non-matching URIs'
48
49 context 'when item does not yet exist' do
50 context 'when a position is given' do
51 it 'creates and verifies the item' do
52 expect { subject.call(collection, object, position:) }.to change(collection.collection_items, :count).by(1)
53
54 expect(stubbed_service).to have_received(:call)
55
56 new_item = collection.collection_items.last
57 expect(new_item.object_uri).to eq 'https://example.com/actor/1'
58 expect(new_item.approval_uri).to be_nil
59 expect(new_item.position).to eq 3
60 end
61 end
62
63 context 'when no position is given' do
64 it 'creates the item' do
65 expect { subject.call(collection, object) }.to change(collection.collection_items, :count).by(1)
66 new_item = collection.collection_items.last
67
68 expect(new_item.position).to eq 1
69 end
70 end
71 end
72
73 context 'when item exists at a different position' do
74 let!(:collection_item) do
75 Fabricate(:collection_item, collection:, uri: featured_item_json['id'], position: 2)
76 end
77
…lines 78–127 unchanged (50 lines)