When running tests that does not initialize rails (e.g. `rake test` under
active_model), it used to just cut off the leading "/" from absolte paths and
report something like
rails test Users/a_matsuda/rails/activemodel/test/cases/api_test.rb:40
that cannot be executed.
Running `bin/rails action_text:install` appends `import "trix"` to the `application.js` file without inserting a newline.
In my app this resulted in the following:
```js
// import statements....
import Rails from "@rails/ujs"
Rails.start()import "trix"
import "@rails/actiontext"
```
I assume this bug occurred because my `application.js` was listed at some point and removed an extra line, which was not expected by this generator.
I recommend prepending the string to be inserted with a `\n` just to be safe.
because Hash#transform_values! takes no argument and so raises when delegating
with the given arguments.
{}.with_indifferent_access.transform_values!(1) { p :hello }
=> wrong number of arguments (given 1, expected 0) (ArgumentError)
These helpers are called from both test class definition and test execution,
so we're defining them as both class and instance methods on AR::TestCase.
Defining methods on toplevel changes the behavior of all Ruby Objects which of
course includes the test target, and thus that will spoil the meaning of the
whole testing. This is something that testing libraries or helpers should never
do.
These methods are just called from testing methods, so we can just move them
under AR::TestCase as its instance methods.
Previously, ActionDispatch::IntegrationTest would always set
CONTENT_TYPE on the request whether or not the value being set was a
string or nil. However, Rack SPEC requires that if CONTENT_TYPE is set,
it must be a string.
Since the request_encoder can return nil for #content_type (and the
IdentityEncoder always will), IntegrationTest must check before it sets
the CONTENT_TYPE value.
A Rack::Lint test has been added to prevent regressions. Additionally,
it will make changes needed for Rack 3 more obvious when the time comes.
Prior to this commit, there were several places to potentially add a new
message metadata test:
* `SharedMessageMetadataTests` module
* `MessageEncryptorMetadataTest` class
(includes `SharedMessageMetadataTests`)
* `MessageEncryptorMetadataMarshalTest` class
(subclasses `MessageEncryptorMetadataTest`)
* `MessageEncryptorMetadataJSONTest` class
(subclasses `MessageEncryptorMetadataTest`)
* `MessageEncryptorMetadataJsonWithMarshalFallbackTest` class
(subclasses `MessageEncryptorMetadataTest`)
* `MessageVerifierMetadataTest` class
(includes `SharedMessageMetadataTests`)
* `MessageVerifierMetadataMarshalTest` class
(subclasses `MessageVerifierMetadataTest`)
* `MessageVerifierMetadataJsonWithMarshalFallbackTest` class
(subclasses `MessageVerifierMetadataTest`)
* `MessageVerifierMetadataJsonTest` class
(subclasses `MessageVerifierMetadataTest`)
* `MessageVerifierMetadataCustomJSONTest` class
(subclasses `MessageVerifierMetadataTest`)
* `MessageEncryptorMetadataNullSerializerTest` class
(subclasses `MessageVerifierMetadataTest`)
This commit refactors the message metadata tests, reducing the list to:
* `MessageMetadataTests` module
* `MessageEncryptorMetadataTest` class (includes `MessageMetadataTests`)
* `MessageVerifierMetadataTest` class (includes `MessageMetadataTests`)
This makes it easier to add new tests, as well as new testing scenarios
(e.g. new encryptor / verifier configurations).
Additionally, this commit fixes two tests that were ineffective:
* The `test_passing_expires_in_less_than_a_second_is_not_expired` test
(which is now simply a part of the "message expires with :expires_in"
test) did not use the `with_usec: true` option. Therefore, the time
resulting from `travel 0.5.seconds` was truncated, effectively
traveling 0 seconds.
* The `test_verify_with_use_standard_json_time_format_as_false` test
(which is now named "expiration works with
ActiveSupport.use_standard_json_time_format = false") did not specify
an expiration time. Therefore, the conditional branch that it was
supposed to test was never exercised.