commander_agent_spec.rb 813 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. require 'spec_helper'
  2. describe Agents::CommanderAgent do
  3. let(:valid_params) {
  4. {
  5. name: 'Example',
  6. schedule: 'every_1h',
  7. options: {
  8. 'action' => 'run',
  9. },
  10. }
  11. }
  12. let(:agent) {
  13. described_class.create!(valid_params) { |agent|
  14. agent.user = users(:bob)
  15. }
  16. }
  17. it_behaves_like AgentControllerConcern
  18. describe "check!" do
  19. it "should command targets" do
  20. stub(agent).control!.once { nil }
  21. agent.check!
  22. end
  23. end
  24. describe "receive_events" do
  25. it "should command targets" do
  26. stub(agent).control!.once { nil }
  27. event = Event.new
  28. event.agent = agents(:bob_rain_notifier_agent)
  29. event.payload = {
  30. 'url' => 'http://xkcd.com',
  31. 'link' => 'Random',
  32. }
  33. agent.receive([event])
  34. end
  35. end
  36. end