Commit Graph

46027 Commits

Author SHA1 Message Date
Aaron Patterson
ed9b23d898 invert check so we fail faster
there's no reason to to_sym the string if it doesn't match the regexp
anyway
2014-07-31 11:25:01 -07:00
Aaron Patterson
3e9158bb95 do a hash lookup for collision detection
hash lookup should be faster than searching an array.
2014-07-31 11:22:05 -07:00
Rafael Mendonça França
71fac05c74 Merge pull request #16350 from JackDanger/test-rake-db-migrate-task
Add ActiveRecord::Tasks::DatabaseTasks.migrate
2014-07-31 15:00:05 -03:00
Rafael Mendonça França
0361a6a3d2 Merge pull request #16361 from JackDanger/clearer-connection-pool-documentation
[doc] Clarify how the ConnectionHandler works
2014-07-31 14:46:34 -03:00
Jack Danger Canty
38be6335fe Clarify how the ConnectionHandler works
This makes the implicit description of how connection pooling works a
little more explicit. It converts the examples of a model hierarchy into
actual Ruby code and demonstrates how the key structure of the
database.yml relates to the `establish_connection` method.
2014-07-31 10:42:41 -07:00
Jack Danger Canty
d66ed3b08d Add ActiveRecord::Tasks::DatabaseTasks.migrate
This extracts the logic that was embedded in a Rake task into a static
method.
Bonus: the first test for `rake db:migrate`
2014-07-31 10:06:04 -07:00
Rafael Mendonça França
639a2e7c43 Merge pull request #16353 from eileencodes/refactor-join_keys-usage-in-reflection
Refactor join_keys to remove complex conditionals
2014-07-31 14:04:41 -03:00
Carlos Antonio da Silva
ddb0d4bec1 Realign assignments ✂️ 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
0b859dfefe Do not reassign variable when mutation is happening
These methods mutate the path variable/argument so there is no need
to reassign it every time.
2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
091a59301f Only concatenate path if it was given rather than converting blindly 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
fafff357cc Rename variable to better show its intent 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
277247110c Simplify conditional 2014-07-31 13:24:16 -03:00
Carlos Antonio da Silva
8d61463f34 Push options check up so we can simplify internal methods 2014-07-31 13:24:16 -03:00
joker1007
1d6a87779c Fix type casting to Decimal from Float with ...
When I defines large precision column at RDBMS,
I assigns float value, raise ArgumentError (precision too large).
2014-08-01 00:29:20 +09:00
eileencodes
377bece684 Refactor join_keys to remove complex conditionals
Pushing conditionals down to through reflection

Only the through association needs the part of this conditional
that deals with belongs to and polymorphic? so that can be pushed
down into the ThroughReflection reducing the conditionals.

Remove conditional because we can delegate join keys to source reflection

Remove need for source_macro checking

By adding join_id_for to the other reflections we remove the need
to cehck against the source_macro and can reduce the conditioanl
from the original join_id_for(owner)

Using polymorphism instead of testing the source_macro

This case statement in join_association is almost exactly the same
as the original join_keys code. Testing taht theory by creating a
new join_dependency_keys(assoc_klass) method.

Refactor join_keys further to be more concise

Fixed format of "#:nodoc:" to "# :nodoc:" where I added them to this
file.
2014-07-31 11:07:25 -04:00
Rafael Mendonça França
84093c6627 Merge pull request #16351 from eileencodes/finish-refactoring-macro-to-eliminate-checking-against-symbols
Redefine macro checks for reflections
2014-07-31 11:25:41 -03:00
Carlos Antonio da Silva
dccdee7e2d Simplify code branch, remove #tap 2014-07-31 09:47:46 -03:00
Carlos Antonio da Silva
a9c0eb4392 Avoid a new hash object 2014-07-31 09:43:02 -03:00
Carlos Antonio da Silva
4e09c509af Fix assertion arguments order 2014-07-31 08:56:22 -03:00
Carlos Antonio da Silva
c1dadf3d62 Avoid creating an extra hash 2014-07-31 08:10:37 -03:00
Carlos Antonio da Silva
d97ba0d31b Remove unnecessary call to #tap
This is not storying the RouteSet instance anywhere as the other
examples in the file, so no need to use #tap.
2014-07-31 08:10:37 -03:00
Yves Senn
7dd452cc89 Merge pull request #16356 from gchan/add-hwia-tests
Add tests to ensure default proc is used when `HashWithIndifferentAccess' is initialized with a block
2014-07-31 12:38:29 +02:00
Gordon Chan
787d5b1342 Add tests to ensure default proc is used when `HashWithIndifferentAccess' is initialized with a block 2014-07-31 17:59:00 +12:00
Aaron Patterson
316b32d19c Merge pull request #16355 from xaviershay/validate-in-groups-of-args
Raise a descriptive error if non-positive integer passed to in_groups_of
2014-07-30 22:48:09 -07:00
Xavier Shay
acac631cc9 Raise a descriptive error if non-positive integer passed to in_groups_of.
This is more consistent than the current behaviour of raising a
`ZeroDivisionError: divided by 0` error when 0 is given, which can be
non-obvious especially if `in_groups_of` is part of a longer chain of
methods.

The negative case was ok - "ArgumentError: invalid slice size" - but
this error is clearer still.
2014-07-30 20:39:53 -07:00
Carlos Antonio da Silva
29a6a17a11 Properly assert for the expected messages
The message passed to Minitest's assert_raise is used as output in case
the assertion fails, but we can test against the exact message by using
the actual exception object that is returned from the assert_raise call.
2014-07-30 23:41:19 -03:00
Carlos Antonio da Silva
811604f3f7 Avoid defining the test if it does not need to when not on JRuby 2014-07-30 23:41:19 -03:00
Carlos Antonio da Silva
72c96dea2d Use default argument when testing generators without the need for extra args 2014-07-30 23:41:19 -03:00
Carlos Antonio da Silva
bfc2b23128 Simplify path setup 2014-07-30 23:41:18 -03:00
Carlos Antonio da Silva
9023e3b773 Simplify plugin tests a bit, leave the regexp work for minitest 2014-07-30 23:41:18 -03:00
Carlos Antonio da Silva
c8c8fe98b3 Invert unless..else conditions on JRuby checks 2014-07-30 23:41:18 -03:00
Carlos Antonio da Silva
dc9a6825be Merge pull request #16352 from gchan/remove-unnecessary-convert-key
Removed unnecessary call to 'convert_key' in 'HashWithIndifferentAccess#to_hash'
2014-07-30 22:57:17 -03:00
Carlos Antonio da Silva
5d4fce640e Remove some more globals from tests
We are using blocks here so we have access to the environment around
them, no need for globals.
2014-07-30 22:52:38 -03:00
Carlos Antonio da Silva
32f49612e7 Fix / improve some assertions 2014-07-30 22:52:38 -03:00
Carlos Antonio da Silva
5fc5665066 Remove some globals from configuration tests 2014-07-30 22:52:38 -03:00
Aaron Patterson
3429b0ccba remove useless deup
every call to default_resources_path_names allocates a new hash, no need
to dup
2014-07-30 18:11:24 -07:00
Aaron Patterson
20ec0d2aae push options inside the scope object 2014-07-30 17:20:37 -07:00
Aaron Patterson
dc3f25c8a5 turn scope in to a linked list
this makes scope rollback much easier
2014-07-30 17:19:00 -07:00
Gordon Chan
d952a7afc5 Removed unnecessary call to 'convert_key' in 'HashWithIndifferentAccess#to_hash'
All the keys are already Strings by virtue of being a HashWithIndifferentAccess.
2014-07-31 12:16:48 +12:00
eileencodes
8d7dea766e Redefine macro checks for reflections
Now that we define the macro on the reflection type we no longer
need to check `macro == :what` on each type for `belongs_to?` or
`has_one?` etc. These now default to false unless it's defined
in the reflection class.

Reuse existing belongs_to? method to check macros

We don't need to do `:belongs_to == macro` anymore becasue we
have a `belongs_to?` method. I didn't find this being used
anywhere for `has_one?` or `collection?` since they were already
fixed.
2014-07-30 20:16:27 -04:00
Aaron Patterson
20a277c9a2 don't access named routes internals
just ask whether or not the route is defined
2014-07-30 15:27:20 -07:00
Aaron Patterson
68aea29cf5 remove alias_method_chain
we can `super` in to the previous implementation.
2014-07-30 14:53:28 -07:00
Aaron Patterson
09603275e9 avoid instrospection on the module
we already know what helpers are path helpers, so just iterate through
that list and define the helpers with warnings
2014-07-30 14:51:28 -07:00
Aaron Patterson
d9108abcad fix variable name 2014-07-30 14:46:45 -07:00
Aaron Patterson
210b338db2 split path_helpers and url_helpers
this lets us avoid hard coding a regexp for separating path and url
helpers in the clear! method.
2014-07-30 14:46:07 -07:00
Aaron Patterson
cf6658c284 add will remove the method if it exists already 2014-07-30 14:38:50 -07:00
Xavier Noria
bd944e078d Merge pull request #15840 from schneems/schneems/deprecate-mailer_path_methods
Deprecate `*_path` methods in mailers
2014-07-30 23:08:59 +02:00
Rafael Mendonça França
30194a5b47 Merge pull request #16346 from JackDanger/remove_redundant_self_in_class_method_calls
Remove redundant `self.` in class method calls
2014-07-30 15:31:39 -03:00
Jack Danger Canty
cf629889bd Remove redundant self. in class method calls
These are the only instances of this in the whole code base.
2014-07-30 11:29:12 -07:00
Rafael Mendonça França
7657a033d3 Merge pull request #16345 from robin850/rbx-tidy-bytes
Prevent using String#scrub on Rubinius
2014-07-30 15:25:39 -03:00