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

pulibrary / pdc_describe / cace366a-ffad-45f1-9b60-678e607fa527

14 May 2024 02:21PM UTC coverage: 60.862% (-35.0%) from 95.908%
cace366a-ffad-45f1-9b60-678e607fa527

push

circleci

jrgriffiniii
wip

1 of 3 new or added lines in 2 files covered. (33.33%)

1194 existing lines in 57 files now uncovered.

2076 of 3411 relevant lines covered (60.86%)

22.71 hits per line

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

77.27
/app/services/work_metadata_service.rb
1
# frozen_string_literal: true
2

3
# A place to move the logic to from the work controllers
4
#   Process the parameters and permissions to update a work
5
class WorkMetadataService
1✔
6
  attr_reader :params, :current_user
1✔
7

8
  # @params [User] current_user the user who is currently logged in
9
  # @param [HashWithIndifferentAccess] update_params values to update the work with
10
  def initialize(params:, current_user:)
1✔
11
    @params = params
3✔
12
    @current_user = current_user
3✔
13
  end
14

15
  # creates or finds the work for the new submission form based on the parameters
16
  #
17
  # @returns the new or updated work
18
  def work_for_new_submission
1✔
19
    if params[:id].present?
3✔
20
      Work.find(params[:id])
3✔
21
    else
22
      Work.new(created_by_user_id: current_user.id, group_id: group_code.id)
×
23
    end
24
  end
25

26
  # generates the work for a new submission
27
  #
28
  # @returns the new work
29
  def new_submission
1✔
30
    work = work_for_new_submission
2✔
31
    work.resource = FormToResourceService.convert(params, work)
2✔
32
    if work.valid_to_draft
2✔
33
      work.draft!(current_user)
1✔
34
    end
35
    work
2✔
36
  end
37

38
  def self.file_location_url(work)
1✔
UNCOV
39
    if work.files_location == "file_upload"
×
UNCOV
40
      Rails.application.routes.url_helpers.work_file_upload_path(work)
×
41
    else
UNCOV
42
      Rails.application.routes.url_helpers.work_file_other_path(work)
×
43
    end
44
  end
45

46
private
1✔
47

48
  def group_code
1✔
49
    @group_code ||= Group.find_by(code: params[:group_code]) || current_user.default_group
×
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