Commit eb84a5b0 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fix key removal

parent 54108b6c
......@@ -16,8 +16,9 @@ class GeoKeyRefreshWorker
key = Key.find(key_id)
key.add_to_shell
when :delete
# ActiveRecord::RecordNotFound when not found (so job will retry)
key = Key.find(key_id)
# we are physically removing the key after model is removed
# so we must reconstruct ids to schedule removal
key = Key.new(id: key_id)
key.remove_from_shell
else
fail "Invalid action: #{action}"
......
......@@ -15,7 +15,7 @@ describe GeoKeyRefreshWorker do
context 'key removal' do
it 'removes key from the shell' do
expect(Key).to receive(:find).with(key.id) { key }
expect(Key).to receive(:new).with(id: key.id) { key }
expect(key).to receive(:remove_from_shell)
expect { key_delete }.not_to raise_error
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