mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-14 22:51:41 +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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue