aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/loading_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Treat ActiveRecord::Base and ApplicationRecord as "primary"eileencodes2019-06-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | When someone has a multi-db application their `ApplicationRecord` will look like: ```ruby class ApplicationRecord < ActiveRecord::Base self.abstract_class = true connects_to database: { writing: :primary, reading: :replica } end ``` This will cause us to open 2 connections to ActiveRecord::Base's database when we actually only want 1. This is because Rails sees `ApplicationRecord` and thinks it's a new connection, not the existing `ActiveRecord::Base` connection because the `connection_specification_name` is different. This PR changes `ApplicationRecord` classes to consider themselves the same as the "primary" connection. Fixes #36382
* let Zeitwerk integration unhook AS::DependenciesXavier Noria2019-02-191-0/+16
|
* Add a test that exercice better the behavior we expect in the query cacheRafael Mendonça França2018-09-121-2/+43
| | | | | | | In production the query cache was already being loaded before the first request even without #33856, so added a test to make sure of it. This new test is passing even if #33856 is reverted.
* Fix query cache to load before first requestEileen Uchitelle2018-09-121-0/+33
| | | | | | | | | | | | | | | | In a test app we observed that the query cache was not enabled on the first request. This was because the query cache hooks are installed on load and active record is loaded in the middle of the first request. If we remove the `on_load` from the railtie the query cache hooks will be installed before the first request, allowing the cache to be enabled on that first request. This is ok because query cache doesn't load anything else, only itself so we're not eager loading all of active record before the first request, just the query cache hooks. [Eileen M. Uchitelle & Matthew Draper]
* Use lazy load hook to configure ActiveStorage::BlobEugene Kenny2018-02-251-0/+12
| | | | | | | | | `to_prepare` callbacks are run during initialization; using one here meant that `ActiveStorage::Blob` would be loaded when the app boots, which would in turn load `ActiveRecord::Base`. By using a lazy load hook to configure `ActiveStorage::Blob` instead, we can avoid loading `ActiveRecord::Base` unnecessarily.
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-4/+4
|
* Invoke rails command inside the railties' test app with ↵bogdanvlviv2017-10-081-2/+2
| | | | | | TestHelpers::Generation#rails See #30520
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-0/+2
|
* Convert to strings so array can be sorted deterministicallyDavid Heinemeier Hansson2017-08-041-3/+3
|
* Deterministic comparisons pleaseDavid Heinemeier Hansson2017-08-031-3/+3
|
* Including new default classes in loading testDavid Heinemeier Hansson2017-08-031-3/+3
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Privatize unneededly protected methods in Railties testsAkira Matsuda2016-12-241-1/+1
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-7/+7
|
* applies new string literal convention in railties/testXavier Noria2016-08-061-19/+19
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Remove unused boot_rails method and it's usagePrathamesh Sonpatki2016-07-041-1/+0
| | | | | - The `boot_rails` method from abstract_unit.rb is empty after 2abcdfd978fdcd491576a237e8c6b. - So let's remove it and its usage.
* remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-221-4/+4
|
* Prevent destructive action on production databaseschneems2016-01-071-3/+3
| | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* Internal test migrations use the private 'Current' versionMatthew Draper2015-12-151-2/+2
| | | | | | | | Apart from specific versioning support, our tests should focus on the behaviour of whatever version they're accompanying, regardless of when they were written. Application code should *not* do this.
* Fix failing test using custom file watcherMatthew Erhard2015-12-021-0/+2
| | | | | | | LoadingTest#test_does_not_reload_constants_on_development_if_custom_file_watcher_always_returns_false in railties/test/application/loading_test.rb is failing with: `NoMethodError: undefined method 'execute' for #<#<Class:0x00000002465a30>:0x00000001f79698>` The test creates an anonymous class to be used as a custom file watcher using `config.file_watcher=`. Per the Rails guides for Configuring, the class set to `config.file_watcher` “Must conform to ActiveSupport::FileUpdateChecker API”. Per the docs for ActiveSupport::FileUpdateChecker, the API depends on four methods: #initialize, #updated?, #execute, and #execute_if_updated. The custom file watcher in the failing test only implements the first two methods. This pull request adds #execute and #execute_if_updated to the custom file_watcher, conforming it to the ActiveSupport::FileUpdateChecker API, and passing the test.
* Fix constant in void context warningsAndrew White2015-05-051-2/+2
|
* actually autoload all second-level directories called `app/*/concerns`Alex Robbin2014-12-261-0/+29
|
* Use block instead passing as argumentRafael Mendonça França2013-07-021-1/+1
|
* Calls to the application constant have been refactored to usewangjohn2013-06-101-1/+1
| | | | | Rails.application when drawing routes and creating other configurations on the application.
* clearing autoloaded constants triggers routes reloading [Fixes #10685]Xavier Noria2013-06-061-1/+34
| | | | | Conflicts: railties/test/application/loading_test.rb
* Removing use of subclassed application constant and instead using thewangjohn2013-06-031-11/+11
| | | | | more agnostic Rails.application syntax. This means tests will be more portable, and won't rely on the existence of a particular subclass.
* Use Ruby 1.9 Hash syntax in railtiesRobin Dupret2012-10-141-14/+14
|
* Remove all references to attr_accessible/protected and old ↵Guillermo Iguaran2012-09-161-1/+0
| | | | mass_assignment_sanitizers
* Remove default match without specified methodJose and Yehuda2012-04-241-8/+8
| | | | | | | | | | | | | | | | In the current router DSL, using the +match+ DSL method will match all verbs for the path to the specified endpoint. In the vast majority of cases, people are currently using +match+ when they actually mean +get+. This introduces security implications. This commit disallows calling +match+ without an HTTP verb constraint by default. To explicitly match all verbs, this commit also adds a :via => :all option to +match+. Closes #5964
* Rails.initialized? can be called at any time without raising an exception ↵Franck Verrot2012-03-281-0/+10
| | | | | | | | | | [Closes #2507] Changes: * `Rails.initialized=` has been removed * `Rails.initialized?` and `Rails.application.initialized?` are now * delegating to `MyApp::Application.initialized?`
* Simplify helpers handling. Ensure Metal can run AC hooks.José Valim2012-03-151-1/+30
|
* Now all the models need to explicitly declare the accessible attributesRafael Mendonça França2012-03-041-0/+1
|
* Fix railties testsPiotr Sarnacki2012-01-151-4/+4
| | | | | SchemaMigration model is loaded on rails initialization, which means that it will not be cleaned on each request.
* convert railties to use AS::TestCaseAaron Patterson2012-01-051-1/+1
|
* Clean up the cache before the request in case we are running in the ↵José Valim2011-12-151-3/+51
| | | | reload_classes_only_on_change schema.
* FileUpdateChecker should be able to handle deleted files.José Valim2011-12-131-0/+32
|
* Add config.file_watcher so developers can provide their own watchers (for ↵José Valim2011-12-131-3/+79
| | | | instance, hooking on fsevents).
* Speed up development by only reloading classes if dependencies files changed.José Valim2011-12-121-0/+1
| | | | | | | | This can be turned off by setting `config.reload_classes_only_on_change` to false. Extensions like Active Record should add their respective files like db/schema.rb and db/structure.sql to `config.watchable_files` if they want their changes to affect classes reloading. Thanks to https://github.com/paneq/active_reload and Pastorino for the inspiration. <3
* Solve the RAILS_ENV problem in the railties tests in a more generic wayJon Leighton2011-06-061-3/+1
|
* loading_test.rb with RAILS_ENV=developmentArun Agrawal2011-06-061-0/+6
|
* Removed deprecated router API from railtiesPiotr Sarnacki2010-09-051-1/+1
|
* Ensure that Rails.application.initialize! is called only oncePiotr Sarnacki2010-09-031-0/+5
|
* Allow Engines loading its own environment file from config/environmentsPiotr Sarnacki2010-09-031-0/+17
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-3/+3
| | | | 's/[ \t]*$//' -i {} \;)
* Push a failing test for issues [#4994] and [#5003].José Valim2010-06-291-1/+14
|
* Clear DescendantsTracker on each request.José Valim2010-06-191-0/+73