5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 10:36:22 +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' require 'test_helper'
class MetadataBooleanTest < ActiveSupport::TestCase 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 test 'son false por defecto' do
site = create :site assert_equal false, @metadata.default_value
post = site.posts.build 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 end
test 'pueden ser 0' do test 'pueden ser 0' do
site = create :site @metadata.value = '0'
post = site.posts.build
post.draft.value = '0' assert_equal false, @metadata.value
assert_equal false, post.draft.value @metadata.save
post.save assert_equal false, @metadata.value
assert_equal false, post.draft.value
site.destroy
end end
test 'pueden ser 1' do test 'pueden ser 1' do
site = create :site @metadata.value = '1'
post = site.posts.build
post.draft.value = '1' assert_equal true, @metadata.value
assert_equal true, post.draft.value @metadata.save
post.save assert_equal true, @metadata.value
assert_equal true, post.draft.value
site.destroy
end end
test 'pueden ser false' do test 'pueden ser false' do
site = create :site @metadata.value = false
post = site.posts.build
post.draft.value = false assert_equal false, @metadata.value
assert_equal false, post.draft.value @metadata.save
post.save assert_equal false, @metadata.value
assert_equal false, post.draft.value
site.destroy
end end
test 'pueden ser true' do test 'pueden ser true' do
site = create :site @metadata.value = true
post = site.posts.build
post.draft.value = true assert_equal true, @metadata.value
assert_equal true, post.draft.value @metadata.save
post.save assert_equal true, @metadata.value
assert_equal true, post.draft.value
site.destroy
end end
end end