Skip to content

Commit

Permalink
Fix call for future retirement
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed May 17, 2018
1 parent 5430d1d commit f2bb584
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/mixins/retirement_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module RetirementMixin
module ClassMethods
def make_retire_request(*src_ids)
options = {:src_ids => src_ids.presence || id}
(name + "RetireRequest").constantize.make_request(nil, options, User.current_user, true)
(name.demodulize + "RetireRequest").constantize.make_request(nil, options, User.current_user, true)
end

def retire(ids, options = {})
Expand Down Expand Up @@ -122,7 +122,7 @@ def retirement_check
end
end

make_retire_request if retirement_due?
self.class.make_retire_request(self.id) if retirement_due?
end

def retire_now(requester = nil)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
describe "Service Retirement Management" do
let(:user) { FactoryGirl.create(:user_miq_request_approver, :userid => "admin") }
before do
@miq_server = EvmSpecHelper.local_miq_server
@stack = FactoryGirl.create(:orchestration_stack)
end

it "#retirement_check" do
User.current_user = user
expect(MiqEvent).to receive(:raise_evm_event)
@stack.update_attributes(:retires_on => 90.days.ago, :retirement_warn => 60, :retirement_last_warn => nil)
expect(@stack.retirement_last_warn).to be_nil
expect(@stack).to receive(:make_retire_request).once
@stack.retirement_check
@stack.reload
expect(@stack.retirement_last_warn).not_to be_nil
Expand Down
2 changes: 1 addition & 1 deletion spec/models/service/retirement_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

# shouldn't be running make_retire_request because it's the bimodal not from ui part
it "#retirement_check" do
User.current_user = user
expect(MiqEvent).to receive(:raise_evm_event)
@service.update_attributes(:retires_on => 90.days.ago, :retirement_warn => 60, :retirement_last_warn => nil)
expect(@service.retirement_last_warn).to be_nil
expect(@service).to receive(:make_retire_request).once
@service.retirement_check
@service.reload
expect(@service.retirement_last_warn).not_to be_nil
Expand Down
2 changes: 1 addition & 1 deletion spec/models/vm/retirement_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
end

it "#retirement_check" do
User.current_user = user
expect(MiqEvent).to receive(:raise_evm_event).once
@vm.update_attributes(:retires_on => 90.days.ago, :retirement_warn => 60, :retirement_last_warn => nil)
expect(@vm.retirement_last_warn).to be_nil
expect(@vm).to receive(:make_retire_request).once
@vm.retirement_check
@vm.reload
expect(@vm.retirement_last_warn).not_to be_nil
Expand Down

0 comments on commit f2bb584

Please sign in to comment.