Sha256: 2fe81c67f25a3f203263a88c363cf5090d24b1341156d39992e4152bccd1a1ff

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require "test_helper"

module PushType

  describe TagListField do
    let(:field) { PushType::TagListField.new :tags, opts }
    let(:val)   { ['foo', 'bar'] }

    describe 'default' do
      let(:opts) { {} }
      it { field.template.must_equal 'tag_list' }
      it { field.multiple?.must_equal true }
      it { field.param.must_equal tags: [] }
      it { field.html_options.keys.must_include :multiple }
      it { field.html_options.keys.must_include :placeholder }
      it { field.to_json(val + ['']).must_equal val }
    end

    describe 'initialized on node' do
      before do
        TestPage.instance_variable_set '@fields', ActiveSupport::OrderedHash.new
        TestPage.field :tags, :tag_list
        TestPage.create FactoryGirl.attributes_for(:node, tags: ['foo', 'bar'])
        TestPage.create FactoryGirl.attributes_for(:node, tags: ['baz', 'bar'])
        TestPage.create FactoryGirl.attributes_for(:node, tags: ['qux'])
      end
      after { TestPage.instance_variable_set '@fields', ActiveSupport::OrderedHash.new }
      it { TestPage.must_respond_to :all_tags }
      it { TestPage.all_tags.must_equal ['bar', 'baz', 'foo', 'qux'] }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
push_type_core-0.5.0 test/fields/push_type/tag_list_field_test.rb