Commit 46ef775ec4bd3e08302389cb647033e515721f00

Authored by Antonio Terceiro
1 parent 158f6220

Any community members can edit - controller

(ActionItem2345)
app/controllers/my_profile/cms_controller.rb
@@ -20,10 +20,14 @@ class CmsController < MyProfileController @@ -20,10 +20,14 @@ class CmsController < MyProfileController
20 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) 20 user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile))
21 end 21 end
22 22
23 - protect_if :only => [:edit, :destroy, :publish] do |c, user, profile| 23 + protect_if :only => [:destroy, :publish] do |c, user, profile|
24 profile.articles.find(c.params[:id]).allow_post_content?(user) 24 profile.articles.find(c.params[:id]).allow_post_content?(user)
25 end 25 end
26 26
  27 + protect_if :only => :edit do |c,user,profile|
  28 + profile.articles.find(c.params[:id]).allow_edit?(user)
  29 + end
  30 +
27 def boxes_holder 31 def boxes_holder
28 profile 32 profile
29 end 33 end
test/functional/cms_controller_test.rb
@@ -1143,6 +1143,21 @@ class CmsControllerTest < ActionController::TestCase @@ -1143,6 +1143,21 @@ class CmsControllerTest < ActionController::TestCase
1143 assert_template 'edit' 1143 assert_template 'edit'
1144 end 1144 end
1145 1145
  1146 + should 'allow community members to edit articles that allow it' do
  1147 + community = fast_create(Community)
  1148 + admin = create_user('community-admin').person
  1149 + member = create_user.person
  1150 +
  1151 + community.add_admin(admin)
  1152 + community.add_member(member)
  1153 +
  1154 + article = community.articles.create!(:name => 'test_article', :allow_members_to_edit => true)
  1155 +
  1156 + login_as member.identifier
  1157 + get :edit, :profile => community.identifier, :id => article.id
  1158 + assert_response :success
  1159 + end
  1160 +
1146 should 'create thumbnails for images with delayed_job' do 1161 should 'create thumbnails for images with delayed_job' do
1147 post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/rails.png', 'image/png'), fixture_file_upload('/files/test.txt', 'text/plain')] 1162 post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/rails.png', 'image/png'), fixture_file_upload('/files/test.txt', 'text/plain')]
1148 file_1 = profile.articles.find_by_path('rails.png') 1163 file_1 = profile.articles.find_by_path('rails.png')