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

pulibrary / pdc_describe / b1776731-62d7-41a7-882d-6a5b4760db75

14 May 2024 12:28PM UTC coverage: 79.223% (-16.7%) from 95.9%
b1776731-62d7-41a7-882d-6a5b4760db75

push

circleci

carolyncole
Adding a submission completion page

fixes #1791

9 of 9 new or added lines in 2 files covered. (100.0%)

567 existing lines in 42 files now uncovered.

2692 of 3398 relevant lines covered (79.22%)

60.03 hits per line

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

91.3
/app/models/work_activity_notification.rb
1
# frozen_string_literal: true
2

3
class WorkActivityNotification < ApplicationRecord
1✔
4
  belongs_to :work_activity
1✔
5
  belongs_to :user
1✔
6

7
  after_create do
1✔
8
    if send_message?
47✔
9
      mailer = NotificationMailer.with(user:, work_activity:)
47✔
10
      message = mailer.build_message
47✔
11
      message.deliver_later(wait: 10.seconds) unless Rails.env.development?
47✔
12
    end
13
  end
14

15
  private
1✔
16

17
    def direct_message?
1✔
18
      @direct_message ||= work_activity.activity_type == WorkActivity::MESSAGE && work_activity.message.include?("@#{user.uid}")
47✔
19
    end
20

21
    def send_message?
1✔
22
      return true if direct_message? # always send a direct message
47✔
23
      return false unless user.email_messages_enabled? # do not send message if all emails are disabled
47✔
24
      work = work_activity.work
47✔
25

26
      if work.resource.subcommunities.count > 1
47✔
UNCOV
27
        subcommunities_can_send = work.resource.subcommunities.map { |subcommunity| send_message_for_community?(subcommunity) }
×
UNCOV
28
        subcommunities_can_send.any?
×
29
      else
30
        send_message_for_community?(work.resource.subcommunities.first)
47✔
31
      end
32
    end
33

34
    def send_message_for_community?(subcommunity)
1✔
35
      group.messages_enabled_for?(user:, subcommunity:)
47✔
36
    end
37

38
    def group
1✔
39
      @group ||= work_activity.work.group
47✔
40
    end
41
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