From 04e1281990fd1d18d95c6b609690380711d0b48a Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sun, 13 Jul 2014 02:28:25 +0530 Subject: Add link to minitest rdoc & github --- guides/source/testing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/guides/source/testing.md b/guides/source/testing.md index 561fe2cf70..a416cd36b5 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -365,7 +365,7 @@ Ideally, you would like to include a test for everything which could possibly br By now you've caught a glimpse of some of the assertions that are available. Assertions are the worker bees of testing. They are the ones that actually perform the checks to ensure that things are going as planned. There are a bunch of different types of assertions you can use. -Here's an extract of the assertions you can use with `minitest`, the default testing library used by Rails. The `[msg]` parameter is an optional string message you can specify to make your test failure messages clearer. It's not required. +Here's an extract of the assertions you can use with [`Minitest`](https://github.com/seattlerb/minitest), the default testing library used by Rails. The `[msg]` parameter is an optional string message you can specify to make your test failure messages clearer. It's not required. | Assertion | Purpose | | ---------------------------------------------------------------- | ------- | @@ -395,6 +395,8 @@ Here's an extract of the assertions you can use with `minitest`, the default tes | `assert_send( array, [msg] )` | Ensures that executing the method listed in `array[1]` on the object in `array[0]` with the parameters of `array[2 and up]` is true. This one is weird eh?| | `flunk( [msg] )` | Ensures failure. This is useful to explicitly mark a test that isn't finished yet.| +The above are subset of assertions that minitest supports. For an exhaustive & more up-to-date list, please check [Minitest API documentation](http://docs.seattlerb.org/minitest/), specifically [`Minitest::Assertions`](http://docs.seattlerb.org/minitest/Minitest/Assertions.html) + Because of the modular nature of the testing framework, it is possible to create your own assertions. In fact, that's exactly what Rails does. It includes some specialized assertions to make your life easier. NOTE: Creating your own assertions is an advanced topic that we won't cover in this tutorial. -- cgit v1.2.3 From 758ae373055b977892db3673dcd4cae58cdc98a8 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Wed, 16 Jul 2014 22:45:58 +0800 Subject: [ci skip] Use appropriate mailer syntax. Reference: https://github.com/rails/rails/commit/f7e4362011ceb1317fd401125d48d7ccb9a1079c --- guides/source/active_record_querying.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index c9e265de08..a0a2f31a63 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -293,7 +293,7 @@ This may appear straightforward: ```ruby # This is very inefficient when the users table has thousands of rows. User.all.each do |user| - NewsLetter.weekly_deliver(user) + NewsMailer.weekly(user).deliver end ``` @@ -333,7 +333,7 @@ The `:batch_size` option allows you to specify the number of records to be retri ```ruby User.find_each(batch_size: 5000) do |user| - NewsLetter.weekly_deliver(user) + NewsMailer.weekly(user).deliver end ``` @@ -345,7 +345,7 @@ For example, to send newsletters only to users with the primary key starting fro ```ruby User.find_each(start: 2000, batch_size: 5000) do |user| - NewsLetter.weekly_deliver(user) + NewsMailer.weekly(user).deliver end ``` -- cgit v1.2.3 From 59b93dfda7def9e949f700fdb4d71885a1b17f59 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Wed, 16 Jul 2014 23:12:13 +0800 Subject: [ci skip] Remove duplicated last! section. Reference: https://github.com/rails/rails/commit/d4fd0bd17709735ac91e434c94fe99429f078c6e cc @schneems --- guides/source/active_record_querying.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index a0a2f31a63..35467fe95b 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -267,23 +267,6 @@ This is equivalent to writing: Client.where(first_name: 'does not exist').take! ``` -#### `last!` - -`Model.last!` finds the last record ordered by the primary key. For example: - -```ruby -client = Client.last! -# => # -``` - -The SQL equivalent of the above is: - -```sql -SELECT * FROM clients ORDER BY clients.id DESC LIMIT 1 -``` - -`Model.last!` raises `ActiveRecord::RecordNotFound` if no matching record is found. - ### Retrieving Multiple Objects in Batches We often need to iterate over a large set of records, as when we send a newsletter to a large set of users, or when we export data. -- cgit v1.2.3 From 78788ad72390806803adf38d8847fd0c858154f6 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sat, 19 Jul 2014 20:06:59 +0530 Subject: Performed Returns true if redirect/render has happened --- actionpack/lib/action_controller/metal.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 9a427ebfdb..0fa0357bae 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -182,7 +182,10 @@ module ActionController body = [body] unless body.nil? || body.respond_to?(:each) super end - + + # Tests if render or redirect already happended. Could be useful when used as a + # conditional to return early out a controller action to avoid AbstractController::DoubleRenderError + # example in case of multiple render/redirects in single controller action def performed? response_body || (response && response.committed?) end -- cgit v1.2.3 From 132e3fdf80046d4e2def9494cb0d1e9212caf0cf Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Sun, 20 Jul 2014 18:30:27 +0800 Subject: [ci skip] Normalize all localhost linking. --- guides/source/getting_started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index ef97cda3bc..ae3e0a3946 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -909,7 +909,7 @@ And then finally, add the view for this action, located at ``` -Now if you go to `http://localhost:3000/articles` you will see a list of all the +Now if you go to you will see a list of all the articles that you have created. ### Adding links @@ -1105,7 +1105,7 @@ standout. Now you'll get a nice error message when saving an article without title when you attempt to do just that on the new article form -[(http://localhost:3000/articles/new)](http://localhost:3000/articles/new). +: ![Form With Errors](images/getting_started/form_with_errors.png) -- cgit v1.2.3 From d9bd75a0d85355b8d63e4003a76c6399f0dbce17 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 2 Aug 2014 12:05:26 +0000 Subject: copy edits[ci skip] --- actionpack/lib/action_controller/metal.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 0fa0357bae..bfbc15a901 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -183,9 +183,7 @@ module ActionController super end - # Tests if render or redirect already happended. Could be useful when used as a - # conditional to return early out a controller action to avoid AbstractController::DoubleRenderError - # example in case of multiple render/redirects in single controller action + # Tests if render or redirect has already happened. def performed? response_body || (response && response.committed?) end -- cgit v1.2.3