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

pulibrary / pdc_describe / 9091a1ae-29be-458c-984a-339d213919c4

12 Dec 2024 07:41PM UTC coverage: 26.434% (-69.7%) from 96.113%
9091a1ae-29be-458c-984a-339d213919c4

Pull #2000

circleci

jrgriffiniii
Removing integration with ActiveStorage
Pull Request #2000: Bump actionpack from 7.2.1.1 to 7.2.2.1

945 of 3575 relevant lines covered (26.43%)

0.35 hits per line

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

34.29
/app/models/readme.rb
1
# frozen_string_literal: true
2
class Readme
1✔
3
  attr_reader :work, :current_user
1✔
4

5
  def initialize(work, current_user)
1✔
6
    @work = work
×
7
    @current_user = current_user
×
8
  end
9

10
  def attach(readme_file_param)
1✔
11
    return "A README file is required!" if readme_file_param.blank? && blank?
×
12
    return nil if readme_file_param.blank?
×
13
    remove_old_readme
×
14

15
    key = upload_readme(readme_file_param)
×
16
    if key
×
17
      @file_names = [readme_file_param.original_filename]
×
18
      @s3_readme_idx = 0
×
19
      log_changes
×
20
      nil
21
    else
22
      "An error uploading your README was encountered.  Please try again."
×
23
    end
24
  end
25

26
  def blank?
1✔
27
    s3_readme_idx.nil?
×
28
  end
29

30
  def file_name
1✔
31
    return nil if blank?
×
32
    file_names[s3_readme_idx]
×
33
  end
34

35
    private
1✔
36

37
      def s3_readme_idx
1✔
38
        @s3_readme_idx ||= file_names.find_index { |file_name| file_name.upcase.include?("README") }
×
39
      end
40

41
      def file_names
1✔
42
        @file_names ||= work.pre_curation_uploads.map(&:filename_display)
×
43
      end
44

45
      def remove_old_readme
1✔
46
        return if blank?
×
47
        work.s3_query_service.delete_s3_object(work.pre_curation_uploads[s3_readme_idx].key)
×
48
      end
49

50
      def upload_readme(readme_file_param)
1✔
51
        readme_name = readme_file_param.original_filename
×
52
        size = readme_file_param.size
×
53
        work.s3_query_service.upload_file(io: readme_file_param.to_io, filename: readme_name, size:)
×
54
      end
55

56
      def log_changes
1✔
57
        work.s3_query_service.client_s3_files(reload: true)
×
58
        work.reload_snapshots(user_id: current_user.id)
×
59
      end
60
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