Commit Graph

49728 Commits

Author SHA1 Message Date
Kasper Timm Hansen
11644fd0ce Collections automatically cache and fetch partials.
Collections can take advantage of `multi_read` if they render one template
and their partials begin with a cache call.

The cache call must correspond to either what the collections elements are
rendered as, or match the inferred name of the partial.

So with a notifications/_notification.html.erb template like:

```ruby
<% cache notification %>
  <%# ... %>
<% end %>
```

A collection would be able to use `multi_read` if rendered like:

```ruby
<%= render @notifications %>
<%= render partial: 'notifications/notification', collection: @notifications, as: :notification %>
```
2015-02-21 16:06:57 +01:00
Kasper Timm Hansen
e56c635427 Merge multi_fetch_fragments.
Makes caching a collection of template partials faster using `read_multi`
on the Rails cache store.

Some caching implementations have optimized `read_multi` so we don't have
to check in the cache store for every template.
2015-02-20 20:07:50 +01:00
Abdelkader Boudih
66a30dc322 Merge pull request #18945 from y-yagi/layouts_and_rendering_guide
fix syntax error in render partial example [ci skip]
2015-02-15 10:58:49 +00:00
yuuji.yaginuma
cf7b677def fix syntax error in render partial example [ci skip] 2015-02-15 19:55:24 +09:00
Arthur Nogueira Neves
676d4ae787 Merge pull request #18938 from tchandy/updating_query_tracer_link
Updating Query Tracer github repository
2015-02-14 11:13:36 -05:00
Vijay Dev
95546d4935 Merge branch 'master' of github.com:rails/docrails 2015-02-14 15:35:47 +00:00
Godfrey Chan
698afe1173 Mention where.not in the example
...so it doesn't look like you *have* to use SQL strings for that case (not
anymore!). Would like to replace the SQL string example with something that
you cannot do with the "normal" query API, but I could not come up with a
short, realistic example. Suggestions welcome!
2015-02-14 00:04:16 -08:00
Godfrey Chan
e076d7290d Fixed a bug where NULLs are casted into the first enum value 2015-02-13 23:51:43 -08:00
Thiago Pradi
a9e200b252 Updating Query Tracer github repository 2015-02-14 00:44:44 -02:00
Godfrey Chan
53f3803b52 Partially revert ae33aea
Using enum names in SQL strings doesn't actually work, the test was wrong (fixed
in 3dfd1ba).
2015-02-13 16:50:08 -08:00
Godfrey Chan
58adda3477 Break up these tests
Make sure we have coverage for both the find/build cases
2015-02-13 16:46:52 -08:00
Godfrey Chan
3dfd1bab6a oops, 'format' is not a real enum 2015-02-13 16:40:43 -08:00
Godfrey Chan
91f431972b Enums mapping is a HWIA [ci skip]
The previous edit kind of de-emphasized that, so changing it to be more explict.
(It also avoids showing it as if it's a string-keyed hash.)
2015-02-13 16:22:20 -08:00
Godfrey Chan
ae33aea62c Enums should be referred to by symbols
Also updated the documentation about the new ability to query them normally,
and added test to make sure they work!
2015-02-13 16:18:26 -08:00
Arthur Neves
62133326df Add missing comma 2015-02-13 13:25:13 -05:00
Rafael Mendonça França
7919c29d50 Merge pull request #16381 from kakipo/validate-length-tokenizer
Allow symbol as values for `tokenizer` of `LengthValidator`
2015-02-13 12:09:36 -02:00
Kasper Timm Hansen
cc08de856a Merge pull request #18924 from tgxworld/correct_module_in_depre_msg
Correct module name in deprecation message.
2015-02-13 12:30:25 +01:00
Guo Xiang Tan
899e10f562 Correct module name in deprecation message. 2015-02-13 19:06:25 +08:00
Kasper Timm Hansen
7ce3174306 Merge pull request #18923 from tgxworld/fix_deprecation_warning_message
Improve deprecation warning message
2015-02-13 10:32:52 +01:00
Yves Senn
57a1d2bf9d remove CHANGELOG entry for Rails 5.0 only feature. #18918
`has_secure_token` hasen't been released yet. No need to track
every change in the CHANGELOG.
2015-02-13 09:16:22 +01:00
Yves Senn
d0326bbae5 Merge pull request #18918 from morgoth/do-not-overwrite-value-of-secret-token-when-present
Do not overwrite secret token value when already present.
2015-02-13 08:40:53 +01:00
Yves Senn
9e30346b3a Merge pull request #18922 from yui-knk/fix/action_controller_overview
[ci skip] escape under score
2015-02-13 08:36:44 +01:00
Guo Xiang Tan
aca4c82d95 Improve deprecation message. 2015-02-13 15:30:13 +08:00
Guo Xiang Tan
dbf38a06f4 Do not recommend xhr since it is going to be deprecated. 2015-02-13 15:22:58 +08:00
yui-knk
6b4c5aeb35 [ci skip] escape under score 2015-02-13 13:56:48 +09:00
Arthur Nogueira Neves
1ca13b47da Merge pull request #18919 from nerdrew/missing-rack-utils-require
require rack/utils in exception_wrapper
2015-02-12 20:10:20 -05:00
Andrew Lazarus
85842c553d require rack/utils in exception_wrapper 2015-02-12 14:56:35 -08:00
Wojciech Wnętrzak
0817bb06f7 Do not overwrite secret token value when already present.
```
user = User.create(token: "custom-secure-token")
user.token # => "custom-secure-token"
```
2015-02-12 22:05:45 +01:00
Aaron Patterson
b03b09dc86 remove meta programming
there's really no benefit here.  It's the same number of lines without
the meta programming and is faster
2015-02-12 12:11:19 -08:00
Aaron Patterson
4cf3b8ac47 there is always an integration session, so remove the check 2015-02-12 12:09:03 -08:00
Aaron Patterson
303567e554 lazily create the integration session
now we don't have to call reset! everywhere
2015-02-12 12:04:23 -08:00
Aaron Patterson
fa63448420 use before_setup to set up test instance variables 2015-02-12 11:51:52 -08:00
eileencodes
0acd4a5776 Skip url_helpers instead of caching, speed up integration tests
We shouldn't cache if it's not absolutely necessary. Removes
route caching and instead skips using the `url_helpers` is the
integration test session doesn't require it. Benchmark ips on
integration and controller index method tests below.

Without any caching or changes to `#url_helpers`:
```
Calculating -------------------------------------
INDEX: Integration Test
                        71.000  i/100ms
INDEX: Functional Test
                        99.000  i/100ms
-------------------------------------------------
INDEX: Integration Test
                        728.878  (± 8.0%) i/s -      3.692k
INDEX: Functional Test
                          1.015k (± 6.7%) i/s -      5.148k

Comparison:
INDEX: Functional Test:     1015.4 i/s
INDEX: Integration Test:      728.9 i/s - 1.39x slower
```

With caching on `#url_helpers`:
```
Calculating -------------------------------------
INDEX: Integration Test
                        74.000  i/100ms
INDEX: Functional Test
                        99.000  i/100ms
-------------------------------------------------
INDEX: Integration Test
                        752.377  (± 6.9%) i/s -      3.774k
INDEX: Functional Test
                          1.021k (± 6.7%) i/s -      5.148k

Comparison:
INDEX: Functional Test:     1021.1 i/s
INDEX: Integration Test:      752.4 i/s - 1.36x slower
```

Afer removing the caching and bypassing the `url_helpers` when not
necessary in the session:
```
Calculating -------------------------------------
INDEX: Integration Test
                        87.000  i/100ms
INDEX: Functional Test
                        97.000  i/100ms
-------------------------------------------------
INDEX: Integration Test
                        828.433  (± 6.4%) i/s -      4.176k
INDEX: Functional Test
                        926.763  (± 7.2%) i/s -      4.656k

Comparison:
INDEX: Functional Test:      926.8 i/s
INDEX: Integration Test:      828.4 i/s - 1.12x slower
```
2015-02-12 14:48:14 -05:00
Rafael Mendonça França
ce32ff462f Merge pull request #18915 from kamipo/extract_date_time_precision_test
Extract `DateTimePrecisionTest`
2015-02-12 17:42:48 -02:00
Eugene Gilburg
d7a7a050e1 Optimize none? and one? relation query methods to use LIMIT and COUNT.
Use SQL COUNT and LIMIT 1 queries for none? and one? methods if no block or limit is given,
instead of loading the entire collection to memory. The any? and many? methods already
follow this behavior.

[Eugene Gilburg & Rafael Mendonça França]
2015-02-12 17:40:59 -02:00
Ryuta Kamizono
694f4b5120 Extract DateTimePrecisionTest
The datetime precision tests for any adapters is duplicated.
2015-02-13 03:16:47 +09:00
Zachary Scott
8d0fe8047a Merge pull request #18844 from yuki24/guides-add-render-example-without-partial-and-locals
Add tip for skipping `partial` and `locals` options for `render`
2015-02-12 10:00:32 -08:00
Rafael Mendonça França
76f6524538 Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
2015-02-12 15:39:17 -02:00
Rafael Mendonça França
68ce508e18 Merge pull request #18886 from kamipo/allow_precision_option_for_time_column
Allow `:precision` option for time type columns
2015-02-12 15:12:27 -02:00
Rafael Mendonça França
6eaadd9fc1 Merge pull request #18885 from ypxing/master
remove unnecessary assignment/parameter passing in AS::Callbacks...::Around (master branch)
2015-02-12 15:09:57 -02:00
Yves Senn
9e9a3c5314 get rid of transaction warning when running PG tests.
This finally removes the warning "WARNING:  there is no transaction in progress"
when running Active Record tests using PostgreSQL.
2015-02-12 14:45:34 +01:00
Yves Senn
efeaa01e74 pg tests, be clear about the missing type that causes a test skip.
Also removed some cruft in the `setup` and `teardown` methods.
2015-02-12 12:20:03 +01:00
Yves Senn
d93aae9ae7 tests, remove unused requires.
"active_support/testing/stream" is already required in `test_case.rb`.
Furthermore the test "test/cases/migration_test.rb" could no longer be executed
directly.
2015-02-12 10:31:37 +01:00
Kasper Timm Hansen
22934e02c2 Merge pull request #18911 from y-yagi/fix-typo
fix typo in fresh_when example [ci skip]
2015-02-12 09:47:56 +01:00
yuuji.yaginuma
697688663f fix typo in fresh_when example [ci skip] 2015-02-12 16:54:01 +09:00
Yves Senn
6201e62cc4 Merge pull request #18907 from square/dont-load-app-on-structure
Schema creation doesn't load the app
2015-02-12 08:50:27 +01:00
Godfrey Chan
debe7aedda Properly dump primitive-like AS::SafeBuffer strings as YAML
`coder.represent_scalar` means something along the lines of "Here is a quoted
string, you can just add it to the output", which is not the case here. It only
works for simple strings that can appear unquoted in YAML, but causes problems
for e.g. primitive-like strings ("1", "true").

`coder.represent_object` on the other hand, means that "This is the Ruby-object
representation for this thing suitable for use in YAML dumping", which is what
we want here.

Before:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => true
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => false
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => 1
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => 1.1

 After:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => "true"
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => "false"
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => "1"
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => "1.1"

If we ever want Ruby to behave more like PHP or JavaScript though, this is an
excellent trick to use ;)
2015-02-11 17:08:13 -08:00
Ryuta Kamizono
1502caefd3 Allow :precision option for time type columns 2015-02-12 07:23:53 +09:00
Tamir Duberstein
4f357ea104 Schema creation doesn't load the app 2015-02-11 14:20:56 -08:00
Sean Griffin
933decceaf Don't break enum on PG 2015-02-11 15:14:21 -07:00