Sha256: dd464841064f75fec6d471e33101a3934350f11973b644555521c19c923e7635

Contents?: true

Size: 644 Bytes

Versions: 33

Compression:

Stored size: 644 Bytes

Contents

require 'test_helper'

module Workarea
  class MongoidLocalizedDefaultsTest < TestCase
    class Foo
      include Mongoid::Document

      field :name, type: String, default: -> { 'foo' }, localize: true
      field :config, type: Hash, default: { foo: 'bar' }, localize: true
    end

    def test_localized_defaults
      set_locales(available: [:en, :es], default: :en, current: :en)

      instance = Foo.new
      assert_equal('foo', instance.name)
      assert_equal({ foo: 'bar' }, instance.config)

      I18n.locale = :es

      assert_equal('foo', instance.name)
      assert_equal({ foo: 'bar' }, instance.config)
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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