* VRFS-98 one test to verify you can't create duplicatie join_requests

This commit is contained in:
Seth Call 2012-11-30 10:39:35 -06:00
parent 3e36df4160
commit 397281eab6
3 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,7 @@
object @join_request
attributes :id, :text
attributes :music_session_id => :music_session
child(:user => :user) {
attributes :id, :name

View File

@ -78,4 +78,17 @@ describe "Join Request API", :type => :api do
get "/api/join_requests/#{join_request["id"]}.json", "CONTENT_TYPE" => 'application/json'
last_response.status.should == 404
end
it "can't create duplicate join_request" do
login(other)
post '/api/join_requests.json', { :music_session => user.music_sessions[0].id, :text => "lemme in" }.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should == 201
join_request = JSON.parse(last_response.body)
post '/api/join_requests.json', { :music_session => user.music_sessions[0].id, :text => "lemme in" }.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should == 422
join_request = JSON.parse(last_response.body)
join_request["errors"]["user_id"].should == ["has already been taken"]
end
end

View File

@ -405,7 +405,7 @@ describe "Music Session API ", :type => :api do
get last_response.headers["Location"] + ".json", "CONTENT_TYPE" => 'application/json'
join_request = JSON.parse(last_response.body)
# pop back to user1 and allow user2 to get in
login(user)
post '/api/invitations.json', {:music_session => music_session["id"], :receiver => user2.id, :join_request => join_request["id"]}.to_json, "CONTENT_TYPE" => 'application/json'