aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
Commit message (Collapse)AuthorAgeFilesLines
...
* Comment `require "active_storage/engine"` in `bin/rails` of plugin if ↵bogdanvlviv2018-02-231-1/+2
| | | | `--skip-active-storage`
* Add cop for preferring 'Foo.method' over 'Foo::method'Andrew White2018-02-222-2/+2
|
* Do not add routes when actions are not specifiedYuji Yaginuma2018-02-221-0/+7
| | | | | | | | | | Since #30241, if namepsace is specified, routes will be generated even if there is no actions. However, it seems that this behavior is not intentionally added behavior. As with 5.1, routes should not be generated if actions are not specified. Fixes #32072.
* Ensure that `mini_magick` is absent after `rails new` with ↵bogdanvlviv2018-02-201-8/+9
| | | | | | | | | | `--skip-active-storage` Remove redundant assertions of an absence of `mini_magick` in `Gemfile` since `bin/rails app:update` does not update Gemfile. This assertions was added by 4a835aa3236eedb135ccf8b59ed3c03e040b8b01, after reviewing of https://github.com/rails/rails/pull/32049 i realized that assertions are redundant.
* 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.
* rubocop single space after assignmentDixit Patel2018-02-191-1/+1
|
* Fix test method nameGuillermo Iguaran2018-02-181-1/+1
|
* Don't generate empty app/views folder when --api and --skip-action-mailer ↵Guillermo Iguaran2018-02-181-0/+17
| | | | | | | are used together The purpose of keeping app/views folder in API apps is that it's used for mailer views so doesn't makes sense to keep it when Action Mailer is skipped.
* Clean up reporter replacement a bit.Kasper Timm Hansen2018-02-181-19/+23
| | | | | | | | | | | | * Don't use :: for class methods, we don't do that elsewhere. * Don't install a needless method on minitest. Prefer assigning the reporter anyway as that's what minitest does internally. * Don't bother opting out when the reporter ain't a Minitest::CompositeReporter. It's hardcoded: https://github.com/seattlerb/minitest/blob/005a3ba42c07d04797e2d00ac2c53e3be127c12f/lib/minitest.rb#L125 And overrides have to create delegate reporters: https://github.com/kern/minitest-reporters/blob/1018b1b42f34b01d4de179c8aad2fa06771fe9b0/lib/minitest/minitest_reporter_plugin.rb#L72
* 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.
* | Merge pull request #31901 from Kevinrob/patch-1Rafael França2018-02-161-0/+38
|\ \ | | | | | | Use SuppressedSummaryReporter and Rails::TestUnitReporter only if needed
| * | Add SuppressedSummaryReporter and TestUnitReporter only if necessaryKevin Robatel2018-02-151-0/+38
| |/
* | 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-163-26/+23
| | | | | | | | | | 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-153-5/+89
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* Don't overwrite config/master.key even on --forceclaudiob2018-02-121-1/+2
| | | | | | | | | | | | See https://github.com/rails/rails/pull/31957#issuecomment-364817423 The purpose of `--force` is not to have any prompt whether a file should be kept or overwritten. In general, all existing files should be overwritten. However, `config/master.key` is special because it is git-ignored, and overwriting it will cause the app not to run (since there won't be a way to decrypt the credentials). As a result, it's probably better to keep the existing config/master.key.
* Do not update `load_defaults` version when running `app:update` (#31951)Yuji Yaginuma2018-02-131-0/+15
| | | | | Incompatible settings are included in the settings set by `load_defaults`. So, I think that target version should be updated by a user when becomes available, and should not be updated with `app:update`.
* Respect --force option for config/master.keyclaudiob2018-02-111-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to #30700 which ensures the `--quiet` option of `rails new` is respected by the `MasterKeyGenerator` (missing from #30067). Before this commit, running `rails new app --force` would still prompt the user what to do with the conflict in `config/master.key`: ``` … identical config/locales/en.yml conflict config/master.key Overwrite /Users/claudiob/Desktop/pizza/config/master.key? (enter "h" for help) [Ynaqdh] ``` After this commit, `config/master.key` is overwritten: ``` … identical config/locales/en.yml force config/master.key append .gitignore ``` The newly added test generates an app and then generates it again with `--force`. Without this commit, the test would just wait forever for user input.
* Do not add master key when `RAILS_MASTER_KEY` env specified (#31922)Yuji Yaginuma2018-02-082-0/+24
| | | Fixes #31917
* Add Rack::TempfileReaper to tests and docsGeorge Claghorn2018-01-301-2/+4
|
* Remove extra whitespaceDaniel Colson2018-01-252-7/+7
|
* Use assert_empty and assert_not_emptyDaniel Colson2018-01-251-1/+1
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-2511-39/+39
|
* 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-182-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #31651 from eugeneius/use_sha1_digestsSean Griffin2018-01-122-7/+15
|\ | | | | Use SHA-1 for non-sensitive digests by default
| * 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`.
* | Merge pull request #31671 from larskanis/pg-1.0Rafael Mendonça França2018-01-111-1/+1
|\ \ | | | | | | | | | PostgreSQL: Allow pg-1.0 gem to be used with ActiveRecord
| * | PostgreSQL: Allow pg-1.0 gem to be used with ActiveRecordLars Kanis2018-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pg-1.0.0 is just released and most Gemfiles don't restrict it's version. But the version is checked when connecting to the database, which leads to the following error: Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0 See also this pg issue: https://bitbucket.org/ged/ruby-pg/issues/270/pg-100-x64-mingw32-rails-server-not-start Preparation for pg-1.0 was done in commit f28a331023fab, but the pg version constraint was not yet relaxed.
* | | Merge pull request #31624 from y-yagi/fix_minitest_511Aaron Patterson2018-01-101-4/+4
|\ \ \ | |/ / |/| | Add support for Minitest 5.11
| * | Need to use `klass` to get the class name of the test resultyuuji.yaginuma2018-01-031-5/+4
| | | | | | | | | | | | Ref: http://docs.seattlerb.org/minitest/Minitest/Result.html#attribute-i-klass
| * | Correctly get source locationyuuji.yaginuma2018-01-031-0/+1
| | | | | | | | | | | | | | | `filtered_results` returns an instance of `Minitest::Result` since https://github.com/seattlerb/minitest/commit/00433fc0a4fdd0e6b302aace633384ba13122376 `Minitest::Result` is not test class. So cannot get location directly.
* | | Clean up railties testsbogdanvlviv2018-01-102-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove `AppGeneratorTest#test_active_storage_install`. The test is added by 67db41aa7f17c2d34eb5a914ac7a6b2574930ff4, since #31534 this test doesn't test anything. Remove redundant assertions in `SharedGeneratorTests`. These assertions is added by 4a835aa3236eedb135ccf8b59ed3c03e040b8b01. Follows 67db41aa7f17c2d34eb5a914ac7a6b2574930ff4, #31534.
* | | Merge pull request #31534 from claudiob/kaspth-approachKasper Timm Hansen2018-01-091-2/+2
|\ \ \ | |_|/ |/| | Don't include Active Storage migrations in new apps
| * | Don't run rails active_storage:install in new appsclaudiob2017-12-141-2/+2
| | | | | | | | | | | | See #31315 for full discussion
* | | 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
* | Remove unused methodsyuuji.yaginuma2017-12-281-16/+0
| | | | | | | | | | * `assert_header` and `assert_body` were unused since 6f6a589. * `assert_success` and `assert_missing` were unused since added.
* | Prevent to install gems when run test (#31564)Yuji Yaginuma2017-12-262-4/+12
| | | | | | | | | | | | `invoke_all` cause `bundle install`. This will install gems actually defined in `Gemfile`. To avoid this, stubbed `bundle_command`. Fixes #31557
* | 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
* | Move `test_skip_bundle` to `AppGeneratorTest`yuuji.yaginuma2017-12-242-9/+9
| | | | | | | | `skip_bundle` option was removed from plugin generator in 9b72fcc3c22a6f75f37f52dd6cb682bc00c51cf0.
* | Merge pull request #31520 from yahonda/introduce_frozen_error_classRyuta Kamizono2017-12-202-1/+5
|\ \ | | | | | | Handle `FrozenError` if it is available