Commit 1144d92c8047a6c47496d44ef123769d5b0ed33e
1 parent
25a6373d
Exists in
suggest_rejected_value
Added unit test to OrganizationRatings
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
2 changed files
with
40 additions
and
7 deletions
Show diff stats
plugins/organization_ratings/test/test_helper.rb
plugins/organization_ratings/test/unit/organization_rating_test.rb
1 | 1 | require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' |
2 | 2 | |
3 | 3 | class OrganizationRatingTest < ActiveSupport::TestCase |
4 | + | |
5 | + def setup | |
6 | + @person = fast_create(Person) | |
7 | + @community = fast_create(Community) | |
8 | + @adminuser = Person[create_admin_user(Environment.default)] | |
9 | + @rating = fast_create(OrganizationRating, {:value => 1, | |
10 | + :person_id => @person.id, | |
11 | + :organization_id => @organization_id, | |
12 | + :comment_rejected => true | |
13 | + }) | |
14 | + end | |
15 | + | |
4 | 16 | test "The value must be between 1 and 5" do |
5 | 17 | organization_rating1 = OrganizationRating.new :value => -1 |
6 | 18 | organization_rating2 = OrganizationRating.new :value => 6 |
... | ... | @@ -21,9 +33,34 @@ class OrganizationRatingTest < ActiveSupport::TestCase |
21 | 33 | assert_equal false, organization_rating2.errors[:value].include?("must be between 1 and 5") |
22 | 34 | end |
23 | 35 | |
24 | - test "display rating comment to env admin" do | |
25 | - p = fast_create(OrganizationRating) | |
36 | + test "display rejected rating to env admin" do | |
37 | + assert @rating.display_comment_to?(@adminuser) | |
38 | + end | |
39 | + | |
40 | + test "display rejected rating to owner" do | |
41 | + assert @rating.display_comment_to?(@person) | |
42 | + end | |
43 | + | |
44 | + test "do not display rejected rating to regular user" do | |
45 | + regular_person = fast_create(Person) | |
46 | + assert_not @rating.display_comment_to?(@otherperson) | |
47 | + end | |
26 | 48 | |
49 | + test "do not display rejected rating to not logged user" do | |
50 | + assert_not @rating.display_comment_to?(nil) | |
51 | + end | |
52 | + | |
53 | + test "display rejected warning to env admin" do | |
54 | + assert @rating.display_rejected_message_to?(@adminuser) | |
55 | + end | |
56 | + | |
57 | + test "display rejected warning to owner" do | |
58 | + assert @rating.display_rejected_message_to?(@person) | |
59 | + end | |
60 | + | |
61 | + test "do not display rejected warnimg to regular user" do | |
62 | + regular_person = fast_create(Person) | |
63 | + assert_not @rating.display_rejected_message_to?(@otherperson) | |
27 | 64 | end |
28 | 65 | |
29 | 66 | test "Create task for create a rating comment" do |
... | ... | @@ -101,7 +138,7 @@ class OrganizationRatingTest < ActiveSupport::TestCase |
101 | 138 | assert_equal 2, create_organization_rating_comment.status |
102 | 139 | message = "Comment rejected" |
103 | 140 | comment = Comment.find_by_id(create_organization_rating_comment.organization_rating_comment_id) |
104 | - assert_equal message, comment.body | |
141 | + assert_equal "sample comment", comment.body | |
105 | 142 | end |
106 | 143 | |
107 | 144 | test "Check comment message when Task status = FINISHED" do | ... | ... |