Commit 46ef775ec4bd3e08302389cb647033e515721f00
1 parent
158f6220
Exists in
master
and in
28 other branches
Any community members can edit - controller
(ActionItem2345)
Showing
2 changed files
with
20 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -20,10 +20,14 @@ class CmsController < MyProfileController |
| 20 | 20 | user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) |
| 21 | 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 | 24 | profile.articles.find(c.params[:id]).allow_post_content?(user) |
| 25 | 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 | 31 | def boxes_holder |
| 28 | 32 | profile |
| 29 | 33 | end | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -1143,6 +1143,21 @@ class CmsControllerTest < ActionController::TestCase |
| 1143 | 1143 | assert_template 'edit' |
| 1144 | 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 | 1161 | should 'create thumbnails for images with delayed_job' do |
| 1147 | 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 | 1163 | file_1 = profile.articles.find_by_path('rails.png') | ... | ... |