|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe "Music Session API ", :type => :api do
|
|
|
|
|
describe "Active Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
include Rack::Test::Methods
|
|
|
|
|
|
|
|
|
|
@ -23,7 +23,15 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
let(:user) { FactoryGirl.create(:user) }
|
|
|
|
|
|
|
|
|
|
# defopts are used to setup default options for the session
|
|
|
|
|
let(:defopts) { { :description => "a session", :fan_chat => true, :fan_access => true, :approval_required => false, :genres => ["classical"], :musician_access => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}], :legal_terms => true, :intellectual_property => true} }
|
|
|
|
|
let(:defopts) { { :name => "session name", :description => "session description",
|
|
|
|
|
:genres => ["classical"], :musician_access => true, :approval_required => false,
|
|
|
|
|
:fan_chat => true, :fan_access => true,
|
|
|
|
|
:legal_policy => true, :language => 'english',
|
|
|
|
|
:timezone => "utc"} }
|
|
|
|
|
let(:defpart) { { :as_musician => true,
|
|
|
|
|
:tracks => [{"instrument_id" => "electric guitar",
|
|
|
|
|
"sound" => "mono",
|
|
|
|
|
"client_track_id" => "client_track_guid"}] } }
|
|
|
|
|
before do
|
|
|
|
|
#sign_in user
|
|
|
|
|
ActiveMusicSession.delete_all
|
|
|
|
|
@ -38,13 +46,12 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
it "should create session" do
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1", :client_id => "1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
location_header = last_response.headers["Location"]
|
|
|
|
|
get location_header
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants", defpart.merge({ :client_id => client.client_id, }).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
get '/api/sessions.json'
|
|
|
|
|
music_sessions = JSON.parse(last_response.body)
|
|
|
|
|
@ -184,14 +191,16 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
it "should add/remove member from session" do
|
|
|
|
|
# create the session
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
location_header = last_response.headers["Location"]
|
|
|
|
|
get location_header + ".json", "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants", defpart.merge({ :client_id => client.client_id, }).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
get "/api/sessions.json", "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)[0]
|
|
|
|
|
|
|
|
|
|
# and the creator should be in the session
|
|
|
|
|
music_session["participants"].length.should == 1
|
|
|
|
|
@ -219,14 +228,16 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
user2 = FactoryGirl.create(:user)
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
client2 = FactoryGirl.create(:connection, :user => user2, :ip_address => "2.2.2.2")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
music_session_uri = last_response.headers["Location"]
|
|
|
|
|
get music_session_uri + ".json", "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants", defpart.merge({ :client_id => client.client_id, }).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
get "/api/sessions.json", "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)[0]
|
|
|
|
|
|
|
|
|
|
# and the creator should be in the session
|
|
|
|
|
music_session["participants"].length.should == 1
|
|
|
|
|
@ -239,8 +250,7 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
musician["client_id"].should == client.client_id
|
|
|
|
|
|
|
|
|
|
login(user2)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants/legacy.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
@ -260,9 +270,9 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
# refetch the session and make sure both participnats are accounted for
|
|
|
|
|
login(user2)
|
|
|
|
|
get music_session_uri + ".json", "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
get "/api/sessions.json", "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
music_session = JSON.parse(last_response.body)[0]
|
|
|
|
|
# and the creator should be in the session
|
|
|
|
|
music_session["participants"].length.should == 2
|
|
|
|
|
|
|
|
|
|
@ -284,14 +294,14 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
# create the session
|
|
|
|
|
original_count = ActiveMusicSession.all().length
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :genres => nil}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.merge({:genres => nil}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
ActiveMusicSession.all().length.should == original_count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "should error with invalid genre specified" do
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({ :client_id => client.client_id, :genres => ["Junk"]}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.merge({:genres => ["Junk"]}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
JSON.parse(last_response.body)["errors"]["genre"].should == ["can't be blank"]
|
|
|
|
|
end
|
|
|
|
|
@ -300,8 +310,12 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
original_count = ActiveMusicSession.all().length
|
|
|
|
|
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :tracks => nil}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client.client_id, :as_musician => true, :tracks => []}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
JSON.parse(last_response.body)["errors"]["tracks"].should == [ValidationMessages::SELECT_AT_LEAST_ONE]
|
|
|
|
|
|
|
|
|
|
# check that the transaction was rolled back
|
|
|
|
|
@ -312,7 +326,12 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
original_count = ActiveMusicSession.all().length
|
|
|
|
|
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :tracks => [{"instrument_id" => "mom", "sound" => "mono", "client_track_id" => "client_track_guid"}]}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants", defpart.merge({ :client_id => client.client_id, :tracks => [{"instrument_id" => "mom", "sound" => "mono", "client_track_id" => "client_track_guid"}] }).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(404)
|
|
|
|
|
|
|
|
|
|
# check that the transaction was rolled back
|
|
|
|
|
@ -323,10 +342,13 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
original_count = ActiveMusicSession.all().length
|
|
|
|
|
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mom", "client_track_id" => "client_track_guid"}]}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
JSON.parse(last_response.body)["errors"]["tracks"][0].should == "is invalid"
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants", defpart.merge({ :client_id => client.client_id, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mom", "client_track_id" => "client_track_guid"}] }).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(406)
|
|
|
|
|
|
|
|
|
|
# check that the transaction was rolled back
|
|
|
|
|
ActiveMusicSession.all().length.should == original_count
|
|
|
|
|
@ -367,9 +389,18 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
user2 = FactoryGirl.create(:user) # in the music session
|
|
|
|
|
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :musician_access => false}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
session = JSON.parse(last_response.body)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
get '/api/sessions.json'
|
|
|
|
|
last_response.status.should eql(200)
|
|
|
|
|
music_sessions = JSON.parse(last_response.body)
|
|
|
|
|
session = music_sessions[0]
|
|
|
|
|
|
|
|
|
|
FactoryGirl.create(:friendship, :user => user, :friend => user2)
|
|
|
|
|
FactoryGirl.create(:friendship, :user => user2, :friend => user)
|
|
|
|
|
@ -381,7 +412,7 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
music_sessions = JSON.parse(last_response.body)
|
|
|
|
|
music_session = music_sessions[0]
|
|
|
|
|
music_session["id"].should == session["id"]
|
|
|
|
|
music_session["musician_access"].should == false
|
|
|
|
|
music_session["musician_access"].should == true
|
|
|
|
|
|
|
|
|
|
# we should be able to see the invitation
|
|
|
|
|
music_session["invitations"].length.should == 1
|
|
|
|
|
@ -401,7 +432,13 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
user2 = FactoryGirl.create(:user) # in the music session
|
|
|
|
|
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1", :client_id => "3")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :musician_access => false}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
login(user)
|
|
|
|
|
post '/api/sessions.json', defopts.merge({:musician_access => false}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
session = JSON.parse(last_response.body)
|
|
|
|
|
|
|
|
|
|
@ -411,31 +448,32 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
FactoryGirl.create(:friendship, :user => user2, :friend => user)
|
|
|
|
|
|
|
|
|
|
# users are friends, but no invitation... so we shouldn't be able to join as user 2
|
|
|
|
|
|
|
|
|
|
login(user2)
|
|
|
|
|
post "/api/sessions/#{session["id"]}/participants/legacy.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}] }.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post "/api/sessions/#{session["music_session_id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
join_response = JSON.parse(last_response.body)
|
|
|
|
|
join_response["errors"]["musician_access"].should == [ValidationMessages::INVITE_REQUIRED]
|
|
|
|
|
|
|
|
|
|
# but let's make sure if we then invite, that we can then join'
|
|
|
|
|
login(user)
|
|
|
|
|
post '/api/invitations.json', { :music_session => session["id"], :receiver => user2.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/invitations.json', { :music_session => session["music_session_id"], :receiver => user2.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
login(user2)
|
|
|
|
|
post "/api/sessions/#{session["id"]}/participants/legacy.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}] }.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post "/api/sessions/#{session["music_session_id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}] }.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "join_requests don't show up in session listing" do
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
location_header = last_response.headers["Location"]
|
|
|
|
|
get location_header
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
get '/api/sessions.json'
|
|
|
|
|
music_sessions = JSON.parse(last_response.body)
|
|
|
|
|
@ -480,20 +518,22 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
it "should now allow join of approval_required=true session" do
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :approval_required => true}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.merge({:approval_required => true}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
location_header = last_response.headers["Location"]
|
|
|
|
|
get location_header
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
get "/api/sessions.json"
|
|
|
|
|
music_session = JSON.parse(last_response.body)[0]
|
|
|
|
|
|
|
|
|
|
# try to add 2nd user to session - should fail because approval is required
|
|
|
|
|
user2 = FactoryGirl.create(:user)
|
|
|
|
|
client2 = FactoryGirl.create(:connection, :user => user2, :ip_address => "2.2.2.2")
|
|
|
|
|
|
|
|
|
|
login(user2)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants/legacy.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
rejected_join_attempt = JSON.parse(last_response.body)
|
|
|
|
|
rejected_join_attempt["errors"]["approval_required"] = [ValidationMessages::INVITE_REQUIRED]
|
|
|
|
|
@ -515,7 +555,7 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
# finally, go back to user2 and attempt to join again
|
|
|
|
|
login(user2)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants/legacy.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -527,13 +567,15 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
# https://jamkazam.atlassian.net/browse/VRFS-254
|
|
|
|
|
user.admin = true
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user)
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
# now fetch it's data
|
|
|
|
|
location_header = last_response.headers["Location"]
|
|
|
|
|
get location_header
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
get "/api/sessions.json"
|
|
|
|
|
music_session = JSON.parse(last_response.body)[0]
|
|
|
|
|
|
|
|
|
|
get "/api/sessions/#{music_session["id"]}.json"
|
|
|
|
|
last_response.status.should eql(200)
|
|
|
|
|
@ -545,7 +587,7 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
track["instrument_id"].should == "electric guitar"
|
|
|
|
|
track["sound"].should == "mono"
|
|
|
|
|
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants/legacy.json", { :client_id => client.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
@ -571,10 +613,14 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
# 1st user joins
|
|
|
|
|
login(user)
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
location_header = last_response.headers["Location"]
|
|
|
|
|
get location_header
|
|
|
|
|
post '/api/sessions.json', defopts.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
get "/api/sessions.json"
|
|
|
|
|
music_session = JSON.parse(last_response.body)[0]
|
|
|
|
|
|
|
|
|
|
# start a recording
|
|
|
|
|
post "/api/recordings/start", {:format => :json, :music_session_id => music_session['id'] }.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
@ -582,7 +628,7 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
|
|
|
|
|
# user 2 should not be able to join
|
|
|
|
|
login(user2)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants/legacy.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(422)
|
|
|
|
|
JSON.parse(last_response.body)["errors"]["music_session"][0].should == ValidationMessages::CANT_JOIN_RECORDING_SESSION
|
|
|
|
|
end
|
|
|
|
|
@ -592,9 +638,16 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
server = FactoryGirl.create(:icecast_server_minimal)
|
|
|
|
|
user2 = FactoryGirl.create(:user) # in the music session
|
|
|
|
|
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.10", :client_id => "mount_info")
|
|
|
|
|
post '/api/sessions/legacy.json', defopts.merge({:client_id => client.client_id, :fan_access => true}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
post '/api/sessions.json', defopts.merge({:fan_access => true}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
session = JSON.parse(last_response.body)
|
|
|
|
|
|
|
|
|
|
music_session = JSON.parse(last_response.body)
|
|
|
|
|
post "/api/sessions/#{music_session["id"]}/participants.json", defpart.merge({ :client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
|
|
|
|
last_response.status.should eql(201)
|
|
|
|
|
|
|
|
|
|
get "/api/sessions.json"
|
|
|
|
|
session = JSON.parse(last_response.body)[0]
|
|
|
|
|
|
|
|
|
|
music_session = ActiveMusicSession.find(session["id"])
|
|
|
|
|
session["mount"].should_not be_nil
|
|
|
|
|
session["mount"]["name"].should == music_session.mount.name
|
|
|
|
|
@ -723,8 +776,4 @@ describe "Music Session API ", :type => :api do
|
|
|
|
|
music_session.claimed_recording.should be_nil
|
|
|
|
|
music_session.claimed_recording_initiator.should be_nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|