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

pulibrary / pdc_describe / c0e87805-f6a1-49a6-bff2-ecd1f2371edf

26 Mar 2024 05:45PM UTC coverage: 95.523% (-0.6%) from 96.167%
c0e87805-f6a1-49a6-bff2-ecd1f2371edf

Pull #1715

circleci

carolyncole
Split out the work wizard into its own controller
refs #1684
Pull Request #1715: Split out the work wizard into its own controller

133 of 143 new or added lines in 3 files covered. (93.01%)

16 existing lines in 1 file now uncovered.

3222 of 3373 relevant lines covered (95.52%)

203.36 hits per line

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

77.27
/app/controllers/application_controller.rb
1
# frozen_string_literal: true
2
class ApplicationController < ActionController::Base
1✔
3
  # This is necessary only for localhost development, with storage configured for the filesystem,
4
  # but it shouldn't cause problems in other environments that use S3.
5
  # Including this concern lets the disk service generate URLs using
6
  # the same host, protocol, and port as the current request.
7
  include ActiveStorage::SetCurrent
1✔
8

9
  protect_from_forgery with: :exception
1✔
10
  before_action :authenticate_user!
1✔
11

12
  def new_session_path(_scope)
1✔
13
    new_user_session_path
×
14
  end
15

16
  # Take all the errors from the exception and the work and combine them into a single error message that can be shown to the user
17
  #
18
  # @param [AASM::InvalidTransition] aasm_error Error thrown by trying to transition states
19
  # @param [Work] work The work that had the issue
20
  #
21
  # @return [String] a combined error message for the work and transition error
22
  #
23
  def message_from_assm_error(aasm_error:, work:)
1✔
24
    message = aasm_error.message
2✔
25
    if work.errors.count > 0
2✔
26
      message = work.errors.to_a.join(", ")
2✔
27
    end
28
    message.chop! if message.last == "."
2✔
29
    message
2✔
30
  end
31

32
  # Validates that the current user can modify the work
33
  #
34
  # @params [Work] work the work to be modifed
35
  # @params [String] uneditable_message message to send to honey bandger about the work not being editable by the user
36
  # @params [String] current_state_message message to send to honey bandger about the work not being editable in the current state
37
  #
38
  # @returns false if an error occured
39
  #
40
  def validate_modification_permissions(work:, uneditable_message:, current_state_message:)
1✔
41
    no_error = false
15✔
42
    if current_user.blank? || !work.editable_by?(current_user)
15✔
NEW
43
      Honeybadger.notify(uneditable_message)
×
NEW
44
      redirect_to root_path, notice: I18n.t("works.uneditable.privs")
×
45
    elsif !work.editable_in_current_state?(current_user)
15✔
NEW
46
      Honeybadger.notify(current_state_message)
×
NEW
47
      redirect_to root_path, notice: I18n.t("works.uneditable.approved")
×
48
    else
49
      no_error = true
15✔
50
    end
51

52
    no_error
15✔
53
  end
54
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