Skip to content
Snippets Groups Projects
Commit 41d89533 authored by Stan Hu's avatar Stan Hu
Browse files

Fix assorted rspec failures due to stale, cached user permissions

RequestStore is disabled in tests, but the Ability class was
caching user permissions based on the user and project ID of
previous test runs. Revise code to use RequestStore only if it
is active.
parent a16ac37e
Branches
Tags
1 merge request!5919Fix assorted rspec failures due to stale, cached user permissions
Loading
Loading
@@ -166,10 +166,17 @@ class Ability
end
 
def project_abilities(user, project)
rules = []
key = "/user/#{user.id}/project/#{project.id}"
 
RequestStore.store[key] ||= begin
if RequestStore.active?
RequestStore.store[key] ||= uncached_project_abilities(user, project)
else
uncached_project_abilities(user, project)
end
end
def uncached_project_abilities(user, project)
rules = []
# Push abilities on the users team role
rules.push(*project_team_rules(project.team, user))
 
Loading
Loading
@@ -198,7 +205,6 @@ class Ability
 
rules - project_disabled_features_rules(project)
end
end
 
def project_team_rules(team, user)
# Rules based on role in project
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment