5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 10:46:21 +00:00

fix: arreglar tests
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

ahora no es necesario generar todo un sitio para testear atributos
This commit is contained in:
f 2023-10-06 11:14:24 -03:00
parent 68f3839ab1
commit faec2b2004
No known key found for this signature in database

View file

@ -3,72 +3,64 @@
require 'test_helper'
class MetadataBooleanTest < ActiveSupport::TestCase
setup do
@site = build(:site)
@document = build(:document, site: @site.jekyll)
@name = SecureRandom.hex
@layout = build(:layout, site: @site)
@metadata = MetadataBoolean.new(site: @site, document: @document, name: @name, type: 'boolean', layout: @layout)
end
test 'son false por defecto' do
site = create :site
post = site.posts.build
assert_equal false, @metadata.default_value
end
assert_equal false, post.draft.value
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 } } })
@metadata = MetadataBoolean.new(site: @site, document: @document, name: @name, type: 'boolean', layout: @layout)
site.destroy
assert_equal default, @metadata.default_value
end
end
test 'pueden ser 0' do
site = create :site
post = site.posts.build
@metadata.value = '0'
post.draft.value = '0'
assert_equal false, @metadata.value
assert_equal false, post.draft.value
@metadata.save
post.save
assert_equal false, post.draft.value
site.destroy
assert_equal false, @metadata.value
end
test 'pueden ser 1' do
site = create :site
post = site.posts.build
@metadata.value = '1'
post.draft.value = '1'
assert_equal true, @metadata.value
assert_equal true, post.draft.value
@metadata.save
post.save
assert_equal true, post.draft.value
site.destroy
assert_equal true, @metadata.value
end
test 'pueden ser false' do
site = create :site
post = site.posts.build
@metadata.value = false
post.draft.value = false
assert_equal false, @metadata.value
assert_equal false, post.draft.value
@metadata.save
post.save
assert_equal false, post.draft.value
site.destroy
assert_equal false, @metadata.value
end
test 'pueden ser true' do
site = create :site
post = site.posts.build
@metadata.value = true
post.draft.value = true
assert_equal true, @metadata.value
assert_equal true, post.draft.value
@metadata.save
post.save
assert_equal true, post.draft.value
site.destroy
assert_equal true, @metadata.value
end
end