Commit b6ec7ab024edbd686985bc0d70bf44754f4c609c
1 parent
03c1131a
Exists in
master
and in
29 other branches
publish_on_communities: not crash when no community is selected
Showing
2 changed files
with
9 additions
and
0 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -295,6 +295,7 @@ class CmsController < MyProfileController |
295 | 295 | params_marked = (params['q'] || '').split(',').select { |marked| user.memberships.map(&:id).include? marked.to_i } |
296 | 296 | @marked_groups = Profile.find(params_marked) |
297 | 297 | if @marked_groups.empty? |
298 | + redirect_to @back_to | |
298 | 299 | return session[:notice] = _("Select some group to publish your article") |
299 | 300 | end |
300 | 301 | @marked_groups.each do |item| | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -763,6 +763,14 @@ class CmsControllerTest < ActionController::TestCase |
763 | 763 | end |
764 | 764 | end |
765 | 765 | |
766 | + should 'not crash if no community is selected' do | |
767 | + article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | |
768 | + | |
769 | + assert_nothing_raised do | |
770 | + post :publish_on_communities, :profile => profile.identifier, :id => article.id, :q => '', :back_to => '/' | |
771 | + end | |
772 | + end | |
773 | + | |
766 | 774 | should "not crash if there is a post and no portal community defined" do |
767 | 775 | Environment.any_instance.stubs(:portal_community).returns(nil) |
768 | 776 | article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') | ... | ... |