Permalink
Browse files

Image factory, unit tests

  • Loading branch information...
1 parent 2b9294d commit 791dcc540dc597558d760a3fde0cca16a3e713fc @zmcartor zmcartor committed Mar 2, 2013
Showing with 9 additions and 1 deletion.
  1. +3 −0 app/models/image.rb
  2. +1 −1 test/factories/images.rb
  3. +5 −0 test/unit/image_test.rb
View
@@ -1,3 +1,6 @@
class Image < ActiveRecord::Base
attr_accessible :imgur_id
+
+ validates :imgur_id , presence: true
+
end
View
@@ -2,6 +2,6 @@
FactoryGirl.define do
factory :image do
- imgur_id 1
+ imgur_id 'wrt45'
end
end
View
@@ -4,4 +4,9 @@ class ImageTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
+
+ test 'image must have imgur_id' do
+ image = build(:image, imgur_id: nil)
+ assert !image.save, 'image saved without imgur_id'
+ end
end

0 comments on commit 791dcc5

Please sign in to comment.