Commit 47e5f1891b19e98ee20f0df55cb97fb70365562c

Authored by Tallys Martins
Committed by Braulio Bhavamitra
1 parent 75a9f601

Fix cucumber tests for CreateCommunityTask

app/models/create_community.rb
@@ -10,6 +10,7 @@ class CreateCommunity < Task @@ -10,6 +10,7 @@ class CreateCommunity < Task
10 alias :environment= :target= 10 alias :environment= :target=
11 11
12 attr_accessible :environment, :requestor, :target 12 attr_accessible :environment, :requestor, :target
  13 + attr_accessible :reject_explanation, :template_id
13 14
14 acts_as_having_image 15 acts_as_having_image
15 16
features/create_community.feature
@@ -39,44 +39,47 @@ Feature: create community @@ -39,44 +39,47 @@ Feature: create community
39 Then I should see "Creating new community" 39 Then I should see "Creating new community"
40 40
41 Scenario: environment admin receive a task when a user creates a community 41 Scenario: environment admin receive a task when a user creates a community
42 - Given I am logged in as admin 42 + Given I am logged in as "joaosilva"
43 And feature "admin_must_approve_new_communities" is enabled on environment 43 And feature "admin_must_approve_new_communities" is enabled on environment
44 - When I create community "Community for approval" 44 + Given "joaosilva" creates the community "Community for approval"
  45 + Given I am logged in as admin
45 And I go to admin_user's control panel 46 And I go to admin_user's control panel
46 - Then I should see "admin_user wants to create community Community for approval" 47 + Then I should see "Joao Silva wants to create community Community for approval"
47 48
48 Scenario: environment admin accepts new community task 49 Scenario: environment admin accepts new community task
49 - Given I am logged in as admin 50 + Given I am logged in as "joaosilva"
50 And feature "admin_must_approve_new_communities" is enabled on environment 51 And feature "admin_must_approve_new_communities" is enabled on environment
51 - When I create community "Community for approval" 52 + Given "joaosilva" creates the community "Community for approval"
  53 + Given I am logged in as admin
52 And I go to admin_user's control panel 54 And I go to admin_user's control panel
53 And I follow "Process requests" 55 And I follow "Process requests"
54 - And I should see "admin_user wants to create community Community for approval" 56 + And I should see "Joao Silva wants to create community Community for approval"
55 And I choose "Accept" 57 And I choose "Accept"
56 When I press "Apply!" 58 When I press "Apply!"
57 - Then I should not see "admin_user wants to create community Community for approval"  
58 - And I go to admin_user's control panel 59 + Then I should not see "Joao Silva wants to create community Community for approval"
  60 + And I go to joaosilva's control panel
59 And I follow "Manage my groups" 61 And I follow "Manage my groups"
60 Then I should see "Community for approval" 62 Then I should see "Community for approval"
61 63
62 Scenario: environment admin rejects new community task 64 Scenario: environment admin rejects new community task
63 - Given I am logged in as admin 65 + Given I am logged in as "joaosilva"
64 And feature "admin_must_approve_new_communities" is enabled on environment 66 And feature "admin_must_approve_new_communities" is enabled on environment
65 - When I create community "Community for approval" 67 + Given "joaosilva" creates the community "Community for approval"
  68 + Given I am logged in as admin
66 And I go to admin_user's control panel 69 And I go to admin_user's control panel
67 And I follow "Process requests" 70 And I follow "Process requests"
68 - And I should see "admin_user wants to create community Community for approval" 71 + And I should see "Joao Silva wants to create community Community for approval"
69 And I choose "Reject" 72 And I choose "Reject"
70 When I press "Apply!" 73 When I press "Apply!"
71 - Then I should not see "admin_user wants to create community Community for approval"  
72 - And I go to admin_user's control panel 74 + Then I should not see "Joao Silva wants to create community Community for approval"
  75 + And I go to joaosilva's control panel
73 And I follow "Manage my groups" 76 And I follow "Manage my groups"
74 Then I should not see "Community for approval" 77 Then I should not see "Community for approval"
75 78
76 Scenario: new community is listed after approval 79 Scenario: new community is listed after approval
77 Given I am logged in as admin 80 Given I am logged in as admin
78 And feature "admin_must_approve_new_communities" is enabled on environment 81 And feature "admin_must_approve_new_communities" is enabled on environment
79 - When I create community "Community for approval" 82 + Given "admin_user" creates the community "Community for approval"
80 And I approve community "Community for approval" 83 And I approve community "Community for approval"
81 And I go to admin_user's control panel 84 And I go to admin_user's control panel
82 And I follow "Manage my groups" 85 And I follow "Manage my groups"
@@ -85,8 +88,9 @@ Feature: create community @@ -85,8 +88,9 @@ Feature: create community
85 Scenario: new community is not listed after rejection 88 Scenario: new community is not listed after rejection
86 Given I am logged in as admin 89 Given I am logged in as admin
87 And feature "admin_must_approve_new_communities" is enabled on environment 90 And feature "admin_must_approve_new_communities" is enabled on environment
88 - When I create community "Community for approval" 91 + Given "admin_user" creates the community "Community for approval"
89 And I reject community "Community for approval" 92 And I reject community "Community for approval"
90 And I go to admin_user's control panel 93 And I go to admin_user's control panel
91 And I follow "Manage my groups" 94 And I follow "Manage my groups"
92 Then I should not see "Community for approval" 95 Then I should not see "Community for approval"
  96 +
features/step_definitions/create_community_steps.rb
@@ -8,6 +8,14 @@ Given /^I create community "(.+)"$/ do |community| @@ -8,6 +8,14 @@ Given /^I create community "(.+)"$/ do |community|
8 click_button("Create") 8 click_button("Create")
9 end 9 end
10 10
  11 +Given /^"(.+)" creates the community "(.+)"$/ do |username, community|
  12 + When %{I go to #{username}'s control panel}
  13 + click_link('Manage my groups')
  14 + click_link('Create a new community')
  15 + fill_in("Name", :with => community)
  16 + click_button("Create")
  17 +end
  18 +
11 Given /^I approve community "(.+)"$/ do |community| 19 Given /^I approve community "(.+)"$/ do |community|
12 task = CreateCommunity.all.select {|c| c.name == community}.first 20 task = CreateCommunity.all.select {|c| c.name == community}.first
13 Given %{I go to admin_user's control panel} 21 Given %{I go to admin_user's control panel}