Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
99ee8620
Commit
99ee8620
authored
Aug 08, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove six, and use a Set instead
parent
0f4df86a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
20 deletions
+22
-20
Gemfile
Gemfile
+0
-3
Gemfile.lock
Gemfile.lock
+0
-2
app/models/ability.rb
app/models/ability.rb
+19
-6
lib/api/helpers.rb
lib/api/helpers.rb
+1
-5
spec/models/members/project_member_spec.rb
spec/models/members/project_member_spec.rb
+1
-2
spec/models/note_spec.rb
spec/models/note_spec.rb
+1
-2
No files found.
Gemfile
View file @
99ee8620
...
...
@@ -97,9 +97,6 @@ gem 'fog-rackspace', '~> 0.1.1'
# for aws storage
gem
'
unf
'
,
'~> 0.1.4'
# Authorization
gem
'
six
'
,
'~> 0.2.0'
# Seed data
gem
'
seed-fu
'
,
'~> 2.3.5'
...
...
Gemfile.lock
View file @
99ee8620
...
...
@@ -683,7 +683,6 @@ GEM
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
six (0.2.0)
slack-notifier (1.2.1)
slop (3.6.0)
spinach (0.8.10)
...
...
@@ -954,7 +953,6 @@ DEPENDENCIES
sidekiq-cron (~> 0.4.0)
simplecov (= 0.12.0)
sinatra (~> 1.4.4)
six (~> 0.2.0)
slack-notifier (~> 1.2.0)
spinach-rails (~> 0.2.1)
spinach-rerun-reporter (~> 0.0.2)
...
...
app/models/ability.rb
View file @
99ee8620
class
Ability
class
<<
self
end
def
allowed?
(
user
,
action
,
subject
)
allowed
(
user
,
subject
).
include?
(
action
)
end
def
allowed
(
user
,
subject
)
return
anonymous_abilities
(
user
,
subject
)
if
user
.
nil?
return
uncached_allowed
(
user
,
subject
)
unless
RequestStore
.
active?
user_key
=
user
?
user
.
id
:
'anonymous'
subject_key
=
subject
?
"
#{
subject
.
class
.
name
}
/
#{
subject
.
id
}
"
:
'global'
key
=
"/ability/
#{
user_key
}
/
#{
subject_key
}
"
RequestStore
[
key
]
||=
Set
.
new
(
uncached_allowed
(
user
,
subject
)).
freeze
end
def
uncached_allowed
(
user
,
subject
)
return
anonymous_abilities
(
subject
)
if
user
.
nil?
return
[]
unless
user
.
is_a?
(
User
)
return
[]
if
user
.
blocked?
...
...
@@ -586,11 +602,8 @@ class Ability
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
self
abilities
end
warn
'Ability.abilities is deprecated, use Ability.allowed?(user, action, subject) instead'
self
end
private
...
...
lib/api/helpers.rb
View file @
99ee8620
...
...
@@ -409,11 +409,7 @@ module API
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
Ability
abilities
end
Ability
end
def
secret_token
...
...
spec/models/members/project_member_spec.rb
View file @
99ee8620
...
...
@@ -71,8 +71,7 @@ describe ProjectMember, models: true do
describe
:import_team
do
before
do
@abilities
=
Six
.
new
@abilities
<<
Ability
@abilities
=
Ability
@project_1
=
create
:project
@project_2
=
create
:project
...
...
spec/models/note_spec.rb
View file @
99ee8620
...
...
@@ -85,8 +85,7 @@ describe Note, models: true do
@u1
=
create
(
:user
)
@u2
=
create
(
:user
)
@u3
=
create
(
:user
)
@abilities
=
Six
.
new
@abilities
<<
Ability
@abilities
=
Ability
end
describe
'read'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment