per request project rules caching
This commit is contained in:
parent
a5cbb4cb82
commit
8ec02ed9aa
3 changed files with 33 additions and 28 deletions
1
Gemfile
1
Gemfile
|
@ -174,6 +174,7 @@ gem "font-awesome-rails", '~> 3.2'
|
||||||
gem "gitlab_emoji", "~> 0.0.1.1"
|
gem "gitlab_emoji", "~> 0.0.1.1"
|
||||||
gem "gon", '~> 5.0.0'
|
gem "gon", '~> 5.0.0'
|
||||||
gem 'nprogress-rails'
|
gem 'nprogress-rails'
|
||||||
|
gem 'request_store'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem "annotate", "~> 2.6.0.beta2"
|
gem "annotate", "~> 2.6.0.beta2"
|
||||||
|
|
|
@ -412,6 +412,7 @@ GEM
|
||||||
redis-store (1.1.4)
|
redis-store (1.1.4)
|
||||||
redis (>= 2.2)
|
redis (>= 2.2)
|
||||||
ref (1.0.5)
|
ref (1.0.5)
|
||||||
|
request_store (1.0.5)
|
||||||
require_all (1.3.2)
|
require_all (1.3.2)
|
||||||
rest-client (1.6.7)
|
rest-client (1.6.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
|
@ -650,6 +651,7 @@ DEPENDENCIES
|
||||||
rb-inotify
|
rb-inotify
|
||||||
redcarpet (~> 2.2.2)
|
redcarpet (~> 2.2.2)
|
||||||
redis-rails
|
redis-rails
|
||||||
|
request_store
|
||||||
rspec-rails
|
rspec-rails
|
||||||
sanitize (~> 2.0)
|
sanitize (~> 2.0)
|
||||||
sass-rails (~> 4.0.2)
|
sass-rails (~> 4.0.2)
|
||||||
|
|
|
@ -67,7 +67,8 @@ class Ability
|
||||||
|
|
||||||
def project_abilities(user, project)
|
def project_abilities(user, project)
|
||||||
rules = []
|
rules = []
|
||||||
|
key = "/user/#{user.id}/project/#{project.id}"
|
||||||
|
RequestStore.store[key] ||= begin
|
||||||
team = project.team
|
team = project.team
|
||||||
|
|
||||||
# Rules based on role in project
|
# Rules based on role in project
|
||||||
|
@ -102,6 +103,7 @@ class Ability
|
||||||
|
|
||||||
rules
|
rules
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def public_project_rules
|
def public_project_rules
|
||||||
project_guest_rules + [
|
project_guest_rules + [
|
||||||
|
|
Loading…
Reference in a new issue