jam-cloud/web/spec/controllers/api_feeds_controller_spec.rb

49 lines
1.2 KiB
Ruby

require 'spec_helper'
describe ApiFeedsController do
render_views
let(:user) { FactoryGirl.create(:user) }
let(:music_session) {FactoryGirl.create(:music_session, creator: user) }
let(:claimed_recording) {FactoryGirl.create(:claimed_recording) }
before(:each) do
MusicSession.delete_all
MusicSessionHistory.delete_all
Recording.delete_all
end
it "returns nothing" do
get :index
json = JSON.parse(response.body)
json.length.should == 0
end
it "returns a recording" do
claimed_recording.touch
# artifact of factory of :claimed_recording that this gets created
MusicSessionHistory.delete_all
get :index
json = JSON.parse(response.body, {:symbolize_names => true})
json.length.should == 1
claimed_recording = json[0]
claimed_recording[:type] == 'claimed_recording'
end
it "returns a music session" do
music_session.touch
# artifact of factory of :claimed_recording that this gets created
get :index
json = JSON.parse(response.body, {:symbolize_names => true})
json.length.should == 1
music_session = json[0]
music_session[:type] == 'music_session_history'
end
end