Commit Graph

351 Commits

Author SHA1 Message Date
Jonathan Hefner
cb563a27de Split code snippets by context [ci-skip]
This provides a stronger visual cue that the code in these snippets
belongs in different contexts (e.g. separate files).
2020-12-25 10:53:12 -06:00
Guo Xiang Tan
bda10bf3a8
Recover precision when serializing Time, TimeWithZone and DateTime. 2020-10-30 19:58:13 +00:00
Michael Hagar
a3e1590e96 epsilon invert
Update guides/source/testing.md

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2020-08-14 17:06:21 -05:00
Jonathan Hefner
481035fba0 Use bash code fences and prompts for shell code [ci skip]
Follow-up to #39594, which added CSS in order to select shell commands
sans prompts on triple-click.

This commit adds several bash code fences and prompts where they were
missing, and removes a few where they were inappropriate.
2020-06-13 19:27:30 -05:00
Jonathan Hefner
21575ddc32 Update assert_redirected_to docs [ci skip]
`assert_redirected_to` does not partially match `options` anymore.  That
feature was removed in 3900f4007ee6463b8936af23c04017a900673866.

Closes #39446.
2020-05-28 01:17:04 -05:00
Niklas Häusele
9488712365
Adds a rails test:all rake task (#39221)
* Adds a rails test:all rake task

This task runs all tests, including system tests.

* Better placement + slight tweak of the comment

Co-authored-by: David Heinemeier Hansson <david@loudthinking.com>
2020-05-10 17:22:49 -07:00
Brandon Fish
b4ccdcb73a Include parallelize :threads option when fork is not available 2020-05-04 20:26:24 -05:00
danieldimitrov
1e78a12941 Remove confusing json by default support and add json post example 2020-04-28 20:46:39 +02:00
danieldimitrov
3c2d5090b3 Replace all single quotes in code snippets by double quotes for consistency 2020-04-28 20:35:45 +02:00
Haroon Ahmed
6504e97561 update global rails commands to bundled rails i.e. bin/rails 2020-04-11 17:32:26 +01:00
David Heinemeier Hansson
3e0cdbeaf4
require, require_relative, load by double quotes (#38841)
* require, require_relative, load by double quotes

We're getting rid of all single quote usage, unless it serves a specific purpose, as per the general style guide.
2020-03-29 16:30:52 -07:00
Thomas Fankhauser
926365b355 Added parallell testing of transactions section
Based on https://github.com/rails/rails/issues/38578, it would be nice to have some information on transactions in test cases
2020-02-28 14:43:33 +01:00
Muhammad Muhammad Ibrahim
a69df01b80 Update "Eagerly Requiring Helpers" section in testing docs [ci skip]
This will change the path for requiring helper files to be consistent
with previous examples in "Using Separate Files" section
2020-02-04 04:06:54 +02:00
Muhammad
73fdd4c1d1
Make test guides for test helpers consistent [ci skip]
This will correct the paths to the test helpers and make the examples work.
2020-02-01 13:14:54 +02:00
eileencodes
9082609a33
Fix test guides for test helpers
`lib` isn't autoloaded in most applications and I wouldn't recomment
storing test helpers there even if it was.

This was brought up in #38343. I think the original author meant to
write `test/lib`. I updated the docs to say to use either `test/lib` or
`test/test_helpers` (personally I prefer the latter).
2020-01-29 08:23:22 -05:00
Haroon Ahmed
db1ae8cbb4 remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
Petrik
18ee206263 Fix title capitalization in guides according to guidelines [ci skip]
According to the guide guidelines, all words except for prepositions,
conjunctions, internal articles, and forms of the verb "to be" should be
capitalized. This commit fixes some titles.
2019-12-23 10:47:23 +01:00
Ryuta Kamizono
7f6d2914c6 Do not refer guides in edgeguides [ci skip] 2019-10-20 02:35:17 +09:00
Ron Wilson
bb3c3e8608 Adds a link to the Basic Authentication section [ci skip] 2019-10-14 14:57:45 -03:00
Takayuki Nakata
99f125a6bc Fix typo, shoud -> should [ci skip] 2019-09-25 15:54:06 +09:00
yuuji.yaginuma
ea5f509643 Change ActionDispatch::Response#content_type returning Content-Type header as it is
Since #35709, `Response#conten_type` returns only MIME type correctly.
It is a documented behavior that this method only returns MIME type, so
this change seems appropriate.
39de7fac05/actionpack/lib/action_dispatch/http/response.rb (L245-L249)

But unfortunately, some users expect this method to return all
Content-Type that does not contain charset. This seems to be breaking
changes.

We can change this behavior with the deprecate cycle.
But, in that case, a method needs that include Content-Type with
additional parameters. And that method name is probably the
`content_type` seems to properly.

So I changed the new behavior to more appropriate `media_type` method.
And `Response#content_type` changed (as the method name) to return Content-Type
header as it is.

Fixes #35709.

[Rafael Mendonça França & Yuuji Yaginuma ]
2019-06-01 09:20:13 +09:00
Richard Macklin
8783330034 Update testing guide to reflect changes from #36047
In #36047 we moved `take_failed_screenshot` from an `after_teardown`
hook to a `before_teardown` hook. However, I didn't realize the Testing
rails guide was explicitly mentioning that it happened inside
`after_teardown`. So this updates the docs to be consistent with that
change.

[ci skip]
2019-05-08 08:38:42 -07:00
Robin Fisher
50fe4c3c2e
Fix incorrect url in guide [ci skip]
The example functional test lists the 'create' route as article_url rather than articles_url
2019-04-29 21:37:56 +01:00
Gannon McGibbon
9057e64151
Merge pull request #35738 from gmcgibbon/aj_assert_drop_usec_docs
ActiveJob time argument assertion documentation
2019-04-20 12:36:58 +09:00
Shailesh Kalamkar
fbb9a3fc01 [ci skip] Fixed testing guides typo fourty -> forty 2019-03-28 09:41:04 +05:30
Gannon McGibbon
39b6840f3c Add section on asserting time args for jobs 2019-03-25 01:37:42 -04:00
Shailesh Kalamkar
70192cec42 [ci skip] Minor documentation fixes for consistency 2019-03-09 12:15:00 +05:30
Sean Abrahams
6ef90c40f2 Guides: Fix parent class of model test example (#35065)
* Fix parent class of model test example
* include ActiveJob::TestHelper

[ci skip]
2019-03-09 11:24:48 +05:30
Nathaniel Suchy
d9f1cc05b5 Update links and code examples in the guides to use HTTPS where the host supports it. 2019-03-06 15:21:07 -05:00
Ricardo Diaz
4409ab1006 Fix typo in ActionCable::Connection::TestCase reference 2019-01-24 20:35:58 -05:00
Kasper Timm Hansen
36c840057f
Merge pull request #35021 from palkan/refactor/broadcasting-for-testing
Action Cable: move channel_name to Channel.broadcasting_for
2019-01-24 23:40:33 +01:00
Alan Brown
6d6be1f194
Corrected spelling of ActionCable::Connection::TestCase 2019-01-22 16:19:09 -08:00
Vladimir Dementyev
cfe65cb478
fix fixture syntax in cable docs and guides 2019-01-22 16:53:01 -05:00
Vladimir Dementyev
dc80459a9e
Move channel_name to Channel.broadcasting_for
That would allow us to test broadcasting made with channel, e.g.:

```ruby
class ChatRelayJob < ApplicationJob
  def perform_later(room, msg)
    ChatChannel.broadcast_to room, message: msg
  end
end
```

To test this functionality we need to know the underlying stream name
(to use `assert_broadcasts`), which relies on `channel_name`.

We had to use the following code:

```ruby
assert_broadcasts(ChatChannel.broadcasting_for([ChatChannel.channel_name, room]), 1) do
  ChatRelayJob.perform_now
end
```

The problem with this approach is that we use _internal_ API (we shouldn't care about `channel_name` prefix
in our code).

With this commit we could re-write the test as following:

```ruby
 assert_broadcasts(ChatChannel.broadcasting_for(room), 1) do
   ChatRelayJob.perform_now
 end
```
2019-01-22 15:14:20 -05:00
bogdanvlviv
a43052cbbc
Remove frozen_string_literal from Action Cable's template files
Related to 837f602fa1b3281113dac965a8ef96de3cac8b02

Fix the testing guide.
2019-01-16 15:14:35 +00:00
Vladimir Dementyev
a4099debcf
Add Action Cable Testing guides 2019-01-14 11:16:59 -05:00
Bogdan
e9f6ce617b Add option to set parallel test worker count to the physical core count of the machine (#34735)
* Add option to set parallel test worker count to the physical core count of the machine

Also, use the physical core count of the machine as
the default number of workers, and  generate the `test_helper.rb` file
with `parallelize(workers: :number_of_processors)`

Closes #34734

* Ensure that we always test parallel testing

Since #34734 we decided to use the physical core count of the machine as
the default number of workers in the parallel testing, we need to
ensure that some tests use at least 2 workers because we could
run those tests on VM that has only 1 physical core.
It also fixes tests failures on the CI since Travis server we are using
has only one physical core.
See https://travis-ci.org/rails/rails/jobs/469281088#L2352
2018-12-18 10:25:35 -08:00
Sam Bostock
d45b74e897
Add advanced test helpers docs to guides
[ci skip]
2018-12-04 18:29:52 -05:00
bogdanvlviv
4973a7643b
Improve parallel testing guide [ci skip]
- Fix formatting
- Don't repeat "Active Record automatically handles creating and migrating a new
  database for each worker to use."
- Tell that AR loads the schema to a database for each process(Related to #33479)
- Clarify that `parallelize_teardown` is executed for each process
2018-12-03 11:17:58 +02:00
Tom Rossi
ee8dce180e Updating the Testing Guide to Reflect Emails Enqueued With ActiveJob [ci skip] 2018-11-25 16:57:59 -05:00
anthonygharvey
e50debf1ae Fix typo in testing guide 2018-10-17 20:50:16 -04:00
Kadu Ribeiro
919b50822f [ci skip] Recommend testing information displayed over object stored
Since `assigns` is not placed by default with Rails, we suggested to
test if the right information was displayed instead of suggesting to
test if the right object was stored in the template.
2018-09-27 23:27:35 -03:00
Darren
2efae0796a Fix header setting doc in testing guide [ci skip] 2018-08-13 14:06:49 +08:00
utilum
2604d184ec Testing Guide: unnecessary comment
This has been around as far back as I can
[see](5137d03cc5/guides/source/testing.md).

No need to specify the obvious.

[ci skip]
2018-07-25 20:44:40 +02:00
Matthew Draper
ec387c6dd9
Merge pull request #33229 from albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails
Prefer rails command over bin/rails
2018-07-25 04:10:29 +09:30
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Alberto Almagro
40b209db53 Recommend use of rails over bin/rails
As discussed in #33203 rails command already looks for, and runs,
bin/rails if it is present.

We were mixing recommendations within guides and USAGE guidelines,
in some files we recommended using rails, in others bin/rails and
in some cases we even had both options mixed together.
2018-07-06 22:46:35 +02:00
Jon Evans
61725674fc
Fix testing guide typo 2018-06-01 23:25:47 -06:00
Anthony Crumley
258670244d Added a lot of Oxford commas
[ci skip] A regular expression was used to find a lot of missing Oxford
commas and add them.  The regular expression was as follows.

", ([a-zA-Z0-9.\`:'\"]+ ){1,6}(or|and) "
2018-05-10 12:46:06 -05:00
Chris Houhoulis
e7ba10b9a9 Fix url_helper examples in testing guide [ci skip] 2018-04-29 20:19:22 -04:00