Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface to delete a calendar #70

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@ Ribose::Calendar.create(
)
```

#### Delete a calendar

```ruby
Ribose::Calendar.delete(calendar_id)
```

### User

#### Create a signup request
Expand Down
8 changes: 8 additions & 0 deletions lib/ribose/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ class Calendar < Ribose::Base
include Ribose::Actions::Fetch
include Ribose::Actions::Create

def delete
Ribose::Request.delete(resource_path)
end

def self.delete(calendar_id)
new(resource_id: calendar_id).delete
end

private

def resource
Expand Down
11 changes: 11 additions & 0 deletions spec/ribose/calendar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@
expect(calendar.owner_type).to eq("User")
end
end

describe ".delete" do
it "removes a valid user calendar" do
calendar_id = 123_456_789
stub_ribose_calendar_delete_api(calendar_id)

expect do
Ribose::Calendar.delete(calendar_id)
end.not_to raise_error
end
end
end
6 changes: 6 additions & 0 deletions spec/support/fake_ribose_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def stub_ribose_calendar_create_api(attributes)
)
end

def stub_ribose_calendar_delete_api(calender_id)
stub_api_response(
:delete, "calendar/calendar/#{calender_id}", filename: "empty"
)
end

def stub_ribose_app_user_create_api(attributes)
stub_api_response(
:post,
Expand Down