• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_describe / 7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

20 Mar 2024 12:42PM UTC coverage: 30.068% (-66.2%) from 96.266%
7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

Pull #1701

circleci

leefaisonr
makes it so that links open in new window
Pull Request #1701: Update language on submission form

1019 of 3389 relevant lines covered (30.07%)

0.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.59
/app/models/background_upload_snapshot.rb
1
# frozen_string_literal: true
2
class BackgroundUploadSnapshot < UploadSnapshot
1✔
3
  def store_files(uploaded_files, pre_existing_files: [], current_user: nil)
1✔
4
    save # needed so I can point to this snapshot in the files to distinguish new files from existing ones froma past snapshot
×
5
    self.files = uploaded_files.map do |file|
×
6
      { "filename" => prefix_filename(file.original_filename),
×
7
        "upload_status" => "started", user_id: current_user&.id, snapshot_id: id }
8
    end
9
    files.concat pre_existing_files if pre_existing_files.present?
×
10
  end
11

12
  def mark_complete(filename, checksum)
1✔
13
    index = files.index { |file| file["filename"] == prefix_filename(filename) }
×
14
    if index.nil?
×
15
      Rails.logger.error("Uploaded a file that was not part of the orginal Upload: #{id} for work #{work_id}: #{filename}")
×
16
      Honeybadger.notify("Uploaded a file that was not part of the orginal Upload: #{id} for work #{work_id}: #{filename}")
×
17
    else
18
      files[index]["upload_status"] = "complete"
×
19
      files[index]["checksum"] = checksum
×
20
    end
21
    finalize_upload if upload_complete?
×
22
    save
×
23
  end
24

25
  def upload_complete?
1✔
26
    files.select { |file| file.keys.include?("upload_status") }.map { |file| file["upload_status"] }.uniq == ["complete"]
×
27
  end
28

29
  def existing_files
1✔
30
    super.select { |file| file["upload_status"].nil? || file["upload_status"] == "complete" }
×
31
  end
32

33
  def new_files
1✔
34
    files.select { |file| file["snapshot_id"] == id }
×
35
  end
36

37
  def finalize_upload
1✔
38
    new_files.each do |file|
×
39
      work.track_change(:added, file["filename"])
×
40
    end
41
    work.log_file_changes(new_files.first["user_id"])
×
42
  end
43

44
  def prefix_filename(filename)
1✔
45
    if filename.include?(work.prefix)
×
46
      filename
×
47
    else
48
      "#{work.prefix}#{filename}"
×
49
    end
50
  end
51
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc