exchanger 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +53 -0
  3. data/lib/exchanger.rb +2 -0
  4. data/lib/exchanger/elements/attendee.rb +4 -0
  5. data/lib/exchanger/elements/base_folder.rb +9 -0
  6. data/lib/exchanger/elements/calendar_item.rb +5 -0
  7. data/lib/exchanger/elements/calendar_view.rb +12 -0
  8. data/lib/exchanger/elements/item.rb +9 -0
  9. data/lib/exchanger/operations/create_item.rb +4 -2
  10. data/lib/exchanger/operations/find_item.rb +5 -1
  11. data/lib/exchanger/persistence.rb +4 -0
  12. data/lib/exchanger/version.rb +1 -1
  13. data/spec/cassettes/contact/destroy.yml +58 -0
  14. data/spec/cassettes/contact/destroy_setup.yml +61 -0
  15. data/spec/cassettes/contact/find.yml +119 -0
  16. data/spec/cassettes/contact/find_setup.yml +61 -0
  17. data/spec/cassettes/contact/save.yml +399 -0
  18. data/spec/cassettes/contact/save_cleanup.yml +58 -0
  19. data/spec/cassettes/folder/find_calendar.yml +60 -0
  20. data/spec/cassettes/folder/find_contacts.yml +60 -0
  21. data/spec/cassettes/folder/find_root.yml +60 -0
  22. data/spec/cassettes/folder/find_root_folders.yml +108 -0
  23. data/spec/cassettes/get_user_availability.yml +75 -0
  24. data/spec/cassettes/get_user_availability_default.yml +78 -0
  25. data/spec/cassettes/mailbox/search_test.yml +58 -0
  26. data/spec/cassettes/mailbox/search_test_members.yml +58 -0
  27. data/spec/config.yml +9 -6
  28. data/spec/config.yml.example +3 -3
  29. data/spec/exchanger/calendar_folder_spec.rb +13 -0
  30. data/spec/exchanger/calendar_item_spec.rb +13 -0
  31. data/spec/{client_spec.rb → exchanger/client_spec.rb} +1 -1
  32. data/spec/exchanger/contact_spec.rb +102 -0
  33. data/spec/exchanger/element_spec.rb +4 -0
  34. data/spec/{field_spec.rb → exchanger/field_spec.rb} +1 -1
  35. data/spec/exchanger/folder_spec.rb +17 -0
  36. data/spec/exchanger/get_user_availability_spec.rb +46 -0
  37. data/spec/exchanger/mailbox_spec.rb +18 -0
  38. data/spec/fixtures/get_user_availability.yml +4 -0
  39. data/spec/fixtures/get_user_availability.yml.example +3 -3
  40. data/spec/spec_helper.rb +18 -1
  41. metadata +91 -69
  42. data/spec/calendar_item_spec.rb +0 -26
  43. data/spec/contact_spec.rb +0 -67
  44. data/spec/element_spec.rb +0 -4
  45. data/spec/folder_spec.rb +0 -13
  46. data/spec/get_user_availability_spec.rb +0 -44
  47. data/spec/mailbox_spec.rb +0 -9
@@ -1,26 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Exchanger::CalendarFolder do
4
- before do
5
- @folder = Exchanger::Folder.find(:calendar)
6
- end
7
-
8
- it "should return calendar folder" do
9
- @folder.class.should == Exchanger::CalendarFolder
10
- end
11
-
12
- it "should have calendar items" do
13
- @folder.items.size.should > 0
14
- end
15
- end
16
-
17
- describe Exchanger::CalendarItem do
18
- before do
19
- @folder = Exchanger::Folder.find(:calendar)
20
- @item = @folder.items.first
21
- end
22
-
23
- it "should have start time" do
24
- @item.start.class.should == Time
25
- end
26
- end
@@ -1,67 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Exchanger::Contact do
4
- before do
5
- @folder = Exchanger::Folder.find(:contacts)
6
- end
7
-
8
- it "should return calendar folder" do
9
- @folder.class.should == Exchanger::ContactsFolder
10
- end
11
-
12
- it "should create a new contact, update it and destroy it" do
13
- prev_items_size = @folder.items.size
14
- @contact = @folder.new_contact(:given_name => "Edgars", :surname => "Beigarts", :nickname => "EBEI")
15
- @contact.complete_name = \
16
- Exchanger::CompleteName.new(:first_name => "Edgars", :last_name => "Beigarts") # read only
17
- @contact.physical_addresses = [
18
- Exchanger::PhysicalAddress.new(:key => "Business", :city => "Riga", :street => "Brivibas iela 1", :state => ""),
19
- Exchanger::PhysicalAddress.new(:key => "Home", :city => "Riga", :street => "Brivibas iela 2")
20
- ]
21
- @contact.email_addresses = [
22
- Exchanger::EmailAddress.new(:key => "EmailAddress1", :text => "edgars.beigarts@tieto.com")
23
- ]
24
- @contact.should be_changed
25
- @contact.save
26
- @contact.should_not be_new_record
27
- @contact.should_not be_changed
28
- @contact.reload
29
- @contact.nickname.should == "EBEI"
30
- @contact.physical_addresses.size.should == 2
31
- @contact.physical_addresses[0].key.should == "Business"
32
- @contact.physical_addresses[0].city.should == "Riga"
33
- @contact.physical_addresses[1].key.should == "Home"
34
- @contact.physical_addresses[1].city.should == "Riga"
35
- @contact.email_addresses.size.should == 1
36
- @contact.email_addresses[0].key.should == "EmailAddress1"
37
- @contact.email_addresses[0].text.should == "edgars.beigarts@tieto.com"
38
- @folder.items.size.should == prev_items_size + 1
39
- @contact.nickname = "Test"
40
- @contact.physical_addresses.pop # delete last address
41
- @contact.should be_changed
42
- @contact.save
43
- @contact.should_not be_changed
44
- @contact.physical_addresses.size.should == 1
45
- @contact.destroy.should be_true
46
- end
47
-
48
- it "should find a contact by id" do
49
- @contact = @folder.items.first
50
- pending "Folder is empty" unless @contact
51
- Exchanger::Item.find(@contact.id).should be_an_instance_of(Exchanger::Contact)
52
- end
53
-
54
- it "should have parent folder" do
55
- @contact = @folder.items.first
56
- pending "Folder is empty" unless @contact
57
- @contact.parent_folder.should == @folder
58
- @contact = Exchanger::Item.find(@contact.id)
59
- @contact.parent_folder.should == @folder
60
- end
61
-
62
- it "cannot create a contact without a parent_folder" do
63
- @contact = Exchanger::Contact.new
64
- @contact.save.should be_false
65
- @contact.errors.should include("Parent folder can't be blank")
66
- end
67
- end
@@ -1,4 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Exchanger::Element do
4
- end
@@ -1,13 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Exchanger::Folder do
4
- describe "Root" do
5
- before do
6
- @folder = Exchanger::Folder.find(:root)
7
- end
8
-
9
- it "should have sub folders" do
10
- @folder.folders.size.should > 0
11
- end
12
- end
13
- end
@@ -1,44 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Exchanger::GetUserAvailability do
4
- describe "Get user availability" do
5
- before(:all) do
6
- @valid_attributes = YAML.load_file("#{File.dirname(__FILE__)}/fixtures/get_user_availability.yml")
7
- @valid_attributes["start_time"] = Time.parse(@valid_attributes["start_time"])
8
- @valid_attributes["end_time"] = Time.parse(@valid_attributes["end_time"])
9
- end
10
-
11
- before do
12
- @response = Exchanger::GetUserAvailability.run(@valid_attributes)
13
- @items = @response.items
14
- end
15
-
16
- it "should be sucessfull with default values" do
17
- Exchanger::GetUserAvailability.run().status.should == 200
18
- end
19
-
20
- it "should be sucessfull with valid data" do
21
- @response.status.should == 200
22
- end
23
-
24
- it "should response have calendar event items" do
25
- @items.all?{ |i| i.class.name == "Exchanger::CalendarEvent" }.should be_true
26
- end
27
-
28
- it "should calendar event item have valid attributes" do
29
- ["start_time", "end_time", "busy_type", "calendar_event_details"].each do |k|
30
- @items[0].attributes.keys.include?(k).should be_true
31
- end
32
- end
33
-
34
- it "should calendar event items have calendar event details" do
35
- @items.all?{ |i| i.calendar_event_details.class.name == "Exchanger::CalendarEventDetails" }.should be_true
36
- end
37
-
38
- it "should calendar event details item have valid attributes" do
39
- ["id","subject","location", "is_meeting", "is_recurring", "is_exception", "is_reminder_set", "is_private"].each do |k|
40
- @items[0].calendar_event_details.attributes.keys.include?(k).should be_true
41
- end
42
- end
43
- end
44
- end
@@ -1,9 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Exchanger::Mailbox do
4
- it "should resolve names for distribution list and show members" do
5
- @mailboxes = Exchanger::Mailbox.search("DL")
6
- @mailboxes.size.should > 0
7
- @mailboxes[0].members.size.should > 0
8
- end
9
- end