aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/activerecord
Commit message (Collapse)AuthorAgeFilesLines
* Pass the template format to the digestorAaron Patterson2019-02-151-1/+2
| | | | | | | | | | | | | | | This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack.
* Move templates to an anonymous subclass of AV::BaseAaron Patterson2019-02-061-1/+3
| | | | | Now we can throw away the subclass and the generated methods will get GC'd too
* Tighten up the AV::Base constructorAaron Patterson2019-01-291-1/+1
| | | | | | | | | | | | | | | The AV::Base constructor was too complicated, and this commit tightens up the parameters it will take. At runtime, AV::Base is most commonly constructed here: https://github.com/rails/rails/blob/94d54fa4ab641a0ddeb173409cb41cc5becc02a9/actionview/lib/action_view/rendering.rb#L72-L74 This provides an AV::Renderer instance, a hash of assignments, and a controller instance. Since this is the common case for construction, we should remove logic from the constructor that handles other cases. This commit introduces special constructors for those other cases. Interestingly, most code paths that construct AV::Base "strangely" are tests.
* Add allocations to template renderer subscriptionEileen Uchitelle2018-10-101-5/+5
| | | | | | | | | | | | | | | | | | | | | | | This PR adds the allocations to the instrumentation for template and partial rendering. Before: ``` Rendering posts/new.html.erb within layouts/application Rendered posts/_form.html.erb (9.7ms) Rendered posts/new.html.erb within layouts/application (10.9ms) Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms) ``` After: ``` Rendering posts/new.html.erb within layouts/application Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004) Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654) Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564) ```
* Fix more offencesRafael Mendonça França2018-09-251-1/+1
|
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Merge pull request #33973 from rails/remove-catch-allAaron Patterson2018-09-255-1/+39
|\ | | | | Remove deprecated catch-all route in the AV tests
| * make bot happyAaron Patterson2018-09-241-1/+1
| |
| * Remove deprecated catch-all route in the AV testsAaron Patterson2018-09-245-1/+39
| | | | | | | | | | | | | | | | This commit removes a deprecated catch-all route in the AV tests. It defines and includes the necessary routes for each test such that we don't need the catch-all anymore. This also helps push us toward #33970
* | Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Don’t allocate array on no argsschneems2018-09-071-1/+1
| | | | | | | | | | When no dependencies are present to be digested there is no reason to build an array just to turn around and turn it back into a string. The dependencies array is not mutated in this method so we can use the same empty array across all invocations. Total allocated: 791402 bytes (7294 objects) Total allocated: 777442 bytes (7132 objects) (791402 - 777442) / 791402.0 # => 1.76 % speed improvement
* Only preload misses on multifetch cacheLachlan Sylvester2018-03-061-0/+35
|
* Remove unused methods from `RenderPartialWithRecordIdentificationController`yuuji.yaginuma2017-09-301-10/+0
| | | | These methods no longer used since a3da293.
* Use frozen string literal in actionview/Kir Shatrov2017-07-246-0/+12
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-026-6/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-026-0/+6
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-016-0/+6
| |
* | Make ActionView frozen string literal friendly.Pat Allan2017-06-201-2/+2
|/ | | | Plus a couple of related ActionPack patches.
* Merge pull request https://github.com/rails/rails/pull/28637 from ↵Kasper Timm Hansen2017-06-081-2/+5
| | | | st0012/fix-partial-cache-logging
* Use a hash to record every partial's cache hit status instead of sharing a ↵Stan Lo2017-06-081-0/+1
| | | | boolean.
* Use recyclable cache keys (#29092)David Heinemeier Hansson2017-05-181-1/+1
|
* Should escape meta characters in regexpRyuta Kamizono2017-05-071-1/+1
|
* Always use original url_for when generating direct routesAndrew White2017-03-171-0/+46
| | | | | | | Action View overrides `url_for` in the view context to render paths by default when using `url_for` and this means that direct route helpers don't get the full url when called with the url suffix. To fix this always call the original `url_for`.
* Add assertion to polymorphic_routes_test.rbbogdanvlviv2017-02-201-2/+1
| | | | | | | | | | | | | | | | The assertion will ensure that the behavior doesn't regress. assert_equal "/projects", polymorphic_path("projects") Remove FIXME related to polymorphic_url behavior. polymorphic_url with Symbol or String works equally. Example: default_url_options[:host] = "example.com" polymorphic_url(:projects) # => "http://example.com/projects" polymorphic_url("projects") # => "http://example.com/projects" Related to 37d4415a7b433fcb987b1c6a5b51bf2d8efc5d5e
* module Blog; class Post appears twice in AV testsAkira Matsuda2017-02-021-3/+3
| | | | This causes TypeError when loaded separately
* class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-1/+1
| | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-1/+1
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Privatize unneededly protected methods in Action View testsAkira Matsuda2016-12-231-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-1/+1
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Add three new rubocop rulesRafael Mendonça França2016-08-162-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-24/+24
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-3/+3
|
* modernizes hash syntax in actionviewXavier Noria2016-08-064-37/+37
|
* applies new string literal convention in actionview/testXavier Noria2016-08-066-44/+44
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Store the old logger before calling superRafael Mendonça França2016-07-171-1/+1
| | | | | | setup in ActiveSupport::LogSubscriber::TestHelper call set_logger that will change ActionController::Base.logger to the MockLogger so that logger will be always MockLogger
* Fix debug helper testRyuta Kamizono2016-06-031-1/+4
|
* Fix calling cache helper with a relationLachlan Sylvester2015-08-281-0/+18
|
* Remove `assigns` and `assert_template`.Guo Xiang Tan2015-05-301-16/+2
|
* :put_litter_in_its_place: Unused methodsAkira Matsuda2015-04-251-4/+0
|
* don't need to rescue Exception in this caseAaron Patterson2015-03-051-0/+6
|
* Avoid accurate assertions on error messagesRobin Dupret2015-03-021-1/+1
| | | | | Since there are disparities between the raised error messages on the different implementations, let's avoid being too accurate.
* Make the helpers a required argumentEvan Phoenix2015-02-191-1/+1
|
* Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846robertomiranda2015-01-311-1/+1
| | | | ref: https://github.com/rails/rails/pull/18763#issuecomment-72349769
* Fix form_for to work with objects that implement to_modelTravis Grathwell2014-12-291-5/+15
| | | | | | | | | | | | | Previously, if you tried to use form_for with a presenter object that implements to_model, it would crash in action_dispatch/routing/polymorphic_routes.rb when asking the presenter whether it is .persisted? Now, we always ask .persisted? of the to_model object instead. This seems to been an issue since 1606fc9d840da869a60213bc889da6fcf1fdc431 Signed-off-by: Eugenia Dellapenna <eugenia.dellapenna@gmail.com>
* Move test that depends on ActiveRecordclaudiob2014-11-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | This commit moves a test from `test/template` to `test/activerecord` since the test depends on ActiveRecord. This matches the documentation from [RUNNING_UNIT_TESTS](https://github.com/rails/rails/blob/f28d1ddd507174ac233b773cc4f35c3c05ad32e7/actionview/RUNNING_UNIT_TESTS.rdoc): > Test cases in the test/activerecord/ directory depend on having activerecord and sqlite3 installed. > If Active Record is not in actionview/../activerecord directory, or the sqlite3 rubygem is not installed, these tests are skipped. > Other tests are runnable from a fresh copy of actionview without any configuration. --- More details about this commit. All the tests starting with `require 'active_record_unit'` are already inside `test/activerecord`, except for the one test this commit moves. If you don't have `active_record` on your machine, the following command currently fails on master: ```bash ```
* Remove internal options from query string of pathsGert Goet2014-09-251-0/+9
| | | | Fixes #17057
* Remove warningRafael Mendonça França2014-09-011-2/+2
|