• 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

0.0
/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
×
6
  attr_reader :params, :current_user
×
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:)
×
11
    @params = params
×
12
    @current_user = current_user
×
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
×
19
    if params[:id].present?
×
20
      Work.find(params[:id])
×
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
×
30
    work = work_for_new_submission
×
31
    work.resource = FormToResourceService.convert(params, work)
×
32
    if work.valid_to_draft
×
33
      work.draft!(current_user)
×
34
    end
×
35
    work
×
36
  end
×
37

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

46
private
×
47

48
  def group_code
×
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