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

pulibrary / pdc_describe / 7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

20 Mar 2024 12:42PM UTC coverage: 30.068% (-66.2%) from 96.266%
7ae96b6b-0a64-4479-9fa1-8ba6526e2c87

Pull #1701

circleci

leefaisonr
makes it so that links open in new window
Pull Request #1701: Update language on submission form

1019 of 3389 relevant lines covered (30.07%)

0.4 hits per line

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

0.0
/app/models/work_state_transition_notification.rb
1
# frozen_string_literal: true
2

3
# Connect with the curators of a work when an activity occurs
4
#
5
class WorkStateTransitionNotification
×
6
  attr_accessor :group_administrators, :depositor, :to_state, :from_state, :group,
×
7
                :work_url, :notification, :users, :id, :current_user_id, :work_title
×
8

9
  def initialize(work, current_user_id)
×
10
    @to_state = work.aasm.to_state
×
11
    @from_state = work.aasm.from_state
×
12
    @depositor = work.created_by_user
×
13
    @group = work.group
×
14
    @group_administrators = group.administrators.to_a
×
15
    @work_url = Rails.application.routes.url_helpers.work_url(work)
×
16
    @work_title = work.title
×
17
    @notification = notification_for_transition
×
18
    @id = work.id
×
19
    @current_user_id = current_user_id
×
20
  end
×
21

22
  def send
×
23
    return if notification.nil?
×
24

25
    WorkActivity.add_work_activity(id, notification, current_user_id, activity_type: WorkActivity::NOTIFICATION)
×
26
  end
×
27

28
    private
×
29

30
      def notification_for_transition
×
31
        case to_state
×
32
        when :awaiting_approval
×
33
          "#{user_tags} [#{work_title}](#{work_url}) is ready for review."
×
34
        when :draft
×
35
          "#{user_tags} [#{work_title}](#{work_url}) has been created."
×
36
        when :approved
×
37
          "#{user_tags} [#{work_title}](#{work_url}) has been approved."
×
38
        end
×
39
      end
×
40

41
      def user_tags
×
42
        @user_tags = begin
×
43
                      groups_users_for_tags = ["@#{group.code}"]
×
44
                      unless group_administrators.include?(depositor)
×
45
                        groups_users_for_tags << "@#{depositor.uid}"
×
46
                      end
×
47

48
                      groups_users_for_tags.join(", ")
×
49
                    end
×
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