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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
c534d2e8
Commit
c534d2e8
authored
Jun 13, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve tests
parent
b0b1b85d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
18 deletions
+12
-18
spec/models/build_spec.rb
spec/models/build_spec.rb
+1
-1
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+2
-2
spec/workers/expire_build_artifacts_worker_spec.rb
spec/workers/expire_build_artifacts_worker_spec.rb
+9
-15
No files found.
spec/models/build_spec.rb
View file @
c534d2e8
...
@@ -472,7 +472,7 @@ describe Ci::Build, models: true do
...
@@ -472,7 +472,7 @@ describe Ci::Build, models: true do
end
end
it
'when assigning invalid duration'
do
it
'when assigning invalid duration'
do
expect
{
build
.
artifacts_expire_in
=
'7 elephants'
}.
not_to
raise_error
expect
{
build
.
artifacts_expire_in
=
'7 elephants'
}.
not_to
raise_error
is_expected
.
to
be_nil
is_expected
.
to
be_nil
end
end
...
...
spec/requests/ci/api/builds_spec.rb
View file @
c534d2e8
...
@@ -380,7 +380,7 @@ describe Ci::API::API do
...
@@ -380,7 +380,7 @@ describe Ci::API::API do
context
'with an expire_in given'
do
context
'with an expire_in given'
do
let
(
:expire_in
)
{
'7 days'
}
let
(
:expire_in
)
{
'7 days'
}
it
do
it
'updates when specified'
do
build
.
reload
build
.
reload
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'artifacts_expire_at'
]).
not_to
be_empty
expect
(
json_response
[
'artifacts_expire_at'
]).
not_to
be_empty
...
@@ -391,7 +391,7 @@ describe Ci::API::API do
...
@@ -391,7 +391,7 @@ describe Ci::API::API do
context
'with no expire_in given'
do
context
'with no expire_in given'
do
let
(
:expire_in
)
{
nil
}
let
(
:expire_in
)
{
nil
}
it
do
it
'ignores if not specified'
do
build
.
reload
build
.
reload
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'artifacts_expire_at'
]).
to
be_nil
expect
(
json_response
[
'artifacts_expire_at'
]).
to
be_nil
...
...
spec/workers/expire_build_artifacts_worker_spec.rb
View file @
c534d2e8
...
@@ -6,14 +6,14 @@ describe ExpireBuildArtifactsWorker do
...
@@ -6,14 +6,14 @@ describe ExpireBuildArtifactsWorker do
let
(
:worker
)
{
described_class
.
new
}
let
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
describe
'#perform'
do
context
'with expired artifacts'
do
before
{
build
}
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
artifacts_expire_at:
Time
.
now
-
7
.
days
)
}
it
do
subject!
{
worker
.
perform
}
expect_any_instance_of
(
Ci
::
Build
).
to
receive
(
:erase_artifacts!
)
worker
.
perform
context
'with expired artifacts'
do
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
artifacts_expire_at:
Time
.
now
-
7
.
days
)
}
it
'does expire'
do
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_truthy
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_truthy
end
end
end
end
...
@@ -21,22 +21,16 @@ describe ExpireBuildArtifactsWorker do
...
@@ -21,22 +21,16 @@ describe ExpireBuildArtifactsWorker do
context
'with not yet expired artifacts'
do
context
'with not yet expired artifacts'
do
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
}
it
do
it
'does not expire'
do
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_truthy
worker
.
perform
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_falsey
end
end
end
end
context
'without expire date'
do
context
'without expire date'
do
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
it
do
it
'does not expire'
do
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_falsey
worker
.
perform
end
end
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