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

pulibrary / orangelight / 7a3f5439-104b-4b35-a2c8-d8c640a77b8e

13 Sep 2024 01:16AM UTC coverage: 96.251% (-0.02%) from 96.272%
7a3f5439-104b-4b35-a2c8-d8c640a77b8e

push

circleci

web-flow
Merge pull request #4329 from pulibrary/libanswers-harmful-language-form

[#4130] Use Libanswers API for the ReportHarmfulLanguage form

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

2 existing lines in 1 file now uncovered.

6033 of 6268 relevant lines covered (96.25%)

1436.99 hits per line

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

90.91
/app/forms/report_harmful_language_form.rb
1
# frozen_string_literal: true
2
class ReportHarmfulLanguageForm
3✔
3
  include ActiveModel::Model
3✔
4
  include Honeypot
3✔
5
  attr_accessor :name, :email, :message, :context, :title, :error
3✔
6

7
  validates :message, presence: true
3✔
8

9
  def submit
3✔
10
    if /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i.match?(email) || email&.empty?
6✔
11
      unless spam?
5✔
12
        HarmfulLanguageFormSubmission.new(
3✔
13
          patron_name: name,
14
          patron_email: email,
15
          message:,
16
          title:,
17
          context:
18
        ).send_to_libanswers
19
      end
20
      @submitted = true
5✔
21
      @name = ""
5✔
22
      @email = ""
5✔
23
      @message = ""
5✔
24
    else
25
      @submitted = false
1✔
26
      @errors.add(:email, :invalid, message: "is not a valid email address")
1✔
27
      false
1✔
28
    end
29
  end
30

31
  def submitted?
3✔
32
    @submitted == true
2✔
33
  end
34

35
  def routed_mail_to
3✔
UNCOV
36
    Orangelight.config["report_harmful_language_form"]["to"]
×
37
  end
38

39
  # If the form does not include an email, use the routed_mail_to email for the "from" field
40
  def from_email
3✔
UNCOV
41
    @from_email ||= @email.presence || routed_mail_to
×
42
  end
43
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