-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathstack_update_spec.rb
More file actions
59 lines (52 loc) · 1.78 KB
/
stack_update_spec.rb
File metadata and controls
59 lines (52 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'spec_helper'
require 'actions/stack_update'
module VCAP::CloudController
RSpec.describe StackUpdate do
let(:user) { User.make }
let(:user_email) { 'user@example.com' }
let(:user_audit_info) { UserAuditInfo.new(user_guid: user.guid, user_email: user_email) }
subject(:stack_update) { StackUpdate.new(user_audit_info) }
describe '#update' do
let(:body) do
{
metadata: {
labels: {
freaky: 'wednesday'
},
annotations: {
tokyo: 'grapes'
}
}
}
end
let(:stack) { Stack.make }
let(:message) { StackUpdateMessage.new(body) }
it 'updates the stack metadata' do
expect(message).to be_valid
stack_update.update(stack, message)
stack.reload
expect(stack).to have_labels({ key_name: 'freaky', value: 'wednesday' })
expect(stack).to have_annotations({ key_name: 'tokyo', value: 'grapes' })
end
it 'creates an audit event' do
stack_update.update(stack, message)
expect(VCAP::CloudController::Event.count).to eq(1)
stack_update_event = VCAP::CloudController::Event.find(type: 'audit.stack.update')
expect(stack_update_event).to exist
expect(stack_update_event.values).to include(
type: 'audit.stack.update',
actor: user_audit_info.user_guid,
actor_type: 'user',
actor_name: user_audit_info.user_email,
actee: stack.guid,
actee_type: 'stack',
actee_name: stack.name,
space_guid: '',
organization_guid: ''
)
expect(stack_update_event.metadata).to eq({ 'request' => message.audit_hash })
expect(stack_update_event.timestamp).to be
end
end
end
end