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.15 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.4.36 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.5.14 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.4.35 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.5.13 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.4.34 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.5.12 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.4.33 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.5.11 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.5.10 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.4.32 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.5.9 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb
workarea-core-3.4.31 test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb