* changing musicians to participants
This commit is contained in:
parent
5599aa9405
commit
757c016b67
|
|
@ -28,11 +28,11 @@ class ApiMusicSessionsController < ApplicationController
|
|||
respond_with @music_session, responder: ApiResponder
|
||||
end
|
||||
|
||||
def client_show
|
||||
def participant_show
|
||||
@music_session_client = MusicSessionClient.find(params[:id])
|
||||
end
|
||||
|
||||
def client_create
|
||||
def participant_create
|
||||
@music_session = MusicSession.find(params[:id])
|
||||
|
||||
@music_session_client = MusicSessionClient.new()
|
||||
|
|
@ -41,13 +41,13 @@ class ApiMusicSessionsController < ApplicationController
|
|||
@music_session_client.user = current_user
|
||||
@music_session_client.save
|
||||
|
||||
respond_with @music_session_client, responder: ApiResponder, :location => api_session_client_detail_url(@music_session_client)
|
||||
respond_with @music_session_client, responder: ApiResponder, :location => api_session_participant_detail_url(@music_session_client)
|
||||
end
|
||||
|
||||
def client_delete
|
||||
def participant_delete
|
||||
@music_session_client = MusicSessionClient.find(params[:id])
|
||||
@music_session_client.delete
|
||||
|
||||
respond_with @music_session_client, responder: ApiResponder
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ object @music_session
|
|||
|
||||
attributes :id, :description
|
||||
|
||||
child(:music_session_clients => :musicians) {
|
||||
child(:music_session_clients => :participants) {
|
||||
collection @music_sessions, :object_root => false
|
||||
attributes :id, :ip_address
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ SampleApp::Application.routes.draw do
|
|||
match '/client', to: 'clients#index'
|
||||
|
||||
scope '/api' do
|
||||
match '/sessions/:id/musicians' => 'api_music_sessions#client_create', :via => :post
|
||||
match '/musicians/:id' => 'api_music_sessions#client_show', :via => :get, :as => 'api_session_client_detail'
|
||||
match '/musicians/:id' => 'api_music_sessions#client_delete', :via => :delete
|
||||
match '/sessions/:id/participants' => 'api_music_sessions#participant_create', :via => :post
|
||||
match '/participants/:id' => 'api_music_sessions#participant_show', :via => :get, :as => 'api_session_participant_detail'
|
||||
match '/participants/:id' => 'api_music_sessions#participant_delete', :via => :delete
|
||||
match '/sessions/:id' => 'api_music_sessions#show', :via => :get, :as => 'api_session_detail'
|
||||
match '/sessions/:id' => 'api_music_sessions#delete', :via => :delete
|
||||
match '/sessions' => 'api_music_sessions#index', :via => :get
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ describe "Music Session API ", :type => :api do
|
|||
# now fetch it's data
|
||||
get last_response.headers["Location"]
|
||||
music_session = JSON.parse(last_response.body)
|
||||
music_session["musicians"].length.should == 0
|
||||
music_session["participants"].length.should == 0
|
||||
|
||||
# create a member
|
||||
post "/api/sessions/#{music_session["id"]}/musicians.json", '{ "ip_address" : "1.2.3.4" }', "CONTENT_TYPE" => 'application/json'
|
||||
post "/api/sessions/#{music_session["id"]}/participants.json", '{ "ip_address" : "1.2.3.4" }', "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(201)
|
||||
|
||||
musician = JSON.parse(last_response.body)
|
||||
|
|
@ -83,14 +83,14 @@ describe "Music Session API ", :type => :api do
|
|||
music_session = JSON.parse(last_response.body)
|
||||
|
||||
# there should be one musician in the response
|
||||
music_session["musicians"].length.should == 1
|
||||
musician = music_session["musicians"][0]
|
||||
music_session["participants"].length.should == 1
|
||||
musician = music_session["participants"][0]
|
||||
|
||||
# and that musician should have the same IP address
|
||||
musician["ip_address"].should == "1.2.3.4"
|
||||
|
||||
# now delete that musician
|
||||
delete "/api/musicians/#{musician["id"]}.json", '', "CONTENT_TYPE" => 'application/json'
|
||||
delete "/api/participants/#{musician["id"]}.json", '', "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(204)
|
||||
|
||||
# re-fetch the session now that there is not a musician
|
||||
|
|
@ -98,7 +98,7 @@ describe "Music Session API ", :type => :api do
|
|||
music_session = JSON.parse(last_response.body)
|
||||
|
||||
# there should be no musicians in the response
|
||||
music_session["musicians"].length.should == 0
|
||||
music_session["participants"].length.should == 0
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue