Commit 3c633e98b09e1f2c0db4be58d8a5e2b3493aa45e
1 parent
ce143b50
Exists in
master
Fixed tests
Showing
2 changed files
with
21 additions
and
9 deletions
Show diff stats
lib/email_article_plugin.rb
@@ -8,13 +8,16 @@ class EmailArticlePlugin < Noosfero::Plugin | @@ -8,13 +8,16 @@ class EmailArticlePlugin < Noosfero::Plugin | ||
8 | _("A plugin that emails an article to the members of the community") | 8 | _("A plugin that emails an article to the members of the community") |
9 | end | 9 | end |
10 | 10 | ||
11 | + def page | ||
12 | + @page | ||
13 | + end | ||
14 | + | ||
11 | def article_toolbar_extra_buttons | 15 | def article_toolbar_extra_buttons |
12 | label = _("Send article to members") | 16 | label = _("Send article to members") |
13 | htmlclass = _("button with-text icon-menu-mail") | 17 | htmlclass = _("button with-text icon-menu-mail") |
14 | title = _("Email article to all community members") | 18 | title = _("Email article to all community members") |
15 | - | ||
16 | - proc do | ||
17 | - if !profile.blank? and !user.blank? and user.is_admin?(profile) and @page.kind_of?(TextArticle) | 19 | + proc do |
20 | + if !profile.blank? and !user.blank? and user.is_admin?(profile) and page.kind_of?(TextArticle) | ||
18 | link_to_remote( | 21 | link_to_remote( |
19 | label, | 22 | label, |
20 | { | 23 | { |
test/functional/email_article_plugin_myprofile_controller_test.rb
@@ -16,7 +16,6 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase | @@ -16,7 +16,6 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase | ||
16 | @profile.add_admin(@user.person) | 16 | @profile.add_admin(@user.person) |
17 | @article = @profile.articles.create!(:name => 'a test article') | 17 | @article = @profile.articles.create!(:name => 'a test article') |
18 | @article.author = @user.person | 18 | @article.author = @user.person |
19 | - puts "---->" + @article.author_id.to_yaml | ||
20 | @article.save | 19 | @article.save |
21 | get :send_email, :profile => @profile.identifier, :id => @article.id | 20 | get :send_email, :profile => @profile.identifier, :id => @article.id |
22 | assert_response :success | 21 | assert_response :success |
@@ -37,11 +36,21 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase | @@ -37,11 +36,21 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase | ||
37 | @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') | 36 | @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') |
38 | @user = create_user('user-out-of-the-community') | 37 | @user = create_user('user-out-of-the-community') |
39 | login_as(@user.login) | 38 | login_as(@user.login) |
40 | - @article = @profile.articles.create!(:name => 'a test article') | 39 | + @article = TextArticle.new |
40 | + @article.name = 'a test article' | ||
41 | + @article.profile = @profile | ||
41 | @article.author = @user.person | 42 | @article.author = @user.person |
42 | @article.save | 43 | @article.save |
43 | - ep = EmailArticlePlugin.new | ||
44 | - ep.article_toolbar_extra_buttons.call | ||
45 | - end | ||
46 | - | 44 | + @plugin = EmailArticlePlugin.new |
45 | + @plugin.stubs(:link_to_remote).returns(true) | ||
46 | + send_mail_button = @plugin.article_toolbar_extra_buttons | ||
47 | + self.stubs(:profile).returns(@profile) | ||
48 | + self.stubs(:user).returns(@user) | ||
49 | + self.stubs(:page).returns(@article) | ||
50 | + @user.stubs(:is_admin?).returns(true) | ||
51 | + self.stubs(:link_to_remote).returns("send mail button") | ||
52 | + html = self.instance_eval(&send_mail_button) | ||
53 | + assert_equal html, "send mail button" | ||
54 | + end | ||
55 | + | ||
47 | end | 56 | end |