Skip to content

Instantly share code, notes, and snippets.

@dce
Created April 28, 2009 18:04
Show Gist options
  • Save dce/103291 to your computer and use it in GitHub Desktop.
Save dce/103291 to your computer and use it in GitHub Desktop.
class Test::Unit::TestCase
def self.should_sum_total_ratings
klass = model_class
context "finding total ratings" do
setup do
@ratable = Factory(klass.to_s.downcase)
end
should "have zero total ratings if no rated talks" do
assert_equal 0, @ratable.total_ratings
end
should "have one total rating if one delivery & content rating" do
talk = block_given? ? yield(@ratable) : @ratable
Factory(:content_rating, :talk => talk)
Factory(:delivery_rating, :talk => talk)
assert_equal 1, @ratable.reload.total_ratings
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment