diff --git a/plugins/comment_paragraph/features/cms.feature b/plugins/comment_paragraph/features/cms.feature new file mode 100644 index 0000000..bd64106 --- /dev/null +++ b/plugins/comment_paragraph/features/cms.feature @@ -0,0 +1,23 @@ +Feature: Create a new Discussion Article + As a noosfero user + I want to create a discusssion article + + Background: + Given Noosfero is configured to use English as default + Given plugin CommentParagraph is enabled on environment + Given I am on the homepage + And the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + + @selenium + Scenario: discussion article should save content body + Given I am on joaosilva's control panel + And I follow "Manage Content" + And I follow "New content" + When I follow "Comments Discussion" + And I fill in "Title" with "My discussion" + And I fill in tinyMCE "article_body" with "My discussion body!!!" + And I press "Save" + Then I should see "My discussion body!!!" diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb index af2b473..1bca003 100644 --- a/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb @@ -22,7 +22,7 @@ class CommentParagraphPlugin::DiscussionBlock < Block def discussions current_time = Time.now - discussions = holder.articles.where(type: VALID_CONTENT).order('start_date ASC, end_date DESC, created_at DESC').limit(self.total_items) + discussions = holder.articles.where(type: VALID_CONTENT).order('start_date ASC, end_date ASC, created_at DESC').limit(self.total_items) case discussion_status when STATUS_NOT_OPENED discussions = discussions.where("start_date > ?", current_time) diff --git a/plugins/comment_paragraph/lib/ext/article.rb b/plugins/comment_paragraph/lib/ext/article.rb index 0eaee8c..d00285b 100644 --- a/plugins/comment_paragraph/lib/ext/article.rb +++ b/plugins/comment_paragraph/lib/ext/article.rb @@ -49,7 +49,8 @@ class Article commentable.inner_html = paragraph.inner_html paragraph.inner_html = commentable end - self.body = doc.at('body').inner_html + doc_body = doc.at('body') + self.body = doc_body.inner_html if doc_body end end diff --git a/plugins/comment_paragraph/test/unit/discussion_block_test.rb b/plugins/comment_paragraph/test/unit/discussion_block_test.rb index 769396f..34c30d6 100644 --- a/plugins/comment_paragraph/test/unit/discussion_block_test.rb +++ b/plugins/comment_paragraph/test/unit/discussion_block_test.rb @@ -79,6 +79,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase assert_equivalent [a1, a2], b.discussions end + should 'return only not opened discussions if discussion status is not opened odered by end_date' do + community = fast_create(Community) + community.boxes << Box.new + b = CommentParagraphPlugin::DiscussionBlock.new + b.box = community.boxes.last + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_NOT_OPENED + b.save + current_date = DateTime.now + 1 + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 7.day) + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 3.day) + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 1.day) + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 4.day) + assert_equal [a3, a2, a4, a1], b.discussions + end + should 'return only not opened discussions if discussion status is not opened' do community = fast_create(Community) community.boxes << Box.new @@ -108,6 +123,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase assert_equivalent [a2, a3, a5], b.discussions end + should 'return only available discussions if discussion status is available odered by end_date' do + community = fast_create(Community) + community.boxes << Box.new + b = CommentParagraphPlugin::DiscussionBlock.new + b.box = community.boxes.last + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_AVAILABLE + b.save + current_date = DateTime.now + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 7.day) + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 3.day) + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 1.day) + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now + 4.day) + assert_equal [a3, a2, a4, a1], b.discussions + end + should 'return only closed discussions if discussion status is closed' do community = fast_create(Community) community.boxes << Box.new @@ -122,6 +152,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase assert_equivalent [a4], b.discussions end + should 'return only closed discussions if discussion status is closed odered by end_date' do + community = fast_create(Community) + community.boxes << Box.new + b = CommentParagraphPlugin::DiscussionBlock.new + b.box = community.boxes.last + b.discussion_status = CommentParagraphPlugin::DiscussionBlock::STATUS_CLOSED + b.save + current_date = DateTime.now - 10 + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 7.day) + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 3.day) + a3 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 1.day) + a4 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id, :start_date => current_date, :end_date => DateTime.now - 4.day) + assert_equal [a1, a4, a2, a3], b.discussions + end + end require 'boxes_helper' diff --git a/plugins/comment_paragraph/views/cms/comment_paragraph_plugin/_discussion.html.erb b/plugins/comment_paragraph/views/cms/comment_paragraph_plugin/_discussion.html.erb index f313f1b..a9b4aed 100644 --- a/plugins/comment_paragraph/views/cms/comment_paragraph_plugin/_discussion.html.erb +++ b/plugins/comment_paragraph/views/cms/comment_paragraph_plugin/_discussion.html.erb @@ -1,7 +1,5 @@ <%= required_fields_message %> -<%= render :file => 'shared/tiny_mce' %> -
<%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> @@ -9,5 +7,5 @@ <%= render :partial => 'general_fields' %> <%= render :partial => 'translatable' %> <%= date_range_field('article[start_date]', 'article[end_date]', @article.start_date, @article.end_date, {:time => true}, {:id => 'article_start_date'} ) %> - <%= render :partial => 'shared/lead_and_body', :locals => {:tiny_mce => true} %> + <%= render :partial => 'shared/lead_and_body' %>
-- libgit2 0.21.2