From ce143b505a065735bce796cdd2dfc9b5bb315f62 Mon Sep 17 00:00:00 2001 From: Evandro Junior Date: Mon, 23 Feb 2015 12:30:16 -0300 Subject: [PATCH] fixed testes --- controllers/email_article_plugin_myprofile_controller.rb | 3 ++- test/functional/email_article_plugin_myprofile_controller_test.rb | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/controllers/email_article_plugin_myprofile_controller.rb b/controllers/email_article_plugin_myprofile_controller.rb index b74ceb9..b5bed2d 100644 --- a/controllers/email_article_plugin_myprofile_controller.rb +++ b/controllers/email_article_plugin_myprofile_controller.rb @@ -14,6 +14,7 @@ class EmailArticlePluginMyprofileController < MyProfileController class Sender < ActionMailer::Base def content(article) + sender = Person.find(article.author_id) members = article.profile.members emails = [] members.each{ |m| @@ -22,7 +23,7 @@ class EmailArticlePluginMyprofileController < MyProfileController mail( content_type: 'text/html', to: emails, - from: "#{article.author.user.name} <#{article.author.user.email}>", + from: "#{article.author_name} <#{sender.contact_email}>", reply_to: article.author.user.email, subject: "[Artigo] " + article.title, body: set_absolute_path(article.body, article.environment) diff --git a/test/functional/email_article_plugin_myprofile_controller_test.rb b/test/functional/email_article_plugin_myprofile_controller_test.rb index 4f1d1c4..748bb9c 100644 --- a/test/functional/email_article_plugin_myprofile_controller_test.rb +++ b/test/functional/email_article_plugin_myprofile_controller_test.rb @@ -14,7 +14,9 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase @user = create_user('testinguser') login_as(@user.login) @profile.add_admin(@user.person) - @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) + @article = @profile.articles.create!(:name => 'a test article') + @article.author = @user.person + puts "---->" + @article.author_id.to_yaml @article.save get :send_email, :profile => @profile.identifier, :id => @article.id assert_response :success @@ -24,16 +26,22 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') @user = create_user('user-out-of-the-community') login_as(@user.login) - @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) + @article = @profile.articles.create!(:name => 'a test article') + @article.author = @user.person @article.save get :send_email, :profile => @profile.identifier, :id => @article.id assert_response 403 end -end - - - - - + should 'show button at article_toolbar_extra_buttons' do + @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') + @user = create_user('user-out-of-the-community') + login_as(@user.login) + @article = @profile.articles.create!(:name => 'a test article') + @article.author = @user.person + @article.save + ep = EmailArticlePlugin.new + ep.article_toolbar_extra_buttons.call + end +end -- libgit2 0.21.2