You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove ActionController::TestCase from documentation
In Rails 5.1 `ActionController::TestCase` will be moved out of Rails
into it's own gem.
Please use `ActionDispatch::IntegrationTest` going foward.
Because this will be moved to a gem I used `# :stopdoc:` instead of
deleting the documentation. This will remove it from the Rails
documentation but still leave the method documented for when we move it
to a gem.
Guides have been updated to use the routing structure used in Integration
and all test examples have been updated to inherit from
`ActionDispatch::IntegrationTest` instead of `ActionController::TestCase.
Fixes#22496
Copy file name to clipboardExpand all lines: guides/source/active_support_core_extensions.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -517,17 +517,17 @@ Extensions to `Module`
517
517
518
518
Using plain Ruby you can wrap methods with other methods, that's called _alias chaining_.
519
519
520
-
For example, let's say you'd like params to be strings in functional tests, as they are in real requests, but still want the convenience of assigning integers and other kind of values. To accomplish that you could wrap `ActionController::TestCase#process` this way in `test/test_helper.rb`:
520
+
For example, let's say you'd like params to be strings in functional tests, as they are in real requests, but still want the convenience of assigning integers and other kind of values. To accomplish that you could wrap `ActionDispatch::IntegrationTest#process` this way in `test/test_helper.rb`:
521
521
522
522
```ruby
523
-
ActionController::TestCase.class_eval do
523
+
ActionDispatch::IntegrationTest.class_eval do
524
524
# save a reference to the original process method
525
525
alias_method:original_process, :process
526
526
527
527
# now redefine process and delegate to original_process
@@ -537,10 +537,10 @@ That's the method `get`, `post`, etc., delegate the work to.
537
537
That technique has a risk, it could be the case that `:original_process` was taken. To try to avoid collisions people choose some label that characterizes what the chaining is about:
Copy file name to clipboardExpand all lines: guides/source/testing.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,7 +330,6 @@ You'll see the usage of some of these assertions in the next chapter.
330
330
All the basic assertions such as `assert_equal` defined in `Minitest::Assertions` are also available in the classes we use in our own test cases. In fact, Rails provides the following classes for you to inherit from:
331
331
332
332
* `ActiveSupport::TestCase`
333
-
* `ActionController::TestCase`
334
333
* `ActionMailer::TestCase`
335
334
* `ActionView::TestCase`
336
335
* `ActionDispatch::IntegrationTest`
@@ -682,9 +681,9 @@ Let me take you through one such test, `test_should_get_index` from the file `ar
682
681
683
682
```ruby
684
683
# articles_controller_test.rb
685
-
class ArticlesControllerTest < ActionController::TestCase
684
+
class ArticlesControllerTest < ActionDispatch::IntegrationTest
686
685
test "should get index" do
687
-
get :index
686
+
get '/articles'
688
687
assert_response :success
689
688
assert_includes @response.body, 'Articles'
690
689
end
@@ -697,7 +696,7 @@ and also ensuring that the right response body has been generated.
697
696
The `get` method kicks off the web request and populates the results into the response. It accepts 4 arguments:
698
697
699
698
* The action of the controller you are requesting.
700
-
This can be in the form of a string or a symbol.
699
+
This can be in the form of a string or a route (i.e. `articles_url`).
701
700
702
701
* `params`: option with a hash of request parameters to pass into the action
703
702
(e.g. query string parameters or article variables).
NOTE: If you try running `test_should_create_article` test from `articles_controller_test.rb` it will fail on account of the newly added model level validation and rightly so.
@@ -727,7 +726,7 @@ Let us modify `test_should_create_article` test in `articles_controller_test.rb`
0 commit comments