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

pulibrary / pdc_describe / d9f86608-3df2-4f43-8850-71459996c82b

25 Mar 2024 12:07PM UTC coverage: 30.999% (-65.2%) from 96.206%
d9f86608-3df2-4f43-8850-71459996c82b

Pull #1710

circleci

carolyncole
Separating edit into wizard and non wizard controller methods
Pull Request #1710: Separating wizard new & edit and non wizard new & edit controller methods

956 of 3084 relevant lines covered (31.0%)

0.42 hits per line

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

41.94
/app/decorators/work_decorator.rb
1
# frozen_string_literal: true
2
class WorkDecorator
1✔
3
  include Rails.application.routes.url_helpers
1✔
4

5
  attr_reader :work, :changes, :messages, :can_curate, :current_user
1✔
6

7
  delegate :group, :resource, :draft?, to: :work
1✔
8
  delegate :migrated, to: :resource
1✔
9

10
  def initialize(work, current_user)
1✔
11
    @work = work
×
12
    @current_user = current_user
×
13
    @changes =  WorkActivity.changes_for_work(work.id)
×
14
    @messages = WorkActivity.messages_for_work(work.id).order(created_at: :desc)
×
15
    @can_curate = current_user&.can_admin?(group)
×
16
  end
17

18
  def current_user_is_admin?
1✔
19
    current_user.has_role?(:group_admin, group)
×
20
  end
21

22
  def show_approve_button?
1✔
23
    work.awaiting_approval? && current_user_is_admin?
×
24
  end
25

26
  def show_complete_button?
1✔
27
    draft? && (work.created_by_user_id == current_user.id || current_user_is_admin?)
×
28
  end
29

30
  def show_migrate_button?
1✔
31
    draft? && migrated && current_user_is_admin?
×
32
  end
33

34
  def wizard_mode?
1✔
35
    draft? && !migrated
×
36
  end
37

38
  def file_list_path
1✔
39
    return work_file_list_path("NONE") if @work.nil? || !@work.persisted?
×
40

41
    # This is a horrible hack to work-around the issue where Rails is not adding
42
    # the correct prefix to the URL in production and staging.
43
    if Rails.env.production? || Rails.env.staging?
×
44
      "/describe" + work_file_list_path(@work.id)
×
45
    else
46
      work_file_list_path(@work.id)
×
47
    end
48
  end
49

50
  def download_path
1✔
51
    return if @work.nil? || !@work.persisted?
×
52

53
    if Rails.env.production? || Rails.env.staging?
×
54
      "/describe" + work_download_path(@work.id)
×
55
    else
56
      work_download_path(@work.id)
×
57
    end
58
  end
59
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