require 'test_helper'

class TesteTest < ActiveSupport::TestCase
  
  test "name cannot be duplicated" do
  	
  	teste = Teste.new
  	teste.name = "name"
  	teste.when = Time.now
  	assert teste.save

  	teste = Teste.new
  	teste.name = "name"
  	teste.when = Time.now
  	assert_not teste.save
  	assert teste.errors.full_messages.include?("Name has already been taken")

  end

  test "name cannot be empty" do
  	
  	teste = Teste.new
  	teste.name = "name"
  	teste.when = Time.now
  	assert teste.save

  	teste = Teste.new
  	teste.when = Time.now
  	assert_not teste.save
  	assert teste.errors.full_messages.include?("Name can't be blank")

  end

  test "when cannot be empty" do
  	
  	teste = Teste.new
  	teste.name = "name"
  	teste.when = Time.now
  	assert teste.save

  	teste = Teste.new
  	teste.name = "name"
  	assert_not teste.save
  	assert teste.errors.full_messages.include?("When can't be blank")

  end

  test "name and when cannot be empty" do
  	
  	teste = Teste.new
  	teste.name = "name"
  	teste.when = Time.now
  	assert teste.save

  	teste = Teste.new
  	assert_not teste.save
  	assert teste.errors.full_messages.include?("When can't be blank")
  	assert teste.errors.full_messages.include?("Name can't be blank")

  end


end
