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

pulibrary / pdc_describe / 31a62f9e-3a5b-4033-a3e3-effd2d651737

pending completion
31a62f9e-3a5b-4033-a3e3-effd2d651737

Pull #962

circleci

Hector Correa
Fixes tests for S3 query service (and a couple of code duplications from a merge?)
Pull Request #962: Fetch pre-curation files from directly from AWS

35 of 35 new or added lines in 4 files covered. (100.0%)

1821 of 1864 relevant lines covered (97.69%)

149.32 hits per line

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

96.43
/app/models/s3_file.rb
1
# frozen_string_literal: true
2
class S3File
1✔
3
  attr_accessor :filename, :last_modified, :size, :checksum
1✔
4
  alias key filename
1✔
5
  alias id filename
1✔
6

7
  def initialize(filename:, last_modified:, size:, checksum:, query_service: nil)
1✔
8
    @filename = filename
57✔
9
    @last_modified = last_modified
57✔
10
    @size = size
57✔
11
    @checksum = checksum.delete('"')
57✔
12
    @query_service = query_service
57✔
13
  end
14

15
  def created_at
1✔
16
    last_modified
1✔
17
  end
18

19
  def byte_size
1✔
20
    size
×
21
  end
22

23
  def url
1✔
24
    @query_service.file_url(key)
7✔
25
  end
26

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

32
  def to_blob
1✔
33
    existing_blob = ActiveStorage::Blob.find_by(key: filename)
2✔
34

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

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