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 @@ |
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 | 22 | |
23 | 23 | def discussions |
24 | 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 | 26 | case discussion_status |
27 | 27 | when STATUS_NOT_OPENED |
28 | 28 | discussions = discussions.where("start_date > ?", current_time) | ... | ... |
plugins/comment_paragraph/lib/ext/article.rb
plugins/comment_paragraph/test/unit/discussion_block_test.rb
... | ... | @@ -79,6 +79,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase |
79 | 79 | assert_equivalent [a1, a2], b.discussions |
80 | 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 | 97 | should 'return only not opened discussions if discussion status is not opened' do |
83 | 98 | community = fast_create(Community) |
84 | 99 | community.boxes << Box.new |
... | ... | @@ -108,6 +123,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase |
108 | 123 | assert_equivalent [a2, a3, a5], b.discussions |
109 | 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 | 141 | should 'return only closed discussions if discussion status is closed' do |
112 | 142 | community = fast_create(Community) |
113 | 143 | community.boxes << Box.new |
... | ... | @@ -122,6 +152,21 @@ class DiscussionBlockTest < ActiveSupport::TestCase |
122 | 152 | assert_equivalent [a4], b.discussions |
123 | 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 | 170 | end |
126 | 171 | |
127 | 172 | require 'boxes_helper' | ... | ... |
plugins/comment_paragraph/views/cms/comment_paragraph_plugin/_discussion.html.erb
1 | 1 | <%= required_fields_message %> |
2 | 2 | |
3 | -<%= render :file => 'shared/tiny_mce' %> | |
4 | - | |
5 | 3 | <div> |
6 | 4 | <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> |
7 | 5 | |
... | ... | @@ -9,5 +7,5 @@ |
9 | 7 | <%= render :partial => 'general_fields' %> |
10 | 8 | <%= render :partial => 'translatable' %> |
11 | 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 | 11 | </div> | ... | ... |