From 757c016b67971d2dd9fa0adaa166fe751672f156 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 3 Oct 2012 21:09:01 -0500 Subject: [PATCH] * changing musicians to participants --- app/controllers/api_music_sessions_controller.rb | 10 +++++----- app/views/api_music_sessions/show.rabl | 4 ++-- config/routes.rb | 6 +++--- spec/requests/music_session_pages_spec.rb | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/api_music_sessions_controller.rb b/app/controllers/api_music_sessions_controller.rb index 10cd7e41b..90a7b9d25 100644 --- a/app/controllers/api_music_sessions_controller.rb +++ b/app/controllers/api_music_sessions_controller.rb @@ -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 \ No newline at end of file +end diff --git a/app/views/api_music_sessions/show.rabl b/app/views/api_music_sessions/show.rabl index 81f6bffe7..dd6989eca 100644 --- a/app/views/api_music_sessions/show.rabl +++ b/app/views/api_music_sessions/show.rabl @@ -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 -} \ No newline at end of file +} diff --git a/config/routes.rb b/config/routes.rb index 51e84b7dd..32ed1c8e9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/requests/music_session_pages_spec.rb b/spec/requests/music_session_pages_spec.rb index 5b55829a2..97b98a0f8 100644 --- a/spec/requests/music_session_pages_spec.rb +++ b/spec/requests/music_session_pages_spec.rb @@ -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