Commit 60b07c1ca347204a17d7ac467074baacc7dd579a
1 parent
27b7acbc
Exists in
staging
and in
30 other branches
comment_paragraph: permit the new content type to enable this plugin
Showing
5 changed files
with
23 additions
and
2 deletions
Show diff stats
plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion.rb
@@ -23,4 +23,8 @@ class CommentParagraphPlugin::Discussion < Event | @@ -23,4 +23,8 @@ class CommentParagraphPlugin::Discussion < Event | ||
23 | environment.plugin_enabled?(CommentParagraphPlugin) | 23 | environment.plugin_enabled?(CommentParagraphPlugin) |
24 | end | 24 | end |
25 | 25 | ||
26 | + def comment_paragraph_plugin_activation_mode | ||
27 | + "auto" | ||
28 | + end | ||
29 | + | ||
26 | end | 30 | end |
plugins/comment_paragraph/lib/ext/article.rb
@@ -12,7 +12,7 @@ class Article | @@ -12,7 +12,7 @@ class Article | ||
12 | settings_items :comment_paragraph_plugin_activate, :type => :boolean, :default => false | 12 | settings_items :comment_paragraph_plugin_activate, :type => :boolean, :default => false |
13 | 13 | ||
14 | def comment_paragraph_plugin_enabled? | 14 | def comment_paragraph_plugin_enabled? |
15 | - environment.plugin_enabled?(CommentParagraphPlugin) && self.kind_of?(TextArticle) | 15 | + environment.plugin_enabled?(CommentParagraphPlugin) && (self.kind_of?(TextArticle) || self.kind_of?(CommentParagraphPlugin::Discussion)) |
16 | end | 16 | end |
17 | 17 | ||
18 | def comment_paragraph_plugin_activated? | 18 | def comment_paragraph_plugin_activated? |
@@ -55,7 +55,11 @@ class Article | @@ -55,7 +55,11 @@ class Article | ||
55 | 55 | ||
56 | def comment_paragraph_plugin_set_initial_value | 56 | def comment_paragraph_plugin_set_initial_value |
57 | self.comment_paragraph_plugin_activate = comment_paragraph_plugin_enabled? && | 57 | self.comment_paragraph_plugin_activate = comment_paragraph_plugin_enabled? && |
58 | - comment_paragraph_plugin_settings.activation_mode == 'auto' | 58 | + comment_paragraph_plugin_activation_mode == 'auto' |
59 | + end | ||
60 | + | ||
61 | + def comment_paragraph_plugin_activation_mode | ||
62 | + comment_paragraph_plugin_settings.activation_mode | ||
59 | end | 63 | end |
60 | 64 | ||
61 | def comment_paragraph_plugin_settings | 65 | def comment_paragraph_plugin_settings |
plugins/comment_paragraph/test/unit/api_test.rb
@@ -81,4 +81,13 @@ class APITest < ActiveSupport::TestCase | @@ -81,4 +81,13 @@ class APITest < ActiveSupport::TestCase | ||
81 | json = JSON.parse(last_response.body) | 81 | json = JSON.parse(last_response.body) |
82 | assert_equivalent [comment1.id], json['comments'].map {|c| c['id']} | 82 | assert_equivalent [comment1.id], json['comments'].map {|c| c['id']} |
83 | end | 83 | end |
84 | + | ||
85 | + should "create discussion article" do | ||
86 | + article = fast_create(Article, :profile_id => person.id) | ||
87 | + params[:article] = {name: "Title", type: "CommentParagraphPlugin::Discussion"} | ||
88 | + post "/api/v1/articles/#{article.id}/children?#{params.to_query}" | ||
89 | + json = JSON.parse(last_response.body) | ||
90 | + assert_equal "CommentParagraphPlugin::Discussion", json["article"]["type"] | ||
91 | + assert json["article"]["setting"]["comment_paragraph_plugin_activate"] | ||
92 | + end | ||
84 | end | 93 | end |
plugins/comment_paragraph/test/unit/article_test.rb
@@ -170,4 +170,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -170,4 +170,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
170 | assert_equal nil, article.comment_paragraph_plugin_paragraph_content(1) | 170 | assert_equal nil, article.comment_paragraph_plugin_paragraph_content(1) |
171 | end | 171 | end |
172 | 172 | ||
173 | + should 'be enabled if plugin is enabled and article is a kind of Discussion' do | ||
174 | + assert fast_create(CommentParagraphPlugin::Discussion, profile_id: profile.id).comment_paragraph_plugin_enabled? | ||
175 | + end | ||
173 | end | 176 | end |
plugins/comment_paragraph/test/unit/discussion_test.rb
@@ -15,6 +15,7 @@ class DiscussionTest < ActiveSupport::TestCase | @@ -15,6 +15,7 @@ class DiscussionTest < ActiveSupport::TestCase | ||
15 | discussion = CommentParagraphPlugin::Discussion.new(profile: profile, name: "discussion", start_date: Time.now, end_date: Time.now + 1.day) | 15 | discussion = CommentParagraphPlugin::Discussion.new(profile: profile, name: "discussion", start_date: Time.now, end_date: Time.now + 1.day) |
16 | discussion.body = '<ul><li class="custom_class">item1</li><li>item2</li></ul>' | 16 | discussion.body = '<ul><li class="custom_class">item1</li><li>item2</li></ul>' |
17 | discussion.save! | 17 | discussion.save! |
18 | + assert discussion.comment_paragraph_plugin_activate | ||
18 | assert_mark_paragraph discussion.body, 'li', 'item1' | 19 | assert_mark_paragraph discussion.body, 'li', 'item1' |
19 | assert_mark_paragraph discussion.body, 'li', 'item2' | 20 | assert_mark_paragraph discussion.body, 'li', 'item2' |
20 | end | 21 | end |