file_handling_consumer.rb 664B

12345678910111213141516
  1. require 'rails_helper'
  2. shared_examples_for 'FileHandlingConsumer' do
  3. it 'returns a file pointer' do
  4. expect(@checker.get_file_pointer('testfile')).to eq(file_pointer: { file: "testfile", agent_id: @checker.id})
  5. end
  6. it 'get_io raises an exception when trying to access an agent of a different user' do
  7. @checker2 = @checker.dup
  8. @checker2.user = users(:bob)
  9. @checker2.save!
  10. expect(@checker2.user.id).not_to eq(@checker.user.id)
  11. event = Event.new(user: @checker.user, payload: {'file_pointer' => {'file' => 'test', 'agent_id' => @checker2.id}})
  12. expect { @checker.get_io(event) }.to raise_error(ActiveRecord::RecordNotFound)
  13. end
  14. end