5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 20:36:21 +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
test 'se pueden reordenar' do
lang = I18n.available_locales.sample
posts = @site.posts(lang: lang)
lang = { lang: @site.locales.sample }
(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]
post site_posts_reorder_url(@site),
headers: @authorization,
params: { post: { lang: lang, reorder: reorder } }
params: { post: { lang: lang[:lang], reorder: reorder } }
@site = Site.find @site.id
assert_equal I18n.t('post_service.reorder'),
@site.repository.rugged.head.target.message
assert_equal reorder,
Hash[@site.posts(lang: lang).map do |p|
Hash[@site.posts(**lang).map do |p|
[p.uuid.value, p.order.value]
end]
assert_equal I18n.t('post_service.reorder'),
@site.repository.rugged.head.target.message
end
end