Commit Graph

49728 Commits

Author SHA1 Message Date
Rafael Mendonça França
e26fa7b921 Stoping using Relation#merge in default_scoped
Relation#merge checks if the argument is an array and the only possible
returns of build_default_scope is nil or a Relation.

Doing this we can raise an ArgumentError when Relation#merge receive a
nil value.
2015-02-06 17:51:48 -02:00
Rafael Mendonça França
decb7b66d0 Merge pull request #18833 from perceptec/add_only_performed_option
Add an `:only` option to `perform_enqueued_jobs` to filter jobs based on type.
2015-02-06 17:17:18 -02:00
Michael Ryan
e818f65770 Add an :only option to perform_enqueued_jobs to filter jobs based on
type.

This allows specific jobs to be tested, while preventing others from
being performed unnecessarily.

Example:

    def test_hello_job
      assert_performed_jobs 1, only: HelloJob do
        HelloJob.perform_later('jeremy')
        LoggingJob.perform_later
      end
    end

An array may also be specified, to support testing multiple jobs.

Example:

    def test_hello_and_logging_jobs
      assert_nothing_raised do
        assert_performed_jobs 2, only: [HelloJob, LoggingJob] do
          HelloJob.perform_later('jeremy')
          LoggingJob.perform_later('stewie')
          RescueJob.perform_later('david')
        end
      end
    end

Fixes #18802.

Trim space and document :only option.
2015-02-06 14:11:42 -05:00
Sean Griffin
ec6c98f7d1 Significantly improve the performance of _read_attribute on JRuby
The `&block` form is more than twice as fast as the manual form of
delegation (and is the code I'd rather write anyway). Unfortunately,
it's still twice as slow on MRI. However, this is enough of a hotspot to
justify giving JRuby special treatment.

I can't currently provide benchmarks in the context of Active Record,
since the JDBC adapters still aren't updated for 4.2, but the actual
work performed (assuming it's been read at least once already) will have
nearly the same performance characteristics as
https://gist.github.com/sgrif/b86832786551aaee74de.
2015-02-06 12:10:47 -07:00
Rafael Mendonça França
f4e8d67367 Use keyword argument in the find_in_batches API
We already validate the keys, so it is better to use the built-in
feature to do this
2015-02-06 17:05:19 -02:00
Sean Griffin
101c19f55f Allow a symbol to be passed to attribute, in place of a type object
The same is not true of `define_attribute`, which is meant to be the low
level no-magic API that sits underneath. The differences between the two
APIs are:

- `attribute`
  - Lazy (the attribute will be defined after the schema has loaded)
  - Allows either a type object or a symbol
- `define_attribute`
  - Runs immediately (might get trampled by schema loading)
  - Requires a type object

This was the last blocker in terms of public interface requirements
originally discussed for this feature back in May. All the
implementation blockers have been cleared, so this feature is probably
ready for release (pending one more look-over by me).
2015-02-06 11:51:13 -07:00
claudiob
124d4d59a0 Do not use the same name for two :belongs_to
A model cannot have two `:belongs_to` with the same exact name, so
we are better off avoiding this code in our examples, which might
mislead users in thinking it's admissible.

[ci skip]
2015-02-06 10:50:44 -08:00
Rafael Mendonça França
d731859916 Merge branch 'rm-ntp'
Merge #12067 rebasing and improving the code.
2015-02-06 16:22:05 -02:00
Rafael Mendonça França
2d2bcde3cb Merge pull request #12067 from jackxxu/keep_precision
Enable number_to_percentage to keep the number's precision by allowing :precision option value to be nil

Conflicts:
	activesupport/CHANGELOG.md
	activesupport/lib/active_support/number_helper.rb
	activesupport/test/number_helper_test.rb
2015-02-06 16:21:28 -02:00
Rafael Mendonça França
01c86fbf84 Merge pull request #18831 from colinrymer/patch-1
Indicate link_to creates an anchor element
2015-02-06 15:55:54 -02:00
Colin Rymer
7fb6759a84 Indicate link_to creates an anchor element
The `link_to` helper generates an HTML anchor element (consisting of opening and closing anchor tags and an element body). The docs currently state the a link tag is generated (which would indicate a tag like `<link>`, which is another valid HTML tag), so this change clarifies that an anchor element is actually generated.

[ci skip]
2015-02-06 12:46:38 -05:00
Sean Griffin
8f6cfd9e9f Revert "Improve the performance of HWIDA select and reject"
This reverts commit 9c47b874d112414df7f80f9ed852adb48ba6d268.
2015-02-06 10:45:20 -07:00
Sean Griffin
9c47b874d1 Improve the performance of HWIDA select and reject
These are (potentially, depending on input) called in several places in
both the router, and Active Record. The code also becomes much cleaner.
This results in ~33% performance gain in both methods.

    Calculating -------------------------------------
                  before    15.696k i/100ms
                  after     19.865k i/100ms
    -------------------------------------------------
                  before    303.064k (± 2.6%) i/s -      1.523M
                  after     446.734k (± 2.4%) i/s -      2.245M

On Ruby 2.2, a warning will be emitted about states not being copied,
because we're calling `super` from a subclass. We can safely ignore it,
however, since we're converting the result back into a HWIDA
2015-02-06 10:39:12 -07:00
Rafael Mendonça França
de9313ce7c Merge pull request #14028 from uberllama/json_escape_comments
Amended json_escape comments
2015-02-06 14:49:32 -02:00
Rafael Mendonça França
16809025fe Merge pull request #18388 from claudiob/better-docs-for-active-model-lint-tests
Better docs for AM::Lint::Tests
2015-02-06 11:06:59 -02:00
Xavier Noria
6f8d9bd6da revises AM:Dirty example [Godfrey Chan & Xavier Noria]
The existing example seems somewhat forced: is it realistic
to have a model that accepts state in its initializer but
considers it has not been changed? By allowing state changes
to happen only via accessors it seems more natural that new
instances are considered to be unchanged (as they are in AR).

[ci skip]
2015-02-06 10:29:05 +01:00
Xavier Noria
a2af7bb928 use parentheses here, for the beard of the Prophet! [ci skip] 2015-02-06 09:45:24 +01:00
Xavier Noria
4af4cead15 applies guidelines to dirty.rb [ci skip] 2015-02-06 09:36:28 +01:00
Rafael Mendonça França
25bbe595f1 Merge pull request #18399 from kommen/unify-structure-file-envvar-names
Use SCHEMA instead of DB_STRUCTURE for specifiying structure file.

Conflicts:
	activerecord/CHANGELOG.md
2015-02-05 18:55:33 -02:00
Rafael Mendonça França
726b95e5ce Merge pull request #18589 from kamipo/fix_test_types_line_up
Fix `test_types_line_up` when column type missing
2015-02-05 18:30:03 -02:00
Rafael Mendonça França
6953f16efa Merge pull request #18526 from vipulnsward/add-silence-stream
Extracted silence_stream method to new module in activesupport/testing
2015-02-05 18:28:51 -02:00
Rafael Mendonça França
35e2255b7a Merge pull request #18771 from kirs/deprecate-xhr
Migrating xhr methods to keyword arguments syntax
2015-02-05 18:27:47 -02:00
Rafael Mendonça França
9cb461ba03 Use keyword arguments
Also remove the default value since it will be always passed and
Array(nil) returns an empty array
2015-02-05 17:59:03 -02:00
Rafael Mendonça França
459a9ea47f Merge pull request #18747 from vipulnsward/merge-skip-callback
Rename AS::Callback#merge
2015-02-05 17:48:54 -02:00
Rafael Mendonça França
9ec973f0ac Do not run remove_connection in memory db test
This will make rake test_sqlite3_mem work again
2015-02-05 17:31:00 -02:00
Rafael Mendonça França
0abd0b54f0 Mark some methods as nodoc
They are implementation details
2015-02-05 17:15:53 -02:00
Rafael Mendonça França
e7e72ec7d7 Remove special case for symbols at find
Deprecated finders are not supported anymore
2015-02-05 17:13:42 -02:00
Rafael Mendonça França
fdc0d93424 Merge branch 'rm-use-active-model-correctly'
Closes #18646
2015-02-05 16:29:17 -02:00
Rafael Mendonça França
4b4e2281a0 Rename method to make explicit its intention
call is too generic
2015-02-05 16:28:12 -02:00
Rafael Mendonça França
003c0cda26 Use kwags to make the argument meaning explicit 2015-02-05 16:26:16 -02:00
Rafael Mendonça França
d80996ea8d Use new hash syntax 2015-02-05 16:21:39 -02:00
Rafael Mendonça França
44e1cda314 Change the method visibility
Thse methods are used only inside this class
2015-02-05 16:20:39 -02:00
Rafael Mendonça França
0caac9bf9b Add tests to make sure label and placeholder respect to_model 2015-02-05 16:19:29 -02:00
Andrew White
80838d9bd5 Force generated route to be inserted
Thor isn't very discerning over whether some content is present when passed
to `inject_into_file`, e.g. a commented out route is detected as being present.
So to prevent people scratching their heads as to why a route hasn't appeared
it's better to fall on the side of having duplicate routes.
2015-02-05 17:54:23 +00:00
Rafael Mendonça França
79100b8a3a Only check if object respond_to to_model once 2015-02-05 15:28:25 -02:00
Rafael Mendonça França
96be4f65d0 placeholder doesn't exist inside this context 2015-02-05 15:27:27 -02:00
Rafael Mendonça França
ed85348877 Merge pull request #18647 from mcls/placeholderable-to-model
The `model_name` method should be called on `to_model`
2015-02-05 15:16:57 -02:00
Akira Matsuda
da9038eaa5 Partial template name does no more have to be a valid Ruby identifier
because the partial renderer would not create an lvar per each template since c67005f221f102fe2caca231027d9b11cf630484
2015-02-06 01:46:59 +09:00
Akira Matsuda
4ca1dda0bf Merge pull request #18610 from amatsuda/privatize_config_accessor
config_accessor should better not be a public method, as with Ruby's attr_accessor
2015-02-06 01:18:23 +09:00
Akira Matsuda
c2bfe6cbc8 Privatize config_accessor as with attr_accessor 2015-02-06 01:12:07 +09:00
Sean Griffin
63f959d21b Move ruby-head to allowed failures [ci skip]
We're about a year a way from either project releasing, their
development doesn't need to break our builds for now.
2015-02-05 07:39:32 -07:00
Sean Griffin
494c789443 Merge pull request #18820 from tycooon/transaction-rollback-fix
Fix transaction rollback in case of aborting thread
2015-02-05 07:04:23 -07:00
Yuri Smirnov
68198c3e38 fix transaction rollback in case of aborting thread 2015-02-05 16:21:37 +03:00
Arthur Nogueira Neves
f499ecf961 Merge pull request #18817 from y-yagi/fix_action_controller_gem_template
load "rack/test" before "action_controller/railtie" in bug report templates [ci skip]
2015-02-04 22:38:25 -05:00
yuuji.yaginuma
7c342af1b7 load "rack/test" before "action_controller/railtie" in bug report templates [ci skip] 2015-02-05 08:19:45 +09:00
Sean Griffin
e440e8daba Merge pull request #18809 from meltheadorable/bugfix/postgres_money
Fix bug causing table creation to fail for models with postgresql 'money' field
2015-02-04 09:13:55 -07:00
Melody
2eeb29a925 Fix test cases for money, bit and bit_varying 2015-02-04 11:07:08 -05:00
Sean Griffin
cd0ed12d1a Respect custom primary keys for associations in Relation#where
While we query the proper columns, we go through normal handling for
converting the value to a primitive which assumes it should use the
table's primary key. If the association specifies a different value (and
we know that we're working with an association), we should use the
custom primary key instead.

Fixes #18813.
2015-02-04 08:56:46 -07:00
Abdelkader Boudih
1405c7a2cb revert 539d929b7b32302afe548e4cb06b5f4dd56e9942 [ci skip] 2015-02-04 09:30:47 +00:00
Abdelkader Boudih
02bebab7f5 Merge pull request #18812 from yatmsu/fix_typo_in_rails_guides
Fix typo in Creating and Customizing Rails Generators & Templates guide... [ci skip]
2015-02-04 09:21:19 +00:00