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

pulibrary / orangelight / 99dd9090-fa71-4fe7-96e9-bcd9c8c6c339

23 Dec 2025 06:39PM UTC coverage: 95.216% (-0.01%) from 95.23%
99dd9090-fa71-4fe7-96e9-bcd9c8c6c339

Pull #5458

circleci

christinach
Update feedback controller:
- Extract the context url from params
- Update specs

helps with upgrading to rails 8.1.1
Pull Request #5458: Update feedback controller:

1 of 2 new or added lines in 1 file covered. (50.0%)

6170 of 6480 relevant lines covered (95.22%)

1452.08 hits per line

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

97.87
/app/controllers/feedback_controller.rb
1
# frozen_string_literal: true
2

3
class FeedbackController < ApplicationController
3✔
4
  include ApplicationHelper
3✔
5

6
  before_action :current_user_email
3✔
7
  before_action :build_feedback_form, only: [:create]
3✔
8
  before_action :build_ask_a_question_form, only: [:ask_a_question]
3✔
9
  before_action :build_suggest_correction_form, only: [:suggest_correction]
3✔
10
  before_action :build_report_biased_results_form, only: [:report_biased_results]
3✔
11

12
  def new
3✔
13
    @feedback_form = FeedbackForm.new if @feedback_form.nil?
5✔
14
    @feedback_form.current_url = request.referer || root_url
5✔
15
  end
16

17
  def create
3✔
18
    respond_to do |format|
4✔
19
      if @feedback_form.valid?
4✔
20
        @feedback_form.deliver
3✔
21
        format.js { flash.now[:notice] = I18n.t('blacklight.feedback.success') }
6✔
22
      else
23
        format.js { flash.now[:error] = @feedback_form.error_message }
2✔
24
      end
25
    end
26
  end
27

28
  def ask_a_question; end
3✔
29

30
  def suggest_correction; end
3✔
31

32
  def report_biased_results; end
3✔
33

34
  protected
3✔
35

36
    def build_feedback_form
3✔
37
      @feedback_form = FeedbackForm.new(feedback_form_params)
4✔
38
      @feedback_form.request = request
4✔
39
      @feedback_form
4✔
40
    end
41

42
    def feedback_form_params
3✔
43
      params.require(:feedback_form).permit(:name, :email, :message, :current_url, :feedback_desc)
4✔
44
    end
45

46
    def build_ask_a_question_form
3✔
47
      @question_form = AskAQuestionForm.new(
5✔
48
        context: page_url(question_form_params),
49
        title: question_form_params['title']
50
      )
51
    end
52

53
    def question_form_params
3✔
54
      params.require(:ask_a_question_form).permit(:id, :title)
10✔
55
    end
56

57
    def build_suggest_correction_form
3✔
58
      @suggest_correction_form = SuggestCorrectionForm.new(
6✔
59
        context: page_url(suggest_correction_form_params),
60
        title: suggest_correction_form_params['title']
61
      )
62
    end
63

64
    def suggest_correction_form_params
3✔
65
      params.require(:suggest_correction_form).permit(:id, :title)
12✔
66
    end
67

68
    def build_report_biased_results_form
3✔
69
      @biased_results_form = ReportBiasedResultsForm.new(
2✔
70
        context: biased_results_params['context']
71
      )
72
    end
73

74
    def biased_results_params
3✔
75
      params.require(:report_biased_results_form).permit(:context)
2✔
76
    end
77

78
    def search_results_url(biased_params)
3✔
NEW
79
      search_catalog_url(q: biased_params['q'])
×
80
    end
81

82
    def page_url(params)
3✔
83
      solr_document_url(id: params['id'])
11✔
84
    end
85

86
    def current_user_email
3✔
87
      return if current_user.nil?
22✔
88
      return if current_user.provider != 'cas'
1✔
89
      @user_email = "#{current_user.uid}@princeton.edu"
1✔
90
      @user_email
1✔
91
    end
92
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