class UsuarioTest < ActiveSupport::TestCase
# Replace this with your real tests.
#test "the truth" do
#assert true
#end
def test_salvar
usuario = Usuario.new
assert usuario.save
end
def test_dois
assert true
end
end
1) Error:
test_dois(UsuarioTest):
ActiveRecord::StatementInvalid: Mysql::Error: Field 'usuario_id' doesn't
have a
default value: INSERT INTO `albums` (...
2) Error:
test_salvar(UsuarioTest):
ActiveRecord::StatementInvalid: Mysql::Error: Field 'usuario_id' doesn't
have a
default value: INSERT INTO `albums` (...
1) Error:
test_dois(UsuarioTest):
ActiveRecord::StatementInvalid: Mysql::Error: Field 'usuario_id' doesn't
have a
default value: INSERT INTO `albums` (...
This is saying 'I tried to insert the fixtures you defined but mysql
didn't like the data you tried to insert'
There is no Usuario "leonardo", but the Album "funk" is saved anyway.
your validations aren't run when inserting fixtures. in addition the
foxy fixtures stuff that means that you can write leonardo to mean '
the users fixtures with label usario' does no validation of the label:
it just generates the id that it knows would be used if there was one