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
a6948538
Commit
a6948538
authored
Dec 20, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve specs
parent
71ef0c9e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
26 deletions
+56
-26
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/project.rb
app/models/project.rb
+4
-0
app/views/shared/_shared_runners_minutes_limit.html.haml
app/views/shared/_shared_runners_minutes_limit.html.haml
+5
-4
spec/models/build_spec.rb
spec/models/build_spec.rb
+4
-21
spec/models/project_spec.rb
spec/models/project_spec.rb
+42
-0
No files found.
app/models/ci/build.rb
View file @
a6948538
...
@@ -538,7 +538,7 @@ module Ci
...
@@ -538,7 +538,7 @@ module Ci
end
end
def
shared_runners_minutes_quota?
def
shared_runners_minutes_quota?
runner
&&
runner
.
shared?
&&
!
project
.
public
?
runner
&&
runner
.
shared?
&&
project
.
shared_runners_minutes_quota
?
end
end
private
private
...
...
app/models/project.rb
View file @
a6948538
...
@@ -1567,6 +1567,10 @@ class Project < ActiveRecord::Base
...
@@ -1567,6 +1567,10 @@ class Project < ActiveRecord::Base
end
end
end
end
def
shared_runners_minutes_quota?
!
public
?
&&
shared_runners_enabled?
end
private
private
# Check if a reference is being done cross-project
# Check if a reference is being done cross-project
...
...
app/views/shared/_shared_runners_minutes_limit.html.haml
View file @
a6948538
-
project
=
local_assigns
.
fetch
(
:project
,
nil
)
-
project
=
local_assigns
.
fetch
(
:project
,
nil
)
-
namespace
=
local_assigns
.
fetch
(
:namespace
,
project
&&
project
.
namespace
)
-
has_limit
=
(
project
||
namespace
).
shared_runners_minutes_limit_enabled?
-
if
cookies
[
:hide_shared_runner_quota_message
].
blank?
&&
-
can_see_status
=
project
.
nil?
||
can?
(
current_user
,
:create_pipeline
,
project
)
project.shared_runners_minutes_quota?
&&
-
if
cookies
[
:hide_shared_runner_quota_message
].
blank?
&&
has_limit
&&
namespace
.
shared_runners_minutes_used?
&&
can_see_status
namespace.shared_runners_minutes_used?
&&
can?(current_user, :create_pipeline, project)
.shared-runner-quota-message.alert.alert-warning.hidden-xs
.shared-runner-quota-message.alert.alert-warning.hidden-xs
=
namespace
.
name
=
namespace
.
name
has exceeded their build minutes quota. Pipelines will not run anymore on shared runners.
has exceeded their build minutes quota. Pipelines will not run anymore on shared runners.
...
...
spec/models/build_spec.rb
View file @
a6948538
...
@@ -1330,28 +1330,11 @@ describe Ci::Build, models: true do
...
@@ -1330,28 +1330,11 @@ describe Ci::Build, models: true do
build
.
runner
=
create
(
:ci_runner
,
:shared
)
build
.
runner
=
create
(
:ci_runner
,
:shared
)
end
end
context
'for public project'
do
it
do
before
do
expect
(
build
.
project
).
to
receive
(
:shared_runners_minutes_quota?
).
build
.
project
.
visibility_level
=
Gitlab
::
VisibilityLevel
::
PUBLIC
and_return
(
true
)
end
it
{
is_expected
.
to
be_falsey
}
end
context
'for internal project'
do
before
do
build
.
project
.
visibility_level
=
Gitlab
::
VisibilityLevel
::
INTERNAL
end
it
{
is_expected
.
to
be_truthy
}
is_expected
.
to
be_truthy
end
context
'for private project'
do
before
do
build
.
project
.
visibility_level
=
Gitlab
::
VisibilityLevel
::
INTERNAL
end
it
{
is_expected
.
to
be_truthy
}
end
end
end
end
...
...
spec/models/project_spec.rb
View file @
a6948538
...
@@ -2092,6 +2092,48 @@ describe Project, models: true do
...
@@ -2092,6 +2092,48 @@ describe Project, models: true do
end
end
end
end
describe
'#shared_runners_minutes_quota?'
do
subject
{
project
.
shared_runners_minutes_quota?
}
context
'with shared runners enabled'
do
before
do
project
.
shared_runners_enabled
=
true
end
context
'for public project'
do
before
do
project
.
visibility_level
=
Project
::
PUBLIC
end
it
{
is_expected
.
to
be_falsey
}
end
context
'for internal project'
do
before
do
project
.
visibility_level
=
Project
::
INTERNAL
end
it
{
is_expected
.
to
be_truthy
}
end
context
'for private project'
do
before
do
project
.
visibility_level
=
Project
::
INTERNAL
end
it
{
is_expected
.
to
be_truthy
}
end
end
context
'without shared runners'
do
before
do
project
.
shared_runners_enabled
=
false
end
it
{
is_expected
.
to
be_falsey
}
end
end
def
enable_lfs
def
enable_lfs
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
end
end
...
...
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