Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created October 5, 2011 01:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save willrjmarshall/1263387 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment