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
6bd3550e
Commit
6bd3550e
authored
May 29, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create with_plan namespace scope
parent
08b1302d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
app/models/ee/namespace.rb
app/models/ee/namespace.rb
+3
-1
spec/models/ee/namespace_spec.rb
spec/models/ee/namespace_spec.rb
+32
-0
No files found.
app/models/ee/namespace.rb
View file @
6bd3550e
...
@@ -21,6 +21,8 @@ module EE
...
@@ -21,6 +21,8 @@ module EE
prepended
do
prepended
do
has_one
:namespace_statistics
,
dependent: :destroy
has_one
:namespace_statistics
,
dependent: :destroy
scope
:with_plan
,
->
{
where
.
not
(
plan:
[
nil
,
''
])
}
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
to: :namespace_statistics
,
allow_nil:
true
to: :namespace_statistics
,
allow_nil:
true
...
@@ -58,7 +60,7 @@ module EE
...
@@ -58,7 +60,7 @@ module EE
def
plans
def
plans
@ancestors_plans
||=
@ancestors_plans
||=
if
parent_id
if
parent_id
ancestors
.
w
here
.
not
(
plan:
[
nil
,
''
])
.
reorder
(
nil
).
pluck
(
'DISTINCT plan'
)
+
[
plan
]
ancestors
.
w
ith_plan
.
reorder
(
nil
).
pluck
(
'DISTINCT plan'
)
+
[
plan
]
else
else
[
plan
]
[
plan
]
end
end
...
...
spec/models/ee/namespace_spec.rb
View file @
6bd3550e
...
@@ -10,6 +10,38 @@ describe Namespace, models: true do
...
@@ -10,6 +10,38 @@ describe Namespace, models: true do
it
{
is_expected
.
to
delegate_method
(
:shared_runners_seconds_last_reset
).
to
(
:namespace_statistics
)
}
it
{
is_expected
.
to
delegate_method
(
:shared_runners_seconds_last_reset
).
to
(
:namespace_statistics
)
}
it
{
is_expected
.
to
validate_inclusion_of
(
:plan
).
in_array
(
Namespace
::
EE_PLANS
.
keys
).
allow_blank
}
it
{
is_expected
.
to
validate_inclusion_of
(
:plan
).
in_array
(
Namespace
::
EE_PLANS
.
keys
).
allow_blank
}
context
'scopes'
do
describe
'.with_plan'
do
let!
(
:namespace
)
{
create
:namespace
,
plan:
namespace_plan
}
context
'plan is set'
do
let
(
:namespace_plan
)
{
EE
::
Namespace
::
BRONZE_PLAN
}
it
'returns namespaces with plan'
do
expect
(
described_class
.
with_plan
).
to
eq
([
namespace
])
end
end
context
'plan is not set'
do
context
'plan is empty string'
do
let
(
:namespace_plan
)
{
''
}
it
'returns no namespace'
do
expect
(
described_class
.
with_plan
).
to
be_empty
end
end
context
'plan is nil'
do
let
(
:namespace_plan
)
{
nil
}
it
'returns no namespace'
do
expect
(
described_class
.
with_plan
).
to
be_empty
end
end
end
end
end
describe
'#feature_available?'
do
describe
'#feature_available?'
do
let
(
:group
)
{
create
(
:group
,
plan:
plan_license
)
}
let
(
:group
)
{
create
(
:group
,
plan:
plan_license
)
}
...
...
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