diff --git a/lib/onfleet-ruby/team.rb b/lib/onfleet-ruby/team.rb index 9a75350..b01ed71 100644 --- a/lib/onfleet-ruby/team.rb +++ b/lib/onfleet-ruby/team.rb @@ -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 - diff --git a/spec/onfleet/team_spec.rb b/spec/onfleet/team_spec.rb index 5a62461..e1ff396 100644 --- a/spec/onfleet/team_spec.rb +++ b/spec/onfleet/team_spec.rb @@ -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