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 missing CRUD operations for Team object #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion lib/onfleet-ruby/team.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
module Onfleet
class Team < OnfleetObject
include Onfleet::Actions::Create
include Onfleet::Actions::List
include Onfleet::Actions::Get
include Onfleet::Actions::Save
include Onfleet::Actions::Update
include Onfleet::Actions::Delete

def self.api_url
'teams'
end
end
end

32 changes: 31 additions & 1 deletion spec/onfleet/team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,40 @@
end
end

describe ".create" do
subject { -> { described_class.create(params) } }
it_should_behave_like Onfleet::Actions::Create, path: 'teams'
end

describe ".get" do
subject { -> { described_class.get(id) } }
let(:id) { 'a-team' }
it_should_behave_like Onfleet::Actions::Get, path: 'teams/a-team'
end
end

describe ".update" do
subject { -> { described_class.update(id, params) } }
let(:id) { 'a-team' }
it_should_behave_like Onfleet::Actions::Update, path: 'teams/a-team'
end

describe ".delete" do
subject { -> { described_class.delete(id) } }
let(:id) { 'a-team' }
it_should_behave_like Onfleet::Actions::Delete, path: 'teams/a-team'
end

describe "#save" do
subject { -> { team.save } }

context "with an ID attribute" do
before { expect(params[:id]).to be }
it_should_behave_like Onfleet::Actions::Update, path: 'teams/a-team'
end

context "without an ID attribute" do
let(:params) { { name: 'A Team' } }
it_should_behave_like Onfleet::Actions::Create, path: 'teams'
end
end
end