Commit Graph

60194 Commits

Author SHA1 Message Date
Jon Moss
3256dcd8b9 Install libxml-ruby gem so full XMLMini test suite can be run 2016-11-19 10:46:28 -05:00
Jon Moss
1d18b9b2fb Do not include ActiveSupport into test classes
Will help get rid of errors like the following:

```
  1) Error:
JDOMEngineTest#test_order=:
ArgumentError: wrong number of arguments (0 for 1)
    /Users/jon/code/rails/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb:106:in `test_order='
```
2016-11-19 10:30:57 -05:00
Eileen M. Uchitelle
4aacace550 Merge pull request #27103 from y-yagi/move_changelog_entry_to_appropriate_file
move CHANGELOG entry to the appropriate file [ci skip]
2016-11-19 09:03:15 -05:00
Matthew Draper
f9230a2d42 Merge pull request #27057 from kamipo/fix_race_condition
Fix the race condition caused by `with_new_connections_blocked`
2016-11-19 20:33:02 +10:30
yuuji.yaginuma
f5e738b604 move CHANGELOG entry to the appropriate file [ci skip]
Follow up to #27098
2016-11-19 16:18:21 +09:00
Rafael Mendonça França
ff2fe014d9
Merge pull request #27089 from erickueen/erickueen_fix_26606
Fix incorrect output from rails routes when using singular resources …
2016-11-18 17:38:35 -05:00
Rafael França
8106a177a4 Merge pull request #27092 from prathamesh-sonpatki/https-source-bundler
Use secure source for gems referencing "github" in the generated apps
2016-11-18 16:54:31 -05:00
Erick Reyna
c79848e1e7 Fix incorrect output from rails routes when using singular resources issue #26606
Rails routes (even rake routes in previous versions) output showed incorrect routes when an application use resource :controller, implying that edit_controller_path match with controller#show.
The order of the output has changed to correct this. View #26606 for more information.

Added a test case, change unit test in rake to expect the new output.
Since the output of resource :controller is changing, the string spected of the railties/test/application/rake_test.rb test_rails_routes_with_controller_environment had to be modified.
2016-11-18 15:12:13 -06:00
Rafael Mendonça França
60c333eb10
Merge pull request #27098 from sina-s/fix-unexpected-session-sharing
Fix unexpected session sharing
2016-11-18 15:07:33 -05:00
Tawan Sierek
064744bef6
Fix ActionDispatch::IntegrationTest#open_session
Reset a new session directly after its creation in
`ActionDispatch::IntegrationTest#open_session`. Reset the session to a clean
state before making it available to the client's test code.

Issue #22742 reports unexpected behavior of integration tests that run multiple
sessions. For example an `ActionDispatch::Flash` instance is shared across
multiple sessions, though a client code will rightfully assume that each new
session has its own flash hash.

The following test failed due to this behavior:

    class Issue22742Test < ActionDispatch::IntegrationTest
      test 'issue #22742' do
        integration_session # initialize first session
        a = open_session
        b = open_session

        refute_same(a.integration_session, b.integration_session)
      end
    end

Instead of creating a new `ActionDispatch::Integration::Session` instance,
the same instance is shared across all newly opened test sessions. This is
due to the way how new test sessions are created in
`ActionDispatch::IntegrationTest#open_session`. The already existing
`ActionDispatch::IntegrationTest` instance is duplicated  with `Object#dup`,
This approach was introduced in commit 15c31c7639b. `Object#dup` copies the
instance variables, but not the objects they reference. Therefore this issue
only occurred when the current test instance had been tapped in such a way that
the instance variable `@integration_session` was initialized before creating the
new test session.

Close #22742

[Tawan Sierek + Sina Sadeghian]
2016-11-18 15:07:16 -05:00
Kasper Timm Hansen
8dbc1ca339 Merge pull request #27094 from y-yagi/remove_warnings_from_activejob_test_helper
remove Ruby warning from Active Job test helper methods
2016-11-18 11:15:56 +01:00
yuuji.yaginuma
5b825c55fe remove Ruby warning from Active Job test helper methods
This removes the following warnings.

```
/home/travis/build/rails/rails/activejob/lib/active_job/test_helper.rb:241: warning: shadowing outer local variable - job
/home/travis/build/rails/rails/activejob/lib/active_job/test_helper.rb:265: warning: shadowing outer local variable - job
```
2016-11-18 18:20:48 +09:00
Prathamesh Sonpatki
efcc361b32
Use secure source for gems referencing "github" in the generated apps
- New apps generated on master and latest bundler give warning about
  "github" source being insecure.
- Use the same solution used for Rails master in the generated app's
  Gemfile to fix this issue.
2016-11-18 12:24:48 +05:30
Ryuta Kamizono
700639e4f6 Fix the race condition caused by with_new_connections_blocked
`with_new_connections_blocked` was introduced at #14938.
But the method sometimes causes `@new_cons_enabled = false` then never
toggled to true.
2016-11-18 09:59:42 +09:00
Rafael França
796049ef3e Merge pull request #26551 from mgpnd/FixContentLength
Fixed CONTENT_LENGTH header in ActionController::TestRequest
2016-11-17 19:00:18 -05:00
Rafael França
c659cb8561 Merge pull request #26981 from kamipo/should_not_except_order_for_exists
Should except `:distinct` rather than `:order` for `exists?`
2016-11-17 18:27:25 -05:00
Rafael França
6e63b0aa13 Merge pull request #27090 from tomprats/update-preprocessor-documentation
Updated Sprockets Documentation
2016-11-17 18:22:56 -05:00
Rafael França
76c273868e Merge pull request #27070 from jonhyman/patch-raw-true
Removes 'raw: true' from MemCacheStore#read_multi
2016-11-17 18:18:34 -05:00
Tom Prats
dd66493d70 Updated Sprockets Documentation 2016-11-17 18:18:14 -05:00
Sean Griffin
7a3be90dce Refactor the handling of fallback exception handlers 2016-11-17 15:03:57 -05:00
Sean Griffin
4331ee8390 Merge pull request #27076 from y-yagi/fix_postgresql_array_encoding
use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`
2016-11-17 14:56:38 -05:00
Sean Griffin
07af54d43c Merge pull request #26980 from kamipo/respect_new_records_for_collection_proxy_distinct
Respect new records for `CollectionProxy#uniq`
2016-11-17 14:55:19 -05:00
Sean Griffin
f48bb1b4ad Call fallback exception handlers with the right exception
The issue presented in #26246 showed a deeper underlying problem. When
we fell back to the exception handler for an exceptions cause, we were
calling that handler with the outer raised exception. This breaks the
calling code's expectations, especially if the exception has methods on
it behond those from `StandardError`.
2016-11-17 14:50:41 -05:00
Vipul A M
8d015dff82 Remove mention of deprecated SafeERB gem from security docs for now, prior section already speaks about sanitization as a safety measure. [ci skip] (#27086)
Fixes #27085
2016-11-18 00:11:48 +05:30
Kasper Timm Hansen
a48740deed Merge pull request #27084 from vipulnsward/fix-connection-config-mutation
Fix mucking of connection_config leading to issues in prepared_statements issues
2016-11-17 18:49:09 +01:00
Vipul A M
0085155100
Fix mucking of connection_config leading to issues in prepared_statements 2016-11-17 22:44:52 +05:30
Kasper Timm Hansen
b9afb01283 Merge pull request #27078 from vipulnsward/fix-pg-prepared-statement-test
Fix PG prepared statement test
2016-11-17 10:20:12 +01:00
Vipul A M
f09deb9c8e
Fix PG prepared statement test 2016-11-17 14:24:37 +05:30
yuuji.yaginuma
70878b6e82 use force_encoding instread of encode! to avoid UndefinedConversionError
`PG::TextEncoder::Array#encode` returns the encoded value with `ASCII-8BIT`.
But in some cases, trying to convert `ASCII-8BIT` to `UTF-8` cause an error.

```ruby
"{\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB}".encode!(Encoding::UTF_8)
# => Encoding::UndefinedConversionError: "\xE3" from ASCII-8BIT to UTF-8
```
Should use `force_encoding` to avoid this error.

Follow up to 7ba3a48df5bfdc5e98506bb829f937e03b55a5b3

Ref: https://github.com/rails/rails/pull/23619#issuecomment-189924036
2016-11-17 11:59:03 +09:00
Rafael França
7f86429a82 Merge pull request #27075 from maclover7/jm-jruby-activejob
Enable JRuby testing for Active Job
2016-11-16 21:54:53 -05:00
Jon Moss
2694a74c88 Make JRUBY_OPTS a global Travis environment variable 2016-11-16 21:24:18 -05:00
Jon Moss
9140c11fcb Enable JRuby testing for Active Job
All tests pass for me locally.
2016-11-16 21:23:34 -05:00
Rafael França
27210f1dd2 Merge pull request #27072 from maxboisvert/use_named_parameters_in_assert_enqueued_with
Use named parameters instead of `assert_valid_keys` in active_job/test_helper
2016-11-16 18:12:17 -05:00
Rafael França
84c58ced46 Merge pull request #27064 from koic/bump_ruby_versions
Run tests by Ruby 2.2.6 and 2.3.2
2016-11-16 17:44:38 -05:00
Rafael França
1dcfe98235 Merge pull request #27074 from maclover7/jm-jruby-actionmailer
Enable JRuby testing for Action Mailer
2016-11-16 17:43:11 -05:00
Jon Moss
780aaf1f10 Enable JRuby testing for Action Mailer
All tests passing locally for me:

```
195 runs, 441 assertions, 0 failures, 0 errors, 0 skips
```
2016-11-16 17:23:10 -05:00
Maxime Boisvert
c061236cc7 Use named parameters instead of assert_valid_keys 2016-11-16 17:19:48 -05:00
Jonathan Hyman
226b845113 Removes 'raw: true' from MemCacheStore#read_multi, per https://github.com/rails/rails/issues/27066. 2016-11-16 15:42:31 -05:00
Koichi ITO
8e239fa712 Run tests by Ruby 2.2.6 and 2.3.2 2016-11-16 17:29:56 +09:00
Yves Senn
3b2346ea13 docs, add update_all example with SQL fragment. [ci skip]
The relation method `update_all` allows you to pass a SQL fragment. The
functionality is already mentioned in the prose but the examples section
does not cover it.
2016-11-16 08:52:49 +01:00
Guillermo Iguaran
c2c6b7be23 Merge pull request #27056 from kirs/fix-testing-isolation
Fix testing isolation
2016-11-15 22:05:14 -05:00
Jon Moss
bce3d1f8c0 Merge pull request #27058 from maclover7/jm-fix-26904
Support AC::Parameters for PG HStore
2016-11-15 17:12:08 -05:00
Jon Moss
0a8b212db7 Support AC::Parameters for PG HStore
As reported via #26904, there is a regression in how values for
Postgres' HStore column type are being processed, beginning in Rails 5.
Currently, the way that Active Record checks whether or not values need
to be serialized and put into the correct storage format is whether or
not it is a `Hash` object. Since `ActionController::Parameters` no
longer inherits from `Hash` in Rails 5, this conditional now returns
false. To remedy this, we are now checking to see whether the `value`
parameters being passed in responds to a certain method, and then
calling the `serialize` method, except this time with a real Hash
object. Keeping things DRY!

Fixes #26904.
2016-11-15 16:42:44 -05:00
Kir Shatrov
3261470452 Fix testing isolation
AS::Testing::Isolation has two ways to isolate the process:
forking and subprocessing. The second way is used on JRuby and other
platforms that don't support forking.

The way how subprocessing works is that we prepare a command to run a
new process:

```
/opt/rubies/2.3.0/bin/ruby -I{skipped_load_path} test/initializable_test.rb '' -nInitializableTests::Basic#test_Initializer_provides_context's_class_name
```

As you see, there's unescaped quote at the end of the line.
It leads to:

```
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
```

This fixes tests on MRI + NO_FORK variable and on JRuby 🎉
2016-11-15 15:56:32 -05:00
Sean Griffin
6e692e6e5b Merge pull request #27054 from kamipo/null_relation_calculate
Refactor `NullRelation#calculate`
2016-11-15 13:25:51 -05:00
Ryuta Kamizono
7c1b14f041 Refactor NullRelation#calculate
Before:

```ruby
    def calculate(operation, _column_name)
      if [:count, :sum].include? operation
        group_values.any? ? Hash.new : 0
      elsif [:average, :minimum, :maximum].include?(operation) && group_values.any?
        Hash.new
      else
        nil
      end
    end
```

After:

```ruby
    def calculate(operation, _column_name)
      case operation
      when :count, :sum
        group_values.any? ? Hash.new : 0
      when :average, :minimum, :maximum
        group_values.any? ? Hash.new : nil
      end
    end
```
2016-11-16 02:42:24 +09:00
Artem Rashev
b388ca41d8 Fixed CONTENT_LENGTH header in ActionController::TestRequest
CONENT_LENGTH setted by string length, which is equal to number of
characters in string but StringIO.length is byte sequence and
when payload contains non-ASCII characters, stream's length will be
different. That's why real byte length should be used for CONTENT_LENGTH
header.

Add unit test for CONTENT_LENGTH header fix

It just passes non-ascii symbols as parameters and verifies that
"CONTENT_LENGTH" header has content bytes count as value.
2016-11-15 12:50:38 +03:00
Akira Matsuda
3a558aa2bc Make sure to bundle json 2.x on CI
Without this, bundler tries to bundle json 1.8 on Ruby 2.4 in some cases
https://travis-ci.org/rails/rails/jobs/175874852
2016-11-15 09:26:03 +09:00
प्रथमेश Sonpatki
a4208bb974 Merge pull request #27048 from y-yagi/remove_alias_method_chain_from_guide
remove `alias_method_chain` from guide [ci skip]
2016-11-15 05:35:39 +05:30
yuuji.yaginuma
eda23fa62f remove alias_method_chain from guide [ci skip]
Follow up to 7c848e6dd493ff236d33a0410a92f4c3e5cc3c7f
2016-11-15 08:42:02 +09:00