5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 06:51:42 +00:00

tests de reordenamiento

This commit is contained in:
f 2021-02-17 18:48:01 -03:00
parent 737416488b
commit b38db8f988

View file

@ -143,21 +143,26 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
end end
test 'se pueden reordenar' do test 'se pueden reordenar' do
lang = I18n.available_locales.sample lang = { lang: @site.locales.sample }
posts = @site.posts(lang: lang)
(rand * 10).round.times do
@site.posts(**lang).create title: SecureRandom.hex, description: SecureRandom.hex
end
posts = @site.posts(**lang)
reorder = Hash[posts.map { |p| p.uuid.value }.shuffle.each_with_index.to_a] reorder = Hash[posts.map { |p| p.uuid.value }.shuffle.each_with_index.to_a]
post site_posts_reorder_url(@site), post site_posts_reorder_url(@site),
headers: @authorization, headers: @authorization,
params: { post: { lang: lang, reorder: reorder } } params: { post: { lang: lang[:lang], reorder: reorder } }
@site = Site.find @site.id @site = Site.find @site.id
assert_equal I18n.t('post_service.reorder'),
@site.repository.rugged.head.target.message
assert_equal reorder, assert_equal reorder,
Hash[@site.posts(lang: lang).map do |p| Hash[@site.posts(**lang).map do |p|
[p.uuid.value, p.order.value] [p.uuid.value, p.order.value]
end] end]
assert_equal I18n.t('post_service.reorder'),
@site.repository.rugged.head.target.message
end end
end end