Merge remote-tracking branch 'upstream/pull/2051'

This commit is contained in:
Tom Hughes 2018-11-08 17:51:23 +00:00
commit 6ca22de4f2
5 changed files with 15 additions and 14 deletions

View file

@ -8,6 +8,8 @@ class Ability
can [:index, :rss, :show, :comments], DiaryEntry
can [:search, :search_latlon, :search_ca_postcode, :search_osm_nominatim,
:search_geonames, :search_osm_nominatim_reverse, :search_geonames_reverse], :geocoder
can [:index, :show], Redaction
can [:index, :show, :blocks_on, :blocks_by], UserBlock
if user
can :welcome, :site
@ -18,6 +20,8 @@ class Ability
if user.moderator?
can [:index, :show, :resolve, :ignore, :reopen], Issue
can :create, IssueComment
can [:new, :create, :edit, :update, :destroy], Redaction
can [:new, :edit, :create, :update, :revoke], UserBlock
end
if user.administrator?

View file

@ -3,8 +3,9 @@ class RedactionsController < ApplicationController
before_action :authorize_web
before_action :set_locale
before_action :require_user, :only => [:new, :create, :edit, :update, :destroy]
before_action :require_moderator, :only => [:new, :create, :edit, :update, :destroy]
authorize_resource
before_action :lookup_redaction, :only => [:show, :edit, :update, :destroy]
before_action :check_database_readable
before_action :check_database_writable, :only => [:create, :update, :destroy]

View file

@ -3,8 +3,9 @@ class UserBlocksController < ApplicationController
before_action :authorize_web
before_action :set_locale
before_action :require_user, :only => [:new, :create, :edit, :update, :revoke]
before_action :require_moderator, :only => [:new, :create, :edit, :update, :revoke]
authorize_resource
before_action :lookup_user, :only => [:new, :create, :blocks_on, :blocks_by]
before_action :lookup_user_block, :only => [:show, :edit, :update, :revoke]
before_action :require_valid_params, :only => [:create, :update]

View file

@ -63,8 +63,7 @@ class RedactionsControllerTest < ActionController::TestCase
session[:user] = create(:user).id
get :new
assert_response :redirect
assert_redirected_to redactions_path
assert_response :forbidden
end
def test_create_moderator
@ -140,8 +139,7 @@ class RedactionsControllerTest < ActionController::TestCase
session[:user] = create(:user).id
get :edit, :params => { :id => create(:redaction).id }
assert_response :redirect
assert_redirected_to(redactions_path)
assert_response :forbidden
end
def test_update_moderator

View file

@ -145,8 +145,7 @@ class UserBlocksControllerTest < ActionController::TestCase
# Check that normal users can't load the block creation page
get :new, :params => { :display_name => target_user.display_name }
assert_redirected_to user_blocks_path
assert_equal "You need to be a moderator to perform that action.", flash[:error]
assert_response :forbidden
# Login as a moderator
session[:user] = create(:moderator_user).id
@ -189,8 +188,7 @@ class UserBlocksControllerTest < ActionController::TestCase
# Check that normal users can't load the block edit page
get :edit, :params => { :id => active_block.id }
assert_redirected_to user_blocks_path
assert_equal "You need to be a moderator to perform that action.", flash[:error]
assert_response :forbidden
# Login as a moderator
session[:user] = create(:moderator_user).id
@ -361,8 +359,7 @@ class UserBlocksControllerTest < ActionController::TestCase
# Check that normal users can't load the block revoke page
get :revoke, :params => { :id => active_block.id }
assert_redirected_to user_blocks_path
assert_equal "You need to be a moderator to perform that action.", flash[:error]
assert_response :forbidden
# Login as a moderator
session[:user] = create(:moderator_user).id