Commit 60e0137c authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix specs

parent 278a0e1a
...@@ -107,20 +107,16 @@ describe "Builds" do ...@@ -107,20 +107,16 @@ describe "Builds" do
let(:expire_at) { nil } let(:expire_at) { nil }
it 'does not have the Keep button' do it 'does not have the Keep button' do
page.within('.artifacts') do
expect(page).not_to have_content 'Keep' expect(page).not_to have_content 'Keep'
end end
end end
end
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 'keeps artifacts when Keep button is clicked' do it 'keeps artifacts when Keep button is clicked' 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'
end
expect(page).not_to have_link 'Keep' expect(page).not_to have_link 'Keep'
expect(page).not_to have_content 'The artifacts will be removed' expect(page).not_to have_content 'The artifacts will be removed'
...@@ -131,13 +127,11 @@ describe "Builds" do ...@@ -131,13 +127,11 @@ describe "Builds" do
let(:expire_at) { Time.now - 7.days } let(:expire_at) { Time.now - 7.days }
it 'does not have the Keep button' do it 'does not have the Keep button' 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'
end end
end end
end end
end
context 'Build raw trace' do context 'Build raw trace' do
before do before do
......
...@@ -415,12 +415,14 @@ describe Ci::Build, models: true do ...@@ -415,12 +415,14 @@ describe Ci::Build, models: true do
context 'is expired' do context 'is expired' do
before { build.update(artifacts_expire_at: Time.now - 7.days) } before { build.update(artifacts_expire_at: Time.now - 7.days) }
it { is_expected.to be_falsy }
it { is_expected.to be_truthy }
end end
context 'is not expired' do context 'is not expired' do
before { build.update(artifacts_expire_at: Time.now + 7.days) } before { build.update(artifacts_expire_at: Time.now + 7.days) }
it { is_expected.to be_truthy }
it { is_expected.to be_falsey }
end end
end end
......
...@@ -11,37 +11,45 @@ describe ExpireBuildArtifactsWorker do ...@@ -11,37 +11,45 @@ describe ExpireBuildArtifactsWorker do
subject! { worker.perform } subject! { worker.perform }
context 'with expired artifacts' do 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 it 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy expect(build.reload.artifacts_expired?).to be_truthy
end end
it 'does remove files' do
expect(build.reload.artifacts_file.exists?).to be_falsey
end
end end
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 'does not expire' do 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
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 'does not expire' do it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey expect(build.reload.artifacts_expired?).to be_falsey
end end
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
end end
context 'for expired artifacts' do 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 it 'is still expired' do
expect_any_instance_of(Ci::Build).not_to have_received(:erase_artifacts!)
end
it 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy expect(build.reload.artifacts_expired?).to be_truthy
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