la descripción de los artículos es obligatoria

This commit is contained in:
f 2019-10-17 16:16:30 -03:00
parent 5f6678a33e
commit 74e47274ff
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
6 changed files with 29 additions and 9 deletions

View file

@ -74,6 +74,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
post: { post: {
lang: lang, lang: lang,
title: site.licencia.name, title: site.licencia.name,
description: I18n.t('sites.form.licencia.title'),
author: %w[Sutty], author: %w[Sutty],
permalink: "#{I18n.t('activerecord.models.licencia').downcase}/", permalink: "#{I18n.t('activerecord.models.licencia').downcase}/",
content: CommonMarker.render_html(site.licencia.deed) content: CommonMarker.render_html(site.licencia.deed)

View file

@ -296,7 +296,7 @@ en:
url: 'Demo' url: 'Demo'
licencia: 'Read the license' licencia: 'Read the license'
licencia: licencia:
title: 'License for the site and everything in it' title: 'License for the site and everything published on it'
url: 'Read the license' url: 'Read the license'
privacidad: privacidad:
title: 'Privacy policy and code of conduct' title: 'Privacy policy and code of conduct'

View file

@ -306,7 +306,7 @@ es:
url: 'Demostración' url: 'Demostración'
license: 'Leer la licencia' license: 'Leer la licencia'
licencia: licencia:
title: 'Licencia del sitio y todo lo que publiques' title: 'Licencia del sitio y todo lo publicado'
url: 'Leer la licencia' url: 'Leer la licencia'
privacidad: privacidad:
title: Políticas de privacidad y código de convivencia title: Políticas de privacidad y código de convivencia

View file

@ -7,7 +7,8 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
@rol = create :rol @rol = create :rol
@site = @rol.site @site = @rol.site
@usuarie = @rol.usuarie @usuarie = @rol.usuarie
@post = @site.posts.build(title: SecureRandom.hex) @post = @site.posts.build(title: SecureRandom.hex,
description: SecureRandom.hex)
@post.save @post.save
@authorization = { @authorization = {
@ -33,6 +34,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
params: { params: {
post: { post: {
title: title, title: title,
description: title,
date: 2.days.ago.strftime('%F') date: 2.days.ago.strftime('%F')
} }
} }
@ -62,8 +64,14 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
test 'se pueden actualizar' do test 'se pueden actualizar' do
title = SecureRandom.hex title = SecureRandom.hex
patch site_post_url(@site, @post.id), headers: @authorization, patch site_post_url(@site, @post.id),
params: { post: { title: title } } headers: @authorization,
params: {
post: {
title: title,
description: title
}
}
assert_equal 302, response.status assert_equal 302, response.status

View file

@ -43,6 +43,7 @@ class EditorTest < ActionDispatch::IntegrationTest
params: { params: {
post: { post: {
title: SecureRandom.hex, title: SecureRandom.hex,
description: SecureRandom.hex,
content: content content: content
} }
} }
@ -61,6 +62,7 @@ class EditorTest < ActionDispatch::IntegrationTest
params: { params: {
post: { post: {
title: SecureRandom.hex, title: SecureRandom.hex,
description: SecureRandom.hex,
content: trix_orig content: trix_orig
} }
} }

View file

@ -5,7 +5,8 @@ require 'test_helper'
class PostTest < ActiveSupport::TestCase class PostTest < ActiveSupport::TestCase
setup do setup do
@site = create :site @site = create :site
@post = @site.posts.create(title: SecureRandom.hex) @post = @site.posts.create(title: SecureRandom.hex,
description: SecureRandom.hex)
end end
teardown do teardown do
@ -65,6 +66,7 @@ class PostTest < ActiveSupport::TestCase
test 'se pueden guardar los cambios' do test 'se pueden guardar los cambios' do
title = SecureRandom.hex title = SecureRandom.hex
@post.title.value = title @post.title.value = title
@post.description.value = title
@post.categories.value << title @post.categories.value << title
assert @post.save assert @post.save
@ -78,6 +80,7 @@ class PostTest < ActiveSupport::TestCase
assert document.data['categories'].include?(title) assert document.data['categories'].include?(title)
assert_equal title, document.data['title'] assert_equal title, document.data['title']
assert_equal title, document.data['description']
assert_equal 'post', document.data['layout'] assert_equal 'post', document.data['layout']
end end
end end
@ -136,14 +139,16 @@ class PostTest < ActiveSupport::TestCase
end end
test 'new?' do test 'new?' do
post = @site.posts.build title: SecureRandom.hex post = @site.posts.build title: SecureRandom.hex,
description: SecureRandom.hex
assert post.new? assert post.new?
assert post.save assert post.save
assert_not post.new? assert_not post.new?
end end
test 'no podemos pisar otros archivos' do test 'no podemos pisar otros archivos' do
post = @site.posts.create title: SecureRandom.hex post = @site.posts.create title: SecureRandom.hex,
description: SecureRandom.hex
@post.slug.value = post.slug.value @post.slug.value = post.slug.value
@post.date.value = post.date.value @post.date.value = post.date.value
@ -157,6 +162,7 @@ class PostTest < ActiveSupport::TestCase
post = @site.posts.build(layout: :post) post = @site.posts.build(layout: :post)
post.title.value = SecureRandom.hex post.title.value = SecureRandom.hex
post.content.value = SecureRandom.hex post.content.value = SecureRandom.hex
post.description.value = SecureRandom.hex
assert post.new? assert post.new?
assert post.save assert post.save
@ -165,9 +171,12 @@ class PostTest < ActiveSupport::TestCase
test 'se pueden inicializar con valores' do test 'se pueden inicializar con valores' do
title = SecureRandom.hex title = SecureRandom.hex
post = @site.posts.build(title: title, content: title) post = @site.posts.build(title: title,
description: title,
content: title)
assert_equal title, post.title.value assert_equal title, post.title.value
assert_equal title, post.description.value
assert_equal title, post.content.value assert_equal title, post.content.value
assert post.save assert post.save
end end