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
Hide 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
end
def
shared_runners_minutes_quota?
runner
&&
runner
.
shared?
&&
!
project
.
public
?
runner
&&
runner
.
shared?
&&
project
.
shared_runners_minutes_quota
?
end
private
...
...
app/models/project.rb
View file @
a6948538
...
...
@@ -1567,6 +1567,10 @@ class Project < ActiveRecord::Base
end
end
def
shared_runners_minutes_quota?
!
public
?
&&
shared_runners_enabled?
end
private
# 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
)
-
namespace
=
local_assigns
.
fetch
(
:namespace
,
project
&&
project
.
namespace
)
-
has_limit
=
(
project
||
namespace
).
shared_runners_minutes_limit_enabled?
-
can_see_status
=
project
.
nil?
||
can?
(
current_user
,
:create_pipeline
,
project
)
-
if
cookies
[
:hide_shared_runner_quota_message
].
blank?
&&
has_limit
&&
namespace
.
shared_runners_minutes_used?
&&
can_see_status
-
if
cookies
[
:hide_shared_runner_quota_message
].
blank?
&&
project.shared_runners_minutes_quota?
&&
namespace.shared_runners_minutes_used?
&&
can?(current_user, :create_pipeline, project)
.shared-runner-quota-message.alert.alert-warning.hidden-xs
=
namespace
.
name
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
build
.
runner
=
create
(
:ci_runner
,
:shared
)
end
context
'for public project'
do
before
do
build
.
project
.
visibility_level
=
Gitlab
::
VisibilityLevel
::
PUBLIC
end
it
{
is_expected
.
to
be_falsey
}
end
context
'for internal project'
do
before
do
build
.
project
.
visibility_level
=
Gitlab
::
VisibilityLevel
::
INTERNAL
end
it
do
expect
(
build
.
project
).
to
receive
(
:shared_runners_minutes_quota?
).
and_return
(
true
)
it
{
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
}
is_expected
.
to
be_truthy
end
end
...
...
spec/models/project_spec.rb
View file @
a6948538
...
...
@@ -2092,6 +2092,48 @@ describe Project, models: true do
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
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
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