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

pulibrary / pdc_describe / cace366a-ffad-45f1-9b60-678e607fa527

14 May 2024 02:21PM UTC coverage: 60.862% (-35.0%) from 95.908%
cace366a-ffad-45f1-9b60-678e607fa527

push

circleci

jrgriffiniii
wip

1 of 3 new or added lines in 2 files covered. (33.33%)

1194 existing lines in 57 files now uncovered.

2076 of 3411 relevant lines covered (60.86%)

22.71 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?
4✔
9
      mailer = NotificationMailer.with(user:, work_activity:)
4✔
10
      message = mailer.build_message
4✔
11
      message.deliver_later(wait: 10.seconds) unless Rails.env.development?
4✔
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}")
4✔
19
    end
20

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

26
      if work.resource.subcommunities.count > 1
4✔
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)
4✔
31
      end
32
    end
33

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

38
    def group
1✔
39
      @group ||= work_activity.work.group
4✔
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