On Rails 4.
Just added an approved?
attribute to my article model with default: false
When I went to write an integration test I noticed that in the testing environment the approved?
was defaulting to true. To counteract this behavior, I manually added approved: false
to the fixtures (articles.yml) file, but feel I shouldn't have to do this.
Is this the correct behavior? Still new to testing.
Here is what my migration looks like:
class AddApprovalToArticles < ActiveRecord::Migration
def change
add_column :articles, :approved, :boolean, default: false
add_column :articles, :approved_at, :datetime
add_column :articles, :approved_by, :string
end
end
I recently finished Michael Hartl's Rails Tutorial, in which we added an admin?
boolean to the user model. In that case, the fixtures knew to default the value to false.
Thanks for the help, let me know if you need any other specific code of mine.
Aucun commentaire:
Enregistrer un commentaire