Commit 7ceaf692b90eacb649b021b6d6dbdad6707ff336
Exists in
staging
and in
7 other branches
mergin with branch comment paragraph
Showing
18 changed files
with
245 additions
and
58 deletions
Show diff stats
app/views/content_viewer/_article_toolbar.html.erb
... | ... | @@ -50,6 +50,8 @@ |
50 | 50 | <%#*Adds extra buttons to the toolbar%> |
51 | 51 | <%= @plugins.dispatch(:article_extra_toolbar_buttons, @page).collect { |content| instance_exec(&content) }.join("") %> |
52 | 52 | |
53 | + <%= @plugins.dispatch(:article_toolbar_actions, @page).collect { |content| instance_exec(&content) }.join("")%> | |
54 | + | |
53 | 55 | <%= report_abuse(profile, :link, @page) %> |
54 | 56 | </div> |
55 | 57 | <div id="article-header"> | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -448,6 +448,12 @@ class Noosfero::Plugin |
448 | 448 | [] |
449 | 449 | end |
450 | 450 | |
451 | + # -> Adds aditional actions to article | |
452 | + # returns = lambda block that creates html code | |
453 | + def article_toolbar_actions article | |
454 | + nil | |
455 | + end | |
456 | + | |
451 | 457 | # -> Adds adicional content to article |
452 | 458 | # returns = lambda block that creates html code |
453 | 459 | def article_extra_contents(article) | ... | ... |
plugins/comment_paragraph/controllers/myprofile/comment_paragraph_plugin_myprofile_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +class CommentParagraphPluginMyprofileController < MyProfileController | |
2 | + | |
3 | + before_filter :check_permission | |
4 | + | |
5 | + def toggle_activation | |
6 | + @article.comment_paragraph_plugin_activate = !@article.comment_paragraph_plugin_activate | |
7 | + @article.save! | |
8 | + redirect_to @article.view_url | |
9 | + end | |
10 | + | |
11 | + protected | |
12 | + | |
13 | + def check_permission | |
14 | + @article = profile.articles.find(params[:id]) | |
15 | + render_access_denied unless @article.comment_paragraph_plugin_enabled? && @article.allow_edit?(user) | |
16 | + end | |
17 | + | |
18 | +end | ... | ... |
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
... | ... | @@ -41,7 +41,14 @@ class CommentParagraphPlugin < Noosfero::Plugin |
41 | 41 | end |
42 | 42 | |
43 | 43 | def self.activation_mode_default_setting |
44 | - 'auto' | |
44 | + 'manual' | |
45 | + end | |
46 | + | |
47 | + def article_toolbar_actions(article) | |
48 | + return unless article.comment_paragraph_plugin_enabled? | |
49 | + proc do | |
50 | + button :toggle_comment_paragraph, article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'), :controller => 'comment_paragraph_plugin_myprofile', :action => 'toggle_activation', :id => article.id if article.allow_edit?(user) | |
51 | + end | |
45 | 52 | end |
46 | 53 | |
47 | 54 | end | ... | ... |
plugins/comment_paragraph/lib/comment_paragraph_plugin/macros/allow_comment.rb
... | ... | @@ -12,7 +12,7 @@ class CommentParagraphPlugin::AllowComment < Noosfero::Plugin::Macro |
12 | 12 | count = article.paragraph_comments.without_spam.in_paragraph(paragraph_uuid).count |
13 | 13 | |
14 | 14 | proc { |
15 | - if controller.kind_of?(ContentViewerController) | |
15 | + if controller.kind_of?(ContentViewerController) && article.comment_paragraph_plugin_activated? | |
16 | 16 | render :partial => 'comment_paragraph_plugin_profile/comment_paragraph', |
17 | 17 | :locals => {:paragraph_uuid => paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => count, :profile_identifier => article.profile.identifier } |
18 | 18 | else | ... | ... |
plugins/comment_paragraph/lib/ext/article.rb
... | ... | @@ -12,21 +12,21 @@ class Article |
12 | 12 | environment.plugin_enabled?(CommentParagraphPlugin) && self.kind_of?(TextArticle) |
13 | 13 | end |
14 | 14 | |
15 | - protected | |
16 | - | |
17 | - def comment_paragraph_plugin_activate? | |
18 | - comment_paragraph_plugin_enabled? && comment_paragraph_plugin_settings.activation_mode == 'auto' | |
15 | + def comment_paragraph_plugin_activated? | |
16 | + comment_paragraph_plugin_activate && comment_paragraph_plugin_enabled? | |
19 | 17 | end |
20 | 18 | |
21 | - def comment_paragraph_plugin_parse_html | |
22 | - comment_paragraph_plugin_activate = comment_paragraph_plugin_activate? | |
23 | - return unless comment_paragraph_plugin_activate | |
19 | + protected | |
24 | 20 | |
25 | - if body && body_changed? | |
21 | + def comment_paragraph_plugin_parse_html | |
22 | + comment_paragraph_plugin_set_initial_value unless persisted? | |
23 | + return unless comment_paragraph_plugin_activated? | |
24 | + if body && (body_changed? || setting_changed?(:comment_paragraph_plugin_activate)) | |
26 | 25 | parsed_paragraphs = [] |
27 | - updated = body_change[1] | |
28 | - doc = Hpricot(updated) | |
29 | - doc.search("/*").each do |paragraph| | |
26 | + updated = body_changed? ? body_change[1] : body | |
27 | + doc = Nokogiri::HTML(updated).css('body') | |
28 | + | |
29 | + doc.children.each do |paragraph| | |
30 | 30 | if paragraph.to_html =~ /^<div(.*)paragraph_comment(.*)$/ || paragraph.to_html =~ /^<p>\W<\/p>$/ |
31 | 31 | parsed_paragraphs << paragraph.to_html |
32 | 32 | else |
... | ... | @@ -41,6 +41,11 @@ class Article |
41 | 41 | end |
42 | 42 | end |
43 | 43 | |
44 | + def comment_paragraph_plugin_set_initial_value | |
45 | + self.comment_paragraph_plugin_activate = comment_paragraph_plugin_enabled? && | |
46 | + comment_paragraph_plugin_settings.activation_mode == 'auto' | |
47 | + end | |
48 | + | |
44 | 49 | def comment_paragraph_plugin_settings |
45 | 50 | @comment_paragraph_plugin_settings ||= Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin) |
46 | 51 | end |
... | ... | @@ -48,8 +53,7 @@ class Article |
48 | 53 | def comment_paragraph_plugin_parse_paragraph(paragraph_content, paragraph_uuid) |
49 | 54 | "<div class='macro article_comments paragraph_comment' " + |
50 | 55 | "data-macro='comment_paragraph_plugin/allow_comment' " + |
51 | - "data-macro-paragraph_uuid='#{paragraph_uuid}'>#{paragraph_content}</div>\r\n" + | |
52 | - "<p> </p>" | |
56 | + "data-macro-paragraph_uuid='#{paragraph_uuid}'>#{paragraph_content}</div>\r\n" | |
53 | 57 | end |
54 | 58 | |
55 | 59 | end | ... | ... |
plugins/comment_paragraph/public/style.css
1 | +#content #article-toolbar .icon-toggle_comment_paragraph { | |
2 | + top: -71px; | |
3 | + border: 0; | |
4 | + background-color: transparent; | |
5 | + color: gray; | |
6 | +} | |
7 | +#content #article-toolbar .icon-toggle_comment_paragraph:hover { | |
8 | + color: black; | |
9 | +} | |
10 | + | |
11 | +.icon-toggle_comment_paragraph{ | |
12 | + background-image: url('/plugins/comment_paragraph/images/internet-group-chat.png'); | |
13 | +} | |
14 | + | |
1 | 15 | #comment-bubble.visible { |
2 | 16 | visibility: visible; |
3 | 17 | } | ... | ... |
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_admin_controller_test.rb
1 | -require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | -require File.dirname(__FILE__) + '/../../controllers/comment_paragraph_plugin_admin_controller' | |
1 | +require_relative '../../../../test/test_helper' | |
2 | +require_relative '../../controllers/comment_paragraph_plugin_admin_controller' | |
3 | 3 | |
4 | 4 | # Re-raise errors caught by the controller. |
5 | 5 | class CommentParagraphPluginAdminController; def rescue_action(e) raise e end; end |
... | ... | @@ -22,10 +22,10 @@ class CommentParagraphPluginAdminControllerTest < ActionController::TestCase |
22 | 22 | end |
23 | 23 | |
24 | 24 | should 'update comment paragraph plugin settings' do |
25 | - assert_not_equal 'manual', plugin_settings.get_setting(:activation_mode) | |
26 | - post :index, :settings => { :activation_mode => 'manual' } | |
25 | + assert_not_equal 'auto', plugin_settings.get_setting(:activation_mode) | |
26 | + post :index, :settings => { :activation_mode => 'auto' } | |
27 | 27 | environment.reload |
28 | - assert_equal 'manual', plugin_settings.get_setting(:activation_mode) | |
28 | + assert_equal 'auto', plugin_settings.get_setting(:activation_mode) | |
29 | 29 | end |
30 | 30 | |
31 | 31 | should 'get article types previously selected' do | ... | ... |
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_myprofile_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,35 @@ |
1 | +require_relative '../test_helper' | |
2 | + | |
3 | +class CommentParagraphPluginMyprofileControllerTest < ActionController::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @environment = Environment.default | |
7 | + @environment.enable_plugin(CommentParagraphPlugin) | |
8 | + @profile = fast_create(Profile) | |
9 | + @user = create_user_with_permission('testuser', 'post_content', @profile) | |
10 | + login_as(@user.identifier) | |
11 | + @article = fast_create(TextArticle, :profile_id => profile.id, :author_id => @user.id) | |
12 | + end | |
13 | + | |
14 | + attr_reader :article, :profile, :user, :environment | |
15 | + | |
16 | + should 'toggle comment paragraph activation' do | |
17 | + assert !article.comment_paragraph_plugin_activate | |
18 | + get :toggle_activation, :id => article.id, :profile => profile.identifier | |
19 | + assert article.reload.comment_paragraph_plugin_activate | |
20 | + assert_redirected_to article.view_url | |
21 | + end | |
22 | + | |
23 | + should 'deny access to toggle activation for forbidden users' do | |
24 | + login_as(create_user('anotheruser').login) | |
25 | + get :toggle_activation, :id => article.id, :profile => profile.identifier | |
26 | + assert_response :forbidden | |
27 | + end | |
28 | + | |
29 | + should 'deny access to toggle activation if plugin is not enabled' do | |
30 | + environment.disable_plugin(CommentParagraphPlugin) | |
31 | + get :toggle_activation, :id => article.id, :profile => profile.identifier | |
32 | + assert_response :forbidden | |
33 | + end | |
34 | + | |
35 | +end | ... | ... |
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
2 | -require File.dirname(__FILE__) + '/../../controllers/profile/comment_paragraph_plugin_profile_controller' | |
1 | +require_relative '../test_helper' | |
2 | +require_relative '../../controllers/profile/comment_paragraph_plugin_profile_controller' | |
3 | 3 | |
4 | 4 | # Re-raise errors caught by the controller. |
5 | 5 | class CommentParagraphPluginProfileController; def rescue_action(e) raise e end; end | ... | ... |
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_public_controller_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
2 | -require File.dirname(__FILE__) + '/../../controllers/public/comment_paragraph_plugin_public_controller' | |
1 | +require_relative '../test_helper' | |
2 | +require_relative '../../controllers/public/comment_paragraph_plugin_public_controller' | |
3 | 3 | |
4 | 4 | |
5 | 5 | # Re-raise errors caught by the controller. |
... | ... | @@ -9,8 +9,7 @@ class CommentParagraphPluginPublicControllerTest < ActionController::TestCase |
9 | 9 | |
10 | 10 | def setup |
11 | 11 | @profile = create_user('testuser').person |
12 | - @article = profile.articles.build(:name => 'test') | |
13 | - @article.save! | |
12 | + @article = profile.articles.create!(:name => 'test') | |
14 | 13 | end |
15 | 14 | attr_reader :article, :profile |
16 | 15 | ... | ... |
plugins/comment_paragraph/test/functional/content_viewer_controller_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
1 | +require_relative '../test_helper' | |
2 | 2 | |
3 | 3 | class ContentViewerController |
4 | 4 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
... | ... | @@ -10,10 +10,12 @@ end |
10 | 10 | class ContentViewerControllerTest < ActionController::TestCase |
11 | 11 | |
12 | 12 | def setup |
13 | - @profile = fast_create(Community) | |
14 | - @page = fast_create(Article, :profile_id => @profile.id, :body => "<div class=\"macro\" data-macro-paragraph_uuid=\"0\" data-macro='comment_paragraph_plugin/allow_comment' ></div>") | |
15 | 13 | @environment = Environment.default |
16 | 14 | @environment.enable_plugin(CommentParagraphPlugin) |
15 | + @profile = fast_create(Community) | |
16 | + @page = fast_create(TextArticle, :profile_id => @profile.id, :body => "<p>inner text</p>") | |
17 | + @page.comment_paragraph_plugin_activate = true | |
18 | + @page.save! | |
17 | 19 | end |
18 | 20 | |
19 | 21 | attr_reader :page | ... | ... |
plugins/comment_paragraph/test/test_helper.rb
plugins/comment_paragraph/test/unit/allow_comment_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
1 | +require_relative '../test_helper' | |
2 | 2 | |
3 | 3 | class AllowCommentTest < ActiveSupport::TestCase |
4 | 4 | |
5 | 5 | def setup |
6 | 6 | @macro = CommentParagraphPlugin::AllowComment.new |
7 | + @environment = Environment.default | |
8 | + @environment.enable_plugin(CommentParagraphPlugin) | |
9 | + | |
10 | + @profile = fast_create(Community) | |
11 | + | |
12 | + @article = fast_create(TextArticle, :profile_id => profile.id, :body => 'inner') | |
13 | + @article.comment_paragraph_plugin_activate = true | |
14 | + @article.save! | |
15 | + | |
16 | + @comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id) | |
17 | + @controller = mock | |
7 | 18 | end |
8 | 19 | |
9 | - attr_reader :macro | |
20 | + attr_reader :macro, :profile, :article, :controller, :comment, :environment | |
10 | 21 | |
11 | 22 | should 'have a configuration' do |
12 | 23 | assert CommentParagraphPlugin::AllowComment.configuration |
13 | 24 | end |
14 | 25 | |
15 | 26 | should 'parse contents to include comment paragraph view' do |
16 | - profile = fast_create(Community) | |
17 | - article = fast_create(Article, :profile_id => profile.id) | |
18 | - comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id) | |
19 | - inner_html = 'inner' | |
20 | - content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article) | |
21 | - expects(:controller).returns(ContentViewerController.new) | |
22 | - | |
23 | - expects(:render).with({:partial => 'comment_paragraph_plugin_profile/comment_paragraph', :locals => {:paragraph_uuid => comment.paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => 1, :profile_identifier => profile.identifier} }) | |
27 | + content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, article.body, article) | |
28 | + controller.expects(:kind_of?).with(ContentViewerController).returns(true) | |
29 | + | |
30 | + expects(:render).with({:partial => 'comment_paragraph_plugin_profile/comment_paragraph', :locals => {:paragraph_uuid => comment.paragraph_uuid, :article_id => article.id, :inner_html => article.body, :count => 1, :profile_identifier => profile.identifier} }) | |
24 | 31 | instance_eval(&content) |
25 | 32 | end |
26 | 33 | |
27 | 34 | should 'not parse contents outside content viewer controller' do |
28 | - profile = fast_create(Community) | |
29 | - article = fast_create(Article, :profile_id => profile.id) | |
30 | - comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id) | |
31 | - inner_html = 'inner' | |
32 | - content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article) | |
33 | - expects(:controller).returns(HomeController.new) | |
35 | + article = fast_create(TextArticle, :profile_id => profile.id, :body => 'inner') | |
36 | + content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, article.body, article) | |
37 | + controller.expects(:kind_of?).with(ContentViewerController).returns(false) | |
38 | + assert_equal 'inner', instance_eval(&content) | |
39 | + end | |
34 | 40 | |
41 | + should 'not parse contents if comment_paragraph is not activated' do | |
42 | + article = fast_create(TextArticle, :profile_id => profile.id, :body => 'inner') | |
43 | + article.expects(:comment_paragraph_plugin_activated?).returns(false) | |
44 | + content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, article.body, article) | |
45 | + controller.expects(:kind_of?).with(ContentViewerController).returns(true) | |
35 | 46 | assert_equal 'inner', instance_eval(&content) |
36 | 47 | end |
37 | 48 | ... | ... |
plugins/comment_paragraph/test/unit/article_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
1 | +require_relative '../test_helper' | |
2 | 2 | require 'benchmark' |
3 | 3 | |
4 | 4 | class ArticleTest < ActiveSupport::TestCase |
5 | 5 | |
6 | 6 | def setup |
7 | - profile = fast_create(Community) | |
8 | - @article = fast_create(Article, :profile_id => profile.id) | |
7 | + @profile = fast_create(Community) | |
8 | + @article = fast_create(TextArticle, :profile_id => profile.id) | |
9 | 9 | @environment = Environment.default |
10 | 10 | @environment.enable_plugin(CommentParagraphPlugin) |
11 | 11 | end |
12 | 12 | |
13 | - attr_reader :article, :environment | |
13 | + attr_reader :article, :environment, :profile | |
14 | 14 | |
15 | 15 | should 'return paragraph comments from article' do |
16 | 16 | comment1 = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id) |
... | ... | @@ -34,9 +34,67 @@ class ArticleTest < ActiveSupport::TestCase |
34 | 34 | |
35 | 35 | should 'parse html if the plugin is not enabled' do |
36 | 36 | article.body = "<p>paragraph 1</p><p>paragraph 2</p>" |
37 | - article.expects(:comment_paragraph_plugin_enabled?).returns(true) | |
37 | + article.comment_paragraph_plugin_activate = true | |
38 | 38 | article.save! |
39 | - assert_match /data-macro='comment_paragraph_plugin\/allow_comment'/, article.body | |
39 | + assert_match /data-macro="comment_paragraph_plugin\/allow_comment"/, article.body | |
40 | + end | |
41 | + | |
42 | + should 'do not remove macro div when disable comment paragraph' do | |
43 | + article.body = "<p>paragraph 1</p><p>paragraph 2</p>" | |
44 | + article.comment_paragraph_plugin_activate = true | |
45 | + article.save! | |
46 | + assert_match /data-macro="comment_paragraph_plugin\/allow_comment"/, article.body | |
47 | + article.comment_paragraph_plugin_activate = false | |
48 | + article.save! | |
49 | + assert_match /data-macro="comment_paragraph_plugin\/allow_comment"/, article.body | |
50 | + end | |
51 | + | |
52 | + should 'parse html when activate comment paragraph' do | |
53 | + article.body = "<p>paragraph 1</p><p>paragraph 2</p>" | |
54 | + article.comment_paragraph_plugin_activate = false | |
55 | + article.save! | |
56 | + assert_equal "<p>paragraph 1</p><p>paragraph 2</p>", article.body | |
57 | + article.comment_paragraph_plugin_activate = true | |
58 | + article.save! | |
59 | + assert_match /data-macro="comment_paragraph_plugin\/allow_comment"/, article.body | |
60 | + end | |
61 | + | |
62 | + should 'be enabled if plugin is enabled and article is a kind of TextArticle' do | |
63 | + assert article.comment_paragraph_plugin_enabled? | |
64 | + end | |
65 | + | |
66 | + should 'not be enabled if plugin is not enabled' do | |
67 | + environment.disable_plugin(CommentParagraphPlugin) | |
68 | + assert !article.comment_paragraph_plugin_enabled? | |
69 | + end | |
70 | + | |
71 | + should 'not be enabled if article if not a kind of TextArticle' do | |
72 | + article = fast_create(Article, :profile_id => profile.id) | |
73 | + assert !article.comment_paragraph_plugin_enabled? | |
74 | + end | |
75 | + | |
76 | + should 'not be activated by default' do | |
77 | + article = fast_create(TextArticle, :profile_id => profile.id) | |
78 | + assert !article.comment_paragraph_plugin_activated? | |
79 | + end | |
80 | + | |
81 | + should 'be activated by default if it is enabled and activation mode is auto' do | |
82 | + settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin) | |
83 | + settings.activation_mode = 'auto' | |
84 | + settings.save! | |
85 | + article = TextArticle.create!(:profile => profile, :name => 'title') | |
86 | + assert article.comment_paragraph_plugin_activated? | |
87 | + end | |
88 | + | |
89 | + should 'be activated when forced' do | |
90 | + article.comment_paragraph_plugin_activate = true | |
91 | + assert article.comment_paragraph_plugin_activated? | |
92 | + end | |
93 | + | |
94 | + should 'not be activated if plugin is not enabled' do | |
95 | + article.comment_paragraph_plugin_activate = true | |
96 | + environment.disable_plugin(CommentParagraphPlugin) | |
97 | + assert !article.comment_paragraph_plugin_enabled? | |
40 | 98 | end |
41 | 99 | |
42 | 100 | end | ... | ... |
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
1 | +require_relative '../test_helper' | |
2 | 2 | include ActionView::Helpers::FormTagHelper |
3 | 3 | |
4 | 4 | class CommentParagraphPluginTest < ActiveSupport::TestCase |
... | ... | @@ -6,9 +6,10 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase |
6 | 6 | def setup |
7 | 7 | @environment = Environment.default |
8 | 8 | @plugin = CommentParagraphPlugin.new |
9 | + @user = create_user('testuser').person | |
9 | 10 | end |
10 | 11 | |
11 | - attr_reader :environment, :plugin | |
12 | + attr_reader :environment, :plugin, :user | |
12 | 13 | |
13 | 14 | should 'have a name' do |
14 | 15 | assert_not_equal Noosfero::Plugin.plugin_name, CommentParagraphPlugin::plugin_name |
... | ... | @@ -35,4 +36,30 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase |
35 | 36 | assert_nil /comment_paragraph_selected_area/.match(prok.call.inspect) |
36 | 37 | end |
37 | 38 | |
39 | + should 'display button to toggle comment paragraph for users which can edit the article' do | |
40 | + article = fast_create(Article) | |
41 | + article.expects(:comment_paragraph_plugin_enabled?).returns(true) | |
42 | + article.expects(:allow_edit?).with(user).returns(true) | |
43 | + | |
44 | + content = plugin.article_header_extra_contents(article) | |
45 | + expects(:button).once | |
46 | + instance_eval(&content) | |
47 | + end | |
48 | + | |
49 | + should 'not display button to toggle comment paragraph for users which can not edit the article' do | |
50 | + article = fast_create(Article) | |
51 | + article.expects(:comment_paragraph_plugin_enabled?).returns(true) | |
52 | + article.expects(:allow_edit?).with(user).returns(false) | |
53 | + | |
54 | + content = plugin.article_header_extra_contents(article) | |
55 | + assert_equal nil, instance_eval(&content) | |
56 | + end | |
57 | + | |
58 | + should 'not display button to toggle comment paragraph if plugin is not enabled' do | |
59 | + article = fast_create(Article) | |
60 | + article.expects(:comment_paragraph_plugin_enabled?).returns(false) | |
61 | + | |
62 | + assert_equal nil, plugin.article_header_extra_contents(article) | |
63 | + end | |
64 | + | |
38 | 65 | end | ... | ... |
plugins/comment_paragraph/test/unit/comment_test.rb
plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb
... | ... | @@ -6,10 +6,14 @@ |
6 | 6 | <div class="activation-mode"> |
7 | 7 | <h4><%= _('Activation Mode') %></h4> |
8 | 8 | <div class="auto"> |
9 | - <%= f.radio_button(:activation_mode, 'auto') %> <%= _('Auto') %> | |
9 | + <%= f.radio_button(:activation_mode, 'auto') %> | |
10 | + <span class="name"><strong><%= _('Auto') %></strong></span> | |
11 | + <span class="detail"><%= _('(all text articles will be activated by default)') %></span> | |
10 | 12 | </div> |
11 | - <div> | |
12 | - <%= f.radio_button(:activation_mode, 'manual') %> <%= _('Manual') %> | |
13 | + <div class="manual"> | |
14 | + <%= f.radio_button(:activation_mode, 'manual') %> | |
15 | + <span class="name"><strong><%= _('Manual') %></strong></span> | |
16 | + <span class="detail"><%= _('(click on "Activate Comment Paragraph" )') %></span> | |
13 | 17 | </div> |
14 | 18 | </div> |
15 | 19 | ... | ... |