ebeigarts / exchanger

Ruby client for Exchange Web Services
MIT License
57 stars 36 forks source link

Calendar Item Updates #17

Closed chadrschroeder closed 8 years ago

chadrschroeder commented 8 years ago

The CalendarView support in this gem has been very helpful!

This pull request addresses some issues I ran into with updating calendar items. Please let me know if these would be OK to bring into master.

1. VCR Version Bump

The VCR version was bumped up to 3.0.1 because version 2.2.5 was producing blank YAML files.

2. VCR Password Filter Update

The VCR filter_sensitive_data use was updated to handle passwords with sensitive characters. For example, a password of secret! would get encoded as secret%21 and would remain in the cassette file.

3. Contact Test Updates

When running the contact_spec on a fresh cassette, this failure occurred:

Exchanger::Operation::ResponseError:
The request failed schema validation: The 'SendMeetingInvitations' attribute is invalid - The value '' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:CalendarItemCreateOrDeleteOperationType' - The Enumeration constraint failed.

This appears to be because the SendMeetingInvitations attribute was added to the CreateItem operation for CalendarItem#create but this unintentionally affected Item#create.

4. Return ID for New CalendarItem

A newly created Item would return its id but a CalendarItem would not. CalendarItem needed to be able to use this code:

response = UpdateItem.run(:items => [self])
move_changes

5. Fix CalendarItem Destroy

Running destroy on a CalendarItem was resulting in:

Exchanger::Operation::ResponseError:
SendMeetingCancellations attribute is required for Calendar items.

I've added this attribute.

6. Allow Body for New CalendarItem

When attempting to create a new calendar item with a body value, the request was failing on:

Exchanger::Operation::ResponseError:
The request failed schema validation: The required attribute 'BodyType' is missing.

I've created a new Body element to allow the BodyType to be sent.

7. Fix CalendarItem Update

Running save on an existing CalendarItem was resulting in:

Exchanger::Operation::ResponseError:
The SendMeetingInvitationsOrCancellations attribute is required for calendar items.

I've added this attribute.


Note: The calendar_item_spec.rb is passing on my machine. I'm not sure why it is failing in the Travis CI build.

ebeigarts commented 8 years ago

Great work! I think the specs could be failing because config.yml.example has endpoint amsprd0710.outlook.com but your config.yml had different hostname. Maybe you can try to:

  1. remove your own config.yml
  2. change the hostnames in vcr casettes from outlook.office365.com to amsprd0710.outlook.com
  3. run rake, so that it copies config.yml.example to config.yml and runs the specs (this is the way CI runs)

Maybe it is possible to filter the hostname in VCR to smthg like example.com, but i'm not sure it that will work.

chadrschroeder commented 8 years ago

Thanks. Yes, that was it. When VCR.use_cassette is called, it compares the currently configured URI with the cassette URI to decide if it can use the previous recording or if it has to create a new one. As suggested, I've added a filter to make sure that amsprd0710.outlook.com is assigned as the endpoint when new cassette files are created. CI will then use the cassette files for its tests.

ebeigarts commented 8 years ago

Will try to release a new version this week.

ebeigarts commented 8 years ago

Released in 0.1.5.