summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-06-14 11:38:34 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-06-14 11:38:34 +0200
commit60e0137c864e26fee0120dc4447bb95acc46ce51 (patch)
tree98e9bc8f87c048844655bdd587fa782089002215
parent278a0e1a0fb094dc2eceec0d82d9a56be81c8046 (diff)
downloadgitlab-ce-60e0137c864e26fee0120dc4447bb95acc46ce51.tar.gz
Fix specs
-rw-r--r--lib/api/builds.rb2
-rw-r--r--spec/features/builds_spec.rb16
-rw-r--r--spec/models/build_spec.rb6
-rw-r--r--spec/workers/expire_build_artifacts_worker_spec.rb28
4 files changed, 28 insertions, 24 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 644e5a2a99d..645e2dda0b7 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -184,7 +184,7 @@ module API
status 200
present build, with: Entities::Build,
- user_can_download_artifacts: can?(current_user, :read_build, user_project)
+ user_can_download_artifacts: can?(current_user, :read_build, user_project)
end
end
diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb
index 0fd95295388..16832c297ac 100644
--- a/spec/features/builds_spec.rb
+++ b/spec/features/builds_spec.rb
@@ -107,9 +107,7 @@ describe "Builds" do
let(:expire_at) { nil }
it 'does not have the Keep button' do
- page.within('.artifacts') do
- expect(page).not_to have_content 'Keep'
- end
+ expect(page).not_to have_content 'Keep'
end
end
@@ -117,10 +115,8 @@ describe "Builds" do
let(:expire_at) { Time.now + 7.days }
it 'keeps artifacts when Keep button is clicked' do
- page.within('.artifacts') do
- expect(page).to have_content 'The artifacts will be removed'
- click_link 'Keep'
- end
+ expect(page).to have_content 'The artifacts will be removed'
+ click_link 'Keep'
expect(page).not_to have_link 'Keep'
expect(page).not_to have_content 'The artifacts will be removed'
@@ -131,10 +127,8 @@ describe "Builds" do
let(:expire_at) { Time.now - 7.days }
it 'does not have the Keep button' do
- page.within('.artifacts') do
- expect(page).to have_content 'The artifacts were removed'
- expect(page).not_to have_link 'Keep'
- end
+ expect(page).to have_content 'The artifacts were removed'
+ expect(page).not_to have_link 'Keep'
end
end
end
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index c07832a4b5f..35554e1e0c0 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -415,12 +415,14 @@ describe Ci::Build, models: true do
context 'is expired' do
before { build.update(artifacts_expire_at: Time.now - 7.days) }
- it { is_expected.to be_falsy }
+
+ it { is_expected.to be_truthy }
end
context 'is not expired' do
before { build.update(artifacts_expire_at: Time.now + 7.days) }
- it { is_expected.to be_truthy }
+
+ it { is_expected.to be_falsey }
end
end
diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb
index eb8afb20275..e3827cae9a6 100644
--- a/spec/workers/expire_build_artifacts_worker_spec.rb
+++ b/spec/workers/expire_build_artifacts_worker_spec.rb
@@ -11,37 +11,45 @@ describe ExpireBuildArtifactsWorker do
subject! { worker.perform }
context 'with 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 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy
end
+
+ it 'does remove files' do
+ expect(build.reload.artifacts_file.exists?).to be_falsey
+ end
end
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 'does not expire' do
- expect(build.reload.artifacts_expired?).to be_truthy
+ expect(build.reload.artifacts_expired?).to be_falsey
+ end
+
+ it 'does not remove files' do
+ expect(build.reload.artifacts_file.exists?).to be_truthy
end
end
context 'without expire date' do
- let!(:build) { create(:ci_build, :artifacts) }
+ let(:build) { create(:ci_build, :artifacts) }
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey
end
+
+ it 'does not remove files' do
+ expect(build.reload.artifacts_file.exists?).to be_truthy
+ end
end
context 'for expired artifacts' do
- let!(:build) { create(:ci_build, artifacts_expire_at: Time.now - 7.days) }
+ let(:build) { create(:ci_build, artifacts_expire_at: Time.now - 7.days) }
- it 'does not erase artifacts' do
- expect_any_instance_of(Ci::Build).not_to have_received(:erase_artifacts!)
- end
-
- it 'does expire' do
+ it 'is still expired' do
expect(build.reload.artifacts_expired?).to be_truthy
end
end