Commit 25a6373de305494d7af845c5e5e340118b318425
Committed by
Tallys Martins
1 parent
9000ae3d
Exists in
suggest_rejected_value
Adds tests for rejected organization ratings comments
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Showing
2 changed files
with
72 additions
and
0 deletions
Show diff stats
plugins/organization_ratings/features/rejected_organization_rating.feature
0 → 100644
| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | +Feature: rejected_organization_rating | |
| 2 | + As an admin | |
| 3 | + I want to see the rejected organization ratings | |
| 4 | + So I can distinguish them from the accepted and pending ones | |
| 5 | + | |
| 6 | + Background: | |
| 7 | + Given the environment domain is "localhost" | |
| 8 | + And "OrganizationRatings" plugin is enabled | |
| 9 | + And I am logged in as admin | |
| 10 | + And I go to /admin/plugins | |
| 11 | + And I check "Organization Ratings" | |
| 12 | + And I press "Save changes" | |
| 13 | + And the following user | |
| 14 | + | login | name | | |
| 15 | + | joaosilva | Joao Silva | | |
| 16 | + | mariasilva | Maria Silva | | |
| 17 | + And the following communities | |
| 18 | + | name | | |
| 19 | + | mycommunity | | |
| 20 | + | anothercommunity | | |
| 21 | + And the following blocks | |
| 22 | + | owner | type | | |
| 23 | + | mycommunity | OrganizationRatingsBlock | | |
| 24 | + And the following organization ratings | |
| 25 | + | value | comment_body | organization_name | user_login | task_status | | |
| 26 | + | 5 | A first long test text | mycommunity | mariasilva | 3 | | |
| 27 | + | 5 | A second long test text | mycommunity | joaosilva | 2 | | |
| 28 | + | |
| 29 | + @selenium | |
| 30 | + Scenario: display the rejected comment text to an admin | |
| 31 | + Given I am logged in as "admin_user" | |
| 32 | + And I go to /profile/mycommunity | |
| 33 | + And I should see "A first long test text" within ".ratings-list" | |
| 34 | + And I should see "Comment rejected" within ".ratings-list" | |
| 35 | + And I should see "A second long test text" within ".ratings-list" | |
| 36 | + | |
| 37 | + @selenium | |
| 38 | + Scenario: display the rejected comment text to the comment owner | |
| 39 | + Given I am logged in as "joaosilva" | |
| 40 | + And I go to /profile/mycommunity | |
| 41 | + And I should see "A first long test text" within ".ratings-list" | |
| 42 | + And I should see "Comment rejected" within ".ratings-list" | |
| 43 | + And I should see "A second long test text" within ".ratings-list" | |
| 44 | + | |
| 45 | + @selenium | |
| 46 | + Scenario: do not display the rejected comment text to a regular user | |
| 47 | + Given I am logged in as "mariasilva" | |
| 48 | + And I go to /profile/mycommunity | |
| 49 | + And I should see "A first long test text" within ".ratings-list" | |
| 50 | + And I should not see "Comment rejected" within ".ratings-list" | |
| 51 | + And I should not see "A second long test text" within ".ratings-list" | ... | ... |
plugins/organization_ratings/features/step_definitions/organization_rating_steps.rb
0 → 100644
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +Given /^the following organization ratings$/ do |table| | |
| 2 | + table.hashes.each do |item| | |
| 3 | + person = User.where(login: item[:user_login]).first.person | |
| 4 | + organization = Organization.where(name: item[:organization_name]).first | |
| 5 | + | |
| 6 | + rating = OrganizationRating.new | |
| 7 | + rating.value = item[:value] | |
| 8 | + rating.organization_id = organization.id | |
| 9 | + rating.person_id = person.id | |
| 10 | + rating.save | |
| 11 | + | |
| 12 | + comment_task = CreateOrganizationRatingComment.create!( | |
| 13 | + :body => item[:comment_body], | |
| 14 | + :requestor => person, | |
| 15 | + :organization_rating_id => rating.id, | |
| 16 | + :target => organization) | |
| 17 | + | |
| 18 | + comment_task.status = item[:task_status] | |
| 19 | + comment_task.save | |
| 20 | + end | |
| 21 | +end | ... | ... |