Created
December 7, 2010 03:38
-
-
Save santiago/731415 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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