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

Fix specs

parent 278a0e1a
...@@ -184,7 +184,7 @@ module API ...@@ -184,7 +184,7 @@ module API
status 200 status 200
present build, with: Entities::Build, 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
end end
......
...@@ -107,9 +107,7 @@ describe "Builds" do ...@@ -107,9 +107,7 @@ 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
...@@ -117,10 +115,8 @@ describe "Builds" do ...@@ -117,10 +115,8 @@ describe "Builds" 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,10 +127,8 @@ describe "Builds" do ...@@ -131,10 +127,8 @@ 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
......
...@@ -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