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

pulibrary / pdc_describe / 4250c284-5797-493e-ae72-0031c71662ee

09 Apr 2024 03:40PM UTC coverage: 95.838% (-0.02%) from 95.857%
4250c284-5797-493e-ae72-0031c71662ee

push

circleci

jrgriffiniii
Adding a new policy page to the front of the wizard
fixes #1688

12 of 14 new or added lines in 3 files covered. (85.71%)

1 existing line in 1 file now uncovered.

3247 of 3388 relevant lines covered (95.84%)

210.09 hits per line

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

90.91
/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
24✔
12
    @current_user = current_user
24✔
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?
24✔
20
      Work.find(params[:id])
24✔
21
    else
NEW
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
10✔
31
    work.resource = FormToResourceService.convert(params, work)
10✔
32
    if work.valid_to_draft
10✔
33
      work.draft!(current_user)
9✔
34
    end
35
    work
10✔
36
  end
37

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

46
private
1✔
47

48
  def group_code
1✔
UNCOV
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