Commit f7bab27e4e3be8585afc335f8ef42c1340f66c54
Exists in
master
and in
29 other branches
Merge remote-tracking branch 'larissa/stoa-rails3' into stoa-merge
Conflicts: app/controllers/application_controller.rb app/models/profile.rb app/views/friends/index.html.erb app/views/invite/_personalize_invitation_mail.html.erb test/functional/invite_controller_test.rb
Showing
6 changed files
with
30 additions
and
26 deletions
Show diff stats
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +<br/> | ||
2 | + | ||
3 | +<%= link_to ('Personalize invitation mail'), nil, :onclick => "jQuery('#invitation-mail_template').show(); return false;" %> | ||
4 | + | ||
5 | +<div id='invitation-mail_template' style='display:none'> | ||
6 | + <%= h _("Now enter an invitation message. You must keep the <url> code in your invitation text. When your friends receive the invitation e-mail, <url> will be replaced by a link that they need to click to activate their account. <user> and <friend> codes will be replaced by your name and friend name, but they are optional.") %> | ||
7 | + <%= labelled_form_field(_('Invitation text:'), text_area_tag(:mail_template, mail_template, :cols => 72, :rows => 8)) %> | ||
8 | +</div> |
app/views/invite/_personalize_invitation_mail.rhtml
@@ -1,8 +0,0 @@ | @@ -1,8 +0,0 @@ | ||
1 | -<br/> | ||
2 | - | ||
3 | -<%= link_to ('Personalize invitation mail'), nil, :onclick => "jQuery('#invitation-mail_template').show(); return false;" %> | ||
4 | - | ||
5 | -<div id='invitation-mail_template' style='display:none'> | ||
6 | - <%= h _("Now enter an invitation message. You must keep the <url> code in your invitation text. When your friends receive the invitation e-mail, <url> will be replaced by a link that they need to click to activate their account. <user> and <friend> codes will be replaced by your name and friend name, but they are optional.") %> | ||
7 | - <%= labelled_form_field(_('Invitation text:'), text_area_tag(:mail_template, mail_template, :cols => 72, :rows => 8)) %> | ||
8 | -</div> |
plugins/stoa/test/functional/invite_controller_test.rb
@@ -49,15 +49,17 @@ class InviteControllerTest < ActionController::TestCase | @@ -49,15 +49,17 @@ class InviteControllerTest < ActionController::TestCase | ||
49 | end | 49 | end |
50 | 50 | ||
51 | should 'search friends profiles by usp_id' do | 51 | should 'search friends profiles by usp_id' do |
52 | - person1 = User.create!(:login => 'john', :email => 'john@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 12345678}).person | ||
53 | - User.create!(:login => 'mary', :email => 'mary@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 11111111}).person | 52 | + person = User.create!(:login => 'john', :email => 'john@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 12345678}).person |
53 | + User.create!(:login => 'joseph', :email => 'joseph@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 12333333}) | ||
54 | + | ||
55 | + admin = User.create!(:login => 'mary', :email => 'mary@example.com', :password => 'test', :password_confirmation => 'test', :person_data => {:usp_id => 11111111}).person | ||
54 | organization = fast_create(Organization) | 56 | organization = fast_create(Organization) |
55 | - organization.add_admin(person1) | 57 | + organization.add_admin(admin) |
56 | 58 | ||
57 | - login_as(person1.identifier) | 59 | + login_as(admin.identifier) |
58 | get :search_friend, :profile => organization.identifier, :q => '1234' | 60 | get :search_friend, :profile => organization.identifier, :q => '1234' |
59 | 61 | ||
60 | - assert_equal [{"name" => person1.name, "id" => person1.id}].to_json, @response.body | 62 | + assert_equal [{"id" => person.id, "name" => person.name}].to_json, @response.body |
61 | assert_response 200 | 63 | assert_response 200 |
62 | end | 64 | end |
63 | end | 65 | end |
test/functional/invite_controller_test.rb
@@ -246,15 +246,15 @@ class InviteControllerTest < ActionController::TestCase | @@ -246,15 +246,15 @@ class InviteControllerTest < ActionController::TestCase | ||
246 | get :search_friend, :profile => profile.identifier, :q => 'me@' | 246 | get :search_friend, :profile => profile.identifier, :q => 'me@' |
247 | 247 | ||
248 | assert_equal 'text/html', @response.content_type | 248 | assert_equal 'text/html', @response.content_type |
249 | - assert_equal [{"name" => friend2.name, "id" => friend2.id}].to_json, @response.body | 249 | + assert_equal [{"id" => friend2.id, "name" => friend2.name}].to_json, @response.body |
250 | 250 | ||
251 | get :search_friend, :profile => profile.identifier, :q => 'cri' | 251 | get :search_friend, :profile => profile.identifier, :q => 'cri' |
252 | 252 | ||
253 | - assert_equal [{"name" => friend1.name, "id" => friend1.id}].to_json, @response.body | 253 | + assert_equal [{"id" => friend1.id, "name" => friend1.name}].to_json, @response.body |
254 | 254 | ||
255 | get :search_friend, :profile => profile.identifier, :q => 'will' | 255 | get :search_friend, :profile => profile.identifier, :q => 'will' |
256 | 256 | ||
257 | - assert_equal [{"name" => friend1.name, "id" => friend1.id}, {"name" => friend2.name, "id" => friend2.id}].to_json, @response.body | 257 | + assert_equal [{"id" => friend1.id, "name" => friend1.name}, {"id" => friend2.id, "name" => friend2.name}].to_json, @response.body |
258 | end | 258 | end |
259 | 259 | ||
260 | should 'not include members in search friends profiles' do | 260 | should 'not include members in search friends profiles' do |
@@ -268,18 +268,18 @@ class InviteControllerTest < ActionController::TestCase | @@ -268,18 +268,18 @@ class InviteControllerTest < ActionController::TestCase | ||
268 | 268 | ||
269 | get :search_friend, :profile => community.identifier, :q => 'will' | 269 | get :search_friend, :profile => community.identifier, :q => 'will' |
270 | 270 | ||
271 | - assert_equal [{"name" => friend1.name, "id" => friend1.id}].to_json, @response.body | 271 | + assert_equivalent [{"name" => friend1.name, "id" => friend1.id}].to_json, @response.body |
272 | end | 272 | end |
273 | 273 | ||
274 | should 'invite registered users through profile id' do | 274 | should 'invite registered users through profile id' do |
275 | friend1 = create_user('testuser1').person | 275 | friend1 = create_user('testuser1').person |
276 | friend2 = create_user('testuser2').person | 276 | friend2 = create_user('testuser2').person |
277 | - assert_difference Delayed::Job, :count, 1 do | 277 | + assert_difference 'Delayed::Job.count', 1 do |
278 | post :invite_registered_friend, :profile => profile.identifier, :q => "#{friend1.id},#{friend2.id}", :mail_template => "click: <url>" | 278 | post :invite_registered_friend, :profile => profile.identifier, :q => "#{friend1.id},#{friend2.id}", :mail_template => "click: <url>" |
279 | assert_redirected_to :controller => 'profile', :action => 'friends' | 279 | assert_redirected_to :controller => 'profile', :action => 'friends' |
280 | end | 280 | end |
281 | 281 | ||
282 | - assert_difference InviteFriend, :count, 2 do | 282 | + assert_difference 'InviteFriend.count', 2 do |
283 | process_delayed_job_queue | 283 | process_delayed_job_queue |
284 | end | 284 | end |
285 | end | 285 | end |
test/unit/invitation_test.rb
@@ -78,7 +78,7 @@ class InvitationTest < ActiveSupport::TestCase | @@ -78,7 +78,7 @@ class InvitationTest < ActiveSupport::TestCase | ||
78 | 78 | ||
79 | invited_friend.add_friend(person) | 79 | invited_friend.add_friend(person) |
80 | 80 | ||
81 | - assert_no_difference InviteFriend, :count do | 81 | + assert_no_difference 'InviteFriend.count' do |
82 | Invitation.invite( person, [invited_friend.user.email], "", person ) | 82 | Invitation.invite( person, [invited_friend.user.email], "", person ) |
83 | end | 83 | end |
84 | end | 84 | end |
@@ -90,7 +90,7 @@ class InvitationTest < ActiveSupport::TestCase | @@ -90,7 +90,7 @@ class InvitationTest < ActiveSupport::TestCase | ||
90 | invited_friend.add_friend(person) | 90 | invited_friend.add_friend(person) |
91 | community = fast_create(Community) | 91 | community = fast_create(Community) |
92 | 92 | ||
93 | - assert_difference InviteMember, :count do | 93 | + assert_difference 'InviteMember.count' do |
94 | Invitation.invite( person, [invited_friend.user.email], "", community ) | 94 | Invitation.invite( person, [invited_friend.user.email], "", community ) |
95 | end | 95 | end |
96 | end | 96 | end |
@@ -126,10 +126,10 @@ class InvitationTest < ActiveSupport::TestCase | @@ -126,10 +126,10 @@ class InvitationTest < ActiveSupport::TestCase | ||
126 | friend = create_user('testuser2').person | 126 | friend = create_user('testuser2').person |
127 | community = fast_create(Community) | 127 | community = fast_create(Community) |
128 | 128 | ||
129 | - assert_difference InviteMember, :count do | 129 | + assert_difference 'InviteMember.count' do |
130 | Invitation.invite(person, [friend.id.to_s], 'hello friend <url>', community) | 130 | Invitation.invite(person, [friend.id.to_s], 'hello friend <url>', community) |
131 | end | 131 | end |
132 | - assert_difference InviteFriend, :count do | 132 | + assert_difference 'InviteFriend.count' do |
133 | Invitation.invite(person, [friend.id.to_s], 'hello friend <url>', person) | 133 | Invitation.invite(person, [friend.id.to_s], 'hello friend <url>', person) |
134 | end | 134 | end |
135 | end | 135 | end |
test/unit/invite_member_test.rb
@@ -31,7 +31,7 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -31,7 +31,7 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
31 | task = InviteMember.create!(:person => p1, :friend => friend, :community_id => community.id) | 31 | task = InviteMember.create!(:person => p1, :friend => friend, :community_id => community.id) |
32 | InviteMember.create!(:person => p2, :friend => friend, :community_id => community.id) | 32 | InviteMember.create!(:person => p2, :friend => friend, :community_id => community.id) |
33 | 33 | ||
34 | - assert_difference friend.tasks.pending, :count, -2 do | 34 | + assert_difference 'friend.tasks.pending.count', -2 do |
35 | task.finish | 35 | task.finish |
36 | end | 36 | end |
37 | end | 37 | end |
@@ -96,7 +96,9 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -96,7 +96,9 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
96 | p1 = create_user('testuser1').person | 96 | p1 = create_user('testuser1').person |
97 | p2 = create_user('testuser2').person | 97 | p2 = create_user('testuser2').person |
98 | 98 | ||
99 | - TaskMailer.expects(:deliver_target_notification).once | 99 | + mailer = mock |
100 | + mailer.expects(:deliver).at_least_once | ||
101 | + TaskMailer.expects(:target_notification).returns(mailer).once | ||
100 | 102 | ||
101 | task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) | 103 | task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) |
102 | end | 104 | end |
@@ -166,7 +168,7 @@ class InviteMemberTest < ActiveSupport::TestCase | @@ -166,7 +168,7 @@ class InviteMemberTest < ActiveSupport::TestCase | ||
166 | 168 | ||
167 | task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) | 169 | task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id) |
168 | 170 | ||
169 | - email = TaskMailer.deliver_target_notification(task, task.target_notification_message) | 171 | + email = TaskMailer.target_notification(task, task.target_notification_message).deliver |
170 | assert_match(/#{task.requestor.name} invited you to join #{task.community.name}/, email.subject) | 172 | assert_match(/#{task.requestor.name} invited you to join #{task.community.name}/, email.subject) |
171 | end | 173 | end |
172 | 174 |