Commit f4d6132d899f1087c3623020977f59a7b1e30777
1 parent
a6d27d8d
Exists in
staging
save body content of comment paragraph plugin
Showing
5 changed files
with
72 additions
and
5 deletions
Show diff stats
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +Feature: Create a new Discussion Article | ||
2 | + As a noosfero user | ||
3 | + I want to create a discusssion article | ||
4 | + | ||
5 | + Background: | ||
6 | + Given Noosfero is configured to use English as default | ||
7 | + Given plugin CommentParagraph is enabled on environment | ||
8 | + Given I am on the homepage | ||
9 | + And the following users | ||
10 | + | login | name | | ||
11 | + | joaosilva | Joao Silva | | ||
12 | + And I am logged in as "joaosilva" | ||
13 | + | ||
14 | + @selenium | ||
15 | + Scenario: discussion article should save content body | ||
16 | + Given I am on joaosilva's control panel | ||
17 | + And I follow "Manage Content" | ||
18 | + And I follow "New content" | ||
19 | + When I follow "Comments Discussion" | ||
20 | + And I fill in "Title" with "My discussion" | ||
21 | + And I fill in tinyMCE "article_body" with "My discussion body!!!" | ||
22 | + And I press "Save" | ||
23 | + Then I should see "My discussion body!!!" |
plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb
@@ -22,7 +22,7 @@ class CommentParagraphPlugin::DiscussionBlock < Block | @@ -22,7 +22,7 @@ class CommentParagraphPlugin::DiscussionBlock < Block | ||
22 | 22 | ||
23 | def discussions | 23 | def discussions |
24 | current_time = Time.now | 24 | current_time = Time.now |
25 | - discussions = holder.articles.where(type: VALID_CONTENT).order('start_date ASC, end_date DESC, created_at DESC').limit(self.total_items) | 25 | + discussions = holder.articles.where(type: VALID_CONTENT).order('start_date ASC, end_date ASC, created_at DESC').limit(self.total_items) |
26 | case discussion_status | 26 | case discussion_status |
27 | when STATUS_NOT_OPENED | 27 | when STATUS_NOT_OPENED |
28 | discussions = discussions.where("start_date > ?", current_time) | 28 | discussions = discussions.where("start_date > ?", current_time) |
plugins/comment_paragraph/lib/ext/article.rb
@@ -49,7 +49,8 @@ class Article | @@ -49,7 +49,8 @@ class Article | ||
49 | commentable.inner_html = paragraph.inner_html | 49 | commentable.inner_html = paragraph.inner_html |
50 | paragraph.inner_html = commentable | 50 | paragraph.inner_html = commentable |
51 | end | 51 | end |
52 | - self.body = doc.at('body').inner_html | 52 | + doc_body = doc.at('body') |
53 | + self.body = doc_body.inner_html if doc_body | ||
53 | end | 54 | end |
54 | end | 55 | end |
55 | 56 |
plugins/comment_paragraph/test/unit/discussion_block_test.rb
@@ -79,6 +79,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase | @@ -79,6 +79,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase | ||
79 | assert_equivalent [a1, a2], b.discussions | 79 | assert_equivalent [a1, a2], b.discussions |
80 | end | 80 | end |
81 | 81 | ||
82 | + should 'return only not opened discussions if discussion status is not opened odered by end_date' do | ||
83 | + community = fast_create(Community) | ||
84 | + community.boxes << Box.new | ||
85 | + b = CommentParagraphPlugin::DiscussionBlock.new | ||
86 | + b.box = community.boxes.last | ||
87 | + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_NOT_OPENED | ||
88 | + b.save | ||
89 | + current_date = DateTime.now + 1 | ||
90 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 7.day) | ||
91 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 3.day) | ||
92 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 1.day) | ||
93 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 4.day) | ||
94 | + assert_equal [a3, a2, a4, a1], b.discussions | ||
95 | + end | ||
96 | + | ||
82 | should 'return only not opened discussions if discussion status is not opened' do | 97 | should 'return only not opened discussions if discussion status is not opened' do |
83 | community = fast_create(Community) | 98 | community = fast_create(Community) |
84 | community.boxes << Box.new | 99 | community.boxes << Box.new |
@@ -108,6 +123,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase | @@ -108,6 +123,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase | ||
108 | assert_equivalent [a2, a3, a5], b.discussions | 123 | assert_equivalent [a2, a3, a5], b.discussions |
109 | end | 124 | end |
110 | 125 | ||
126 | + should 'return only available discussions if discussion status is available odered by end_date' do | ||
127 | + community = fast_create(Community) | ||
128 | + community.boxes << Box.new | ||
129 | + b = CommentParagraphPlugin::DiscussionBlock.new | ||
130 | + b.box = community.boxes.last | ||
131 | + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_AVAILABLE | ||
132 | + b.save | ||
133 | + current_date = DateTime.now | ||
134 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 7.day) | ||
135 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 3.day) | ||
136 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 1.day) | ||
137 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 4.day) | ||
138 | + assert_equal [a3, a2, a4, a1], b.discussions | ||
139 | + end | ||
140 | + | ||
111 | should 'return only closed discussions if discussion status is closed' do | 141 | should 'return only closed discussions if discussion status is closed' do |
112 | community = fast_create(Community) | 142 | community = fast_create(Community) |
113 | community.boxes << Box.new | 143 | community.boxes << Box.new |
@@ -122,6 +152,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase | @@ -122,6 +152,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase | ||
122 | assert_equivalent [a4], b.discussions | 152 | assert_equivalent [a4], b.discussions |
123 | end | 153 | end |
124 | 154 | ||
155 | + should 'return only closed discussions if discussion status is closed odered by end_date' do | ||
156 | + community = fast_create(Community) | ||
157 | + community.boxes << Box.new | ||
158 | + b = CommentParagraphPlugin::DiscussionBlock.new | ||
159 | + b.box = community.boxes.last | ||
160 | + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_CLOSED | ||
161 | + b.save | ||
162 | + current_date = DateTime.now - 10 | ||
163 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 7.day) | ||
164 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 3.day) | ||
165 | + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 1.day) | ||
166 | + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 4.day) | ||
167 | + assert_equal [a1, a4, a2, a3], b.discussions | ||
168 | + end | ||
169 | + | ||
125 | end | 170 | end |
126 | 171 | ||
127 | require 'boxes_helper' | 172 | require 'boxes_helper' |
plugins/comment_paragraph/views/cms/comment_paragraph_plugin/_discussion.html.erb
1 | <%= required_fields_message %> | 1 | <%= required_fields_message %> |
2 | 2 | ||
3 | -<%= render :file => 'shared/tiny_mce' %> | ||
4 | - | ||
5 | <div> | 3 | <div> |
6 | <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> | 4 | <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> |
7 | 5 | ||
@@ -9,5 +7,5 @@ | @@ -9,5 +7,5 @@ | ||
9 | <%= render :partial => 'general_fields' %> | 7 | <%= render :partial => 'general_fields' %> |
10 | <%= render :partial => 'translatable' %> | 8 | <%= render :partial => 'translatable' %> |
11 | <%= date_range_field('article[start_date]', 'article[end_date]', @article.start_date, @article.end_date, {:time => true}, {:id => 'article_start_date'} ) %> | 9 | <%= date_range_field('article[start_date]', 'article[end_date]', @article.start_date, @article.end_date, {:time => true}, {:id => 'article_start_date'} ) %> |
12 | - <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true} %> | 10 | + <%= render :partial => 'shared/lead_and_body' %> |
13 | </div> | 11 | </div> |