diff options
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/caching_with_rails.md | 7 | ||||
-rw-r--r-- | guides/source/configuring.md | 2 | ||||
-rw-r--r-- | guides/source/testing.md | 16 |
3 files changed, 23 insertions, 2 deletions
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index b0103c9af4..20f11c2bc2 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -31,6 +31,11 @@ the relevant `config/environments/*.rb` file: config.action_controller.perform_caching = true ``` +NOTE: Changing the value of `config.action_controller.perform_caching` will +only have an effect on the caching provided by the Action Controller component. +For instance, it will not impact low-level caching, that we address +[below](#low-level-caching). + ### Page Caching Page caching is a Rails mechanism which allows the request for a generated page @@ -122,7 +127,7 @@ For example, take the following view: Which in turn renders this view: ```erb -<% cache game %> +<% cache game do %> <%= render game %> <% end %> ``` diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 79a80de3cc..167cc549e2 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -326,7 +326,7 @@ The schema dumper adds one additional configuration option: * `config.action_controller.asset_host` sets the host for the assets. Useful when CDNs are used for hosting assets rather than the application server itself. -* `config.action_controller.perform_caching` configures whether the application should perform caching or not. Set to false in development mode, true in production. +* `config.action_controller.perform_caching` configures whether the application should perform the caching features provided by the Action Controller component or not. Set to false in development mode, true in production. * `config.action_controller.default_static_extension` configures the extension used for cached pages. Defaults to `.html`. diff --git a/guides/source/testing.md b/guides/source/testing.md index 2fd54a48fc..d146df3dc6 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -178,6 +178,14 @@ create test/fixtures/articles.yml ... ``` +You can also generate the test stub for a model using the following command: + +```bash +$ bin/rails generate test_unit:model article title:string body:text +create test/models/article_test.rb +create test/fixtures/articles.yml +``` + The default test stub in `test/models/article_test.rb` looks like this: ```ruby @@ -509,6 +517,14 @@ You should test for things such as: Now that we have used Rails scaffold generator for our `Article` resource, it has already created the controller code and tests. You can take look at the file `articles_controller_test.rb` in the `test/controllers` directory. +The following command will generate a controller test case with a filled up +test for each of the seven default actions. + +```bash +$ bin/rails generate test_unit:scaffold article +create test/controllers/articles_controller_test.rb +``` + Let me take you through one such test, `test_should_get_index` from the file `articles_controller_test.rb`. ```ruby |