forked from pinballmap/pbm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add machine_groups endpoint and machine_group_id param to machines en…
…dpoint
- Loading branch information
Showing
5 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Api | ||
module V1 | ||
class MachineGroupsController < InheritedResources::Base | ||
skip_before_action :verify_authenticity_token | ||
|
||
before_action :allow_cors | ||
respond_to :json | ||
|
||
api :GET, '/api/v1/machine_groups.json', 'Fetch all machine groups' | ||
description 'Machine group IDs' | ||
formats ['json'] | ||
def index | ||
return_response(MachineGroup.all, 'machine_groups', nil, nil, 200) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe Api::V1::MachineGroupsController, type: :request do | ||
describe '#index' do | ||
before(:each) do | ||
FactoryBot.create(:machine_group, id: 66, name: 'Cleo Group') | ||
FactoryBot.create(:machine_group, id: 67, name: 'Bawb Group') | ||
end | ||
|
||
it 'returns all machine groups in the database' do | ||
get '/api/v1/machine_groups.json' | ||
|
||
expect(response.body).to include('Cleo Group') | ||
expect(response.body).to include('Bawb Group') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters