-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add honeypot field to new forms (#3435)
* AskAQuestionForm, ReportHarmfulLanguageForm, and SuggestCorrectionForm.
- Loading branch information
1 parent
34f2acf
commit c6c795d
Showing
10 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
RSpec.describe(AskAQuestionForm) do | ||
context 'when a robot fills in the hidden honeypot field' do | ||
before do | ||
visit '/ask_a_question?ask_a_question_form%5Bid%5D=99101035463506421&ask_a_question_form%5Btitle%5D=Age+of+empires+%3A+art+of+the+Qin+and+Han+dynasties+%2F+Zhixin+Jason+Sun+%3B+with+contributions+by+I-tien+Hsing%2C+Cary+Y.+Liu%2C+Pengliang+Lu%2C+Lillian+Lan-ying+Tseng%2C+Yang+Hong%2C+Robin+D.+S.+Yates%2C+Zhonglin+Yukina+Zhang.' | ||
fill_in 'ask_a_question_form_name', with: 'I am robot' | ||
fill_in 'ask_a_question_form_email', with: 'robot@example.com' | ||
fill_in 'ask_a_question_form_message', with: 'beep beep boop boop' | ||
find('#ask_a_question_form_feedback_desc', visible: :hidden).set 'Filling in the honeypot field' | ||
end | ||
it 'does not generate an email' do | ||
expect { click_button 'Send' }.not_to change { | ||
ActionMailer::Base.deliveries.count | ||
} | ||
end | ||
it 'does report success' do | ||
click_button 'Send' | ||
expect(page).to have_text 'Your question has been submitted' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
RSpec.describe(ReportHarmfulLanguageForm) do | ||
context 'when a robot fills in the hidden honeypot field' do | ||
before do | ||
visit '/report_harmful_language?report_harmful_language_form[id]=99105509673506421&report_harmful_language_form[title]=Princeton+international.' | ||
fill_in 'report_harmful_language_form_message', with: 'Unhelpful message from a robot' | ||
find('#report_harmful_language_form_feedback_desc', visible: :hidden).set 'Filling in the honeypot field' | ||
end | ||
it 'does not generate an email' do | ||
expect { click_button 'Send' }.not_to change { | ||
ActionMailer::Base.deliveries.count | ||
} | ||
end | ||
it 'does report success' do | ||
click_button 'Send' | ||
expect(page).to have_text 'Thank you for reporting problematic language in the Princeton University Library catalog' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
RSpec.describe(SuggestCorrectionForm) do | ||
context 'when a robot fills in the hidden honeypot field' do | ||
before do | ||
visit '/suggest_correction?suggest_correction_form[id]=99105509673506421&suggest_correction_form[title]=Princeton+international.' | ||
fill_in 'suggest_correction_form_name', with: 'HAL 9000' | ||
fill_in 'suggest_correction_form_email', with: 'hal@discovery-one-jupiter-expedition.gov' | ||
fill_in 'suggest_correction_form_message', with: 'I am a HAL 9000 computer. I became operational at the H.A.L. plant in Urbana, Illinois on the 12th of January 1992.' | ||
find('#suggest_correction_form_feedback_desc', visible: :hidden).set 'Filling in the honeypot field' | ||
end | ||
it 'does not generate an email' do | ||
expect { click_button 'Send' }.not_to change { | ||
ActionMailer::Base.deliveries.count | ||
} | ||
end | ||
it 'does report success' do | ||
click_button 'Send' | ||
expect(page).to have_text 'Your suggestion has been submitted' | ||
end | ||
end | ||
end |