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 | 8 | _("A plugin that emails an article to the members of the community") |
9 | 9 | end |
10 | 10 | |
11 | + def page | |
12 | + @page | |
13 | + end | |
14 | + | |
11 | 15 | def article_toolbar_extra_buttons |
12 | 16 | label = _("Send article to members") |
13 | 17 | htmlclass = _("button with-text icon-menu-mail") |
14 | 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 | 21 | link_to_remote( |
19 | 22 | label, |
20 | 23 | { | ... | ... |
test/functional/email_article_plugin_myprofile_controller_test.rb
... | ... | @@ -16,7 +16,6 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase |
16 | 16 | @profile.add_admin(@user.person) |
17 | 17 | @article = @profile.articles.create!(:name => 'a test article') |
18 | 18 | @article.author = @user.person |
19 | - puts "---->" + @article.author_id.to_yaml | |
20 | 19 | @article.save |
21 | 20 | get :send_email, :profile => @profile.identifier, :id => @article.id |
22 | 21 | assert_response :success |
... | ... | @@ -37,11 +36,21 @@ class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase |
37 | 36 | @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') |
38 | 37 | @user = create_user('user-out-of-the-community') |
39 | 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 | 42 | @article.author = @user.person |
42 | 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 | 56 | end | ... | ... |