Permalink
Browse files

add specs for changesets#update

  • Loading branch information...
1 parent 7ab4bd3 commit 8d32ea1ae848926affc212b8826e3683d8c4e434 @jimmycuadra committed Feb 10, 2011
Showing with 34 additions and 0 deletions.
  1. +34 −0 spec/controllers/changesets_controller_spec.rb
@@ -48,4 +48,38 @@
end
end
end
+
+ describe "#update" do
+ before(:each) do
+ @changeset = Factory(:changeset)
+ end
+
+ context "when valid" do
+ before(:each) do
+ put :update, :id => @changeset.to_param, :changeset => { :description => "updated" }, :format => :json
+ end
+
+ it "saves the record" do
+ assigns(:changeset).errors.should be_empty
+ end
+
+ it "renders the create template" do
+ response.should render_template("changesets/create")
+ end
+ end
+
+ context "when invalid" do
+ before(:each) do
+ put :update, :id => @changeset.to_param, :changeset => { :revision => "foo" }, :format => :json
+ end
+
+ it "does not save the record" do
+ assigns(:changeset).errors.should_not be_empty
+ end
+
+ it "renders the error template" do
+ response.should render_template("changesets/errors")
+ end
+ end
+ end
end

0 comments on commit 8d32ea1

Please sign in to comment.