2018-04-27 18:48:26 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class SiteTest < ActiveSupport::TestCase
|
|
|
|
setup do
|
|
|
|
@user = Usuaria.find('f@kefir.red')
|
|
|
|
@path = File.join(Site.site_path_for(@user), 'cyber-women.com')
|
|
|
|
reset_git_repo(@path)
|
|
|
|
@site = @user.sites.select { |s| s.name == 'cyber-women.com' }.first
|
|
|
|
@site.read
|
|
|
|
end
|
|
|
|
|
|
|
|
test "El directorio es un sitio jekyll" do
|
|
|
|
assert Site.jekyll?(@path)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'Un directorio se puede cargar como un sitio Jekyll' do
|
|
|
|
jekyll = Site.load_jekyll @path
|
|
|
|
|
|
|
|
assert_equal Jekyll::Site, jekyll.class
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'Los artículos no están ordenados si a alguno le falta orden' do
|
|
|
|
assert_not @site.ordered?
|
|
|
|
assert @site.reorder_collection!
|
|
|
|
assert @site.ordered?
|
|
|
|
end
|
2018-04-30 18:51:39 +00:00
|
|
|
|
|
|
|
test 'No podemos poner órdenes arbitrarios' do
|
|
|
|
total = @site.posts.count
|
|
|
|
new_order = Hash[total.times.map { |i| [i.to_s,rand(total)] }]
|
|
|
|
|
|
|
|
assert_not @site.reorder_collection('posts', new_order)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'Si les damos un orden alternativo los reordenamos' do
|
|
|
|
total = @site.posts.count
|
|
|
|
order = total.times.map { |i| i.to_s }
|
|
|
|
new_order = Hash[order.zip(order.shuffle)]
|
|
|
|
|
|
|
|
assert @site.reorder_collection('posts', new_order)
|
2018-05-02 17:23:45 +00:00
|
|
|
|
|
|
|
# podemos hacer este test porque reordenar los posts no ordena el
|
|
|
|
# array
|
|
|
|
new_order.each do |k,v|
|
|
|
|
v = v.to_i
|
|
|
|
k = k.to_i
|
|
|
|
assert_equal v, @site.posts[k].order
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'Podemos reordenar solo una parte de los artículos' do
|
|
|
|
total = @site.posts.count
|
|
|
|
order = (total - rand(total - 1)).times.map { |i| i.to_s }
|
|
|
|
new_order = Hash[order.zip(order.shuffle)]
|
|
|
|
|
|
|
|
assert @site.reorder_collection('posts', new_order)
|
|
|
|
|
|
|
|
# podemos hacer este test porque reordenar los posts no ordena el
|
|
|
|
# array
|
|
|
|
new_order.each do |k,v|
|
|
|
|
v = v.to_i
|
|
|
|
k = k.to_i
|
|
|
|
assert_equal v, @site.posts[k].order
|
|
|
|
end
|
2018-04-30 18:51:39 +00:00
|
|
|
end
|
2018-05-11 16:24:30 +00:00
|
|
|
|
|
|
|
test 'Un sitio tiene traducciones' do
|
|
|
|
assert_equal %w[ar es en], @site.translations
|
|
|
|
assert @site.i18n?
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'El idioma por defecto es el idioma actual de la plataforma' do
|
|
|
|
assert_equal 'es', @site.default_lang
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'El sitio tiene layouts' do
|
|
|
|
assert_equal %w[anexo archive default feed header.ar header.en
|
|
|
|
header.es header license.ar license.en license.es license pandoc
|
|
|
|
politicas sesion simple style ].sort, @site.layouts
|
|
|
|
end
|
2018-04-27 18:48:26 +00:00
|
|
|
end
|