Sha256: 6f576168bd9ca24055557fdf7b422509720534de19c18d0562891ba098164e51
Contents?: true
Size: 1.68 KB
Versions: 62
Compression:
Stored size: 1.68 KB
Contents
require 'test_helper' module Workarea class DetailsTest < Workarea::TestCase class Foo include Mongoid::Document include Details end def test_cleans_details model = Foo.new model.details = { 'foo' => {} } model.valid? assert_equal(model.details, {}) model.details = { 'foo' => 'bar' } model.valid? assert_equal(model.details['foo'], ['bar']) end def test_update_details_merges_values model = Foo.new(details: { 'foo' => 'bar' }) model.update_details('foo' => 'baz') assert_equal(model.details['foo'], 'baz') end def test_update_details_removes_blank_values model = Foo.new(details: { 'foo' => 'bar' }) model.update_details('foo' => '') refute(model.details.keys.include?('foo')) end def test_matches_details_array_values model = Foo.new(details: { 'foo' => ['BaR '] }) assert(model.matches_detail?('foo', ' BAr')) end def test_matches_details_values model = Foo.new(details: { 'foo' => 'BaR ' }) assert(model.matches_detail?('foo', ' BAr')) end def test_matches_details_array_arguments model = Foo.new(details: { 'foo' => ['BaR '] }) assert(model.matches_details?('foo' => [' BAr'])) model = Foo.new(details: { 'foo' => 'BaR ' }) assert(model.matches_details?('foo' => [' BAr'])) end def test_detail_names default_model = Foo.new(details: { 'foo' => 'bar' }) rehydrated_model = Foo.new(details: { I18n.locale.to_s => { 'foo' => 'bar' } }) assert_includes(default_model.detail_names, 'foo') assert_includes(rehydrated_model.detail_names, 'foo') end end end
Version data entries
62 entries across 62 versions & 1 rubygems