From f1fa0c77fb2e35a556c93057c2e3ca93fe515c90 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 6 Oct 2023 11:18:38 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20testear=20m=C3=A1s=20cosas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/metadata_boolean.rb | 2 ++ test/models/metadata_boolean_test.rb | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/models/metadata_boolean.rb b/app/models/metadata_boolean.rb index e196ad30..607ce569 100644 --- a/app/models/metadata_boolean.rb +++ b/app/models/metadata_boolean.rb @@ -9,6 +9,8 @@ end # Esto es increíblemente difícil de lograr que salga bien! class MetadataBoolean < MetadataTemplate include MetadataBooleanConstants + include Metadata::NonIndexableConcern + include Metadata::AlwaysPublicConcern # Devolver el valor desde el esquema y si no existe, por defecto es # false diff --git a/test/models/metadata_boolean_test.rb b/test/models/metadata_boolean_test.rb index 9f97d757..1649d957 100644 --- a/test/models/metadata_boolean_test.rb +++ b/test/models/metadata_boolean_test.rb @@ -11,10 +11,30 @@ class MetadataBooleanTest < ActiveSupport::TestCase @metadata = MetadataBoolean.new(site: @site, document: @document, name: @name, type: 'boolean', layout: @layout) end + def random_value + [true, false].sample + end + + test 'se guarda en el encabezado' do + assert @metadata.front_matter? + end + + test 'no se puede indexar' do + assert_not @metadata.indexable? + end + + test 'nunca es privado' do + assert_not @metadata.private? + end + test 'son false por defecto' do assert_equal false, @metadata.default_value end + test 'aunque sean false nunca son considerados vacíos' do + assert_not @metadata.empty? + end + test 'pueden tener un valor por defecto desde el layout' do [true, false].each do |default| @layout = build(:layout, site: @site, metadata: { @name => { 'default' => { I18n.locale.to_s => default } } })