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

pulibrary / pdc_describe / f6611b21-97c8-4b26-99d7-cf711c8aa9c1

21 Mar 2024 04:10PM UTC coverage: 96.206% (-0.03%) from 96.234%
f6611b21-97c8-4b26-99d7-cf711c8aa9c1

push

circleci

jrgriffiniii
Ensures that download URLs for Work assets prepend the "/describe" path
(this fixes an urgent bug in production)

2 of 3 new or added lines in 1 file covered. (66.67%)

3170 of 3295 relevant lines covered (96.21%)

208.55 hits per line

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

93.55
/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
237✔
12
    @current_user = current_user
237✔
13
    @changes =  WorkActivity.changes_for_work(work.id)
237✔
14
    @messages = WorkActivity.messages_for_work(work.id).order(created_at: :desc)
237✔
15
    @can_curate = current_user&.can_admin?(group)
237✔
16
  end
17

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

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

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

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

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

38
  def file_list_path
1✔
39
    return work_file_list_path("NONE") if @work.nil? || !@work.persisted?
177✔
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?
148✔
44
      "/describe" + work_file_list_path(@work.id)
×
45
    else
46
      work_file_list_path(@work.id)
148✔
47
    end
48
  end
49

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

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