diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index f786266..6f9642f 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -248,12 +248,15 @@ class CmsController < MyProfileController end.compact unless params[:marked_groups].nil? if request.post? @failed = {} + if @marked_groups.empty? + return session[:notice] = _("Select some group to publish your article") + end @marked_groups.each do |item| task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) begin task.finish unless item[:group].moderated_articles? rescue Exception => ex - @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name] + @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name] end end if @failed.blank? diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index f31b09a..6caa660 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1791,6 +1791,14 @@ class CmsControllerTest < ActionController::TestCase assert_equal other_person, a.created_by end + should 'continue on the same page, when no group is selected' do + c = Community.create!(:name => 'test comm', :identifier => 'test_comm') + c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') + post :publish, :profile => profile.identifier, :id => article.id, :marked_groups => {c.id.to_s => {}} + assert_template 'cms/publish' + end + protected # FIXME this is to avoid adding an extra dependency for a proper JSON parser. -- libgit2 0.21.2