Commit f208dd00 authored by Valery Sizov's avatar Valery Sizov

specs fix

parent 18c73368
...@@ -18,19 +18,33 @@ class Ability ...@@ -18,19 +18,33 @@ class Ability
when "GroupMember" then group_member_abilities(user, subject) when "GroupMember" then group_member_abilities(user, subject)
when "ProjectMember" then project_member_abilities(user, subject) when "ProjectMember" then project_member_abilities(user, subject)
else [] else []
end.concat(global_abilities(user)) end
abilities.concat(global_abilities(user))
abilities -= license_blocked_abilities if License.block_changes? abilities -= license_blocked_abilities if License.block_changes?
abilities abilities
end end
def license_blocked_abilities
[
:create_issue,
:create_merge_request,
:push_code,
:push_code_to_protected_branches
]
end
# List of possible abilities # List of possible abilities
# for non-authenticated user # for non-authenticated user
def not_auth_abilities(user, subject) def anonymous_abilities(user, subject)
project = if subject.kind_of?(Project) project = if subject.is_a?(Project)
subject subject
else elsif subject.respond_to?(:project)
subject.project subject.project
else
nil
end end
if project && project.public? if project && project.public?
...@@ -50,21 +64,19 @@ class Ability ...@@ -50,21 +64,19 @@ class Ability
rules - project_disabled_features_rules(project) rules - project_disabled_features_rules(project)
else else
[] group = if subject.kind_of?(Group)
end subject
end elsif subject.respond_to?(:group)
subject.group
def anonymous_group_abilities(subject) else
group = if subject.is_a?(Group) nil
subject end
else
subject.group
end
if group && group.public_profile? if group && group.public_profile?
[:read_group] [:read_group]
else else
[] []
end
end end
end end
...@@ -378,10 +390,10 @@ class Ability ...@@ -378,10 +390,10 @@ class Ability
def abilities def abilities
@abilities ||= begin @abilities ||= begin
abilities = Six.new abilities = Six.new
abilities << self abilities << self
abilities abilities
end end
end end
private private
......
...@@ -77,7 +77,7 @@ class Project < ActiveRecord::Base ...@@ -77,7 +77,7 @@ class Project < ActiveRecord::Base
has_one :git_hook, dependent: :destroy has_one :git_hook, dependent: :destroy
has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id' has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id'
# Project services # Project services
has_many :services has_many :services
has_one :gitlab_ci_service, dependent: :destroy has_one :gitlab_ci_service, dependent: :destroy
has_one :campfire_service, dependent: :destroy has_one :campfire_service, dependent: :destroy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment