aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-07-05 23:56:49 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-07-05 23:56:49 +0000
commitfefe6591f660fae94b59e88c998a22bf49b5ea37 (patch)
tree66f3f9e4003bfea48c1adbcf78588c89c68cc026 /railties
parent68608e331f88c3168cc3aa270ab5f1deea394c97 (diff)
downloadrails-fefe6591f660fae94b59e88c998a22bf49b5ea37.tar.gz
rails-fefe6591f660fae94b59e88c998a22bf49b5ea37.tar.bz2
rails-fefe6591f660fae94b59e88c998a22bf49b5ea37.zip
Really, this time. References #5612.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4560 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
index 31792767a3..ed7136bb52 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
+++ b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
@@ -11,6 +11,8 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
@controller = <%= controller_class_name %>Controller.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
+
+ @first_id = <%= plural_name %>(:first).id
end
<% for action in unscaffolded_actions -%>
@@ -39,7 +41,7 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
end
def test_show<%= suffix %>
- get :show<%= suffix %>, :id => <%= plural_name %>(:first)
+ get :show<%= suffix %>, :id => @first_id
assert_response :success
assert_template 'show'
@@ -69,7 +71,7 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
end
def test_edit<%= suffix %>
- get :edit<%= suffix %>, :id => <%= plural_name %>(:first)
+ get :edit<%= suffix %>, :id => @first_id
assert_response :success
assert_template 'edit<%= suffix %>'
@@ -79,20 +81,22 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
end
def test_update<%= suffix %>
- post :update<%= suffix %>, :id => <%= plural_name %>(:first)
+ post :update<%= suffix %>, :id => @first_id
assert_response :redirect
- assert_redirected_to :action => 'show<%= suffix %>', :id => 1
+ assert_redirected_to :action => 'show<%= suffix %>', :id => @first_id
end
def test_destroy<%= suffix %>
- assert_not_nil <%= model_name %>.find(<%= plural_name %>(:first))
+ assert_nothing_raised {
+ <%= model_name %>.find(@first_id)
+ }
- post :destroy, :id => 1
+ post :destroy, :id => @first_id
assert_response :redirect
assert_redirected_to :action => 'list<%= suffix %>'
assert_raise(ActiveRecord::RecordNotFound) {
- <%= model_name %>.find(1)
+ <%= model_name %>.find(@first_id)
}
end
end