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

pulibrary / pdc_describe / 9091a1ae-29be-458c-984a-339d213919c4

12 Dec 2024 07:41PM UTC coverage: 26.434% (-69.7%) from 96.113%
9091a1ae-29be-458c-984a-339d213919c4

Pull #2000

circleci

jrgriffiniii
Removing integration with ActiveStorage
Pull Request #2000: Bump actionpack from 7.2.1.1 to 7.2.2.1

945 of 3575 relevant lines covered (26.43%)

0.35 hits per line

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

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

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

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

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

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