|
14 | 14 |
|
15 | 15 | it "produces new copies" do |
16 | 16 | expect(@book.copies).to be_empty |
17 | | - @book.sync_copies |
| 17 | + @book.sync_copies(LibrarySystem::MINUTEMAN) |
18 | 18 | expect(@book.copies.length).to eq(2) |
19 | 19 | expect(@book.copies.map(&:title)).to eq([@book.title, @book.title]) |
20 | 20 | end |
|
23 | 23 | create(:location, name: "Main", library_system_id: LibrarySystem::MINUTEMAN.id) |
24 | 24 |
|
25 | 25 | expect(Location.count).to eq(1) |
26 | | - @book.sync_copies |
| 26 | + @book.sync_copies(LibrarySystem::MINUTEMAN) |
27 | 27 | expect(Location.count).to eq(2) |
28 | 28 | expect(Location.pluck(:name)).to eq(["Main", "Concord"]) |
29 | 29 | end |
|
33 | 33 | copy = create(:copy, book: @book, call_number: "ABC", title: @book.title, status: "Out", location: location) |
34 | 34 |
|
35 | 35 | expect(@book.copies.length).to eq(1) |
36 | | - @book.sync_copies |
| 36 | + @book.sync_copies(LibrarySystem::MINUTEMAN) |
37 | 37 | expect(@book.reload.copies.length).to eq(2) |
38 | 38 | expect(copy.reload.status).to eq("In") |
39 | 39 | end |
|
43 | 43 | copy = create(:copy, book: @book, call_number: "ABC", title: @book.title, status: "Out", location: location, last_synced_at: 1.day.ago) |
44 | 44 |
|
45 | 45 | expect(@book.copies.length).to eq(1) |
46 | | - @book.sync_copies |
| 46 | + @book.sync_copies(LibrarySystem::MINUTEMAN) |
47 | 47 | expect(@book.reload.copies.length).to eq(2) |
48 | 48 | expect(@book.copies).to_not include(copy) |
49 | 49 | end |
| 50 | + |
| 51 | + it "only deletes copies no longer found for the passed library system" do |
| 52 | + location = create(:location, name: "Somewhere Else", library_system_id: LibrarySystem::MINUTEMAN.id) |
| 53 | + copy = create(:copy, book: @book, call_number: "ABC", title: @book.title, status: "Out", location: location, last_synced_at: 1.day.ago) |
| 54 | + |
| 55 | + expect(@book.copies.length).to eq(1) |
| 56 | + @book.sync_copies(LibrarySystem::BOSTON) |
| 57 | + expect(@book.reload.copies.length).to eq(1) |
| 58 | + expect(@book.copies).to include(copy) |
| 59 | + end |
50 | 60 | end |
51 | 61 | end |
0 commit comments