From b3611741462e9f39c775eaf079f43da57383c95b Mon Sep 17 00:00:00 2001 From: Tallys Martins Date: Sun, 13 Sep 2015 14:06:54 -0300 Subject: [PATCH] Fix cucumber tests for CreateCommunityTask --- app/models/create_community.rb | 3 +++ features/create_community.feature | 34 +++++++++++++++++++--------------- features/step_definitions/create_community_steps.rb | 8 ++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/app/models/create_community.rb b/app/models/create_community.rb index 91df0f3..dfe6505 100644 --- a/app/models/create_community.rb +++ b/app/models/create_community.rb @@ -9,6 +9,9 @@ class CreateCommunity < Task alias :environment :target alias :environment= :target= + attr_accessible :environment, :requestor, :target + attr_accessible :reject_explanation, :template_id + acts_as_having_image DATA_FIELDS = Community.fields + ['name', 'closed'] diff --git a/features/create_community.feature b/features/create_community.feature index 573b511..e9497af 100644 --- a/features/create_community.feature +++ b/features/create_community.feature @@ -39,44 +39,47 @@ Feature: create community Then I should see "Creating new community" Scenario: environment admin receive a task when a user creates a community - Given I am logged in as admin + Given I am logged in as "joaosilva" And feature "admin_must_approve_new_communities" is enabled on environment - When I create community "Community for approval" + Given "joaosilva" creates the community "Community for approval" + Given I am logged in as admin And I go to admin_user's control panel - Then I should see "admin_user wants to create community Community for approval" + Then I should see "Joao Silva wants to create community Community for approval" Scenario: environment admin accepts new community task - Given I am logged in as admin + Given I am logged in as "joaosilva" And feature "admin_must_approve_new_communities" is enabled on environment - When I create community "Community for approval" + Given "joaosilva" creates the community "Community for approval" + Given I am logged in as admin And I go to admin_user's control panel And I follow "Process requests" - And I should see "admin_user wants to create community Community for approval" + And I should see "Joao Silva wants to create community Community for approval" And I choose "Accept" When I press "Apply!" - Then I should not see "admin_user wants to create community Community for approval" - And I go to admin_user's control panel + Then I should not see "Joao Silva wants to create community Community for approval" + And I go to joaosilva's control panel And I follow "Manage my groups" Then I should see "Community for approval" Scenario: environment admin rejects new community task - Given I am logged in as admin + Given I am logged in as "joaosilva" And feature "admin_must_approve_new_communities" is enabled on environment - When I create community "Community for approval" + Given "joaosilva" creates the community "Community for approval" + Given I am logged in as admin And I go to admin_user's control panel And I follow "Process requests" - And I should see "admin_user wants to create community Community for approval" + And I should see "Joao Silva wants to create community Community for approval" And I choose "Reject" When I press "Apply!" - Then I should not see "admin_user wants to create community Community for approval" - And I go to admin_user's control panel + Then I should not see "Joao Silva wants to create community Community for approval" + And I go to joaosilva's control panel And I follow "Manage my groups" Then I should not see "Community for approval" Scenario: new community is listed after approval Given I am logged in as admin And feature "admin_must_approve_new_communities" is enabled on environment - When I create community "Community for approval" + Given "admin_user" creates the community "Community for approval" And I approve community "Community for approval" And I go to admin_user's control panel And I follow "Manage my groups" @@ -85,8 +88,9 @@ Feature: create community Scenario: new community is not listed after rejection Given I am logged in as admin And feature "admin_must_approve_new_communities" is enabled on environment - When I create community "Community for approval" + Given "admin_user" creates the community "Community for approval" And I reject community "Community for approval" And I go to admin_user's control panel And I follow "Manage my groups" Then I should not see "Community for approval" + diff --git a/features/step_definitions/create_community_steps.rb b/features/step_definitions/create_community_steps.rb index 5bd09f9..458bc01 100644 --- a/features/step_definitions/create_community_steps.rb +++ b/features/step_definitions/create_community_steps.rb @@ -8,6 +8,14 @@ Given /^I create community "(.+)"$/ do |community| click_button("Create") end +Given /^"(.+)" creates the community "(.+)"$/ do |username, community| + When %{I go to #{username}'s control panel} + click_link('Manage my groups') + click_link('Create a new community') + fill_in("Name", :with => community) + click_button("Create") +end + Given /^I approve community "(.+)"$/ do |community| task = CreateCommunity.all.select {|c| c.name == community}.first Given %{I go to admin_user's control panel} -- libgit2 0.21.2