Skip to content

Commit

Permalink
PolicyEvent::Purging normalization
Browse files Browse the repository at this point in the history
- converted put_or_update to put on general queue
- queuing directly into purge_by_date
  • Loading branch information
kbrock committed Apr 7, 2017
1 parent 28c97a9 commit ce61ca2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
10 changes: 0 additions & 10 deletions app/models/policy_event/purging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ def purge_window_size
::Settings.policy_events.history.purge_window_size
end

def purge_queue
MiqQueue.put_unless_exists(
:class_name => name,
:method_name => "purge",
:role => "event",
:queue_name => "ems"
)
end
alias_method :purge_timer, :purge_queue

def purge_scope(older_than)
where(arel_table[:timestamp].lt(older_than))
end
Expand Down
18 changes: 3 additions & 15 deletions spec/models/policy_event/purging_spec.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
describe PolicyEvent do
context "::Purging" do
context ".purge_queue" do
context ".purge_timer" do
before do
EvmSpecHelper.create_guid_miq_server_zone
end

it "with nothing in the queue" do
described_class.purge_queue
described_class.purge_timer

q = MiqQueue.all
expect(q.length).to eq(1)
expect(q.first).to have_attributes(
:class_name => described_class.name,
:method_name => "purge"
)
end

it "with item already in the queue" do
described_class.purge_queue
described_class.purge_queue

q = MiqQueue.all
expect(q.length).to eq(1)
expect(q.first).to have_attributes(
:class_name => described_class.name,
:method_name => "purge"
:method_name => "purge_by_date"
)
end
end
Expand Down

0 comments on commit ce61ca2

Please sign in to comment.