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

pulibrary / orangelight / 2fb515a9-a4c2-4bc7-b21d-66c7b73b4ed9

21 Nov 2023 03:58PM UTC coverage: 95.475% (-0.003%) from 95.478%
2fb515a9-a4c2-4bc7-b21d-66c7b73b4ed9

push

circleci

web-flow
Merge pull request #3822 from pulibrary/3789-biased-results-form

Submit biased results feedback

38 of 40 new or added lines in 5 files covered. (95.0%)

5718 of 5989 relevant lines covered (95.48%)

1404.22 hits per line

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

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

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

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

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

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

29
  def ask_a_question; end
2✔
30

31
  def suggest_correction; end
2✔
32

33
  def report_harmful_language; end
2✔
34

35
  def report_biased_results; end
2✔
36

37
  protected
2✔
38

39
    def build_feedback_form
2✔
40
      @feedback_form = FeedbackForm.new(feedback_form_params)
4✔
41
      @feedback_form.request = request
4✔
42
      @feedback_form
4✔
43
    end
44

45
    def feedback_form_params
2✔
46
      params.require(:feedback_form).permit(:name, :email, :message, :current_url, :feedback_desc)
4✔
47
    end
48

49
    def build_ask_a_question_form
2✔
50
      @question_form = AskAQuestionForm.new(
4✔
51
        context: page_url(question_form_params),
52
        title: question_form_params['title']
53
      )
54
    end
55

56
    def question_form_params
2✔
57
      params.require(:ask_a_question_form).permit(:id, :title)
8✔
58
    end
59

60
    def build_suggest_correction_form
2✔
61
      @suggest_correction_form = SuggestCorrectionForm.new(
1✔
62
        context: page_url(suggest_correction_form_params),
63
        title: suggest_correction_form_params['title']
64
      )
65
    end
66

67
    def suggest_correction_form_params
2✔
68
      params.require(:suggest_correction_form).permit(:id, :title)
2✔
69
    end
70

71
    def build_report_harmful_language_form
2✔
72
      @harmful_language_form = ReportHarmfulLanguageForm.new(
4✔
73
        context: page_url(harmful_language_params),
74
        title: harmful_language_params['title']
75
      )
76
    end
77

78
    def harmful_language_params
2✔
79
      params.require(:report_harmful_language_form).permit(:id, :title)
8✔
80
    end
81

82
    def build_report_biased_results_form
2✔
83
      @biased_results_form = ReportBiasedResultsForm.new(
2✔
84
        biased_results_params
85
      )
86
    end
87

88
    def biased_results_params
2✔
89
      params.require(:report_biased_results_form).permit(:context)
2✔
90
    end
91

92
    def search_results_url(_params)
2✔
NEW
93
      search_catalog_url(q: biased_results_params['q'])
×
94
    end
95

96
    def page_url(params)
2✔
97
      solr_document_url(id: params['id'])
9✔
98
    end
99

100
    def current_user_email
2✔
101
      return if current_user.nil?
20✔
102
      return if current_user.provider != 'cas'
1✔
103
      @user_email = "#{current_user.uid}@princeton.edu"
1✔
104
      @user_email
1✔
105
    end
106
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