1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test
claudiob 050fda0206 Accept a collection in fresh_when and stale?
The methods `fresh_when` and `stale?` from ActionController::ConditionalGet
accept a single record as a short form for a hash. For instance

```ruby
  def show
    @article = Article.find(params[:id])
    fresh_when(@article)
  end
```

is just a short form for:

```ruby
  def show
    @article = Article.find(params[:id])
    fresh_when(etag: @article, last_modified: @article.created_at)
  end
```

This commit extends `fresh_when` and `stale?` to also accept a collection
of records, so that a short form similar to the one above can be used in
an `index` action. After this commit, the following code:

```ruby
def index
  @article = Article.all
  fresh_when(etag: @articles, last_modified: @articles.maximum(:created_at))
end
```

can be simply written as:

```ruby
def index
  @article = Article.all
  fresh_when(@articles)
end
```
2015-02-10 17:08:44 -08:00
..
abstract Deprecate all *_filter callbacks in favor of *_action callbacks 2015-01-08 20:52:36 +00:00
assertions
controller Accept a collection in fresh_when and stale? 2015-02-10 17:08:44 -08:00
dispatch Explicitly ignored wildcard verbs from head_routes 2015-02-08 12:03:56 -05:00
fixtures Typo: Hello = Guten Tag (in German) 2014-12-05 12:54:15 +07:00
journey Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
lib/controller Removing unused fake models 2014-09-07 22:51:14 -03:00
routing Remove deprecate *_path helpers in email views 2015-01-04 11:58:42 -03:00
tmp
abstract_unit.rb Merge pull request #17862 from lucasmazza/lm-hide-action 2014-12-02 11:40:11 -02:00