Skip to content

Commit

Permalink
Adapt files to call ProjectCreateAutoCleanupRequestsJob instead of Pr…
Browse files Browse the repository at this point in the history
…ojectCreateAutoCleanupRequests
  • Loading branch information
vpereira committed Oct 24, 2020
1 parent 104dc50 commit 2bb9002
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/config/clock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module Clockwork

every(1.day, 'create cleanup requests', at: '06:00') do
User.session = User.get_default_admin
ProjectCreateAutoCleanupRequests.perform_later
ProjectCreateAutoCleanupRequestsJob.perform_later
end

# check for new breakages between api and backend due to dull code
Expand Down
22 changes: 20 additions & 2 deletions src/api/spec/jobs/project_create_auto_cleanup_requests_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
require 'rails_helper'
require 'webmock/rspec'

RSpec.describe ProjectCreateAutoCleanupRequests, type: :job, vcr: true do
RSpec.describe ProjectCreateAutoCleanupRequestsJob, type: :job, vcr: true do
include ActiveJob::TestHelper

describe 'CleanupRequestTemplate' do
describe '#render' do
let(:clean_up_template) { described_class::CleanupRequestTemplate.new(project: 'foo', description: 'bar', cleanup_time: 3) }
let(:bs_delete_request) do
<<~XML
<request>
<action type=\"delete\"><target project=\"foo\"/></action>
<description>bar</description>
<state />
<accept_at>3</accept_at>
</request>
XML
end

it { expect(clean_up_template.render).to eq(bs_delete_request) }
end
end

describe '#perform' do
let(:admin) { create(:admin_user, login: 'Admin') }
let(:project) { create(:project, name: 'ProjectA') }
let(:attribute) { create(:auto_cleanup_attrib, project: project) }

subject { ProjectCreateAutoCleanupRequests.new.perform }
subject { described_class.perform_now }

before do
allow(::Configuration).to receive(:cleanup_after_days).and_return(3)
Expand Down
4 changes: 2 additions & 2 deletions src/api/test/functional/source_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3619,7 +3619,7 @@ def test_branch_creating_project
# in future
Timecop.freeze(10.days) do
User.session = User.find_by_login('fredlibs')
ProjectCreateAutoCleanupRequests.new.perform
ProjectCreateAutoCleanupRequestsJob.perform_now
User.session = nil
end
# validate request
Expand All @@ -3631,7 +3631,7 @@ def test_branch_creating_project
# second run shall not open another request
# in future
Timecop.freeze(12.days) do
ProjectCreateAutoCleanupRequests.new.perform
ProjectCreateAutoCleanupRequestsJob.perform_now
end
assert_equal br, BsRequest.all.last

Expand Down

0 comments on commit 2bb9002

Please sign in to comment.