Commit 8b8feb7c9420d2f2d7b4f59bb2ea60d18be5f560

Authored by Antonio Terceiro
1 parent 5bedd4b0

ActionItem628: several reviews

app/models/approve_article.rb
@@ -4,7 +4,7 @@ class ApproveArticle < Task @@ -4,7 +4,7 @@ class ApproveArticle < Task
4 validates_presence_of :requestor_id, :target_id 4 validates_presence_of :requestor_id, :target_id
5 5
6 def description 6 def description
7 - _('%s wants to publish %s') % [requestor.name, article.name] 7 + _('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article.title, :community => target.name }
8 end 8 end
9 9
10 def data 10 def data
@@ -41,7 +41,7 @@ class ApproveArticle < Task @@ -41,7 +41,7 @@ class ApproveArticle < Task
41 41
42 def target_notification_message 42 def target_notification_message
43 description + "\n\n" + 43 description + "\n\n" +
44 - _('You need login to accept this.') 44 + _('You need to login on %{system} in order to approve or reject this article. You can use the address below to do that.') % { :system => target.environment.name }
45 end 45 end
46 46
47 end 47 end
app/models/person.rb
@@ -141,6 +141,11 @@ class Person < Profile @@ -141,6 +141,11 @@ class Person < Profile
141 self.user.nil? ? nil : self.user.email 141 self.user.nil? ? nil : self.user.email
142 end 142 end
143 143
  144 + # Returns the user e-mail.
  145 + def contact_email
  146 + email
  147 + end
  148 +
144 def email= (email) 149 def email= (email)
145 self.user.email = email if ! self.user.nil? 150 self.user.email = email if ! self.user.nil?
146 end 151 end
app/models/profile.rb
@@ -226,12 +226,11 @@ class Profile < ActiveRecord::Base @@ -226,12 +226,11 @@ class Profile < ActiveRecord::Base
226 226
227 xss_terminate :only => [ :name, :nickname, :address, :contact_phone ] 227 xss_terminate :only => [ :name, :nickname, :address, :contact_phone ]
228 228
229 - # returns the contact email for this profile. By default returns the the  
230 - # e-mail of the owner user. 229 + # returns the contact email for this profile.
231 # 230 #
232 # Subclasses may -- and should -- override this method. 231 # Subclasses may -- and should -- override this method.
233 def contact_email 232 def contact_email
234 - self.user ? self.user.email : nil 233 + raise NotImplementedError
235 end 234 end
236 235
237 # gets recent documents in this profile, ordered from the most recent to the 236 # gets recent documents in this profile, ordered from the most recent to the
test/unit/person_test.rb
@@ -112,6 +112,12 @@ class PersonTest < Test::Unit::TestCase @@ -112,6 +112,12 @@ class PersonTest < Test::Unit::TestCase
112 assert_nil p.email 112 assert_nil p.email
113 end 113 end
114 114
  115 + should 'use email addreess as contact email' do
  116 + p = Person.new
  117 + p.stubs(:email).returns('my@email.com')
  118 + assert_equal 'my@email.com', p.contact_email
  119 + end
  120 +
115 should 'set email through person instance' do 121 should 'set email through person instance' do
116 u = create_user('testuser') 122 u = create_user('testuser')
117 p = u.person 123 p = u.person
test/unit/profile_test.rb
@@ -1133,6 +1133,12 @@ class ProfileTest < Test::Unit::TestCase @@ -1133,6 +1133,12 @@ class ProfileTest < Test::Unit::TestCase
1133 assert_equal [p], c.admins 1133 assert_equal [p], c.admins
1134 end 1134 end
1135 1135
  1136 + should 'not implement contact_email' do
  1137 + assert_raise NotImplementedError do
  1138 + Profile.new.contact_email
  1139 + end
  1140 + end
  1141 +
1136 private 1142 private
1137 1143
1138 def assert_invalid_identifier(id) 1144 def assert_invalid_identifier(id)