From a5267bacbb4f93bc0e0eabb61303ce972d41f84e Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Wed, 19 May 2010 11:44:12 -0300 Subject: [PATCH] Fixing email invitation for community and friend --- app/views/tasks/_add_friend.rhtml | 2 +- app/views/tasks/_invite_friend.rhtml | 1 + app/views/tasks/_invite_member.rhtml | 29 +++++++++++++++++++++++++++++ features/invitation.feature | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- features/step_definitions/invitation_steps.rb | 19 +++++++++++++++++++ features/support/paths.rb | 3 +++ 6 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 app/views/tasks/_invite_friend.rhtml create mode 100644 app/views/tasks/_invite_member.rhtml create mode 100644 features/step_definitions/invitation_steps.rb diff --git a/app/views/tasks/_add_friend.rhtml b/app/views/tasks/_add_friend.rhtml index b8c57ff..f7b71c7 100644 --- a/app/views/tasks/_add_friend.rhtml +++ b/app/views/tasks/_add_friend.rhtml @@ -2,7 +2,7 @@ <%= link_to( profile_image(task.requestor, :minor, :border => 0), task.requestor.public_profile_url ) %> -<%= _('%s wants to connect to you as a friend.') % +<%= _('%s wants to be your friend.') % content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ) %> <% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> diff --git a/app/views/tasks/_invite_friend.rhtml b/app/views/tasks/_invite_friend.rhtml new file mode 100644 index 0000000..10b812f --- /dev/null +++ b/app/views/tasks/_invite_friend.rhtml @@ -0,0 +1 @@ +<%= render :partial => 'add_friend', :locals => {:task => task} %> diff --git a/app/views/tasks/_invite_member.rhtml b/app/views/tasks/_invite_member.rhtml new file mode 100644 index 0000000..2934ce2 --- /dev/null +++ b/app/views/tasks/_invite_member.rhtml @@ -0,0 +1,29 @@ +

<%= _('Join community') %>

+ +<%= link_to( profile_image(task.requestor, :minor, :border => 0), task.requestor.public_profile_url ) %> + +<%= _('%s invites you to join the community %s.') % + [content_tag('strong', link_to( task.requestor.name, task.requestor.public_profile_url ) ), + content_tag('strong', link_to( task.community.name, task.community.public_profile_url ) )] %> + +<% form_for('task', task, :url => { :action => 'close', :id => task.id } ) do |f| %> + +
+ <%= radio_button_tag(:decision, 'finish', true, + :id => "decision-finish-#{task.id}", + :onclick => "Element.show('group-for-friend-#{task.id}')") %> + + +     + + <%= radio_button_tag(:decision, 'cancel', false, + :id => "decision-cancel-#{task.id}", + :onclick => "Element.hide('group-for-friend-#{task.id}')") %> + + +
+ + <% button_bar do %> + <%= submit_button(:ok, _('Ok!')) %> + <% end %> +<% end %> diff --git a/features/invitation.feature b/features/invitation.feature index e1afedc..46b124d 100644 --- a/features/invitation.feature +++ b/features/invitation.feature @@ -4,9 +4,9 @@ Feature: invitation Background: Given the following users - | login | - | josesilva | - | josesantos | + | login | email | + | josesilva | silva@invalid.br | + | josesantos | santos@invalid.br | And the following communities | owner | identifier | name | | josesilva | 26-bsslines | 26 Bsslines | @@ -72,14 +72,89 @@ Feature: invitation Then I should see "Access denied" Scenario: not see link to invite members to enterprise in manage members - Given I am on /myprofile/beatles-for-sale/profile_members + Given I am on Beatles For Sale's members management Then I should not see "Invite your friends to join Beatles For Sale" link Scenario: back to manage members after invite friends - Given I am on /myprofile/26-bsslines/profile_members + Given I am on 26 Bsslines's members management And I follow "Invite your friends to join 26 Bsslines" And I press "Next" And I fill in "manual_import_addresses" with "misfits@devil.doll" And I fill in "mail_template" with "Follow this link " When I press "Invite my friends!" Then I should be on /myprofile/26-bsslines/profile_members + + Scenario: noosfero user receives a task when a user invites to join a community + Given I am on 26 Bsslines's members management + And I follow "Invite your friends to join 26 Bsslines" + And I press "Next" + And I fill in "manual_import_addresses" with "santos@invalid.br" + And I fill in "mail_template" with "Follow this link " + And I press "Invite my friends!" + When I am logged in as "josesantos" + And I follow "Control Panel" + And I should see "josesilva invites you to join the community 26 Bsslines." + + Scenario: noosfero user accepts to join community + Given I invite email "santos@invalid.br" to join community "26 Bsslines" + When I am logged in as "josesantos" + And I follow "Control panel" + And I follow "Process requests" + And I should see "josesilva invites you to join the community 26 Bsslines." + And I choose "Accept" + When I press "Ok!" + Then I should not see "josesilva invites you to join the community 26 Bsslines." + When I follow "Control panel" + And I follow "Manage my groups" + Then I should see "26 Bsslines" + + Scenario: noosfero user rejects to join community + Given I invite email "santos@invalid.br" to join community "26 Bsslines" + When I am logged in as "josesantos" + And I follow "Control panel" + And I follow "Process requests" + And I should see "josesilva invites you to join the community 26 Bsslines." + And I choose "Reject" + When I press "Ok!" + Then I should not see "josesilva invites you to join the community 26 Bsslines." + When I follow "Control panel" + And I follow "Manage my groups" + Then I should not see "26 Bsslines" + + Scenario: noosfero user receives a task when a user invites to be friend + Given I am on josesilva's control panel + And I follow "Manage Friends" + And I follow "Invite people from my e-mail contacts" + And I press "Next" + And I fill in "manual_import_addresses" with "santos@invalid.br" + And I fill in "mail_template" with "Follow this link " + And I press "Invite my friends!" + When I am logged in as "josesantos" + And I follow "Control Panel" + And I should see "josesilva wants to be your friend." + + Scenario: noosfero user accepts to be friend + Given I invite email "santos@invalid.br" to be my friend + When I am logged in as "josesantos" + And I follow "Control panel" + And I follow "Process requests" + And I should see "josesilva wants to be your friend." + And I choose "Accept" + When I press "Ok!" + And I should not see "josesilva wants to be your friend." + When I follow "Control panel" + And I follow "Manage friends" + Then I should see "josesilva" + + Scenario: noosfero user rejects to be friend + Given I invite email "santos@invalid.br" to be my friend + When I am logged in as "josesantos" + And I follow "Control panel" + And I follow "Process requests" + And I should see "josesilva wants to be your friend." + And I choose "Ignore" + When I press "Ok!" + And I should not see "josesilva wants to be your friend." + When I follow "Control panel" + And I follow "Manage friends" + Then I should not see "josesilva" diff --git a/features/step_definitions/invitation_steps.rb b/features/step_definitions/invitation_steps.rb new file mode 100644 index 0000000..7dabb97 --- /dev/null +++ b/features/step_definitions/invitation_steps.rb @@ -0,0 +1,19 @@ +Given /^I invite email "(.+)" to join community "(.+)"$/ do |email, community| + identifier = Community.find_by_name(community).identifier + visit("/myprofile/#{identifier}/profile_members") + click_link('Invite your friends to join 26 Bsslines') + click_button('Next') + fill_in('manual_import_addresses', :with => "#{email}") + fill_in('mail_template', :with => 'Follow this link ') + click_button("Invite my friends!") +end + +Given /^I invite email "(.+)" to be my friend$/ do |email| + click_link('Control panel') + click_link('Manage friends') + click_link('Invite people from my e-mail contacts') + click_button('Next') + fill_in('manual_import_addresses', :with => "#{email}") + fill_in('mail_template', :with => 'Follow this link ') + click_button("Invite my friends!") +end diff --git a/features/support/paths.rb b/features/support/paths.rb index 3417932..074ef57 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -45,6 +45,9 @@ module NavigationHelpers when /^(.+)'s cms/ '/myprofile/%s/cms' % Profile.find_by_name($1).identifier + when /^(.+)'s members management/ + '/myprofile/%s/profile_members' % Profile.find_by_name($1).identifier + # Add more mappings here. # Here is a more fancy example: # -- libgit2 0.21.2