Merge remote-tracking branch 'upstream/pull/2060'
This commit is contained in:
commit
75189bd17d
7 changed files with 9 additions and 43 deletions
|
@ -216,22 +216,6 @@ class DiaryEntriesController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# This is required because, being a default-deny system, cancancan
|
|
||||||
# _cannot_ tell you the reason you were denied access; and so
|
|
||||||
# the "nice" feedback presenting next steps can't be gleaned from
|
|
||||||
# the exception
|
|
||||||
##
|
|
||||||
# for the hide actions, require that the user is a administrator, or fill out
|
|
||||||
# a helpful error message and return them to the user page.
|
|
||||||
def deny_access(exception)
|
|
||||||
if current_user && exception.action.in?([:hide, :hidecomment])
|
|
||||||
flash[:error] = t("users.filter.not_an_administrator")
|
|
||||||
redirect_to :action => "show"
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# return permitted diary entry parameters
|
# return permitted diary entry parameters
|
||||||
def entry_params
|
def entry_params
|
||||||
|
|
|
@ -22,15 +22,6 @@ class IssueCommentsController < ApplicationController
|
||||||
params.require(:issue_comment).permit(:body)
|
params.require(:issue_comment).permit(:body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_access(_exception)
|
|
||||||
if current_user
|
|
||||||
flash[:error] = t("application.require_moderator_or_admin.not_a_moderator_or_admin")
|
|
||||||
redirect_to root_path
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# This sort of assumes there are only two roles
|
# This sort of assumes there are only two roles
|
||||||
def reassign_issue(issue)
|
def reassign_issue(issue)
|
||||||
role = (Issue::ASSIGNED_ROLES - [issue.assigned_role]).first
|
role = (Issue::ASSIGNED_ROLES - [issue.assigned_role]).first
|
||||||
|
|
|
@ -82,13 +82,4 @@ class IssuesController < ApplicationController
|
||||||
def find_issue
|
def find_issue
|
||||||
@issue = Issue.find(params[:id])
|
@issue = Issue.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_access(_exception)
|
|
||||||
if current_user
|
|
||||||
flash[:error] = t("application.require_moderator_or_admin.not_a_moderator_or_admin")
|
|
||||||
redirect_to root_path
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -726,7 +726,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:params => { :display_name => user.display_name, :id => diary_entry.id },
|
:params => { :display_name => user.display_name, :id => diary_entry.id },
|
||||||
:session => { :user => user }
|
:session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal true, DiaryEntry.find(diary_entry.id).visible
|
assert_equal true, DiaryEntry.find(diary_entry.id).visible
|
||||||
|
|
||||||
# Finally try as an administrator
|
# Finally try as an administrator
|
||||||
|
@ -754,7 +754,7 @@ class DiaryEntriesControllerTest < ActionController::TestCase
|
||||||
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id },
|
:params => { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id },
|
||||||
:session => { :user => user }
|
:session => { :user => user }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal true, DiaryComment.find(diary_comment.id).visible
|
assert_equal true, DiaryComment.find(diary_comment.id).visible
|
||||||
|
|
||||||
# Finally try as an administrator
|
# Finally try as an administrator
|
||||||
|
|
|
@ -9,7 +9,7 @@ class IssueCommentsControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
post :create, :params => { :issue_id => issue.id }
|
post :create, :params => { :issue_id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to root_path
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
assert_equal 0, issue.comments.length
|
assert_equal 0, issue.comments.length
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:user).id
|
session[:user] = create(:user).id
|
||||||
get :index
|
get :index
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to root_path
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
|
|
||||||
# Access issues list as administrator
|
# Access issues list as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
|
@ -37,7 +37,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:user).id
|
session[:user] = create(:user).id
|
||||||
get :show, :params => { :id => issue.id }
|
get :show, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to root_path
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
|
|
||||||
# Access issue as administrator
|
# Access issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
|
@ -63,7 +63,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:user).id
|
session[:user] = create(:user).id
|
||||||
get :resolve, :params => { :id => issue.id }
|
get :resolve, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to root_path
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
|
|
||||||
# Resolve issue as administrator
|
# Resolve issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
|
@ -93,7 +93,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:user).id
|
session[:user] = create(:user).id
|
||||||
get :ignore, :params => { :id => issue.id }
|
get :ignore, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to root_path
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
|
|
||||||
# Ignore issue as administrator
|
# Ignore issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
|
@ -125,7 +125,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||||
session[:user] = create(:user).id
|
session[:user] = create(:user).id
|
||||||
get :reopen, :params => { :id => issue.id }
|
get :reopen, :params => { :id => issue.id }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to root_path
|
assert_redirected_to :controller => :errors, :action => :forbidden
|
||||||
|
|
||||||
# Reopen issue as administrator
|
# Reopen issue as administrator
|
||||||
session[:user] = create(:administrator_user).id
|
session[:user] = create(:administrator_user).id
|
||||||
|
|
|
@ -12,7 +12,7 @@ class IssuesTest < ApplicationSystemTestCase
|
||||||
sign_in_as(create(:user))
|
sign_in_as(create(:user))
|
||||||
|
|
||||||
visit issues_path
|
visit issues_path
|
||||||
assert page.has_content?(I18n.t("application.require_moderator_or_admin.not_a_moderator_or_admin"))
|
assert page.has_content?("Forbidden")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_view_no_issues
|
def test_view_no_issues
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue