google_calendar_publish_agent_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. require 'spec_helper'
  2. describe Agents::GoogleCalendarPublishAgent, :vcr do
  3. before do
  4. @valid_params = {
  5. 'expected_update_period_in_days' => "10",
  6. 'calendar_id' => 'sqv39gj35tc837gdns1g4d81cg@group.calendar.google.com',
  7. 'google' => {
  8. 'key_file' => File.dirname(__FILE__) + '/../../data_fixtures/private.key',
  9. 'key_secret' => 'notasecret',
  10. 'service_account_email' => '1029936966326-ncjd7776pcspc98hsg82gsb56t3217ef@developer.gserviceaccount.com'
  11. }
  12. }
  13. @checker = Agents::GoogleCalendarPublishAgent.new(:name => "somename", :options => @valid_params)
  14. @checker.user = users(:jane)
  15. @checker.save!
  16. end
  17. describe '#receive' do
  18. it 'should publish any payload it receives' do
  19. event1 = Event.new
  20. event1.agent = agents(:bob_manual_event_agent)
  21. event1.payload = {
  22. 'message' => {
  23. 'visibility' => 'default',
  24. 'summary' => "Awesome event",
  25. 'description' => "An example event with text. Pro tip: DateTimes are in RFC3339",
  26. 'end' => {
  27. 'dateTime' => '2014-10-02T11:00:00-05:00'
  28. },
  29. 'start' => {
  30. 'dateTime' => '2014-10-02T10:00:00-05:00'
  31. }
  32. }
  33. }
  34. event1.save!
  35. @checker.receive([event1])
  36. expect(@checker.events.count).to eq(1)
  37. end
  38. end
  39. end