From 46ef775ec4bd3e08302389cb647033e515721f00 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 11 May 2012 16:55:03 -0300 Subject: [PATCH] Any community members can edit - controller --- app/controllers/my_profile/cms_controller.rb | 6 +++++- test/functional/cms_controller_test.rb | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 12b866e..18e6d50 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -20,10 +20,14 @@ class CmsController < MyProfileController user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) end - protect_if :only => [:edit, :destroy, :publish] do |c, user, profile| + protect_if :only => [:destroy, :publish] do |c, user, profile| profile.articles.find(c.params[:id]).allow_post_content?(user) end + protect_if :only => :edit do |c,user,profile| + profile.articles.find(c.params[:id]).allow_edit?(user) + end + def boxes_holder profile end diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index dccd102..32d1a9c 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1143,6 +1143,21 @@ class CmsControllerTest < ActionController::TestCase assert_template 'edit' end + should 'allow community members to edit articles that allow it' do + community = fast_create(Community) + admin = create_user('community-admin').person + member = create_user.person + + community.add_admin(admin) + community.add_member(member) + + article = community.articles.create!(:name => 'test_article', :allow_members_to_edit => true) + + login_as member.identifier + get :edit, :profile => community.identifier, :id => article.id + assert_response :success + end + should 'create thumbnails for images with delayed_job' do post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/rails.png', 'image/png'), fixture_file_upload('/files/test.txt', 'text/plain')] file_1 = profile.articles.find_by_path('rails.png') -- libgit2 0.21.2