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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a5dd3dd4
Commit
a5dd3dd4
authored
Aug 10, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add projects_include? method to GeoNode
parent
ac37879f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
app/models/geo_node.rb
app/models/geo_node.rb
+6
-0
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+26
-0
No files found.
app/models/geo_node.rb
View file @
a5dd3dd4
...
...
@@ -108,6 +108,12 @@ class GeoNode < ActiveRecord::Base
end
end
def
projects_include?
(
project_id
)
return
true
if
restricted_project_ids
.
nil?
restricted_project_ids
.
include?
(
project_id
)
end
def
restricted_project_ids
return
unless
namespaces
.
presence
...
...
spec/models/geo_node_spec.rb
View file @
a5dd3dd4
...
...
@@ -317,6 +317,32 @@ describe GeoNode, type: :model do
end
end
describe
'#projects_include?'
do
let
(
:unsynced_project
)
{
create
(
:project
)
}
it
'returns true without namespace restrictions'
do
expect
(
node
.
projects_include?
(
unsynced_project
.
id
)).
to
eq
true
end
context
'with namespace restrictions'
do
let
(
:synced_group
)
{
create
(
:group
)
}
before
do
node
.
update_attribute
(
:namespaces
,
[
synced_group
])
end
it
'returns true when project belongs to one of the namespaces'
do
project_in_synced_group
=
create
(
:project
,
group:
synced_group
)
expect
(
node
.
projects_include?
(
project_in_synced_group
.
id
)).
to
eq
true
end
it
'returns false when project does not belong to one of the namespaces'
do
expect
(
node
.
projects_include?
(
unsynced_project
.
id
)).
to
eq
false
end
end
end
describe
'#restricted_project_ids'
do
context
'without namespace restriction'
do
it
'returns nil'
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