1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/cases
Jon Leighton 94924dc32b Simplify/fix implementation of default scopes
The previous implementation was necessary in order to support stuff
like:

    class Post < ActiveRecord::Base
      default_scope where(published: true)
      scope :ordered, order("created_at")
    end

If we didn't evaluate the default scope at the last possible moment
before sending the SQL to the database, it would become impossible to
do:

    Post.unscoped.ordered

This is because the default scope would already be bound up in the
"ordered" scope, and therefore wouldn't be removed by the
"Post.unscoped" part.

In 4.0, we have deprecated all "eager" forms of scopes. So now you must
write:

    class Post < ActiveRecord::Base
      default_scope { where(published: true) }
      scope :ordered, -> { order("created_at") }
    end

This prevents the default scope getting bound up inside the "ordered"
scope, which means we can now have a simpler/better/more natural
implementation of default scoping.

A knock on effect is that some things that didn't work properly now do.
For example it was previously impossible to use #except to remove a part
of the default scope, since the default scope was evaluated after the
call to #except.
2013-06-28 13:45:57 +01:00
..
adapters the typecast value should be passed to the serializer. fixes #10830 2013-06-05 17:30:11 +09:00
associations Apply default scope when joining associations. 2013-06-28 11:47:00 +01:00
attribute_methods just construct real objects rather than mock and stub 2013-06-17 10:50:11 -07:00
coders
connection_adapters
connection_specification
fixture_set
migration Fixes #10432 add_column not creating array columns in PostgreSQL 2013-06-04 00:18:59 -04:00
relation
scoping Simplify/fix implementation of default scopes 2013-06-28 13:45:57 +01:00
tasks Remove FirebirdDatabaseTasks was deprecated, because this was provided by 3rd-party. 2013-06-05 21:16:50 +09:00
validations Revert "Merge pull request #4490 from EmmanuelOga/master" 2013-06-04 00:33:50 +09:00
adapter_test.rb
aggregations_test.rb
ar_schema_test.rb
associations_test.rb Fix typo in test name and documentation 2013-05-20 10:35:43 +05:30
attribute_methods_test.rb Extract AR::AttributeMethods#attribute_for_inspect's test code out from base_test.rb 2013-05-22 02:32:37 +09:00
autosave_association_test.rb
base_test.rb Remove instance level attr_readonly setting was deprecated. 2013-06-02 10:25:41 +09:00
batches_test.rb When .find_each is called without a block, return an Enumerator. 2013-06-19 04:04:13 -07:00
binary_test.rb
bind_parameter_test.rb
calculations_test.rb Remove fall back and column restrictions for count. 2013-06-09 12:53:04 +02:00
callbacks_test.rb
clone_test.rb
column_alias_test.rb
column_definition_test.rb
column_test.rb
connection_management_test.rb
connection_pool_test.rb fix typos 2013-06-15 09:14:28 +02:00
core_test.rb Extract AR::Core#inspect and AR::Core.inspect's test code from base_test.rb 2013-05-22 02:24:37 +09:00
counter_cache_test.rb Refactor AR's counter_cache_test.rb test 2013-05-23 01:28:04 +09:00
custom_locking_test.rb
database_statements_test.rb
date_time_test.rb
defaults_test.rb Handle single quotes in PostgreSQL default column values 2013-06-19 11:03:40 -05:00
dirty_test.rb
disconnected_test.rb Fix rake test_sqlite3_mem 2013-06-28 11:37:42 +01:00
dup_test.rb
explain_subscriber_test.rb
explain_test.rb
finder_respond_to_test.rb Remove depreacted finders 2013-06-28 00:24:11 +02:00
finder_test.rb
fixtures_test.rb fixture setup does not rely on AR::Base.configurations. 2013-06-15 14:58:38 +02:00
forbidden_attributes_protection_test.rb
habtm_destroy_order_test.rb
helper.rb
hot_compatibility_test.rb
i18n_test.rb
inheritance_test.rb
integration_test.rb
invalid_connection_test.rb Fix test 2013-06-28 11:46:03 +01:00
invalid_date_test.rb
invertible_migration_test.rb
json_serialization_test.rb
locking_test.rb indentation 2013-06-11 11:24:16 -07:00
log_subscriber_test.rb log the sql that is actually sent to the database 2013-06-19 17:37:27 +05:30
migration_test.rb Fix #10789. Now at last ::Logger doesn't support #silence method . 2013-06-05 17:55:53 +09:00
migrator_test.rb
mixin_test.rb
modules_test.rb
multiparameter_attributes_test.rb
multiple_db_test.rb
nested_attributes_test.rb This test does not test anything that happens in the real world. If you 2013-06-13 15:36:50 -07:00
persistence_test.rb Extract AR::Persistence#becomes's test code out from base_test.rb 2013-05-22 12:30:35 +09:00
pooled_connections_test.rb
primary_keys_test.rb Fix class and method name typos 2013-05-12 15:03:14 +05:30
query_cache_test.rb
quoting_test.rb
readonly_test.rb implicit_readonly is being removed in favor of calling readonly explicitly 2013-05-27 21:07:39 +02:00
reaper_test.rb
reflection_test.rb Fix tests which started to fail due to commit 0123c39f41 2013-05-18 18:22:21 +09:00
relation_test.rb flatten merged join_values before building the joins 2013-06-22 08:33:03 +05:30
relations_test.rb Remove depreacted finders 2013-06-28 00:24:11 +02:00
reload_models_test.rb
result_test.rb Merge pull request #10993 from Empact/result-each-enumerator 2013-06-25 20:07:59 -03:00
sanitize_test.rb
schema_dumper_test.rb
serialization_test.rb
serialized_attribute_test.rb Remove instance level serialized_attributes setting was deprecated. 2013-06-02 10:26:04 +09:00
statement_cache_test.rb
store_test.rb Remove unnecessary testcase for instance level stored_attributes. 2013-06-02 10:33:36 +09:00
test_case.rb
timestamp_test.rb
transaction_callbacks_test.rb
transaction_isolation_test.rb
transactions_test.rb
unconnected_test.rb
validations_repair_helper.rb
validations_test.rb
xml_serialization_test.rb
yaml_serialization_test.rb