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

sleede / fab-manager / #98

pending completion
#98

push

coveralls-ruby

sylvainbx
Merge branch 'dev' for release 5.7.0

1368 of 1368 new or added lines in 161 files covered. (100.0%)

7383 of 12030 relevant lines covered (61.37%)

14.06 hits per line

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

88.46
/app/controllers/api/notification_preferences_controller.rb
1
# frozen_string_literal: true
2

3
# API Controller for resources of type Notification Preferences
4
class API::NotificationPreferencesController < API::ApiController
1✔
5
  before_action :authenticate_user!
1✔
6

7
  def index
1✔
8
    @notification_preferences = current_user.notification_preferences
1✔
9
  end
10

11
  # Currently only available for Admin in NotificationPreferencePolicy
12
  def update
1✔
13
    authorize NotificationPreference
1✔
14
    notification_type = NotificationType.find_by(name: params[:notification_preference][:notification_type])
1✔
15
    @notification_preference = NotificationPreference.find_or_create_by(notification_type: notification_type, user: current_user)
1✔
16
    @notification_preference.update(notification_preference_params)
1✔
17

18
    if @notification_preference.save
1✔
19
      render :show, status: :ok
1✔
20
    else
21
      render json: @notification_preference.errors, status: :unprocessable_entity
×
22
    end
23
  end
24

25
  # Currently only available for Admin in NotificationPreferencePolicy
26
  def bulk_update
1✔
27
    authorize NotificationPreference
1✔
28
    errors = []
1✔
29
    params[:notification_preferences].each do |notification_preference|
1✔
30
      notification_type = NotificationType.find_by(name: notification_preference[:notification_type])
2✔
31
      db_notification_preference = NotificationPreference.find_or_create_by(notification_type_id: notification_type.id, user: current_user)
2✔
32

33
      next if db_notification_preference.update(email: notification_preference[:email], in_system: notification_preference[:in_system])
2✔
34

35
      errors.push(db_notification_preference.errors)
×
36
    end
37

38
    if errors.any?
1✔
39
      render json: errors, status: :unprocessable_entity
×
40
    else
41
      head :no_content, status: :ok
1✔
42
    end
43
  end
44

45
  private
1✔
46

47
  def notification_preference_params
1✔
48
    params.require(:notification_preference).permit(:notification_type_id, :in_system, :email)
1✔
49
  end
50
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

© 2026 Coveralls, Inc