Sha256: 2bdc7e31b1ed12c13008c5833fe29317221677974ff454369c335cd8ae18a404

Contents?: true

Size: 1.15 KB

Versions: 32

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

module PushType
  class SelectFieldTest < ActiveSupport::TestCase

    class TestPage < PushType::Node
      field :foo, :select, choices: [['AAA', 'a'], ['BBB', 'b']]
      field :bars, :select, multiple: true, choices: -> { [['XXX', 'x'], ['YYY', 'y']] }
    end

    let(:node)  { TestPage.create FactoryGirl.attributes_for(:node, foo: 'b', bars: ['x', 'y']) }
    let(:foo)   { node.fields[:foo] }
    let(:bars)  { node.fields[:bars] }

    it { foo.json_primitive.must_equal :string }
    it { foo.template.must_equal 'select' }
    it { foo.field_options.keys.must_include :include_blank }
    it { foo.html_options.keys.must_include :multiple }
    it { foo.wont_be :multiple? }
    it { foo.json_value.must_equal 'b' }
    it { foo.value.must_equal 'b' }
    it { foo.choices.must_equal [['AAA', 'a'], ['BBB', 'b']] }

    it { bars.json_primitive.must_equal :array }
    it { bars.must_be :multiple? }
    it { bars.json_value.must_equal ['x', 'y'] }
    it { bars.value.must_equal ['x', 'y'] }
    it { bars.choices.must_equal [['XXX', 'x'], ['YYY', 'y']] }

    it { node.foo.must_equal 'b' }
    it { node.bars.must_equal ['x', 'y'] }

  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
push_type_core-0.11.2 test/fields/push_type/select_field_test.rb
push_type_core-0.11.1 test/fields/push_type/select_field_test.rb
push_type_core-0.11.0.beta.2 test/fields/push_type/select_field_test.rb
push_type_core-0.11.0.beta.1 test/fields/push_type/select_field_test.rb
push_type_core-0.10.4 test/fields/push_type/select_field_test.rb
push_type_core-0.10.3 test/fields/push_type/select_field_test.rb
push_type_core-0.10.2 test/fields/push_type/select_field_test.rb
push_type_core-0.10.1 test/fields/push_type/select_field_test.rb
push_type_core-0.10.0 test/fields/push_type/select_field_test.rb
push_type_core-0.10.0.beta.5 test/fields/push_type/select_field_test.rb
push_type_core-0.10.0.beta.3 test/fields/push_type/select_field_test.rb
push_type_core-0.9.5 test/fields/push_type/select_field_test.rb
push_type_core-0.9.3 test/fields/push_type/select_field_test.rb
push_type_core-0.9.2 test/fields/push_type/select_field_test.rb
push_type_core-0.9.1 test/fields/push_type/select_field_test.rb
push_type_core-0.9.0 test/fields/push_type/select_field_test.rb
push_type_core-0.9.0.beta.4 test/fields/push_type/select_field_test.rb
push_type_core-0.9.0.beta.3 test/fields/push_type/select_field_test.rb
push_type_core-0.9.0.beta.2 test/fields/push_type/select_field_test.rb
push_type_core-0.8.2 test/fields/push_type/select_field_test.rb