2012-08-28 23:04:06 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe KeyObserver do
|
2013-01-03 11:37:12 +01:00
|
|
|
before do
|
2012-08-28 23:04:06 +02:00
|
|
|
@key = double('Key',
|
2013-02-05 11:47:50 +01:00
|
|
|
shell_id: 'key-32',
|
2012-08-28 23:04:06 +02:00
|
|
|
key: '== a vaild ssh key',
|
|
|
|
projects: [],
|
|
|
|
is_deploy_key: false
|
|
|
|
)
|
|
|
|
|
|
|
|
@observer = KeyObserver.instance
|
|
|
|
end
|
|
|
|
|
|
|
|
context :after_save do
|
|
|
|
it do
|
2013-02-11 19:28:27 +01:00
|
|
|
GitlabShellWorker.should_receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
|
2012-08-28 23:04:06 +02:00
|
|
|
@observer.after_save(@key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-03 11:37:12 +01:00
|
|
|
context :after_destroy do
|
2012-08-28 23:04:06 +02:00
|
|
|
it do
|
2013-02-11 19:28:27 +01:00
|
|
|
GitlabShellWorker.should_receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
|
2012-08-28 23:04:06 +02:00
|
|
|
@observer.after_destroy(@key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|