Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #18554 - skip collection_cache_lookup on authorized_for #4299

Merged
merged 1 commit into from Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -97,7 +97,7 @@ def authorized_for(options)
user.allowed_to?({ :controller => controller_name, :action => action, :id => id }) rescue false
else
authorizer = options.delete(:authorizer) || Authorizer.new(user)
authorizer.can?(permission, object) rescue false
authorizer.can?(permission, object, false) rescue false
end
end

Expand Down
14 changes: 14 additions & 0 deletions test/helpers/application_helper_test.rb
Expand Up @@ -87,4 +87,18 @@ def test_generate_link_for
end
end
end
describe 'authorized_for' do
setup do
@permission = Permission.find_by_name('view_domains')
@user = FactoryGirl.create(:user)
@domain1 = FactoryGirl.create(:domain, :name => 'fake-domain.arpa')
end

test "disable cache when calling can?" do
as_user @user do
Authorizer.any_instance.expects(:can?).with(@permission, @domain1, false)
authorized_for({:permission => @permission, :auth_object => @domain1})
end
end
end
end