Commit ce143b505a065735bce796cdd2dfc9b5bb315f62
1 parent
4813e9c1
Exists in
master
fixed testes
Showing
2 changed files
with
18 additions
and
9 deletions
Show diff stats
controllers/email_article_plugin_myprofile_controller.rb
| ... | ... | @@ -14,6 +14,7 @@ class EmailArticlePluginMyprofileController < MyProfileController |
| 14 | 14 | |
| 15 | 15 | class Sender < ActionMailer::Base |
| 16 | 16 | def content(article) |
| 17 | + sender = Person.find(article.author_id) | |
| 17 | 18 | members = article.profile.members |
| 18 | 19 | emails = [] |
| 19 | 20 | members.each{ |m| |
| ... | ... | @@ -22,7 +23,7 @@ class EmailArticlePluginMyprofileController < MyProfileController |
| 22 | 23 | mail( |
| 23 | 24 | content_type: 'text/html', |
| 24 | 25 | to: emails, |
| 25 | - from: "#{article.author.user.name} <#{article.author.user.email}>", | |
| 26 | + from: "#{article.author_name} <#{sender.contact_email}>", | |
| 26 | 27 | reply_to: article.author.user.email, |
| 27 | 28 | subject: "[Artigo] " + article.title, |
| 28 | 29 | body: set_absolute_path(article.body, article.environment) | ... | ... |
test/functional/email_article_plugin_myprofile_controller_test.rb
| ... | ... | @@ -14,7 +14,9 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase |
| 14 | 14 | @user = create_user('testinguser') |
| 15 | 15 | login_as(@user.login) |
| 16 | 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 | 20 | @article.save |
| 19 | 21 | get :send_email, :profile => @profile.identifier, :id => @article.id |
| 20 | 22 | assert_response :success |
| ... | ... | @@ -24,16 +26,22 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase |
| 24 | 26 | @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') |
| 25 | 27 | @user = create_user('user-out-of-the-community') |
| 26 | 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 | 31 | @article.save |
| 29 | 32 | get :send_email, :profile => @profile.identifier, :id => @article.id |
| 30 | 33 | assert_response 403 |
| 31 | 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 | ... | ... |