Sha256: e65d93fee4cb457de1ed96923b981bc3921f5da50f7d7b32b3c3700673036bbd

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'test_helper'
require 'ostruct'

  class Foo
    def self.columns ; [] ; end
  end

class ExpressFormTest < ActiveSupport::TestCase

  def assigns
    {resource: resource}
  end

  def simplest_form
    arbre {
      express_form(:resource) {
        submit value: 'Save it!'
      }
    }
  end

  test "simplest form renders" do
    assert simplest_form
  end

  test "simplest form contains form tag" do
    assert_match "<form", simplest_form
  end

  test "express_form contents are inside the form" do
    assert_match /<form.*submit.*\/form>/, simplest_form.gsub("\n",'')
  end

  test "simplest form contains rails form helpers" do
    compiled_src = simplest_form
    assert_match "input name=\"utf8\" type=\"hidden\"", compiled_src
    assert_match "input type=\"hidden\" name=\"_method\"", compiled_src
    assert_match "name=\"authenticity_token\" value=\"AUTH_TOKEN\"", compiled_src
    assert_match /<form.*authenticity_token.*\/form>/, compiled_src.gsub("\n",'')
  end

  test "simplest_form contains submit" do
    assert_match '<input type="submit" name="commit" value="Save it!" />', simplest_form
  end

  test "simplest_form uses form_action for the action" do
    form_open_tag = simplest_form.match(/<form[^>]*>/)[0]
    assert_match 'action="/resources"', form_open_tag
  end

  test "express_form default method is POST" do
    assert_match 'method="POST"', simplest_form
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
express_admin-1.3.2 vendor/gems/express_templates/test/components/forms/express_form_test.rb
express_admin-1.3.1 vendor/gems/express_templates/test/components/forms/express_form_test.rb
express_templates-0.7.1 test/components/forms/express_form_test.rb