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

Fix specs

parent 278a0e1a
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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