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.8.1 test/fields/push_type/select_field_test.rb
push_type_core-0.8.0 test/fields/push_type/select_field_test.rb
push_type_core-0.8.0.beta.3 test/fields/push_type/select_field_test.rb
push_type_core-0.8.0.beta.2 test/fields/push_type/select_field_test.rb
push_type_core-0.8.0.beta.1 test/fields/push_type/select_field_test.rb
push_type_core-0.7.0 test/fields/push_type/select_field_test.rb
push_type_core-0.7.0.beta.1 test/fields/push_type/select_field_test.rb
push_type_core-0.6.0 test/fields/push_type/select_field_test.rb
push_type_core-0.6.0.beta.4 test/fields/push_type/select_field_test.rb
push_type_core-0.6.0.beta.3 test/fields/push_type/select_field_test.rb
push_type_core-0.6.0.beta.2 test/fields/push_type/select_field_test.rb
push_type_core-0.6.0.beta.1 test/fields/push_type/select_field_test.rb