Sha256: 5cb20ee987a76badb94ecc86025cb0a4f063e0ace9e29f7c277aed2b0c7e9206

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

require 'test_helper'
require 'encrypted_form_fields/helpers/form_tag_helper'

class FormTagHelperTest < ActionView::TestCase
  tests EncryptedFormFields::Helpers::FormTagHelper

  def test_encrypted_form_tag
    tag = HTML::Document.new(encrypted_field_tag "field", "value").find(tag: "input")
    decrypted_value = EncryptedFormFields.decrypt_and_verify(tag.attributes["value"])
    assert_equal "value", decrypted_value
    assert_equal "_encrypted[field]", tag.attributes["name"]
    assert_equal "hidden", tag.attributes["type"]
    assert_equal "field", tag.attributes["id"]
  end

  def test_symbol_form_field_name
    tag = HTML::Document.new(encrypted_field_tag :field, "value").find(tag: "input")
    decrypted_value = EncryptedFormFields.decrypt_and_verify(tag.attributes["value"])
    assert_equal "_encrypted[field]", tag.attributes["name"]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
encrypted_form_fields-0.2.1 test/form_tag_helper_test.rb
encrypted_form_fields-0.2.0 test/form_tag_helper_test.rb