Sha256: 4a396be1edfa25f44d8c96208cf837642a72833233bc2a3b46ce33e6d550ba08

Contents?: true

Size: 716 Bytes

Versions: 62

Compression:

Stored size: 716 Bytes

Contents

require 'test_helper'

module Mongoid
  class ListFieldTest < Workarea::TestCase
    class ListDocument
      include Mongoid::Document
      field :some_ids, type: Array
      list_field :some_ids
    end

    def test_sets_parses_the_list_and_sets_the_array_values
      doc = ListDocument.new(some_ids_list: '1,2,3')
      assert_equal(%w(1 2 3), doc.some_ids)
    end

    def test_strips_whitespace_and_blank_values
      doc = ListDocument.new
      doc.some_ids_list = ' 1 ,  2,  ,,3  '
      assert_equal(%w(1 2 3), doc.some_ids)
    end

    def test_gets_a_list_with_commas_a_single_space
      doc = ListDocument.new(some_ids: %w(1 2 3))
      assert_equal('1, 2, 3', doc.some_ids_list)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.26 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.45 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.25 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.23 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.44 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.22 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.43 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.21 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.42 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.20 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.41 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.19 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.40 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.18 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.39 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.17 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.38 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.5.16 test/lib/workarea/ext/mongoid/list_field_test.rb
workarea-core-3.4.37 test/lib/workarea/ext/mongoid/list_field_test.rb