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 update a user space #72

Merged
merged 1 commit into from
Oct 20, 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 @@ -136,6 +136,12 @@ Ribose::Space.create(
)
```

#### Update a user space

```ruby
Ribose::Space.update("space_uuid", name: "New updated name", **other_attributes)
```

#### Remove a user space

To remove an existing space and we can use the following interface
Expand Down
1 change: 1 addition & 0 deletions lib/ribose/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Space < Ribose::Base
include Ribose::Actions::All
include Ribose::Actions::Fetch
include Ribose::Actions::Create
include Ribose::Actions::Update

def self.create(name:, **attributes)
new(attributes.merge(name: name)).create
Expand Down
12 changes: 12 additions & 0 deletions spec/ribose/space_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
end
end

describe ".update" do
it "updates a space with provided details" do
space_id = 123_456_789

stub_ribose_space_update_api(space_id, space_attributes)
space = Ribose::Space.update(space_id, space_attributes)

expect(space.id).not_to be_nil
expect(space.visibility).to eq("invisible")
end
end

describe ".remove" do
it "removes an existing space" do
space_uuid = "8c63c209-8b98-41aa-a320-336462476ea1"
Expand Down
6 changes: 6 additions & 0 deletions spec/support/fake_ribose_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def stub_ribose_space_create_api(attributes)
)
end

def stub_ribose_space_update_api(uuid, attributes)
stub_api_response(
:put, "spaces/#{uuid}", data: { space: attributes }, filename: "space"
)
end

def stub_ribose_space_fetch_api(space_id)
stub_api_response(:get, "spaces/#{space_id}", filename: "space")
end
Expand Down