Commit ce0a14a2110c5a5391d8472590d280ef0d7db510
Committed by
Fabio Teixeira
1 parent
07774218
Exists in
communities_ratings
Add CreateCommunityRatingComment task test
Showing
1 changed file
with
36 additions
and
12 deletions
Show diff stats
plugins/communities_ratings/test/unit/community_rating_test.rb
| @@ -2,23 +2,47 @@ require 'test_helper' | @@ -2,23 +2,47 @@ require 'test_helper' | ||
| 2 | 2 | ||
| 3 | class CommunityRatingTest < ActiveSupport::TestCase | 3 | class CommunityRatingTest < ActiveSupport::TestCase |
| 4 | test "The value must be between 1 and 5" do | 4 | test "The value must be between 1 and 5" do |
| 5 | - cr1 = CommunityRating.new :value => -1 | ||
| 6 | - cr2 = CommunityRating.new :value => 6 | 5 | + community_rating1 = CommunityRating.new :value => -1 |
| 6 | + community_rating2 = CommunityRating.new :value => 6 | ||
| 7 | 7 | ||
| 8 | - assert_equal false, cr1.valid? | ||
| 9 | - assert_equal false, cr2.valid? | 8 | + assert_equal false, community_rating1.valid? |
| 9 | + assert_equal false, community_rating2.valid? | ||
| 10 | 10 | ||
| 11 | - assert_equal true, cr1.errors[:value].include?("must be between 1 and 5") | ||
| 12 | - assert_equal true, cr2.errors[:value].include?("must be between 1 and 5") | 11 | + assert_equal true, community_rating1.errors[:value].include?("must be between 1 and 5") |
| 12 | + assert_equal true, community_rating2.errors[:value].include?("must be between 1 and 5") | ||
| 13 | 13 | ||
| 14 | - cr1.value = 1 | ||
| 15 | - cr1.valid? | 14 | + community_rating1.value = 1 |
| 15 | + community_rating1.valid? | ||
| 16 | 16 | ||
| 17 | - cr2.value = 5 | ||
| 18 | - cr2.valid? | 17 | + community_rating2.value = 5 |
| 18 | + community_rating2.valid? | ||
| 19 | 19 | ||
| 20 | - assert_equal false, cr1.errors[:value].include?("must be between 1 and 5") | ||
| 21 | - assert_equal false, cr2.errors[:value].include?("must be between 1 and 5") | 20 | + assert_equal false, community_rating1.errors[:value].include?("must be between 1 and 5") |
| 21 | + assert_equal false, community_rating2.errors[:value].include?("must be between 1 and 5") | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + test "Create task for create a rating comment" do | ||
| 25 | + person = create_user('molly').person | ||
| 26 | + person.email = "person@email.com" | ||
| 27 | + person.save! | ||
| 28 | + | ||
| 29 | + community = fast_create(Community) | ||
| 30 | + community.add_admin(person) | ||
| 31 | + | ||
| 32 | + community_rating = CommunityRating.create!( | ||
| 33 | + :value => 3, | ||
| 34 | + :person => person, | ||
| 35 | + :community => community | ||
| 36 | + ) | ||
| 37 | + | ||
| 38 | + create_community_rating_comment = CreateCommunityRatingComment.create!( | ||
| 39 | + :requestor => person, | ||
| 40 | + :source => community, | ||
| 41 | + :community_rating => community_rating, | ||
| 42 | + :organization => community | ||
| 43 | + ) | ||
| 44 | + | ||
| 45 | + assert community.tasks.include?(create_community_rating_comment) | ||
| 22 | end | 46 | end |
| 23 | 47 | ||
| 24 | test "Should calculate community's rating average" do | 48 | test "Should calculate community's rating average" do |