Skip to content

Commit

Permalink
Rated images validation, factory, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zmcartor committed Mar 2, 2013
1 parent 791dcc5 commit c6db318
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/models/rated_images.rb
@@ -1,4 +1,7 @@
class RatedImages < ActiveRecord::Base
belongs_to :image
attr_accessible :status

validates :status, :inclusion => 1..4,

end
2 changes: 1 addition & 1 deletion test/factories/rated_images.rb
Expand Up @@ -2,7 +2,7 @@

FactoryGirl.define do
factory :rated_image, :class => 'RatedImages' do
image nil
image
status 1
end
end
7 changes: 7 additions & 0 deletions test/unit/rated_images_test.rb
Expand Up @@ -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.