Commit 421be01d authored by Kamil Trzcinski's avatar Kamil Trzcinski Committed by Phil Hughes

Improve design based on review

parent 9281709b
...@@ -360,11 +360,10 @@ module Ci ...@@ -360,11 +360,10 @@ module Ci
end end
def artifacts_expire_in=(value) def artifacts_expire_in=(value)
if value self.artifacts_expire_at =
self.artifacts_expire_at = Time.now + ChronicDuration.parse(value) if value
else Time.now + ChronicDuration.parse(value)
self.artifacts_expire_at = nil end
end
end end
def keep_artifacts! def keep_artifacts!
......
...@@ -21,85 +21,85 @@ Example of response ...@@ -21,85 +21,85 @@ Example of response
```json ```json
[ [
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
}, },
"coverage": null, "coverage": null,
"created_at": "2015-12-24T15:51:21.802Z", "created_at": "2015-12-24T15:51:21.802Z",
"artifacts_file": { "artifacts_file": {
"filename": "artifacts.zip", "filename": "artifacts.zip",
"size": 1000 "size": 1000
}, },
"finished_at": "2015-12-24T17:54:27.895Z", "finished_at": "2015-12-24T17:54:27.895Z",
"id": 7, "id": 7,
"name": "teaspoon", "name": "teaspoon",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
"stage": "test", "stage": "test",
"started_at": "2015-12-24T17:54:27.722Z", "started_at": "2015-12-24T17:54:27.722Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
"created_at": "2015-12-21T13:14:24.077Z", "created_at": "2015-12-21T13:14:24.077Z",
"id": 1, "id": 1,
"is_admin": true, "is_admin": true,
"linkedin": "", "linkedin": "",
"name": "Administrator", "name": "Administrator",
"skype": "", "skype": "",
"state": "active", "state": "active",
"twitter": "", "twitter": "",
"username": "root", "username": "root",
"web_url": "http://gitlab.dev/u/root", "web_url": "http://gitlab.dev/u/root",
"website_url": "" "website_url": ""
} }
},
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
}, },
{ "coverage": null,
"commit": { "created_at": "2015-12-24T15:51:21.727Z",
"author_email": "admin@example.com", "artifacts_file": null,
"author_name": "Administrator", "finished_at": "2015-12-24T17:54:24.921Z",
"created_at": "2015-12-24T16:51:14.000+01:00", "id": 6,
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "name": "spinach:other",
"message": "Test the CI integration.", "ref": "master",
"short_id": "0ff3ae19", "runner": null,
"title": "Test the CI integration." "stage": "test",
}, "started_at": "2015-12-24T17:54:24.729Z",
"coverage": null, "status": "failed",
"created_at": "2015-12-24T15:51:21.727Z", "tag": false,
"artifacts_file": null, "user": {
"finished_at": "2015-12-24T17:54:24.921Z", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"id": 6, "bio": null,
"name": "spinach:other", "created_at": "2015-12-21T13:14:24.077Z",
"ref": "master", "id": 1,
"runner": null, "is_admin": true,
"stage": "test", "linkedin": "",
"started_at": "2015-12-24T17:54:24.729Z", "name": "Administrator",
"status": "failed", "skype": "",
"tag": false, "state": "active",
"user": { "twitter": "",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "username": "root",
"bio": null, "web_url": "http://gitlab.dev/u/root",
"created_at": "2015-12-21T13:14:24.077Z", "website_url": ""
"id": 1,
"is_admin": true,
"linkedin": "",
"name": "Administrator",
"skype": "",
"state": "active",
"twitter": "",
"username": "root",
"web_url": "http://gitlab.dev/u/root",
"website_url": ""
}
} }
}
] ]
``` ```
...@@ -125,68 +125,68 @@ Example of response ...@@ -125,68 +125,68 @@ Example of response
```json ```json
[ [
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
},
"coverage": null,
"created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null,
"finished_at": "2016-01-11T10:14:09.526Z",
"id": 69,
"name": "rubocop",
"ref": "master",
"runner": null,
"stage": "test",
"started_at": null,
"status": "canceled",
"tag": false,
"user": null
}, },
{ "coverage": null,
"commit": { "created_at": "2016-01-11T10:13:33.506Z",
"author_email": "admin@example.com", "artifacts_file": null,
"author_name": "Administrator", "finished_at": "2016-01-11T10:14:09.526Z",
"created_at": "2015-12-24T16:51:14.000+01:00", "id": 69,
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "name": "rubocop",
"message": "Test the CI integration.", "ref": "master",
"short_id": "0ff3ae19", "runner": null,
"title": "Test the CI integration." "stage": "test",
}, "started_at": null,
"coverage": null, "status": "canceled",
"created_at": "2015-12-24T15:51:21.957Z", "tag": false,
"artifacts_file": null, "user": null
"finished_at": "2015-12-24T17:54:33.913Z", },
"id": 9, {
"name": "brakeman", "commit": {
"ref": "master", "author_email": "admin@example.com",
"runner": null, "author_name": "Administrator",
"stage": "test", "created_at": "2015-12-24T16:51:14.000+01:00",
"started_at": "2015-12-24T17:54:33.727Z", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "failed", "message": "Test the CI integration.",
"tag": false, "short_id": "0ff3ae19",
"user": { "title": "Test the CI integration."
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", },
"bio": null, "coverage": null,
"created_at": "2015-12-21T13:14:24.077Z", "created_at": "2015-12-24T15:51:21.957Z",
"id": 1, "artifacts_file": null,
"is_admin": true, "finished_at": "2015-12-24T17:54:33.913Z",
"linkedin": "", "id": 9,
"name": "Administrator", "name": "brakeman",
"skype": "", "ref": "master",
"state": "active", "runner": null,
"twitter": "", "stage": "test",
"username": "root", "started_at": "2015-12-24T17:54:33.727Z",
"web_url": "http://gitlab.dev/u/root", "status": "failed",
"website_url": "" "tag": false,
} "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null,
"created_at": "2015-12-21T13:14:24.077Z",
"id": 1,
"is_admin": true,
"linkedin": "",
"name": "Administrator",
"skype": "",
"state": "active",
"twitter": "",
"username": "root",
"web_url": "http://gitlab.dev/u/root",
"website_url": ""
} }
}
] ]
``` ```
...@@ -211,42 +211,42 @@ Example of response ...@@ -211,42 +211,42 @@ Example of response
```json ```json
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
}, },
"coverage": null, "coverage": null,
"created_at": "2015-12-24T15:51:21.880Z", "created_at": "2015-12-24T15:51:21.880Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2015-12-24T17:54:31.198Z", "finished_at": "2015-12-24T17:54:31.198Z",
"id": 8, "id": 8,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
"stage": "test", "stage": "test",
"started_at": "2015-12-24T17:54:30.733Z", "started_at": "2015-12-24T17:54:30.733Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"user": { "user": {
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"bio": null, "bio": null,
"created_at": "2015-12-21T13:14:24.077Z", "created_at": "2015-12-21T13:14:24.077Z",
"id": 1, "id": 1,
"is_admin": true, "is_admin": true,
"linkedin": "", "linkedin": "",
"name": "Administrator", "name": "Administrator",
"skype": "", "skype": "",
"state": "active", "state": "active",
"twitter": "", "twitter": "",
"username": "root", "username": "root",
"web_url": "http://gitlab.dev/u/root", "web_url": "http://gitlab.dev/u/root",
"website_url": "" "website_url": ""
} }
} }
``` ```
...@@ -323,28 +323,28 @@ Example of response ...@@ -323,28 +323,28 @@ Example of response
```json ```json
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
}, },
"coverage": null, "coverage": null,
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": "2016-01-11T10:14:09.526Z", "finished_at": "2016-01-11T10:14:09.526Z",
"id": 69, "id": 69,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
"stage": "test", "stage": "test",
"started_at": null, "started_at": null,
"status": "canceled", "status": "canceled",
"tag": false, "tag": false,
"user": null "user": null
} }
``` ```
...@@ -369,28 +369,28 @@ Example of response ...@@ -369,28 +369,28 @@ Example of response
```json ```json
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
}, },
"coverage": null, "coverage": null,
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"artifacts_file": null, "artifacts_file": null,
"finished_at": null, "finished_at": null,
"id": 69, "id": 69,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
"stage": "test", "stage": "test",
"started_at": null, "started_at": null,
"status": "pending", "status": "pending",
"tag": false, "tag": false,
"user": null "user": null
} }
``` ```
...@@ -419,34 +419,34 @@ Example of response ...@@ -419,34 +419,34 @@ Example of response
```json ```json
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
}, },
"coverage": null, "coverage": null,
"download_url": null, "download_url": null,
"id": 69, "id": 69,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
"stage": "test", "stage": "test",
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"started_at": "2016-01-11T10:13:33.506Z", "started_at": "2016-01-11T10:13:33.506Z",
"finished_at": "2016-01-11T10:15:10.506Z", "finished_at": "2016-01-11T10:15:10.506Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"user": null "user": null
} }
``` ```
## Keep artifacts ## Keep artifacts
Prevents artifacts from being deleted when expiration is set Prevents artifacts from being deleted when expiration is set.
``` ```
POST /projects/:id/builds/:build_id/artifacts/keep POST /projects/:id/builds/:build_id/artifacts/keep
...@@ -459,37 +459,37 @@ Parameters ...@@ -459,37 +459,37 @@ Parameters
| `id` | integer | yes | The ID of a project | | `id` | integer | yes | The ID of a project |
| `build_id` | integer | yes | The ID of a build | | `build_id` | integer | yes | The ID of a build |
Example of request Example request:
``` ```
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/artifacts/keep" curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/artifacts/keep"
``` ```
Example of response Example response:
```json ```json
{ {
"commit": { "commit": {
"author_email": "admin@example.com", "author_email": "admin@example.com",
"author_name": "Administrator", "author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00", "created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.", "message": "Test the CI integration.",
"short_id": "0ff3ae19", "short_id": "0ff3ae19",
"title": "Test the CI integration." "title": "Test the CI integration."
}, },
"coverage": null, "coverage": null,
"download_url": null, "download_url": null,
"id": 69, "id": 69,
"name": "rubocop", "name": "rubocop",
"ref": "master", "ref": "master",
"runner": null, "runner": null,
"stage": "test", "stage": "test",
"created_at": "2016-01-11T10:13:33.506Z", "created_at": "2016-01-11T10:13:33.506Z",
"started_at": "2016-01-11T10:13:33.506Z", "started_at": "2016-01-11T10:13:33.506Z",
"finished_at": "2016-01-11T10:15:10.506Z", "finished_at": "2016-01-11T10:15:10.506Z",
"status": "failed", "status": "failed",
"tag": false, "tag": false,
"user": null "user": null
} }
``` ```
...@@ -167,10 +167,11 @@ module API ...@@ -167,10 +167,11 @@ module API
user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project) user_can_download_artifacts: can?(current_user, :download_build_artifacts, user_project)
end end
# Keep the artifacts to prevent them to be deleted # Keep the artifacts to prevent them from being deleted
# #
# Parameters: # Parameters:
# id (required) - The ID of a build # id (required) - the id of a project
# build_id (required) - The ID of a build
# Example Request: # Example Request:
# POST /projects/:id/builds/:build_id/artifacts/keep # POST /projects/:id/builds/:build_id/artifacts/keep
post ':id/builds/:build_id/artifacts/keep' do post ':id/builds/:build_id/artifacts/keep' do
......
...@@ -20,7 +20,7 @@ module Ci ...@@ -20,7 +20,7 @@ module Ci
expose :name, :token, :stage expose :name, :token, :stage
expose :project_id expose :project_id
expose :project_name expose :project_name
expose :artifacts_file, using: ArtifactFile, if: lambda { |build, opts| build.artifacts? } expose :artifacts_file, using: ArtifactFile, if: ->(build, _) { build.artifacts? }
end end
class BuildDetails < Build class BuildDetails < Build
...@@ -29,7 +29,7 @@ module Ci ...@@ -29,7 +29,7 @@ module Ci
expose :before_sha expose :before_sha
expose :allow_git_fetch expose :allow_git_fetch
expose :token expose :token
expose :artifacts_expire_at, if: lambda { |build, opts| build.artifacts? } expose :artifacts_expire_at, if: ->(build, _) { build.artifacts? }
expose :options do |model| expose :options do |model|
model.options model.options
......
...@@ -106,7 +106,7 @@ describe "Builds" do ...@@ -106,7 +106,7 @@ describe "Builds" do
context 'no expire date defined' do context 'no expire date defined' do
let(:expire_at) { nil } let(:expire_at) { nil }
it 'should not have the Keep button' do it 'does not have the Keep button' do
page.within('.artifacts') do page.within('.artifacts') do
expect(page).not_to have_content 'Keep' expect(page).not_to have_content 'Keep'
end end
...@@ -116,7 +116,7 @@ describe "Builds" do ...@@ -116,7 +116,7 @@ describe "Builds" do
context 'when expire date is defined' do context 'when expire date is defined' do
let(:expire_at) { Time.now + 7.days } let(:expire_at) { Time.now + 7.days }
it 'should keep artifacts when Keep button is clicked' do it 'keeps artifacts when Keep button is clicked' do
page.within('.artifacts') do page.within('.artifacts') do
expect(page).to have_content 'The artifacts will be removed' expect(page).to have_content 'The artifacts will be removed'
click_link 'Keep' click_link 'Keep'
...@@ -130,7 +130,7 @@ describe "Builds" do ...@@ -130,7 +130,7 @@ describe "Builds" do
context 'when artifacts expired' do context 'when artifacts expired' do
let(:expire_at) { Time.now - 7.days } let(:expire_at) { Time.now - 7.days }
it 'should not have the Keep button' do it 'does not have the Keep button' do
page.within('.artifacts') do page.within('.artifacts') do
expect(page).to have_content 'The artifacts were removed' expect(page).to have_content 'The artifacts were removed'
expect(page).not_to have_link 'Keep' expect(page).not_to have_link 'Keep'
...@@ -150,8 +150,6 @@ describe "Builds" do ...@@ -150,8 +150,6 @@ describe "Builds" do
expect(page).to have_link 'Raw' expect(page).to have_link 'Raw'
end end
end end
context ''
end end
describe "POST /:project/builds/:id/cancel" do describe "POST /:project/builds/:id/cancel" do
......
...@@ -467,6 +467,7 @@ describe Ci::Build, models: true do ...@@ -467,6 +467,7 @@ describe Ci::Build, models: true do
it 'when assigning valid duration' do it 'when assigning valid duration' do
build.artifacts_expire_in = '7 days' build.artifacts_expire_in = '7 days'
is_expected.to be_within(10).of(7.days.to_i) is_expected.to be_within(10).of(7.days.to_i)
end end
...@@ -477,6 +478,7 @@ describe Ci::Build, models: true do ...@@ -477,6 +478,7 @@ describe Ci::Build, models: true do
it 'when resseting value' do it 'when resseting value' do
build.artifacts_expire_in = nil build.artifacts_expire_in = nil
is_expected.to be_nil is_expected.to be_nil
end end
end end
...@@ -486,6 +488,7 @@ describe Ci::Build, models: true do ...@@ -486,6 +488,7 @@ describe Ci::Build, models: true do
it 'to reset expire_at' do it 'to reset expire_at' do
build.keep_artifacts! build.keep_artifacts!
expect(build.artifacts_expire_at).to be_nil expect(build.artifacts_expire_at).to be_nil
end end
end end
......
...@@ -253,17 +253,16 @@ describe API::API, api: true do ...@@ -253,17 +253,16 @@ describe API::API, api: true do
project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days) project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days)
end end
it 'should keep artifacts' do it 'keeps artifacts' do
expect(response.status).to eq 200 expect(response.status).to eq 200
build.reload expect(build.reload.artifacts_expire_at).to be_nil
expect(build.artifacts_expire_at).to be_nil
end end
end end
context 'no artifacts' do context 'no artifacts' do
let(:build) { create(:ci_build, project: project, pipeline: pipeline) } let(:build) { create(:ci_build, project: project, pipeline: pipeline) }
it 'should respond with not found' do it 'responds with not found' do
expect(response.status).to eq 404 expect(response.status).to eq 404
end end
end end
......
...@@ -364,7 +364,7 @@ describe Ci::API::API do ...@@ -364,7 +364,7 @@ describe Ci::API::API do
end end
end end
context 'expire date' do context 'with an expire date' do
let!(:artifacts) { file_upload } let!(:artifacts) { file_upload }
let(:post_data) do let(:post_data) do
...@@ -377,7 +377,7 @@ describe Ci::API::API do ...@@ -377,7 +377,7 @@ describe Ci::API::API do
post(post_url, post_data, headers_with_token) post(post_url, post_data, headers_with_token)
end end
context 'updates when specified' do context 'with an expire_in given' do
let(:expire_in) { '7 days' } let(:expire_in) { '7 days' }
it do it do
...@@ -388,7 +388,7 @@ describe Ci::API::API do ...@@ -388,7 +388,7 @@ describe Ci::API::API do
end end
end end
context 'ignores if not specified' do context 'with no expire_in given' do
let(:expire_in) { nil } let(:expire_in) { nil }
it do it do
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe ExpireBuildArtifactsWorker do describe ExpireBuildArtifactsWorker do
include RepoHelpers include RepoHelpers
let(:worker) { ExpireBuildArtifactsWorker.new } let(:worker) { described_class.new }
describe '#perform' do describe '#perform' do
context 'with expired artifacts' do context 'with expired artifacts' do
...@@ -11,9 +11,10 @@ describe ExpireBuildArtifactsWorker do ...@@ -11,9 +11,10 @@ describe ExpireBuildArtifactsWorker do
it do it do
expect_any_instance_of(Ci::Build).to receive(:erase_artifacts!) expect_any_instance_of(Ci::Build).to receive(:erase_artifacts!)
worker.perform worker.perform
build.reload
expect(build.artifacts_expired?).to be_truthy expect(build.reload.artifacts_expired?).to be_truthy
end end
end end
...@@ -22,9 +23,10 @@ describe ExpireBuildArtifactsWorker do ...@@ -22,9 +23,10 @@ describe ExpireBuildArtifactsWorker do
it do it do
expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!) expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!)
worker.perform worker.perform
build.reload
expect(build.artifacts_expired?).to be_falsey expect(build.reload.artifacts_expired?).to be_falsey
end end
end end
...@@ -33,6 +35,7 @@ describe ExpireBuildArtifactsWorker do ...@@ -33,6 +35,7 @@ describe ExpireBuildArtifactsWorker do
it do it do
expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!) expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!)
worker.perform worker.perform
end end
end end
...@@ -47,9 +50,10 @@ describe ExpireBuildArtifactsWorker do ...@@ -47,9 +50,10 @@ describe ExpireBuildArtifactsWorker do
it do it do
expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!) expect_any_instance_of(Ci::Build).not_to receive(:erase_artifacts!)
worker.perform worker.perform
build.reload
expect(build.artifacts_expired?).to be_truthy expect(build.reload.artifacts_expired?).to be_truthy
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment