From b6ec7ab024edbd686985bc0d70bf44754f4c609c Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Fri, 16 Jan 2015 09:53:46 -0300 Subject: [PATCH] publish_on_communities: not crash when no community is selected --- app/controllers/my_profile/cms_controller.rb | 1 + test/functional/cms_controller_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index cdea786..ca21fe2 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -295,6 +295,7 @@ class CmsController < MyProfileController params_marked = (params['q'] || '').split(',').select { |marked| user.memberships.map(&:id).include? marked.to_i } @marked_groups = Profile.find(params_marked) if @marked_groups.empty? + redirect_to @back_to return session[:notice] = _("Select some group to publish your article") end @marked_groups.each do |item| diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 44ee878..09c310a 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -763,6 +763,14 @@ class CmsControllerTest < ActionController::TestCase end end + should 'not crash if no community is selected' do + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') + + assert_nothing_raised do + post :publish_on_communities, :profile => profile.identifier, :id => article.id, :q => '', :back_to => '/' + end + end + should "not crash if there is a post and no portal community defined" do Environment.any_instance.stubs(:portal_community).returns(nil) article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') -- libgit2 0.21.2