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

pulibrary / pdc_describe / bb6e25f1-bcb9-4f0a-95d4-d5cad8a7f2e4

pending completion
bb6e25f1-bcb9-4f0a-95d4-d5cad8a7f2e4

Pull #1028

circleci

jrgriffiniii
wip
Pull Request #1028: [wip] Implementing the UploadSnapshotsController

45 of 45 new or added lines in 2 files covered. (100.0%)

1897 of 1929 relevant lines covered (98.34%)

174.04 hits per line

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

81.82
/app/controllers/upload_snapshots_controller.rb
1
# frozen_string_literal: true
2
class UploadSnapshotsController < ApplicationController
1✔
3
  # POST /upload-snapshots/:work_id
4
  def create
1✔
5
    begin
6
      @upload_snapshot = upload.create_snapshot
2✔
7
      flash[:notice] = "Successfully created the upload snapshot #{@upload_snapshot.uri} for work #{work.id}."
1✔
8
      redirect_to work_path(work)
1✔
9
    rescue StandardError => error
1✔
10
      error_message = "Failed to create the upload snapshot: #{error}"
1✔
11
      Rails.logger.error(error_message)
1✔
12
      flash[:notice] = error_message
1✔
13

14
      redirect_to works_path
1✔
15
    end
16

17
  end
18

19
  # DELETE /upload-snapshots/:id
20
  def destroy
1✔
21
    current_work = upload_snapshot.work
1✔
22
    upload_snapshot_uri = upload_snapshot.uri
1✔
23
    upload_snapshot.destroy
1✔
24
    flash[:notice] = "Successfully deleted the upload snapshot #{upload_snapshot_uri}."
1✔
25

26
    redirect_to work_path(current_work)
1✔
27
  rescue UploadSnapshot::NotFoundError => not_found_error
28
    error_message = "Failed to delete the upload snapshot: #{not_found_error}"
×
29
    Rails.logger.error(error_message)
×
30
    flash[:notice] = error_message
×
31

32
    redirect_to works_path
×
33
  rescue StandardError => error
34
    error_message = "Failed to delete the upload snapshot: #{error}"
×
35
    Rails.logger.error(error_message)
×
36
    flash[:notice] = error_message
×
37

38
    redirect_to work_path(current_work)
×
39
  end
40

41
  private
1✔
42

43
    def upload_snapshot_id
1✔
44
      @upload_snapshot_id = params[:id]
4✔
45
      raise(ArgumentError, "No ID provided for the upload snapshot.") unless @upload_snapshot_id
4✔
46

47
      @upload_snapshot_id
4✔
48
    end
49

50
    def upload_snapshot
1✔
51
      return unless upload_snapshot_id
3✔
52

53
      @upload_snapshot ||= UploadSnapshot.find(upload_snapshot_id)
3✔
54
    end
55

56
    def work_id
1✔
57
      @work_id = params[:work_id]
2✔
58
      raise(ArgumentError, "No ID provided for the work.") unless @work_id
2✔
59

60
      @work_id
2✔
61
    end
62

63
    def uri
1✔
64
      @uri = params[:uri]
1✔
65
      raise(ArgumentError, "No URI provided for the file upload.") unless @uri
1✔
66

67
      @uri
1✔
68
    end
69

70
    def work
1✔
71
      @work ||= Work.find(work_id)
4✔
72
    end
73

74
    def upload
1✔
75
      work.uploads.find { |s3_file| uri.include?(s3_file.url) }
3✔
76
    end
77
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