aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
Commit message (Collapse)AuthorAgeFilesLines
...
* Add test case that configure ↵yuuji.yaginuma2018-05-201-0/+17
| | | | | | `config.action_view.finalize_compiled_template_methods` Follow up of #32418.
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-133-3/+3
| | | | Follow up of #32605.
* Fix typo on method nameAlberto Almagro2018-04-201-1/+1
|
* Replace `assert !` with `assert_not`Daniel Colson2018-04-198-12/+12
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Fix test to allow IF NOT EXISTS in structure:dumputilum2018-04-161-2/+2
| | | | | | | | | | | | | | | | | | Before: ``` $ ruby -v ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] $ ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib -I../actionview/lib -I../activemodel/lib test/application/rake/multi_dbs_test.rb Run options: --seed 28744 F Failure: ApplicationTests::RakeTests::RakeMultiDbsTest#test_db:migrate_and_db:structure:dump_and_db:structure:load_works_on_all_databases [test/application/rake/multi_dbs_test.rb:70]: Expected /CREATE TABLE \"books\"/ to match "CREATE TABLE IF NOT EXISTS \"schema_migrations\" (\"version\" varchar NOT NULL PRIMARY KEY);\nCREATE TABLE IF NOT EXISTS \"ar_internal_metadata\" (\"key\" varchar NOT NULL PRIMARY KEY, \"value\" varchar, \"created_at\" datetime NOT NULL, \"updated_at\" datetime NOT NULL);\nCREATE TABLE IF NOT EXISTS \"books\" (\"id\" integer PRIMARY KEY AUTOINCREMENT NOT NULL, \"title\" varchar, \"created_at\" datetime NOT NULL, \"updated_at\" datetime NOT NULL);\nCREATE TABLE sqlite_sequence(name,seq);\nINSERT INTO \"schema_migrations\" (version) VALUES\n('20180416201805');\n\n\n". ```
* Add multidb application testeileencodes2018-04-091-0/+164
| | | | | | | | | I realized I wasn't really testing some of the new rake tasks added so I built out this new test that uses a multi-db database.yml and allows us to run create/drop/migrate/schema:dump/schema:load and those that are namespaced like create:animals. This will make our testing more robust so we can catch problems quicker and set a good place to add future tests as these features evolve.
* Merge pull request #32441 from composerinteralia/refute-notRafael França2018-04-041-1/+1
|\ | | | | Add custom RuboCop for `assert_not` over `refute`
| * Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-031-1/+1
| | | | | | | | | | | | 73e7aab behaved as expected on codeship, failing the build with exactly these RuboCop violations. Hopefully `rubocop -a` will have been enough to get a passing build!
* | Fix RenderingTest in railtieYoshiyuki Hirano2018-04-041-1/+1
| | | | | | | | Test class name is not `RoutingTest` but `RenderingTest`
* | Merge pull request #32065 from ↵Kasper Timm Hansen2018-04-022-2/+2
|\ \ | |/ |/| | | | | sikachu/move-SourceAnnotationExtractor-under-rails-namespec Move SourceAnnotationExtractor under Rails module
| * Move SourceAnnotationExtractor under Rails modulePrem Sichanugrist2018-03-222-2/+2
| | | | | | | | This class should be under Rails module as it belongs to Rails.
* | Deriving `secret_key_base` breaks `key_generator` defined in 5.1.Yoshiyuki Kinjo2018-03-311-0/+1
|/ | | | | | | | | | | If one created Rails 5.1 app and then updated to 5.2, `secret_key_base` defined in `config/secrets.yml` is ignored for `development` and `test` environment. A change in `secret_key_base` in turn breaks `Rails.application.key_generator`. If one encrypt data in Rails 5.1, she cannot decrypt it in Rails 5.2 for `development` and `test` environment.
* Pass the skip_pipeline option in image_submit_tagAndrew White2018-03-141-1/+2
| | | | Fixes #32248.
* Add --expanded option to "rails routes"Benoit Tigeot2018-02-281-40/+0
| | | | | | | | | | | | | | | | | | | | | | | | | When using rails routes with small terminal or complicated routes it can be very difficult to understand where is the element listed in header. psql had the same issue, that's why they created "expanded mode" you can switch using `\x` or by starting psql with ``` -x --expanded Turn on the expanded table formatting mode. This is equivalent to the \x command. ``` The output is similar to one implemented here for rails routes: db_user-# \du List of roles -[ RECORD 1 ]---------------------------------------------- Role name | super Attributes | Superuser, Create role, Create DB Member of | {} -[ RECORD 2 ]---------------------------------------------- Role name | role Attributes | Superuser, Create role, Create DB, Replication Member of | {}
* Merge pull request #32121 from benoittgt/move-rails-routes-to-rails-commandRafael França2018-02-271-111/+0
|\ | | | | Move rake routes task to rails command
| * Move rake routes task to rails commandBenoit Tigeot2018-02-271-111/+0
| | | | | | | | | | | | After a discussion with matthewd. It was mentioned that rake tasks need to be moved to rails command. See: https://github.com/rails/rails/issues/32117
* | Don't enforce UTF-8 by defaultAndrew White2018-02-271-5/+31
|/ | | | | | With the disabling of TLS 1.0 by most major websites, continuing to run IE8 or lower becomes increasingly difficult so default to not enforcing UTF-8 encoding as it's not relevant to other browsers.
* 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.
* Remove trailing semi-colon from CSPAndrew White2018-02-191-6/+6
| | | | | | | | | Although the spec[1] is defined in such a way that a trailing semi-colon is valid it also doesn't allow a semi-colon by itself to indicate an empty policy. Therefore it's easier (and valid) just to omit it rather than to detect whether the policy is empty or not. [1]: https://www.w3.org/TR/CSP2/#policy-syntax
* Don't accidentally create an empty CSPAndrew White2018-02-191-2/+28
| | | | | | Setting up the request environment was accidentally creating a CSP as a consequence of accessing the option - only set the instance variable if a block is passed.
* Revert "Merge pull request #32045 from eagletmt/skip-csp-header"Andrew White2018-02-191-1/+1
| | | | | | | | | This reverts commit 86f7c269073a3a9e6ddec9b957deaa2716f2627d, reversing changes made to 5ece2e4a4459065b5efd976aebd209bbf0cab89b. If a policy is set then we should generate it even if it's empty. However what is happening is that we're accidentally generating an empty policy when the initializer is commented out by default.
* Skip generating empty CSP header when no policy is configuredKohei Suzuki2018-02-181-1/+1
| | | | | | | | `Rails.application.config.content_security_policy` is configured with no policies by default. In this case, Content-Security-Policy header should not be generated instead of generating the header with no directives. Firefox also warns "Content Security Policy: Couldn't process unknown directive ''".
* Multipart file uploads are very rare in API only apps so don't include ↵Guillermo Iguaran2018-02-171-2/+1
| | | | Rack::TemfileReaper in default middleware stack for API only apps
* Merge pull request #32002 from y-yagi/fix_set_serializerRafael França2018-02-171-0/+12
|\ | | | | Fix custome serializer setting
| * Fix custome serializer settingYuji Yaginuma2018-02-161-0/+12
| | | | | | | | | | | | | | | | The serializer should be set up in `after_initialize` so that it work properly even if the user specifies serializer with initializers. Also, since `custom_serializers` is `Array`, it needs to be flattened before setting the value.
* | Remove needless printyuuji.yaginuma2018-02-171-1/+0
| | | | | | | | It seems to debug print.
* | Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-162-8/+6
| | | | | | | | | | Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
* | Add test parallelization to Railseileencodes2018-02-152-4/+83
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides both a forked process and threaded parallelization options. To use add `parallelize` to your test suite. Takes a `workers` argument that controls how many times the process is forked. For each process a new database will be created suffixed with the worker number; test-database-0 and test-database-1 respectively. If `ENV["PARALLEL_WORKERS"]` is set the workers argument will be ignored and the environment variable will be used instead. This is useful for CI environments, or other environments where you may need more workers than you do for local testing. If the number of workers is set to `1` or fewer, the tests will not be parallelized. The default parallelization method is to fork processes. If you'd like to use threads instead you can pass `with: :threads` to the `parallelize` method. Note the threaded parallelization does not create multiple database and will not work with system tests at this time. parallelize(workers: 2, with: :threads) The threaded parallelization uses Minitest's parallel exector directly. The processes paralleliztion uses a Ruby Drb server. For parallelization via threads a setup hook and cleanup hook are provided. ``` class ActiveSupport::TestCase parallelize_setup do |worker| # setup databases end parallelize_teardown do |worker| # cleanup database end parallelize(workers: 2) end ``` [Eileen M. Uchitelle, Aaron Patterson]
* Add Rack::TempfileReaper to tests and docsGeorge Claghorn2018-01-301-2/+4
|
* Remove extra whitespaceDaniel Colson2018-01-252-7/+7
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-255-11/+11
|
* Change refute to assert_notDaniel Colson2018-01-251-1/+1
|
* Use respond_to test helpersDaniel Colson2018-01-253-5/+5
|
* Add locale selector to email preview (#31596)Hitoshi Nakashima2018-01-181-6/+62
| | | | - Add set_locale to detect suitable locale - Make feature compatible with Rails 5.x
* Add test to properly test down with a blockeileencodes2018-01-181-0/+8
| | | | | | | | | | | | down is only called with a block from the rake tasks where it passes a `SCOPE`. Technically this was tested but since we don't run all the migrations we're not actually testing the down works with a `SCOPE`. To ensure we're testing both we can run `db:migrate` again to migrate users and then run `down` with a scope to test that only the bukkits migration is reverted. Updates test to prevent having to fix regressions like we did in 4d4db4c.
* Refactor migration to move migrations paths to connectioneileencodes2018-01-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rails has some support for multiple databases but it can be hard to handle migrations with those. The easiest way to implement multiple databases is to contain migrations into their own folder ("db/migrate" for the primary db and "db/seconddb_migrate" for the second db). Without this you would need to write code that allowed you to switch connections in migrations. I can tell you from experience that is not a fun way to implement multiple databases. This refactoring is a pre-requisite for implementing other features related to parallel testing and improved handling for multiple databases. The refactoring here moves the class methods from the `Migrator` class into it's own new class `MigrationContext`. The goal was to move the `migrations_paths` method off of the `Migrator` class and onto the connection. This allows users to do the following in their `database.yml`: ``` development: adapter: mysql2 username: root password: development_seconddb: adapter: mysql2 username: root password: migrations_paths: "db/second_db_migrate" ``` Migrations for the `seconddb` can now be store in the `db/second_db_migrate` directory. Migrations for the primary database are stored in `db/migrate`". The refactoring here drastically reduces the internal API for migrations since we don't need to pass `migrations_paths` around to every single method. Additionally this change does not require any Rails applications to make changes unless they want to use the new public API. All of the class methods from the `Migrator` class were `nodoc`'d except for the `migrations_paths` and `migrations_path` getter/setters respectively.
* Use SHA-1 for non-sensitive digests by defaultEugene Kenny2018-01-082-7/+15
| | | | | | Instead of providing a configuration option to set the hash function, switch to SHA-1 for new apps and allow upgrading apps to opt in later via `new_framework_defaults_5_2.rb`.
* Allow use_authenticated_message_encryption to be set in ↵Eugene Kenny2018-01-071-3/+27
| | | | | | | | | | new_framework_defaults_5_2.rb Enabling this option in new_framework_defaults_5_2.rb didn't work before, as railtie initializers run before application initializers. Using `respond_to?` to decide whether to set the option wasn't working either, as `ActiveSupport::OrderedOptions` responds to any message.
* Improve the deprecation message for using subclass of Rails::Application to ↵Prathamesh Sonpatki2018-01-071-1/+1
| | | | start the Rails server
* Ensure to use repo's Gemfile in applicationyuuji.yaginuma2017-12-251-0/+5
| | | | | | | | | Puma gets bundler's info from `Bundler::ORIGINAL_ENV` for restart. https://github.com/puma/puma/blob/f6f3892f4d82638fb7a2a57d993641b1486ee88a/lib/puma/launcher.rb#L168 So, specified `BUNDLE_GEMFILE` env for use same Gemfile in the restart. Fixes #31351
* Merge pull request #31520 from yahonda/introduce_frozen_error_classRyuta Kamizono2017-12-201-1/+1
|\ | | | | Handle `FrozenError` if it is available
| * Handle `FrozenError` if it is availableYasuo Honda2017-12-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pull request handles `FrozenError` introduced by Ruby 2.5. Refer https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/61131 Since `FrozenError` is a subclass of `RuntimeError` minitest used by master branch can handle it, though it would be better to handle `FrozenError` explicitly if possible. `FrozenError` does not exist in Ruby 2.4 or lower, `frozen_error_class` handles which exception is expected to be raised. This pull request is intended to be merged to master, then backported to `5-1-stable` to address #31508
* | Add test case that configure `config.active_support.hash_digest_class`yuuji.yaginuma2017-12-201-0/+18
|/ | | | Follow up of #31289.
* Raise an error only when `require_master_key` is specifiedyuuji.yaginuma2017-12-181-0/+8
| | | | | | | | | To prevent errors from being raise in environments where credentials is unnecessary. Context: https://github.com/rails/rails/issues/31283#issuecomment-348801489 Fixes #31283
* Merge pull request #26815 from olivierlacan/log-query-sourceEileen M. Uchitelle2017-12-142-4/+11
|\ | | | | Log the original call site for an ActiveRecord query
| * Log call site for all queriesOlivier Lacan2017-12-132-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new ActiveRecord configuration option allows you to easily pinpoint what line of application code is triggering SQL queries in the development log by appending below each SQL statement log the line of Ruby code that triggered it. It’s useful with N+1 issues, and to locate stray queries. By default this new option ignores Rails and Ruby code in order to surface only callers from your application Ruby code or your gems. It is enabled on newly generated Rails 5.2 applications and can be enabled on existing Rails applications: ```ruby Rails.application.configure do # ... config.active_record.verbose_query_logs = true end ``` The `rails app:upgrade` task will also add it to `config/development.rb`. This feature purposely avoids coupling with ActiveSupport::BacktraceCleaner since ActiveRecord can be used without ActiveRecord. This decision can be reverted in the future to allow more configurable backtraces (the exclusion of gem callers for example).
* | Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-2/+2
|/ | | | Follow up of #31432.
* Expose Active Storage routesMehmet Emin INAC2017-12-131-13/+32
|
* Set the Rails environment from an environment variableAaron Patterson2017-12-081-1/+1
| | | | | | | | | Option parsing happens too late to have any impact on the Rails environment. Rails accesses the environment name and memoizes it too early in the boot process for a commandline option to have any impact on the database connection, so we'll change this test to set the environment from an environment variable (and ensure it still works when running tests with `ruby`)
* Add failing test for wrong database connectionAaron Patterson2017-12-081-0/+17
| | | | | | When tests are run with just `ruby`, the RAILS_ENV is set to `development` too early, and we connect to the development database rather than the test database.