Commit f3cd985b718e269e510c9c104764a5113aa05ec1
Exists in
master
and in
29 other branches
Merge branch 'AI3228_spreading_article' into 'master'
Ai3228 spreading article AI 3228 fix spreading article. http://noosfero.org/Development/ActionItem3228 See merge request !267
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -248,12 +248,15 @@ class CmsController < MyProfileController | @@ -248,12 +248,15 @@ class CmsController < MyProfileController | ||
248 | end.compact unless params[:marked_groups].nil? | 248 | end.compact unless params[:marked_groups].nil? |
249 | if request.post? | 249 | if request.post? |
250 | @failed = {} | 250 | @failed = {} |
251 | + if @marked_groups.empty? | ||
252 | + return session[:notice] = _("Select some group to publish your article") | ||
253 | + end | ||
251 | @marked_groups.each do |item| | 254 | @marked_groups.each do |item| |
252 | task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) | 255 | task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) |
253 | begin | 256 | begin |
254 | task.finish unless item[:group].moderated_articles? | 257 | task.finish unless item[:group].moderated_articles? |
255 | rescue Exception => ex | 258 | rescue Exception => ex |
256 | - @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name] | 259 | + @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name] |
257 | end | 260 | end |
258 | end | 261 | end |
259 | if @failed.blank? | 262 | if @failed.blank? |
test/functional/cms_controller_test.rb
@@ -1791,6 +1791,14 @@ class CmsControllerTest < ActionController::TestCase | @@ -1791,6 +1791,14 @@ class CmsControllerTest < ActionController::TestCase | ||
1791 | assert_equal other_person, a.created_by | 1791 | assert_equal other_person, a.created_by |
1792 | end | 1792 | end |
1793 | 1793 | ||
1794 | + should 'continue on the same page, when no group is selected' do | ||
1795 | + c = Community.create!(:name => 'test comm', :identifier => 'test_comm') | ||
1796 | + c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) | ||
1797 | + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | ||
1798 | + post :publish, :profile => profile.identifier, :id => article.id, :marked_groups => {c.id.to_s => {}} | ||
1799 | + assert_template 'cms/publish' | ||
1800 | + end | ||
1801 | + | ||
1794 | protected | 1802 | protected |
1795 | 1803 | ||
1796 | # FIXME this is to avoid adding an extra dependency for a proper JSON parser. | 1804 | # FIXME this is to avoid adding an extra dependency for a proper JSON parser. |