Sha256: 4257b794ebf7416724427704c68689e0c04d47ed7e0aa62f3be647882d17211a

Contents?: true

Size: 1.06 KB

Versions: 18

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'

module PushType
  class CustomizableTest < ActiveSupport::TestCase

    class TestPage < PushType::Node
      field :foo
      field :bar, :text
      field :baz, validates: { presence: true }
      field :qux, :number, validates: { presence: true }
    end

    let(:page) { TestPage.new }
    let(:fields) { page.fields }

    it { TestPage.fields.must_be_instance_of Hash }
    it { fields.must_be_instance_of Hash }

    describe '.field' do
      it { fields[:foo].must_be_instance_of StringField }
      it { fields[:bar].must_be_instance_of TextField }
      it { fields[:baz].must_be_instance_of StringField }
      it { TestPage.validators_on(:baz).map(&:class).must_include ActiveRecord::Validations::PresenceValidator }
      it { fields[:qux].must_be_instance_of NumberField }
      it { TestPage.validators_on(:qux).map(&:class).must_include ActiveRecord::Validations::PresenceValidator }
    end

    describe '#attribute_for_inspect' do
      it { page.attribute_for_inspect(:field_store).must_equal "[:foo, :bar, :baz, :qux]" }
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
push_type_core-0.10.2 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.10.1 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.10.0 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.10.0.beta.5 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.10.0.beta.3 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.5 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.3 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.2 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.1 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.0 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.0.beta.4 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.0.beta.3 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.9.0.beta.2 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.8.2 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.8.1 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.8.0 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.8.0.beta.3 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.8.0.beta.2 test/models/concerns/push_type/customizable_test.rb