Permalink
Browse files

Made tests green.

  • Loading branch information...
alloy committed Oct 4, 2008
1 parent da1b92f commit 81a3969739be485776b7511671f8ef9bff8886fb
@@ -1,5 +1,3 @@
-load 'nested_params_form_builder.rb'
-
class ProjectsController < ApplicationController
def index
@projects = Project.find(:all)
View
@@ -1,9 +1,7 @@
class Project < ActiveRecord::Base
- extend NestedParams
-
# Automatically turns on autosave and thus also validates
has_one :author, :nested_params => true
- has_many :tasks, :dependent => :destroy, :nested_params => true, :destroy_missing => true, :reject_empty => true
+ has_many :tasks, :dependent => :destroy, :nested_params => true, :destroy_missing => true
validates_presence_of :name
end
@@ -2,7 +2,7 @@
<%= error_messages_for :project %>
-<% form_for @project, :builder => NestedParamsFormBuilder do |f| -%>
+<% form_for @project do |f| -%>
<p>
<%= f.label :name, "Project:" %>
@@ -76,10 +76,12 @@
end
it "should rollback any changes to the project and tasks if an exception occurs in one of the tasks" do
- Task.any_instance.stubs(:save).raises(ActiveRecord::RecordInvalid.new(@project))
+ Task.any_instance.stubs(:save).raises
- put :update, :id => @project.id, :project => @valid_update_params
- @project.reload
+ lambda {
+ put :update, :id => @project.id, :project => @valid_update_params
+ @project.reload
+ }.should.raise
@project.name.should == 'NestedParams'
@project.tasks.map(&:name).sort.should == ['Check other implementations', 'Try with our plugin']
@@ -56,10 +56,10 @@
end
it "should rollback any changes to the project and tasks if an exception occurs in one of the tasks" do
- Task.any_instance.stubs(:save).raises(Exception, 'Oh noes!')
+ Task.any_instance.stubs(:save).raises
@project.attributes = @valid_update_params
- @project.save
+ lambda { @project.save }.should.raise
@project.reload

0 comments on commit 81a3969

Please sign in to comment.