Permalink
Browse files

Rated images validation, factory, tests

  • Loading branch information...
1 parent 791dcc5 commit c6db31867870f72386f8fab6541c8142b3ab840e @zmcartor zmcartor committed Mar 2, 2013
Showing with 11 additions and 1 deletion.
  1. +3 −0 app/models/rated_images.rb
  2. +1 −1 test/factories/rated_images.rb
  3. +7 −0 test/unit/rated_images_test.rb
@@ -1,4 +1,7 @@
class RatedImages < ActiveRecord::Base
belongs_to :image
attr_accessible :status
+
+ validates :status, :inclusion => 1..4,
+
end
@@ -2,7 +2,7 @@
FactoryGirl.define do
factory :rated_image, :class => 'RatedImages' do
- image nil
+ image
status 1
end
end
@@ -4,4 +4,11 @@ class RatedImagesTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
+
+ test 'should be invalid without a sensible status' do
+ ri = build(:rated_image, status: 'fooo')
+ assert !ri.save , 'rated image saved with goofy status'
+ end
+
+
end

0 comments on commit c6db318

Please sign in to comment.