diff --git a/test/controllers/posts_controller_test.rb b/test/controllers/posts_controller_test.rb index 376c740f..b8c9f560 100644 --- a/test/controllers/posts_controller_test.rb +++ b/test/controllers/posts_controller_test.rb @@ -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