Commit cf3d78e5 authored by Valery Sizov's avatar Valery Sizov

specs fixing

parent f208dd00
...@@ -36,15 +36,25 @@ class Ability ...@@ -36,15 +36,25 @@ class Ability
] ]
end end
# List of possible abilities # List of possible abilities for anonymous user
# for non-authenticated user
def anonymous_abilities(user, subject) def anonymous_abilities(user, subject)
case true
when subject.is_a?(PersonalSnippet)
anonymous_personal_snippet_abilities(subject)
when subject.is_a?(Project) || subject.respond_to?(:project)
anonymous_project_abilities(subject)
when subject.is_a?(Group) || subject.respond_to?(:group)
anonymous_group_abilities(subject)
else
[]
end
end
def anonymous_project_abilities(subject)
project = if subject.is_a?(Project) project = if subject.is_a?(Project)
subject subject
elsif subject.respond_to?(:project)
subject.project
else else
nil subject.project
end end
if project && project.public? if project && project.public?
...@@ -64,12 +74,15 @@ class Ability ...@@ -64,12 +74,15 @@ class Ability
rules - project_disabled_features_rules(project) rules - project_disabled_features_rules(project)
else else
group = if subject.kind_of?(Group) []
end
end
def anonymous_group_abilities(subject)
group = if subject.is_a?(Group)
subject subject
elsif subject.respond_to?(:group)
subject.group
else else
nil subject.group
end end
if group && group.public_profile? if group && group.public_profile?
...@@ -78,7 +91,6 @@ class Ability ...@@ -78,7 +91,6 @@ class Ability
[] []
end end
end end
end
def anonymous_personal_snippet_abilities(snippet) def anonymous_personal_snippet_abilities(snippet)
if snippet.public? if snippet.public?
......
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