por fin arreglar los metadatos booleanos!

This commit is contained in:
f 2020-06-16 19:20:22 -03:00
parent 10a480563e
commit 58a6f1aa9c
2 changed files with 75 additions and 1 deletions

View file

@ -82,7 +82,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
#
# Ver ActionText::ContentHelper#sanitize_action_text_content
def sanitize(string)
return unless string
return if string.nil?
return string unless string.is_a? String
sanitizer.sanitize(string,

View file

@ -0,0 +1,74 @@
# frozen_string_literal: true
require 'test_helper'
class MetadataBooleanTest < ActiveSupport::TestCase
test 'son false por defecto' do
site = create :site
post = site.posts.build
assert_equal false, post.draft.value
site.destroy
end
test 'pueden ser 0' do
site = create :site
post = site.posts.build
post.draft.value = '0'
assert_equal false, post.draft.value
post.save
assert_equal false, post.draft.value
site.destroy
end
test 'pueden ser 1' do
site = create :site
post = site.posts.build
post.draft.value = '1'
assert_equal true, post.draft.value
post.save
assert_equal true, post.draft.value
site.destroy
end
test 'pueden ser false' do
site = create :site
post = site.posts.build
post.draft.value = false
assert_equal false, post.draft.value
post.save
assert_equal false, post.draft.value
site.destroy
end
test 'pueden ser true' do
site = create :site
post = site.posts.build
post.draft.value = true
assert_equal true, post.draft.value
post.save
assert_equal true, post.draft.value
site.destroy
end
end