require "test_helper" class InformativoTest < ActiveSupport::TestCase test "creates with titulo and sets Datainc automatically" do info = Informativo.create!(titulo: "Novo artigo ambiental") assert_not_nil info.Datainc assert_not_nil info.Idinformativo end test "does not overwrite an existing Datainc" do date = Date.new(2010, 6, 1) info = Informativo.create!(titulo: "Artigo antigo", Datainc: date) assert_equal date, info.Datainc end test "to_html renders markdown column as HTML" do info = Informativo.create!(titulo: "Test", markdown: "## Título\nConteúdo") html = info.to_html assert_includes html, "

" assert_includes html, "Título" end test "temas returns matching tema names" do tema = Tema.create!(cod_tema: 7, tema: "Energia", padrao: "Energia Renovável", count: 0) info = Informativo.create!(titulo: "Solar", tema1: 7) assert_includes info.temas, tema.tema end end