* VRFS-254; tracks aren't doubled up on join

This commit is contained in:
Seth Call 2013-02-16 08:56:40 -06:00
parent 57e6951c83
commit 23f56c1347
2 changed files with 42 additions and 0 deletions

View File

@ -49,6 +49,7 @@ FactoryGirl.define do
factory :connection, :class => JamRuby::Connection do
sequence(:client_id) { |n| "Client#{n}" }
ip_address "1.1.1.1"
as_musician true
end

View File

@ -499,6 +499,47 @@ describe "Music Session API ", :type => :api do
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono"}]}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
end
it "should allow create session and join session for creator" do
# this test was created to stop duplication of tracks
# but ultimately it should be fine to create a session, and then 'join' it with no ill effects
# https://jamkazam.atlassian.net/browse/VRFS-254
client = FactoryGirl.create(:connection, :user => user)
post '/api/sessions.json', defopts.merge({:client_id => client.client_id}).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)
get "/api/sessions/#{music_session["id"]}.json"
last_response.status.should eql(200)
music_session["participants"].length.should == 1
participant = music_session["participants"][0]
participant["client_id"].should == client.client_id
participant["tracks"].length.should == 1
track = participant["tracks"][0]
track["instrument_id"].should == "electric guitar"
track["sound"].should == "mono"
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono"}]}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
get "/api/sessions/#{music_session["id"]}.json"
music_session = JSON.parse(last_response.body)
music_session["participants"].length.should == 1
participant = music_session["participants"][0]
participant["client_id"].should == client.client_id
participant["tracks"].length.should == 1 # there should only be one track, still
track = participant["tracks"][0]
track["instrument_id"].should == "electric guitar"
track["sound"].should == "mono"
end
end
it "Finds a single open session" do