require 'test_helper'

class RatingTest < ActiveSupport::TestCase
  fixtures :ratings
  
  def test_should_require_user_id
    rating = Rating.create(:user_id => nil)
    assert rating.errors.on(:user_id), "Missing User ID should add an error"
  end
  
  def test_should_require_song_id
    rating = Rating.create(:song_id => nil)
    assert rating.errors.on(:song_id), "Missing Song ID should add an error"
  end
  
  def test_should_require_rating
    rating = Rating.create(:rating => nil)
    assert rating.errors.on(:rating), "Missing Rating should add an error"
  end
  
  def test_should_have_positive_rating
    rating = Rating.create(:rating => -1)
    assert rating.errors.on(:rating), "Rating should be greater than -1"
  end
  
  def test_should_have_small_rating
    rating = Rating.create(:rating => 6)
    assert rating.errors.on(:rating), "Rating should be less than 6"
  end
end