From 25a6373de305494d7af845c5e5e340118b318425 Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Tue, 24 Nov 2015 19:10:21 +0000 Subject: [PATCH] Adds tests for rejected organization ratings comments --- plugins/organization_ratings/features/rejected_organization_rating.feature | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/organization_ratings/features/step_definitions/organization_rating_steps.rb | 21 +++++++++++++++++++++ 2 files changed, 72 insertions(+), 0 deletions(-) create mode 100644 plugins/organization_ratings/features/rejected_organization_rating.feature create mode 100644 plugins/organization_ratings/features/step_definitions/organization_rating_steps.rb diff --git a/plugins/organization_ratings/features/rejected_organization_rating.feature b/plugins/organization_ratings/features/rejected_organization_rating.feature new file mode 100644 index 0000000..8e34725 --- /dev/null +++ b/plugins/organization_ratings/features/rejected_organization_rating.feature @@ -0,0 +1,51 @@ +Feature: rejected_organization_rating + As an admin + I want to see the rejected organization ratings + So I can distinguish them from the accepted and pending ones + + Background: + Given the environment domain is "localhost" + And "OrganizationRatings" plugin is enabled + And I am logged in as admin + And I go to /admin/plugins + And I check "Organization Ratings" + And I press "Save changes" + And the following user + | login | name | + | joaosilva | Joao Silva | + | mariasilva | Maria Silva | + And the following communities + | name | + | mycommunity | + | anothercommunity | + And the following blocks + | owner | type | + | mycommunity | OrganizationRatingsBlock | + And the following organization ratings + | value | comment_body | organization_name | user_login | task_status | + | 5 | A first long test text | mycommunity | mariasilva | 3 | + | 5 | A second long test text | mycommunity | joaosilva | 2 | + + @selenium + Scenario: display the rejected comment text to an admin + Given I am logged in as "admin_user" + And I go to /profile/mycommunity + And I should see "A first long test text" within ".ratings-list" + And I should see "Comment rejected" within ".ratings-list" + And I should see "A second long test text" within ".ratings-list" + + @selenium + Scenario: display the rejected comment text to the comment owner + Given I am logged in as "joaosilva" + And I go to /profile/mycommunity + And I should see "A first long test text" within ".ratings-list" + And I should see "Comment rejected" within ".ratings-list" + And I should see "A second long test text" within ".ratings-list" + + @selenium + Scenario: do not display the rejected comment text to a regular user + Given I am logged in as "mariasilva" + And I go to /profile/mycommunity + And I should see "A first long test text" within ".ratings-list" + And I should not see "Comment rejected" within ".ratings-list" + And I should not see "A second long test text" within ".ratings-list" diff --git a/plugins/organization_ratings/features/step_definitions/organization_rating_steps.rb b/plugins/organization_ratings/features/step_definitions/organization_rating_steps.rb new file mode 100644 index 0000000..44251e5 --- /dev/null +++ b/plugins/organization_ratings/features/step_definitions/organization_rating_steps.rb @@ -0,0 +1,21 @@ +Given /^the following organization ratings$/ do |table| + table.hashes.each do |item| + person = User.where(login: item[:user_login]).first.person + organization = Organization.where(name: item[:organization_name]).first + + rating = OrganizationRating.new + rating.value = item[:value] + rating.organization_id = organization.id + rating.person_id = person.id + rating.save + + comment_task = CreateOrganizationRatingComment.create!( + :body => item[:comment_body], + :requestor => person, + :organization_rating_id => rating.id, + :target => organization) + + comment_task.status = item[:task_status] + comment_task.save + end +end -- libgit2 0.21.2