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',
|
|
|
|
identifier: 'admin_654654',
|
|
|
|
key: '== a vaild ssh key',
|
|
|
|
projects: [],
|
|
|
|
is_deploy_key: false
|
|
|
|
)
|
|
|
|
|
|
|
|
@gitolite = double('Gitlab::Gitolite',
|
|
|
|
set_key: true,
|
|
|
|
remove_key: true
|
|
|
|
)
|
|
|
|
|
|
|
|
@observer = KeyObserver.instance
|
2013-01-03 11:37:12 +01:00
|
|
|
@observer.stub(gitolite: @gitolite)
|
2012-08-28 23:04:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context :after_save do
|
|
|
|
it do
|
|
|
|
@gitolite.should_receive(:set_key).with(@key.identifier, @key.key, @key.projects)
|
|
|
|
@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
|
|
|
|
@gitolite.should_receive(:remove_key).with(@key.identifier, @key.projects)
|
|
|
|
@observer.after_destroy(@key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|