Commit f7bab27e4e3be8585afc335f8ef42c1340f66c54

Authored by Rodrigo Souto
2 parents 64fddd53 65d3181e

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
app/views/invite/_personalize_invitation_mail.html.erb 0 → 100644
... ... @@ -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   -<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 &lt; ActionController::TestCase
49 49 end
50 50  
51 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 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 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 63 assert_response 200
62 64 end
63 65 end
... ...
test/functional/invite_controller_test.rb
... ... @@ -246,15 +246,15 @@ class InviteControllerTest &lt; ActionController::TestCase
246 246 get :search_friend, :profile => profile.identifier, :q => 'me@'
247 247  
248 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 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 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 258 end
259 259  
260 260 should 'not include members in search friends profiles' do
... ... @@ -268,18 +268,18 @@ class InviteControllerTest &lt; ActionController::TestCase
268 268  
269 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 272 end
273 273  
274 274 should 'invite registered users through profile id' do
275 275 friend1 = create_user('testuser1').person
276 276 friend2 = create_user('testuser2').person
277   - assert_difference Delayed::Job, :count, 1 do
  277 + assert_difference 'Delayed::Job.count', 1 do
278 278 post :invite_registered_friend, :profile => profile.identifier, :q => "#{friend1.id},#{friend2.id}", :mail_template => "click: <url>"
279 279 assert_redirected_to :controller => 'profile', :action => 'friends'
280 280 end
281 281  
282   - assert_difference InviteFriend, :count, 2 do
  282 + assert_difference 'InviteFriend.count', 2 do
283 283 process_delayed_job_queue
284 284 end
285 285 end
... ...
test/unit/invitation_test.rb
... ... @@ -78,7 +78,7 @@ class InvitationTest &lt; ActiveSupport::TestCase
78 78  
79 79 invited_friend.add_friend(person)
80 80  
81   - assert_no_difference InviteFriend, :count do
  81 + assert_no_difference 'InviteFriend.count' do
82 82 Invitation.invite( person, [invited_friend.user.email], "", person )
83 83 end
84 84 end
... ... @@ -90,7 +90,7 @@ class InvitationTest &lt; ActiveSupport::TestCase
90 90 invited_friend.add_friend(person)
91 91 community = fast_create(Community)
92 92  
93   - assert_difference InviteMember, :count do
  93 + assert_difference 'InviteMember.count' do
94 94 Invitation.invite( person, [invited_friend.user.email], "", community )
95 95 end
96 96 end
... ... @@ -126,10 +126,10 @@ class InvitationTest &lt; ActiveSupport::TestCase
126 126 friend = create_user('testuser2').person
127 127 community = fast_create(Community)
128 128  
129   - assert_difference InviteMember, :count do
  129 + assert_difference 'InviteMember.count' do
130 130 Invitation.invite(person, [friend.id.to_s], 'hello friend <url>', community)
131 131 end
132   - assert_difference InviteFriend, :count do
  132 + assert_difference 'InviteFriend.count' do
133 133 Invitation.invite(person, [friend.id.to_s], 'hello friend <url>', person)
134 134 end
135 135 end
... ...
test/unit/invite_member_test.rb
... ... @@ -31,7 +31,7 @@ class InviteMemberTest &lt; ActiveSupport::TestCase
31 31 task = InviteMember.create!(:person => p1, :friend => friend, :community_id => community.id)
32 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 35 task.finish
36 36 end
37 37 end
... ... @@ -96,7 +96,9 @@ class InviteMemberTest &lt; ActiveSupport::TestCase
96 96 p1 = create_user('testuser1').person
97 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 103 task = InviteMember.create!(:person => p1, :friend => p2, :community_id => fast_create(Community).id)
102 104 end
... ... @@ -166,7 +168,7 @@ class InviteMemberTest &lt; ActiveSupport::TestCase
166 168  
167 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 172 assert_match(/#{task.requestor.name} invited you to join #{task.community.name}/, email.subject)
171 173 end
172 174  
... ...