aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Merge pull request #32289 from gsamokovarov/did-you-mean-suggestionsGuillermo Iguaran2018-03-293-5/+5
|\ | | | | Use `did_you_mean` spell checker for option suggestions
| * Use `did_you_mean` spell checker for option suggestionsGenadi Samokovarov2018-03-233-5/+5
| | | | | | | | | | | | | | | | | | | | | | Now that we require Ruby over `2.3`, we can replace the current suggestion methods we have with tooling from the `did_you_mean` gem. There is a small user visible change and this is that we now offer a single suggestion for misspelled options. We are suggesting fixes during generator invocation and during a mistyped rails server rack handler. In both cases, if we don't make a proper prediction on the first match, we won't do so in the second or third one, so in my mind, this is okay.
* | Fix `test_config_another_database` failureRyuta Kamizono2018-03-221-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | Somehow `test_config_another_database` didn't fail on CI, but it will fail locally. https://travis-ci.org/rails/rails/jobs/356212950#L2474-L2482 ``` % bundle exec ruby -w -Itest test/generators/app_generator_test.rb -n test_config_another_database Run options: -n test_config_another_database --seed 7260 # Running: F Failure: AppGeneratorTest#test_config_another_database [test/generators/app_generator_test.rb:417]: Expected /^\s*gem\s+["']mysql2["'], '~> 0.4.4'$*/ to match "source 'https://rubygems.org'\ngit_source(:github) { |repo| \"https://github.com/\#{repo}.git\" }\n\nruby '2.5.0'\n\n# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\ngem 'rails', '~> 6.0.0.alpha'\n# Use mysql as the database for Active Record\ngem 'mysql2', '>= 0.4.4', '< 0.6.0'\n# Use Puma as the app server\ngem 'puma', '~> 3.11'\n# Use SCSS for stylesheets\ngem 'sass-rails', '~> 5.0'\n# Use Uglifier as compressor for JavaScript assets\ngem 'uglifier', '>= 1.3.0'\n# See https://github.com/rails/execjs#readme for more supported runtimes\n# gem 'mini_racer', platforms: :ruby\n\n# Use CoffeeScript for .coffee assets and views\ngem 'coffee-rails', '~> 4.2'\n# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks\ngem 'turbolinks', '~> 5'\n# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\ngem 'jbuilder', '~> 2.5'\n# Use Redis adapter to run Action Cable in production\n# gem 'redis', '~> 4.0'\n# Use ActiveModel has_secure_password\n# gem 'bcrypt', '~> 3.1.7'\n\n# Use ActiveStorage variant\n# gem 'mini_magick', '~> 4.8'\n\n# Use Capistrano for deployment\n# gem 'capistrano-rails', group: :development\n\n# Reduces boot times through caching; required in config/boot.rb\ngem 'bootsnap', '>= 1.1.0', require: false\n\ngroup :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\nend\n\ngroup :development do\n # Access an interactive console on exception pages or by calling 'console' anywhere in the code.\n gem 'web-console', '>= 3.3.0'\n gem 'listen', '>= 3.0.5', '< 3.2'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\n gem 'spring-watcher-listen', '~> 2.0.0'\nend\n\ngroup :test do\n # Adds support for Capybara system testing and selenium driver\n gem 'capybara', '>= 2.15', '< 4.0'\n gem 'selenium-webdriver'\n # Easy installation and use of chromedriver to run system tests with Chrome\n gem 'chromedriver-helper'\nend\n\n# Windows does not include zoneinfo files, so bundle the tzinfo-data gem\ngem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n". bin/rails test test/generators/app_generator_test.rb:411 Finished in 0.174681s, 5.7247 runs/s, 34.3483 assertions/s. 1 runs, 6 assertions, 1 failures, 0 errors, 0 skips ```
* Pass the skip_pipeline option in image_submit_tagAndrew White2018-03-141-1/+2
| | | | Fixes #32248.
* Rely on Rails::Command's help output.Kasper Timm Hansen2018-03-131-57/+58
| | | | | | | | | | | | | | | | | | | | | We end up with: ``` Usage: bin/rails routes [options] Options: -c, [--controller=CONTROLLER] # Filter by a specific controller, e.g. PostsController or Admin::PostsController. -g, [--grep=GREP] # Grep routes by a specific pattern. -E, [--expanded], [--no-expanded] # Print routes expanded vertically with parts explained. ``` which does miss the bit about routes being printed in order. Also: * Renames options to ease help output readability, then clarifies each option. * Fixes a bunch of indentation.
* Merge pull request #32160 from bogdanvlviv/improve-rails-routes-expandedKasper Timm Hansen2018-03-111-38/+47
|\ | | | | Draw line of a route name to the end of row console on `rails routes --expanded`
| * Draw line of a route name to the end of row console on `rails routes --expanded`bogdanvlviv2018-03-051-38/+47
| | | | | | | | | | | | | | In order to get width of console use `IO::console_size`, See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size Related to #32130
* | Remove extra arg passed to `Rails::Command::RoutesTest#run_routes_command`bogdanvlviv2018-03-051-1/+1
|/ | | | Related to 6bd33d66dde015a55912af20b469788ba20ddb4e
* Fix "NameError: undefined local variable or method `host'"yuuji.yaginuma2018-03-051-0/+6
| | | | The `host` and `port` can't use this context.
* Merge pull request #32058 from gsamokovarov/rails-server-x-optionKasper Timm Hansen2018-03-042-4/+39
|\ | | | | Introduce explicit rails server handler option
| * Extract Rails::Command::SpellcheckerGenadi Samokovarov2018-03-041-0/+10
| |
| * Introduce explicit rails server handler optionGenadi Samokovarov2018-03-041-4/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I mistype `rails server production` instead of `rails server -e production` expecting to lunch a server in the production environment all the time. However, the signature of `rails server --help` is: ``` Usage: rails server [puma, thin etc] [options] ``` This means that the `production` argument is being interpreted as a Rack server handler like Puma, Thin or Unicorn. Should we argue for the `rails server production`? I'm not sure of the reasons, but the `rails console production` behavior was deprecated in: https://github.com/rails/rails/pull/29358, so parity with the existing `rails console production` usage may not hold anymore. In any case, this PR introduces an explicit option for the Rack servers configuration. The option is called `--using` (or `-u` for short) to avoid the `rails server --server` tantrum. The new interface of `rails server` is: ``` Usage: rails server [using] [options] Options: -p, [--port=port] # Runs Rails on the specified port - defaults to 3000. -b, [--binding=IP] # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'. -c, [--config=file] # Uses a custom rackup configuration. # Default: config.ru -d, [--daemon], [--no-daemon] # Runs server as a Daemon. -e, [--environment=name] # Specifies the environment to run this server under (development/test/production). -u, [--using=name] # Specifies the Rack server used to run the application (thin/puma/webrick). -P, [--pid=PID] # Specifies the PID file. # Default: tmp/pids/server.pid -C, [--dev-caching], [--no-dev-caching] # Specifies whether to perform caching in development. [--early-hints], [--no-early-hints] # Enables HTTP/2 early hints. ``` As a bonus, if you mistype the server to use, you'll get an auto-correction message: ``` $ rails s tin Could not find handler "tin". Maybe you meant "thin" or "cgi"? Run `rails server --help` for more options. ```
* | Fix routes command tests broken in e137831726.Kasper Timm Hansen2018-03-041-23/+16
|/
* Clean up `RoutesTest` a bityuuji.yaginuma2018-03-011-8/+6
| | | | | | * Remove unused require * Remove redundant `test` * Change `rake` to `rails`
* Add --expanded option to "rails routes"Benoit Tigeot2018-02-282-40/+47
| | | | | | | | | | | | | | | | | | | | | | | | | 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-272-111/+127
|\ | | | | Move rake routes task to rails command
| * Move rake routes task to rails commandBenoit Tigeot2018-02-272-111/+127
| | | | | | | | | | | | 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-272-8/+34
|/ | | | | | 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.
* Improve generated file `app/assets/javascripts/application.js` of pluginbogdanvlviv2018-02-231-1/+5
| | | | | | Add `//= require rails-ujs` Closes #32094
* Improve generated file `app/views/application.html.erb` of pluginbogdanvlviv2018-02-231-0/+9
| | | | | - Do not generate `javascript_include_tag` if `--skip-javascript` - Generate `<%= csp_meta_tag %>`. Related to #32018.
* 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
|