Skip to content

Instantly share code, notes, and snippets.

@santiago
Created December 7, 2010 03:38
Show Gist options
  • Save santiago/731415 to your computer and use it in GitHub Desktop.
Save santiago/731415 to your computer and use it in GitHub Desktop.
def update
wylayps= JSON.parse(params[:wylayps])
wylayps.each do |w|
Wylayp.update(w.delete :id, w)
end
respond_to do |format|
format.json { render :json => [] }
end
end
require File.join('spec', 'spec_helper')
describe WylaypController do
describe "#update" do
it_should_require_a_logged_in_user do
wylayps= mock("wylayps")
wylayps.stub(:each)
JSON.stub(:parse).and_return(wylayps)
put :update
end
describe "when logged in" do
before(:each) do
fake_login()
wylayp= mock("wylayp").as_null_object
JSON.stub(:parse).and_return([wylayp,wylayp])
end
it "should update as many Wylayps as received" do
Wylayp.should_receive(:update).twice
put :update
end
it "should respond with JSON [] if successful" do
Wylayp.stub(:update)
put :update
response.body.should eql "[]"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment