mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 06:51:42 +00:00
tests de reordenamiento
This commit is contained in:
parent
737416488b
commit
b38db8f988
1 changed files with 11 additions and 6 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue