Commit ce143b505a065735bce796cdd2dfc9b5bb315f62

Authored by Evandro Junior
1 parent 4813e9c1
Exists in master

fixed testes

controllers/email_article_plugin_myprofile_controller.rb
@@ -14,6 +14,7 @@ class EmailArticlePluginMyprofileController < MyProfileController @@ -14,6 +14,7 @@ class EmailArticlePluginMyprofileController < MyProfileController
14 14
15 class Sender < ActionMailer::Base 15 class Sender < ActionMailer::Base
16 def content(article) 16 def content(article)
  17 + sender = Person.find(article.author_id)
17 members = article.profile.members 18 members = article.profile.members
18 emails = [] 19 emails = []
19 members.each{ |m| 20 members.each{ |m|
@@ -22,7 +23,7 @@ class EmailArticlePluginMyprofileController &lt; MyProfileController @@ -22,7 +23,7 @@ class EmailArticlePluginMyprofileController &lt; MyProfileController
22 mail( 23 mail(
23 content_type: 'text/html', 24 content_type: 'text/html',
24 to: emails, 25 to: emails,
25 - from: "#{article.author.user.name} <#{article.author.user.email}>", 26 + from: "#{article.author_name} <#{sender.contact_email}>",
26 reply_to: article.author.user.email, 27 reply_to: article.author.user.email,
27 subject: "[Artigo] " + article.title, 28 subject: "[Artigo] " + article.title,
28 body: set_absolute_path(article.body, article.environment) 29 body: set_absolute_path(article.body, article.environment)
test/functional/email_article_plugin_myprofile_controller_test.rb
@@ -14,7 +14,9 @@ class EmailArticlePluginMyprofileControllerTest &lt; ActionController::TestCase @@ -14,7 +14,9 @@ class EmailArticlePluginMyprofileControllerTest &lt; ActionController::TestCase
14 @user = create_user('testinguser') 14 @user = create_user('testinguser')
15 login_as(@user.login) 15 login_as(@user.login)
16 @profile.add_admin(@user.person) 16 @profile.add_admin(@user.person)
17 - @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) 17 + @article = @profile.articles.create!(:name => 'a test article')
  18 + @article.author = @user.person
  19 + puts "---->" + @article.author_id.to_yaml
18 @article.save 20 @article.save
19 get :send_email, :profile => @profile.identifier, :id => @article.id 21 get :send_email, :profile => @profile.identifier, :id => @article.id
20 assert_response :success 22 assert_response :success
@@ -24,16 +26,22 @@ class EmailArticlePluginMyprofileControllerTest &lt; ActionController::TestCase @@ -24,16 +26,22 @@ class EmailArticlePluginMyprofileControllerTest &lt; ActionController::TestCase
24 @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') 26 @profile = Community.create!(:name => 'Another community', :identifier => 'another-community')
25 @user = create_user('user-out-of-the-community') 27 @user = create_user('user-out-of-the-community')
26 login_as(@user.login) 28 login_as(@user.login)
27 - @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) 29 + @article = @profile.articles.create!(:name => 'a test article')
  30 + @article.author = @user.person
28 @article.save 31 @article.save
29 get :send_email, :profile => @profile.identifier, :id => @article.id 32 get :send_email, :profile => @profile.identifier, :id => @article.id
30 assert_response 403 33 assert_response 403
31 end 34 end
32 35
33 -end  
34 -  
35 -  
36 -  
37 -  
38 - 36 + should 'show button at article_toolbar_extra_buttons' do
  37 + @profile = Community.create!(:name => 'Another community', :identifier => 'another-community')
  38 + @user = create_user('user-out-of-the-community')
  39 + login_as(@user.login)
  40 + @article = @profile.articles.create!(:name => 'a test article')
  41 + @article.author = @user.person
  42 + @article.save
  43 + ep = EmailArticlePlugin.new
  44 + ep.article_toolbar_extra_buttons.call
  45 + end
39 46
  47 +end