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

pulibrary / pdc_describe / 00dac745-55d3-4397-95bf-de4f70881e93

pending completion
00dac745-55d3-4397-95bf-de4f70881e93

Pull #995

circleci

Hector Correa
Add tests for new logic
Pull Request #995: Handles external user ids

8 of 8 new or added lines in 1 file covered. (100.0%)

936 of 1902 relevant lines covered (49.21%)

9.91 hits per line

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

66.67
/app/models/s3_file.rb
1
# frozen_string_literal: true
2
class S3File
1✔
3
  include Rails.application.routes.url_helpers
1✔
4

5
  attr_accessor :filename, :last_modified, :size, :checksum, :url
1✔
6
  alias key filename
1✔
7
  alias id filename
1✔
8

9
  def initialize(filename:, last_modified:, size:, checksum:, work:)
1✔
10
    @filename = filename
24✔
11
    @last_modified = last_modified
24✔
12
    @size = size
24✔
13
    @checksum = checksum.delete('"')
24✔
14
    @url = work_download_path(work, filename: filename)
24✔
15
  end
16

17
  def created_at
1✔
18
    last_modified
10✔
19
  end
20

21
  def byte_size
1✔
22
    size
×
23
  end
24

25
  def globus_url
1✔
26
    encoded_filename = filename.split("/").map { |name| ERB::Util.url_encode(name) }.join("/")
60✔
27
    File.join(Rails.configuration.globus["post_curation_base_url"], encoded_filename)
12✔
28
  end
29

30
  def to_blob
1✔
31
    existing_blob = ActiveStorage::Blob.find_by(key: filename)
×
32

33
    if existing_blob.present?
×
34
      Rails.logger.warn("There is a blob existing for #{filename}, which we are not expecting!  It will be reattached #{existing_blob.inspect}")
×
35
      return existing_blob
×
36
    end
37

38
    params = { filename: filename, content_type: "", byte_size: size, checksum: checksum }
×
39
    blob = ActiveStorage::Blob.create_before_direct_upload!(**params)
×
40
    blob.key = filename
×
41
    blob
×
42
  end
43
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