|
18 | 18 | let!(:media_volume) { create(:volume, name: "Media-Repository") } |
19 | 19 | let!(:deposit_folder) { create(:isilon_folder, volume: deposit_volume, full_path: "/Deposit/project") } |
20 | 20 | let!(:media_folder) { create(:isilon_folder, volume: media_volume, full_path: "/Media-Repository/project") } |
| 21 | + let(:export_path) { Rails.root.join("log/isilon-duplicate-paths.csv") } |
| 22 | + let(:detect_log_path) { Rails.root.join("log/isilon-duplicates-detect.log") } |
| 23 | + |
| 24 | + after do |
| 25 | + File.delete(export_path) if File.exist?(export_path) |
| 26 | + File.delete(detect_log_path) if File.exist?(detect_log_path) |
| 27 | + end |
21 | 28 |
|
22 | 29 | it "groups assets with matching checksums" do |
23 | 30 | original = create(:isilon_asset, parent_folder: deposit_folder, file_checksum: "abc", file_size: "100") |
|
37 | 44 | expect(IsilonAsset.where(has_duplicates: true).count).to eq(4) |
38 | 45 | expect(IsilonAsset.where(has_duplicates: false).count).to eq(2) |
39 | 46 | end |
| 47 | + |
| 48 | + it "exports child rows with checksum and file size for checksums shared across main and outside volumes" do |
| 49 | + other_volume = create(:volume, name: "Other") |
| 50 | + other_folder = create(:isilon_folder, volume: other_volume, full_path: "/Other/project") |
| 51 | + |
| 52 | + create(:isilon_asset, parent_folder: deposit_folder, isilon_path: "/project/main.txt", isilon_name: "main.txt", file_checksum: "abc", file_size: "100") |
| 53 | + create(:isilon_asset, parent_folder: media_folder, isilon_path: "/project/main2.txt", isilon_name: "main2.txt", file_checksum: "abc", file_size: "100") |
| 54 | + outside_asset = create(:isilon_asset, parent_folder: other_folder, isilon_path: "/project/out.txt", isilon_name: "out.txt", file_checksum: "abc", file_size: "100") |
| 55 | + create(:isilon_asset, parent_folder: other_folder, isilon_path: "/project/solo.txt", isilon_name: "solo.txt", file_checksum: "xyz", file_size: "100") |
| 56 | + |
| 57 | + Rake::Task["duplicates:detect"].invoke |
| 58 | + |
| 59 | + exported = CSV.read(export_path, headers: true) |
| 60 | + child_row = exported.find { |row| row["File"] == "out.txt" } |
| 61 | + solo_row = exported.find { |row| row["File"] == "solo.txt" } |
| 62 | + |
| 63 | + expect(child_row).to be_present |
| 64 | + expect(child_row["Path"]).to eq("/Other/project/out.txt") |
| 65 | + expect(child_row["Checksum"]).to eq("abc") |
| 66 | + expect(child_row["File Size"]).to eq("100") |
| 67 | + expect(exported.find { |row| row["File"] == "main.txt" }).to be_nil |
| 68 | + expect(exported.find { |row| row["File"] == "main2.txt" }).to be_nil |
| 69 | + expect(solo_row).to be_nil |
| 70 | + end |
40 | 71 | end |
41 | 72 |
|
42 | 73 | describe "duplicates:clear" do |
|
0 commit comments