comment old recording code
This commit is contained in:
parent
69fd8f7cfa
commit
800f4d7de0
|
|
@ -327,56 +327,56 @@ class ApiUsersController < ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
###################### RECORDINGS #######################
|
###################### RECORDINGS #######################
|
||||||
def recording_index
|
# def recording_index
|
||||||
@recordings = User.recording_index(current_user, params[:id])
|
# @recordings = User.recording_index(current_user, params[:id])
|
||||||
respond_with @recordings, responder: ApiResponder, :status => 200
|
# respond_with @recordings, responder: ApiResponder, :status => 200
|
||||||
end
|
# end
|
||||||
|
|
||||||
def recording_show
|
# def recording_show
|
||||||
hide_private = false
|
# hide_private = false
|
||||||
|
|
||||||
# hide private recordings from anyone but the current user
|
# # hide private recordings from anyone but the current user
|
||||||
if current_user.id != params[:id]
|
# if current_user.id != params[:id]
|
||||||
hide_private = true
|
# hide_private = true
|
||||||
end
|
# end
|
||||||
|
|
||||||
@recording = Recording.find(params[:recording_id])
|
# @recording = Recording.find(params[:recording_id])
|
||||||
if !@recording.public && hide_private
|
# if !@recording.public && hide_private
|
||||||
render :json => { :message => "You are not allowed to access this recording." }, :status => 403
|
# render :json => { :message => "You are not allowed to access this recording." }, :status => 403
|
||||||
#respond_with "You are not allowed to access this recording.", responder: ApiResponder, :status => 403
|
# #respond_with "You are not allowed to access this recording.", responder: ApiResponder, :status => 403
|
||||||
else
|
# else
|
||||||
respond_with @recording, responder: ApiResponder, :status => 200
|
# respond_with @recording, responder: ApiResponder, :status => 200
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
def recording_create
|
# def recording_create
|
||||||
@recording = Recording.save(params[:recording_id],
|
# @recording = Recording.save(params[:recording_id],
|
||||||
params[:public],
|
# params[:public],
|
||||||
params[:description],
|
# params[:description],
|
||||||
params[:genres],
|
# params[:genres],
|
||||||
current_user.id,
|
# current_user.id,
|
||||||
params[:id],
|
# params[:id],
|
||||||
false)
|
# false)
|
||||||
|
|
||||||
@user = current_user
|
# @user = current_user
|
||||||
respond_with @recording, responder: ApiResponder, :status => 201, :location => api_recording_detail_url(@user, @recording)
|
# respond_with @recording, responder: ApiResponder, :status => 201, :location => api_recording_detail_url(@user, @recording)
|
||||||
end
|
# end
|
||||||
|
|
||||||
def recording_update
|
# def recording_update
|
||||||
@recording = Recording.save(params[:recording_id],
|
# @recording = Recording.save(params[:recording_id],
|
||||||
params[:public],
|
# params[:public],
|
||||||
params[:description],
|
# params[:description],
|
||||||
params[:genres],
|
# params[:genres],
|
||||||
current_user.id,
|
# current_user.id,
|
||||||
params[:id],
|
# params[:id],
|
||||||
false)
|
# false)
|
||||||
|
|
||||||
respond_with @recording, responder: ApiResponder, :status => 200
|
# respond_with @recording, responder: ApiResponder, :status => 200
|
||||||
end
|
# end
|
||||||
|
|
||||||
def recording_destroy
|
# def recording_destroy
|
||||||
@recording = Recording.find(params[:recording_id])
|
# @recording = Recording.find(params[:recording_id])
|
||||||
@recording.delete
|
# @recording.delete
|
||||||
respond_with responder: ApiResponder, :status => 204
|
# respond_with responder: ApiResponder, :status => 204
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -122,11 +122,11 @@ SampleApp::Application.routes.draw do
|
||||||
match '/users/:id/band_invitations/:invitation_id' => 'api_users#band_invitation_update', :via => :post
|
match '/users/:id/band_invitations/:invitation_id' => 'api_users#band_invitation_update', :via => :post
|
||||||
|
|
||||||
# user recordings
|
# user recordings
|
||||||
match '/users/:id/recordings' => 'api_users#recording_index', :via => :get
|
# match '/users/:id/recordings' => 'api_users#recording_index', :via => :get
|
||||||
match '/users/:id/recordings/:recording_id' => 'api_users#recording_show', :via => :get, :as => 'api_recording_detail'
|
# match '/users/:id/recordings/:recording_id' => 'api_users#recording_show', :via => :get, :as => 'api_recording_detail'
|
||||||
match '/users/:id/recordings' => 'api_users#recording_create', :via => :post
|
# match '/users/:id/recordings' => 'api_users#recording_create', :via => :post
|
||||||
match '/users/:id/recordings/:recording_id' => 'api_users#recording_update', :via => :post
|
# match '/users/:id/recordings/:recording_id' => 'api_users#recording_update', :via => :post
|
||||||
match '/users/:id/recordings/:recording_id' => 'api_users#recording_destroy', :via => :delete
|
# match '/users/:id/recordings/:recording_id' => 'api_users#recording_destroy', :via => :delete
|
||||||
|
|
||||||
# bands
|
# bands
|
||||||
match '/bands' => 'api_bands#index', :via => :get
|
match '/bands' => 'api_bands#index', :via => :get
|
||||||
|
|
|
||||||
|
|
@ -465,177 +465,177 @@ describe "User API", :type => :api do
|
||||||
end
|
end
|
||||||
|
|
||||||
######################### RECORDINGS ########################
|
######################### RECORDINGS ########################
|
||||||
it "should allow musician to create recordings" do
|
# it "should allow musician to create recordings" do
|
||||||
# create public recording
|
# # create public recording
|
||||||
public_description = "My Public Recording"
|
# public_description = "My Public Recording"
|
||||||
last_response = create_user_recording(user, user, public_description, true, ["african"])
|
# last_response = create_user_recording(user, user, public_description, true, ["african"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
recording["description"].should == public_description
|
# recording["description"].should == public_description
|
||||||
recording["public"].should == true
|
# recording["public"].should == true
|
||||||
|
|
||||||
# create private recording
|
# # create private recording
|
||||||
private_description = "My Private Recording"
|
# private_description = "My Private Recording"
|
||||||
last_response = create_user_recording(user, user, private_description, false, ["rock"])
|
# last_response = create_user_recording(user, user, private_description, false, ["rock"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
|
|
||||||
private_recording = JSON.parse(last_response.body)
|
# private_recording = JSON.parse(last_response.body)
|
||||||
private_recording["description"].should == private_description
|
# private_recording["description"].should == private_description
|
||||||
private_recording["public"].should == false
|
# private_recording["public"].should == false
|
||||||
private_recording["genres"].size.should == 1
|
# private_recording["genres"].size.should == 1
|
||||||
private_recording["genres"][0]["id"].should == "rock"
|
# private_recording["genres"][0]["id"].should == "rock"
|
||||||
|
|
||||||
# update the second recording's description, public flag, and genre
|
# # update the second recording's description, public flag, and genre
|
||||||
last_response = update_user_recording(user, user, private_recording["id"], "My Recording 3", true, ["country"])
|
# last_response = update_user_recording(user, user, private_recording["id"], "My Recording 3", true, ["country"])
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
recording["description"].should == "My Recording 3"
|
# recording["description"].should == "My Recording 3"
|
||||||
recording["public"].should == true
|
# recording["public"].should == true
|
||||||
|
|
||||||
# retrieve the recording details again to ensure the change took effect
|
# # retrieve the recording details again to ensure the change took effect
|
||||||
last_response = get_user_recording(user, user, recording["id"])
|
# last_response = get_user_recording(user, user, recording["id"])
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
recording["description"].should == "My Recording 3"
|
# recording["description"].should == "My Recording 3"
|
||||||
recording["public"].should == true
|
# recording["public"].should == true
|
||||||
recording["genres"].size.should == 1
|
# recording["genres"].size.should == 1
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should not allow fan to create recordings" do
|
# it "should not allow fan to create recordings" do
|
||||||
last_response = create_user_recording(fan, fan, "Fan Recording", true, ["african"])
|
# last_response = create_user_recording(fan, fan, "Fan Recording", true, ["african"])
|
||||||
last_response.status.should == 403
|
# last_response.status.should == 403
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should allow creator to see public and private recordings in list" do
|
# it "should allow creator to see public and private recordings in list" do
|
||||||
# create public recording
|
# # create public recording
|
||||||
public_description = "My Public Recording"
|
# public_description = "My Public Recording"
|
||||||
last_response = create_user_recording(user, user, public_description, true, ["african"])
|
# last_response = create_user_recording(user, user, public_description, true, ["african"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
|
|
||||||
# create private recording
|
# # create private recording
|
||||||
private_description = "My Private Recording"
|
# private_description = "My Private Recording"
|
||||||
last_response = create_user_recording(user, user, private_description, false, ["african"])
|
# last_response = create_user_recording(user, user, private_description, false, ["african"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
|
|
||||||
# get all recordings as creator
|
# # get all recordings as creator
|
||||||
last_response = get_user_recordings(user, user)
|
# last_response = get_user_recordings(user, user)
|
||||||
recordings = JSON.parse(last_response.body)
|
# recordings = JSON.parse(last_response.body)
|
||||||
recordings.size.should == 2
|
# recordings.size.should == 2
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should allow creator to see private recording details" do
|
# it "should allow creator to see private recording details" do
|
||||||
# create private recording
|
# # create private recording
|
||||||
private_description = "My Private Recording"
|
# private_description = "My Private Recording"
|
||||||
last_response = create_user_recording(user, user, private_description, false, ["african"])
|
# last_response = create_user_recording(user, user, private_description, false, ["african"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
private_recording = JSON.parse(last_response.body)
|
# private_recording = JSON.parse(last_response.body)
|
||||||
private_recording["description"].should == private_description
|
# private_recording["description"].should == private_description
|
||||||
private_recording["public"].should == false
|
# private_recording["public"].should == false
|
||||||
|
|
||||||
# attempt to get the private recording as non-creator
|
# # attempt to get the private recording as non-creator
|
||||||
last_response = get_user_recording(user, user, private_recording["id"])
|
# last_response = get_user_recording(user, user, private_recording["id"])
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should not allow non-creator to see private recordings in list" do
|
# it "should not allow non-creator to see private recordings in list" do
|
||||||
# create public recording
|
# # create public recording
|
||||||
public_description = "My Public Recording"
|
# public_description = "My Public Recording"
|
||||||
last_response = create_user_recording(user, user, public_description, true, ["country"])
|
# last_response = create_user_recording(user, user, public_description, true, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
|
|
||||||
# create private recording
|
# # create private recording
|
||||||
private_description = "My Private Recording"
|
# private_description = "My Private Recording"
|
||||||
last_response = create_user_recording(user, user, private_description, false, ["country"])
|
# last_response = create_user_recording(user, user, private_description, false, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
|
|
||||||
# get all recordings as non-creator
|
# # get all recordings as non-creator
|
||||||
last_response = get_user_recordings(fan, user)
|
# last_response = get_user_recordings(fan, user)
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
|
|
||||||
recordings = JSON.parse(last_response.body)
|
# recordings = JSON.parse(last_response.body)
|
||||||
recordings.size.should == 1
|
# recordings.size.should == 1
|
||||||
recordings[0]["description"].should == public_description
|
# recordings[0]["description"].should == public_description
|
||||||
recordings[0]["public"].should == true
|
# recordings[0]["public"].should == true
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should not allow non-creator to see private recording details" do
|
# it "should not allow non-creator to see private recording details" do
|
||||||
# create private recording
|
# # create private recording
|
||||||
private_description = "My Private Recording"
|
# private_description = "My Private Recording"
|
||||||
last_response = create_user_recording(user, user, private_description, false, ["country"])
|
# last_response = create_user_recording(user, user, private_description, false, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
private_recording = JSON.parse(last_response.body)
|
# private_recording = JSON.parse(last_response.body)
|
||||||
private_recording["description"].should == private_description
|
# private_recording["description"].should == private_description
|
||||||
private_recording["public"].should == false
|
# private_recording["public"].should == false
|
||||||
|
|
||||||
# attempt to get the private recording as non-creator
|
# # attempt to get the private recording as non-creator
|
||||||
last_response = get_user_recording(fan, user, private_recording["id"])
|
# last_response = get_user_recording(fan, user, private_recording["id"])
|
||||||
last_response.status.should == 403
|
# last_response.status.should == 403
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should allow user to create favorites" do
|
# it "should allow user to create favorites" do
|
||||||
# create recording first
|
# # create recording first
|
||||||
last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
# last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
|
|
||||||
# add favorite
|
# # add favorite
|
||||||
last_response = create_favorite(fan, fan, recording["id"])
|
# last_response = create_favorite(fan, fan, recording["id"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
|
|
||||||
# get favorites
|
# # get favorites
|
||||||
last_response = get_favorites(fan, fan)
|
# last_response = get_favorites(fan, fan)
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
favorites = JSON.parse(last_response.body)
|
# favorites = JSON.parse(last_response.body)
|
||||||
favorites.size.should == 1
|
# favorites.size.should == 1
|
||||||
favorites[0]["recording_id"].should == recording["id"]
|
# favorites[0]["recording_id"].should == recording["id"]
|
||||||
favorites[0]["description"].should == "My Recording"
|
# favorites[0]["description"].should == "My Recording"
|
||||||
favorites[0]["public"].should == true
|
# favorites[0]["public"].should == true
|
||||||
|
|
||||||
# get recording
|
# # get recording
|
||||||
last_response = get_user_recording(user, user, recording["id"])
|
# last_response = get_user_recording(user, user, recording["id"])
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
recording_with_favorite = JSON.parse(last_response.body)
|
# recording_with_favorite = JSON.parse(last_response.body)
|
||||||
recording_with_favorite["favorite_count"].should == 1
|
# recording_with_favorite["favorite_count"].should == 1
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should not allow user to create favorite for another user" do
|
# it "should not allow user to create favorite for another user" do
|
||||||
# create recording first
|
# # create recording first
|
||||||
last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
# last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
|
|
||||||
# attempt to add favorite for another user
|
# # attempt to add favorite for another user
|
||||||
last_response = create_favorite(fan, user, recording["id"])
|
# last_response = create_favorite(fan, user, recording["id"])
|
||||||
last_response.status.should == 403
|
# last_response.status.should == 403
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should allow user to delete favorites" do
|
# it "should allow user to delete favorites" do
|
||||||
# create recording first
|
# # create recording first
|
||||||
last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
# last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
|
|
||||||
# delete favorite
|
# # delete favorite
|
||||||
last_response = delete_favorite(user, user, recording["id"])
|
# last_response = delete_favorite(user, user, recording["id"])
|
||||||
last_response.status.should == 204
|
# last_response.status.should == 204
|
||||||
|
|
||||||
# get favorites
|
# # get favorites
|
||||||
last_response = get_favorites(user, user)
|
# last_response = get_favorites(user, user)
|
||||||
last_response.status.should == 200
|
# last_response.status.should == 200
|
||||||
favorites = JSON.parse(last_response.body)
|
# favorites = JSON.parse(last_response.body)
|
||||||
favorites.size.should == 0
|
# favorites.size.should == 0
|
||||||
end
|
# end
|
||||||
|
|
||||||
it "should not allow user to delete another user's favorites" do
|
# it "should not allow user to delete another user's favorites" do
|
||||||
# create recording first
|
# # create recording first
|
||||||
last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
# last_response = create_user_recording(user, user, "My Recording", true, ["country"])
|
||||||
last_response.status.should == 201
|
# last_response.status.should == 201
|
||||||
recording = JSON.parse(last_response.body)
|
# recording = JSON.parse(last_response.body)
|
||||||
|
|
||||||
# attempt to delete favorite as non-creator
|
# # attempt to delete favorite as non-creator
|
||||||
last_response = delete_favorite(fan, user, recording["id"])
|
# last_response = delete_favorite(fan, user, recording["id"])
|
||||||
last_response.status.should == 403
|
# last_response.status.should == 403
|
||||||
end
|
# end
|
||||||
|
|
||||||
######################### FRIENDS ########################
|
######################### FRIENDS ########################
|
||||||
it "should allow user to send friend request" do
|
it "should allow user to send friend request" do
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue