2019-03-26 15:32:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-27 18:48:26 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class PostTest < ActiveSupport::TestCase
|
|
|
|
setup do
|
|
|
|
@user = Usuaria.find('f@kefir.red')
|
|
|
|
@site = @user.sites.select { |s| s.name == 'cyber-women.com' }.first
|
|
|
|
@post = @site.posts.sample
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'El post no es nuevo si ya existe' do
|
|
|
|
assert_not @post.new?
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'El post está traducido' do
|
|
|
|
assert @post.translated?
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'El post tiene un título' do
|
|
|
|
assert String, @post.title.class
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'El post tiene una fecha' do
|
|
|
|
assert DateTime, @post.date.class
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'Es obvio que un post recién cargado es válido' do
|
|
|
|
assert @post.valid?
|
|
|
|
end
|
2019-05-30 15:52:12 +00:00
|
|
|
|
|
|
|
test 'El post se puede borrar' do
|
|
|
|
path = @post.path
|
|
|
|
|
|
|
|
assert @post.destroy
|
|
|
|
assert_not File.exist?(path)
|
|
|
|
|
|
|
|
post = @site.posts_for(@post.collection).find do |p|
|
|
|
|
p.path == @post.path
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_not post
|
|
|
|
end
|
2018-04-27 18:48:26 +00:00
|
|
|
end
|