Skip to content

Commit

Permalink
Expect "autocomplete=off" for hidden input fields in Rails 7
Browse files Browse the repository at this point in the history
Looks like this was introduced to "fix" a bug in Firefox:

rails/rails#42610
rails/rails#43280
  • Loading branch information
andyundso committed Feb 21, 2022
1 parent e42f365 commit 6d0dfdb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/web/authorize_spec.rb
Expand Up @@ -77,8 +77,14 @@
end
end

it "should generate valid form field string" do
expect(@view.datatrans_notification_request_hidden_fields(@datatrans, @transaction)).to eq "<input type=\"hidden\" name=\"merchantId\" id=\"merchantId\" value=\"1100000000\" /><input type=\"hidden\" name=\"hiddenMode\" id=\"hiddenMode\" value=\"yes\" /><input type=\"hidden\" name=\"reqtype\" id=\"reqtype\" value=\"NOA\" /><input type=\"hidden\" name=\"amount\" id=\"amount\" value=\"1000\" /><input type=\"hidden\" name=\"currency\" id=\"currency\" value=\"CHF\" /><input type=\"hidden\" name=\"useAlias\" id=\"useAlias\" value=\"yes\" /><input type=\"hidden\" name=\"sign\" id=\"sign\" value=\"0402fb3fba8c6fcb40df9b7756e7e637\" /><input type=\"hidden\" name=\"refno\" id=\"refno\" value=\"ABCDEF\" /><input type=\"hidden\" name=\"uppCustomerDetails\" id=\"uppCustomerDetails\" /><input type=\"hidden\" name=\"uppCustomerEmail\" id=\"uppCustomerEmail\" value=\"customer@email.com\" />"
it 'should generate valid form field string' do
if Gem.loaded_specs['activesupport'].version >= Gem::Version.create('7.0')
expected_output = '<input type="hidden" name="merchantId" id="merchantId" value="1100000000" autocomplete="off" /><input type="hidden" name="hiddenMode" id="hiddenMode" value="yes" autocomplete="off" /><input type="hidden" name="reqtype" id="reqtype" value="NOA" autocomplete="off" /><input type="hidden" name="amount" id="amount" value="1000" autocomplete="off" /><input type="hidden" name="currency" id="currency" value="CHF" autocomplete="off" /><input type="hidden" name="useAlias" id="useAlias" value="yes" autocomplete="off" /><input type="hidden" name="sign" id="sign" value="0402fb3fba8c6fcb40df9b7756e7e637" autocomplete="off" /><input type="hidden" name="refno" id="refno" value="ABCDEF" autocomplete="off" /><input type="hidden" name="uppCustomerDetails" id="uppCustomerDetails" autocomplete="off" /><input type="hidden" name="uppCustomerEmail" id="uppCustomerEmail" value="customer@email.com" autocomplete="off" />'
else
expected_output = '<input type="hidden" name="merchantId" id="merchantId" value="1100000000" /><input type="hidden" name="hiddenMode" id="hiddenMode" value="yes" /><input type="hidden" name="reqtype" id="reqtype" value="NOA" /><input type="hidden" name="amount" id="amount" value="1000" /><input type="hidden" name="currency" id="currency" value="CHF" /><input type="hidden" name="useAlias" id="useAlias" value="yes" /><input type="hidden" name="sign" id="sign" value="0402fb3fba8c6fcb40df9b7756e7e637" /><input type="hidden" name="refno" id="refno" value="ABCDEF" /><input type="hidden" name="uppCustomerDetails" id="uppCustomerDetails" /><input type="hidden" name="uppCustomerEmail" id="uppCustomerEmail" value="customer@email.com" />'
end

expect(@view.datatrans_notification_request_hidden_fields(@datatrans, @transaction)).to eq expected_output
end
end

Expand Down

0 comments on commit 6d0dfdb

Please sign in to comment.