public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
require 'spec_helper'
require 'ruby-debug'
 
describe BroadcastsController do
 
 
before :each do
@user = User.make!
sign_in :user, @user
end
 
describe "JSON API" do
#it "should let me create a new broadcast for the current user" do
# post :create, :broadcast => {:name => "test"}, :format => :json
# response.should be_success
#end
 
#it "should fail when the broadcast cannot be created" do
# post :create, :broadcast => {}, :format => :json
# response.status.should == 422
#end
 
describe "with an existing broadcast" do
before :each do
@broadcast = Broadcast.make!(:user => @user)
end
 
#it "should let me update a broadcast" do
# @broadcast.name = "testy"
# put :update, :id => @broadcast.id, :broadcast => @broadcast.attributes, :format => :json
# response.should be_successful
# @broadcast.reload.name.should == "testy"
#end
 
#it "should fail when the broadcast update is invalid" do
# put :update, :id => @broadcast.id, :broadcast => {}, :format => :json
# response.status.should == 422
#end
 
it "should fail when the broadcast does not belong to the user" do
broadcast = Broadcast.make!(:user => User.make!)
put :update, :id => broadcast.id, :broadcast => broadcast.attributes, :format => :json
response.status.should == 403
end
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.