Commit Graph

12490 Commits

Author SHA1 Message Date
Rafael França
d4ea114bd6
Merge pull request #33308 from anniecodes/notes-command-changelog
Add rake notes and SOURCE_ANNOTATION_DIRECTORIES deprecation to Changelog
2018-07-09 11:41:33 -04:00
Annie-Claude Côté
a028d3f775 Add deprecations related to rails notes command to Changelog
* SOURCE_ANNOTATION_DIRECTORIES deprecation
* Deprecation of `rake notes`, use `rails notes` instead
* Deprecation of `rails notes:custom ANNOTATION=custom`, `rails notes:optimize`, `rails notes:todo`, and `rails notes:fixme` in favor of passing `-annotations` or `-a` to `rails notes`
* They have all  been deprecrated in https://github.com/rails/rails/pull/33220
2018-07-09 11:20:28 -04:00
Kasper Timm Hansen
50a9ca665d
Merge pull request #28266 from Stellenticket/allow_disable_server_stdout_logging
rails server: Allow to explicitly specify whether to output Rails's log to stdout
2018-07-08 20:01:45 +02:00
bogdanvlviv
c5cee6cb9b
Fix rubocop offense introduced in 161ed37
We prefer double quotes over single quotes.

Fixes:
```
railties/lib/rails/commands/server/server_command.rb:279:39:
C: Style/StringLiterals: Prefer double-quoted strings unless you need
single quotes to avoi d extra backslashes for escaping.
            original_options.concat [ '-u', using ]
```

Related to 161ed37d7120e1f391eed19e49a3390e53e4fe91
2018-07-08 18:37:10 +03:00
Markus Doits
889a7ccf08
Allow to explicitly specify whether to output Rails' log to stdout
Before Rails' logger output is mirrored to std out if:

* environment is development and
* the process is not daemonized

It was not possible to change that behaviour, e.g. to disable log output
in that case or enable it in other cases.

Now you can explicitly disable or enable output with the new command
line switch `--log-to-stdout`, regardless of any other circumstances.

```
// enable output in production
rails server -e production --log-to-stdout

// disable output in development
rails server -e development --no-log-to-stdout
```

Enabling output when daemonized still makes no sense (since tty is
detached), but this is ignored for now.

If the command line flag is not specified, old behaviour still
applies, so this change is completely backward compatible.
2018-07-08 17:28:34 +02:00
Kasper Timm Hansen
1d97b8f9e4
Don't balloon @original_options with --restart on restart.
Our restart_command would pass in `--restart` which means
that if the @original_options already contains --restart
it would keep getting another --restart appended.

Nothing here that would break the bank, but just a nicety.
2018-07-07 10:21:29 +02:00
Kasper Timm Hansen
161ed37d71
Don't show unneeded deprecation warning on server restart.
If booting a server via `rails s -u puma`, we'd convert the
option to a `using` positional.

When using `rails restart` our `restart_command` would the
option converted to the using positional and put that in
the restart command.

Thus we'd show users deprecation warnings for our own code.

Fix that by converting a passed positional to an option instead.

Also: fix initialize method signature. The local_options are an
array, not a hash. But don't even bother assigning defaults as
Thor passes them in.
2018-07-07 10:21:29 +02:00
Kasper Timm Hansen
688e48d93d
Remove restart_command leftover from switching to Thor options.
Ref:
654704247e

Before the commit we had a restart_command in Rails::Server. But after
there's another one in Rails::ServerCommand. The command version of the
method is the right one as it's used in server_options.

Give the leftover method the boot.
2018-07-07 09:41:48 +02:00
Kasper Timm Hansen
b773318f5a
Use only snake cased symbols in commands.
Mixing strings and symbols seems aesthetically less than ideal.

We can also use underscores just fine. Thor converts them to dashes
for the CLI and it makes access in Ruby code nicer.

Here's the `server --help` output after this change:

```
Usage:
  rails server [thin/puma/webrick] [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.
```

See? Quite dashing 
2018-07-07 09:33:11 +02:00
Kasper Timm Hansen
9ecbd64cd9
Merge pull request #32776 from Edouard-chin/ec-as-hooks
Use testing lazy-load hooks
2018-07-05 20:44:53 +02:00
Annie-Claude Côté
7e229f7430 Make NotesCommand tests more performant by getting rid of unecessary map
* Get rid of map and replace it with a multiplication of "\n" to generate document with multiple line preceding the annotation
* Reduce number from 1000 to 100 since it achieves the same goal
* Only keep one test for the multiple lines document since it's unecessary to test multiple times
* Update some language in tests names to make it clearer what we are testing
2018-07-05 10:01:46 -04:00
Kasper Timm Hansen
ba38e13c82
Merge pull request #33220 from anniecodes/notes-command
Adds `Rails::Command::NotesCommand` and makes `rake notes` use it under the hood
2018-07-05 10:32:58 +02:00
Edouard CHIN
2730f10560 Use testing lazy-load hooks:
- In order to avoid loading classes prematurely, let's use lazy load hooks that are now provided with each test case
2018-07-04 16:34:59 -04:00
Annie-Claude Côté
edf5da4b6c Port Annotations rake task to use Rails::NotesCommand
* Invokes the notes Rails::Command and passes the rake task ENV variables as annotations options to it
* Adds a deprecation warning for unsupported commands
* Gets rid of reference to ENV["SOURCE_ANNOTATION_DIRECTORIES"] in SourceAnnotationExtractor since its now dealt with in the NotesCommand
* Gets rid of rake desc for each rake notes task so they are not documented while using `rails -T` or `rails --help`
2018-07-04 14:30:14 -04:00
Annie-Claude Côté
21f7dadbff Adds support to register directories and extensions to NotesCommand
* Require the application and environnement in the notes command in order to load the config files
* Adds tests for both register_directories and register_extensions added to a config file
2018-07-04 14:30:11 -04:00
Annie-Claude Côté
1996fbe2a3 Adds a Rails::Command for Notes
* It is called with `rails notes`
* It defaults to displaying [OPTIMIZE, FIXME and TODO] annotations
* It accepts custom annotations by using `rails notes -a CUSTOM_ANNOTATION OTHER_ANNOTATION`
* It defaults to look for annotations in [app config db lib test] as dictated by SourceAnnotationExtractor
* It supports ENV["SOURCE_ANNOTATION_DIRECTORIES"] but adds a deprecation warning and recommends using register_directories instead
2018-07-04 14:29:35 -04:00
Annie-Claude Côté
1edc7263c8 [ci skip] Update documentation related to rails notes
* Get rid of references to rake notes in the documentation
* Get rid of references to environement variables used in SourceAnnotationExtractor
* Updates the command line guide to reflect the new rails notes API
2018-07-03 21:27:22 -04:00
Alberto Almagro
d9868d9b61 Remove old TODO comment
This TODO comment has been here more than 7 years and doesn't seem to be
a temporary implementation anymore.
2018-07-04 00:16:12 +02:00
Rafael França
cfc48d0b5f
Merge pull request #33054 from jboler/master
Fix route eager loading
2018-07-03 14:04:04 -04:00
Kasper Timm Hansen
350b7cc9f0
Merge pull request #32706 from yhirano55/fix-app-update-when-hyphenated-name-is-given
Fix app:update when hyphenated name is given
2018-07-01 19:05:01 +02:00
utilum
243c856ce9 Fix assignment of TESTOPTS in railties test task
The assignment of `ENV["TESTOPTS"]` to `ARGV`, introduced in
09f9a7a5b, did not take into account passing multiple options,
such as `--verbose --seed=1`. This patch fixes it.
2018-07-01 11:36:17 +02:00
utilum
09f9a7a5b6 Enable TESTOPTS in railties tests
Unlike the other components' test suites, railties' currently
ignores such useful options as `"--verbose"` or `"--name"`.

This patch allows us to use them.
2018-06-26 12:16:23 +02:00
George Claghorn
8888fc03d6
Merge pull request #33191 from bogdanvlviv/change-rails_welcome-image-on-localhost3000
Changes Rails Welcome image on localhost:3000
2018-06-24 15:37:06 -04:00
yuuji.yaginuma
df20bf4aa2 Add an assertion that credentials:edit works when RAILS_MASTER_KEY env is specified 2018-06-24 20:57:41 +09:00
Xavier Noria
96d2c228e3 OS X -> macOS [Closes #30313]
[Jon Moss & Xavier Noria]
2018-06-23 08:46:40 +02:00
bogdanvlviv
a8fec4fb7c
Changes Rails Welcome image on localhost:3000
Note that I used https://www.base64-image.de/ in order to
convert the image to Base64 with enabled optimization status.

Closes #33181.
Closes #33186.
Follow up #32735.
2018-06-22 15:09:53 +03:00
Jonathan Boler
869ba3ec62 Only execute route updater once on app boot 2018-06-19 16:25:39 -05:00
Rafael França
433a312269
Merge pull request #33152 from bogdanvlviv/fix-ruby-version-file
Fix Ruby version in `.ruby-version`
2018-06-18 17:01:19 -04:00
bogdanvlviv
1aace5e2cc
Fix Ruby version in .ruby-version
Since #30016 Rails generates `.ruby-version` file
in order to help Ruby version manager tools like `rbenv`, `rvm`
determine which Ruby version should be used for the current Rails
project.

Since #32649 Rails sets Ruby version to the file compatible with MRI/JRuby
by default.

Pull Request #31496 reports that `.ruby-version` doesn't match ruby version other
than stable version and recommends to use `ENV["RBENV_VERSION"]`, and
`ENV["rvm_ruby_string"]` in order to set correct Ruby version to the file
that `rbenv` or `rvm` can understand.
Also, there is another similar issue that reports the same case if use
JRuby https://github.com/jruby/jruby/issues/5144.

Closes #31496, https://github.com/jruby/jruby/issues/5144.
2018-06-18 19:59:21 +00:00
yuuji.yaginuma
a865f621ee Remove unused require
`optparse` is unused since #26977.
2018-06-18 16:16:00 +09:00
bogdanvlviv
f1de019993
Include ActiveSupport::Testing::MethodCallAssertions in railties/test/isolation/abstract_unit.rb
Related to #33102
2018-06-09 00:00:28 +03:00
Jonathan Boler
3674ccd444 Merge branch 'master' of github.com:rails/rails 2018-06-04 12:59:43 -05:00
Jonathan Boler
e7758b8b68 Eager load routes on rebuild 2018-06-04 12:56:36 -05:00
yuuji.yaginuma
f7fd680a6d Remove unnecessary test
Since #32289, `Spellchecker.suggest` returns only one value, multiple
suggestions not output.
2018-06-03 20:53:05 +09:00
Rafael Mendonça França
49df9043c6
Merge pull request #30406 from eliotsykes/reduce-spring-watch-calls
Minimize Spring.watch calls
2018-05-23 17:26:09 -04:00
utilum
a48f6a5d9f Enable warnings in all test tasks
Also normalize AJ task use t, like all other Rails test tasks.
2018-05-23 23:05:03 +02:00
Rafael França
9480618f06
Merge pull request #32699 from printercu/patch-3
Respect NODE_ENV when running `rails yarn:install`
2018-05-22 17:48:57 -04:00
Guillermo Iguaran
e10fd57e98 Bump minimum version of Thor to 0.19.0
Thor 0.18 is causing failures in all the generator tests.
2018-05-22 15:58:35 -05:00
Rafael França
9385a5b585
Merge pull request #32934 from aki77/fix-locale-selector
Fix locale selector to email preview
2018-05-22 15:13:29 -04:00
Ryuta Kamizono
a77447f4da Enable Lint/StringConversionInInterpolation rubocop rule
To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008
automatically in the future.
2018-05-21 21:10:14 +09:00
yuuji.yaginuma
ce4d467f7c Add test case that configure config.action_view.finalize_compiled_template_methods
Follow up of #32418.
2018-05-20 10:19:12 +09:00
aki
d7f01a28a9 Fix locale selector 2018-05-19 17:23:03 +09:00
Tsukuru Tanimichi
7b0a316f2d Don't generate yarn's contents in app:update task if it's skipped 2018-05-16 20:24:57 +09:00
Yuji Yaginuma
df850b8d71
Merge pull request #32837 from ttanimichi/app-update-skip-spring
Don't generate `config/spring.rb` in `app:update` task when spring isn't loaded
2018-05-14 07:29:03 +09:00
Tsukuru Tanimichi
8efa112ca6 Don't generate config/spring.rb in app:update task when spring isn't loaded 2018-05-13 21:51:10 +09:00
Ryuta Kamizono
1dc17e7b2e Fix CustomCops/AssertNot to allow it to have failure message
Follow up of #32605.
2018-05-13 11:32:47 +09:00
Tsukuru Tanimichi
9ed1b07b5e Remove unused remove_file method
In #32780, We have supported the `--skip-sprockets` option in the `app:update` task.
When `options[:api]` is truthy, `option[:skip_sprockets]` is also truthy. So we can remove this `remove_file` method.
42b9e7e50c/railties/lib/rails/generators/rails/app/app_generator.rb (L281-L283)
2018-05-08 13:56:59 +09:00
yuuji.yaginuma
9a1b99eb01 Skip bootsnap contents in app:update task if bootsnap is not used 2018-05-07 07:56:00 +09:00
Xavier Noria
be9a32b65f prefer File.write for bulk writes
I saw these ones while working on #32362.

File.write was introduced in Ruby 1.9.3 and it is the most concise way
to perform bulk writes (as File.read is for bulk reading).

The existing flags enabled binmode, but we are dumping text here.
The portable way to dump text is text mode. The only difference is
newlines, and portable code should in particular emit portable newlines.

Please note the hard-coded \ns are still correct. In languages with C
semantics for newlines like Ruby, Python, Perl, and others, "\n" is a
portable newline. Both when writing and when reading. On Windows, the
I/O layer is responsible for prepending a CR before each LF on writing,
and removing CRs followed by LFs on reading. On Unix, binmode is a
no-op.
2018-05-05 19:38:38 +02:00
Yuji Yaginuma
42b9e7e50c
Merge pull request #32780 from ttanimichi/tmp
Don't generate assets' initializer in `app:update` task if sprockets is skipped
2018-05-05 14:02:08 +09:00