spec/isimud/event_observer_spec.rb in isimud-1.4.6 vs spec/isimud/event_observer_spec.rb in isimud-1.4.7
- old
+ new
@@ -55,43 +55,32 @@
@user = User.create(user_params.merge(deactivated: true))
@queue = @client.find_queue(@user.event_queue_name)
end
it 'creates the queue' do
- expect(@client).to receive(:find_queue).with(@user.event_queue_name).and_call_original
+ expect(@client).to receive(:create_queue).with("combustion.user.#{@user.id}",
+ @exchange,
+ routing_keys: keys)
@user.update_attributes(deactivated: false)
end
-
- it 'binds the routing keys' do
- @user.exchange_routing_keys.each do |k|
- expect(@queue).to receive(:bind).with(@exchange, routing_key: k).and_call_original
- end
- @user.update_attributes(deactivated: false)
- end
end
context 'for an already active instance' do
before do
@user = User.create(user_params)
@queue = @client.find_queue(@user.event_queue_name)
end
- it 'binds new keys' do
- @user.exchange_routing_keys.each do |k|
- expect(@queue).to receive(:bind).with(@exchange, routing_key: k).and_call_original
- end
- expect(@queue).to receive(:bind).with(@exchange, routing_key: 'some_other_value').and_call_original
+ it 'deletes and recreates the queue' do
+ new_keys = keys << 'some_other_value'
+ expect(@client).to receive(:delete_queue).with(@user.event_queue_name)
+ expect(@client).to receive(:create_queue).with("combustion.user.#{@user.id}",
+ @exchange,
+ routing_keys: new_keys)
@user.transaction do
@user.keys << 'some_other_value'
@user.save!
end
- end
-
- it 'removes old keys' do
- expect(@queue).to receive(:unbind).with(@exchange, routing_key: 'a.b.c')
- expect(@queue).not_to receive(:unbind).with(@exchange, routing_key: 'd.*.f')
- @user.keys.delete('a.b.c')
- @user.save!
end
end
end
describe 'when destroyed' do
\ No newline at end of file