• 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

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