* fixing tests
This commit is contained in:
parent
9c9a42c2a5
commit
ac204782b3
|
|
@ -157,18 +157,18 @@ describe ApiJamTracksController do
|
|||
|
||||
describe "keys" do
|
||||
it "empty" do
|
||||
get :keys, jamtracks: []
|
||||
get :keys, jamtracks: {tracks: []}
|
||||
response.status.should == 200
|
||||
json = JSON.parse(response.body)
|
||||
json.length == 0
|
||||
end
|
||||
|
||||
it "track with no rights" do
|
||||
get :keys, jamtracks: [@jam_track.id]
|
||||
get :keys, jamtracks: { tracks: [@jam_track.id] }
|
||||
response.status.should == 200
|
||||
json = JSON.parse(response.body)
|
||||
json.length.should == 1
|
||||
json[0]['id'].should == @jam_track.id
|
||||
json[0]['id'].should == @jam_track.id.to_s
|
||||
json[0]['private'].should be_nil
|
||||
json[0]['error'].should == 'not_purchased'
|
||||
end
|
||||
|
|
@ -177,32 +177,32 @@ describe ApiJamTracksController do
|
|||
|
||||
right = FactoryGirl.create(:jam_track_right, user: @user, private_key: nil, jam_track: @jam_track)
|
||||
|
||||
get :keys, jamtracks: [@jam_track.id]
|
||||
get :keys, jamtracks: { tracks: [@jam_track.id] }
|
||||
response.status.should == 200
|
||||
json = JSON.parse(response.body)
|
||||
json.length.should == 1
|
||||
json[0]['id'].should == @jam_track.id
|
||||
json[0]['id'].should == @jam_track.id.to_s
|
||||
json[0]['private'].should be_nil
|
||||
json[0]['error'].should == 'no_key'
|
||||
end
|
||||
|
||||
it "track with key" do
|
||||
right = FactoryGirl.create(:jam_track_right, user: @user, private_key: 'abc', jam_track: @jam_track)
|
||||
get :keys, jamtracks: [@jam_track.id]
|
||||
get :keys, jamtracks: { tracks: [@jam_track.id] }
|
||||
response.status.should == 200
|
||||
json = JSON.parse(response.body)
|
||||
json.length.should == 1
|
||||
json[0]['id'].should == @jam_track.id
|
||||
json[0]['id'].should == @jam_track.id.to_s
|
||||
json[0]['private'].should eq('abc')
|
||||
json[0]['error'].should be_nil
|
||||
end
|
||||
|
||||
it "non-owning user asking for a real track" do
|
||||
right = FactoryGirl.create(:jam_track_right, user: FactoryGirl.create(:user), private_key: 'abc', jam_track: @jam_track)
|
||||
get :keys, jamtracks: [@jam_track.id]
|
||||
get :keys, jamtracks: { tracks: [@jam_track.id] }
|
||||
response.status.should == 200
|
||||
json = JSON.parse(response.body)
|
||||
json[0]['id'].should == @jam_track.id
|
||||
json[0]['id'].should == @jam_track.id.to_s
|
||||
json[0]['private'].should be_nil
|
||||
json[0]['error'].should == 'not_purchased'
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue