2012-08-29 00:04:06 +03:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe KeyObserver do
|
2013-01-03 12:37:12 +02:00
|
|
|
before do
|
2012-08-29 00:04:06 +03:00
|
|
|
@key = double('Key',
|
|
|
|
identifier: 'admin_654654',
|
|
|
|
key: '== a vaild ssh key',
|
|
|
|
projects: [],
|
|
|
|
is_deploy_key: false
|
|
|
|
)
|
|
|
|
|
|
|
|
@observer = KeyObserver.instance
|
|
|
|
end
|
|
|
|
|
|
|
|
context :after_save do
|
|
|
|
it do
|
2013-01-28 23:03:38 +02:00
|
|
|
GitoliteWorker.should_receive(:perform_async).with(:set_key, @key.identifier, @key.key, @key.projects.map(&:id))
|
2012-08-29 00:04:06 +03:00
|
|
|
@observer.after_save(@key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-03 12:37:12 +02:00
|
|
|
context :after_destroy do
|
2012-08-29 00:04:06 +03:00
|
|
|
it do
|
2013-01-28 23:03:38 +02:00
|
|
|
GitoliteWorker.should_receive(:perform_async).with(:remove_key, @key.identifier, @key.projects.map(&:id))
|
2012-08-29 00:04:06 +03:00
|
|
|
@observer.after_destroy(@key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|