radiant 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +33 -1
- data/CONTRIBUTORS +15 -2
- data/INSTALL +9 -7
- data/README +11 -7
- data/app/controllers/admin/layouts_controller.rb +5 -2
- data/app/controllers/admin/pages_controller.rb +8 -5
- data/app/controllers/admin/snippets_controller.rb +5 -2
- data/app/controllers/application_controller.rb +7 -0
- data/app/helpers/admin/node_helper.rb +2 -2
- data/app/helpers/application_helper.rb +2 -2
- data/app/models/radiant/config.rb +36 -4
- data/app/models/standard_tags.rb +1 -1
- data/app/views/admin/layouts/index.html.haml +15 -12
- data/app/views/admin/page_parts/_page_part.html.haml +2 -2
- data/app/views/admin/pages/index.html.haml +1 -1
- data/app/views/admin/snippets/_form.html.haml +1 -1
- data/app/views/admin/snippets/index.html.haml +14 -10
- data/config/database.db2.yml +20 -0
- data/config/environment.rb +4 -4
- data/config/environments/test.rb +1 -2
- data/features/support/env.rb +2 -1
- data/lib/generators/extension/extension_generator.rb +5 -0
- data/lib/generators/extension/templates/RSpecRakefile +11 -8
- data/lib/generators/extension/templates/cucumber.yml +1 -0
- data/lib/generators/extension/templates/cucumber_env.rb +16 -0
- data/lib/generators/extension/templates/cucumber_paths.rb +14 -0
- data/lib/generators/extension/templates/extension.rb +1 -1
- data/lib/generators/instance/instance_generator.rb +1 -1
- data/lib/generators/instance/templates/databases/db2.yml +40 -0
- data/lib/generators/instance/templates/instance_environment.rb +6 -6
- data/lib/local_time.rb +3 -9
- data/lib/radiant.rb +1 -1
- data/lib/radiant/cache.rb +10 -8
- data/lib/radiant/extension.rb +36 -0
- data/lib/radiant/extension/script.rb +1 -1
- data/lib/radiant/extension_loader.rb +5 -1
- data/lib/radiant/initializer.rb +52 -4
- data/lib/task_support.rb +33 -0
- data/lib/tasks/cucumber.rake +5 -1
- data/lib/tasks/radiant_config.rake +18 -0
- data/lib/tasks/release.rake +1 -0
- data/public/javascripts/admin/admin.js +1 -1
- data/spec/controllers/admin/layouts_controller_spec.rb +18 -12
- data/spec/controllers/admin/pages_controller_spec.rb +35 -29
- data/spec/controllers/admin/snippets_controller_spec.rb +11 -5
- data/spec/controllers/admin/welcome_controller_spec.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +18 -0
- data/spec/fixtures/radiant_config.yml +10 -0
- data/spec/generators/extension_generator_spec.rb +12 -0
- data/spec/helpers/admin/node_helper_spec.rb +6 -0
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/lib/radiant/extension_loader_spec.rb +17 -0
- data/spec/lib/radiant/extension_spec.rb +28 -0
- data/spec/lib/radiant/initializer_spec.rb +34 -0
- data/spec/lib/task_support_spec.rb +42 -0
- data/spec/models/page_spec.rb +6 -2
- data/spec/models/radiant/config_spec.rb +42 -1
- data/spec/models/standard_tags_spec.rb +2 -2
- data/test/fixtures/extensions/01_basic/app/metal/basic_metal.rb +9 -0
- data/test/fixtures/extensions/02_overriding/app/metal/basic_metal.rb +9 -0
- data/vendor/extensions/textile_filter/textile.html +2 -2
- data/vendor/plugins/dataset/CHANGELOG +2 -1
- data/vendor/plugins/dataset/Rakefile +3 -0
- data/vendor/plugins/dataset/VERSION.yml +2 -2
- data/vendor/plugins/dataset/dataset.gemspec +9 -3
- data/vendor/plugins/dataset/lib/dataset.rb +3 -0
- data/vendor/radius/lib/radius.rb +5 -0
- data/vendor/radius/test/radius_test.rb +6 -0
- data/vendor/rails/actionmailer/CHANGELOG +8 -0
- data/vendor/rails/actionmailer/Rakefile +3 -2
- data/vendor/rails/actionmailer/lib/action_mailer/base.rb +2 -1
- data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
- data/vendor/rails/actionmailer/test/abstract_unit.rb +0 -3
- data/vendor/rails/actionmailer/test/mail_service_test.rb +3 -2
- data/vendor/rails/actionpack/CHANGELOG +16 -0
- data/vendor/rails/actionpack/Rakefile +5 -3
- data/vendor/rails/actionpack/lib/action_controller.rb +2 -7
- data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +13 -3
- data/vendor/rails/actionpack/lib/action_controller/base.rb +12 -3
- data/vendor/rails/actionpack/lib/action_controller/caching.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/caching/actions.rb +9 -1
- data/vendor/rails/actionpack/lib/action_controller/caching/sweeper.rb +45 -0
- data/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb +0 -42
- data/vendor/rails/actionpack/lib/action_controller/cookies.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/dispatcher.rb +21 -6
- data/vendor/rails/actionpack/lib/action_controller/failsafe.rb +40 -6
- data/vendor/rails/actionpack/lib/action_controller/flash.rb +11 -3
- data/vendor/rails/actionpack/lib/action_controller/http_authentication.rb +7 -3
- data/vendor/rails/actionpack/lib/action_controller/integration.rb +5 -12
- data/vendor/rails/actionpack/lib/action_controller/middlewares.rb +0 -1
- data/vendor/rails/actionpack/lib/action_controller/params_parser.rb +6 -0
- data/vendor/rails/actionpack/lib/action_controller/reloader.rb +47 -7
- data/vendor/rails/actionpack/lib/action_controller/request.rb +6 -2
- data/vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb +2 -1
- data/vendor/rails/actionpack/lib/action_controller/resources.rb +17 -13
- data/vendor/rails/actionpack/lib/action_controller/response.rb +8 -2
- data/vendor/rails/actionpack/lib/action_controller/routing.rb +3 -0
- data/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb +20 -6
- data/vendor/rails/actionpack/lib/action_controller/streaming.rb +4 -2
- data/vendor/rails/actionpack/lib/action_controller/test_process.rb +9 -1
- data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +1 -1
- data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +21 -9
- data/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +2 -2
- data/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +26 -12
- data/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +71 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +10 -4
- data/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +7 -7
- data/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +5 -5
- data/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +23 -14
- data/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +2 -2
- data/vendor/rails/actionpack/lib/action_view/locale/en.yml +4 -0
- data/vendor/rails/actionpack/lib/action_view/paths.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/template.rb +22 -33
- data/vendor/rails/actionpack/test/abstract_unit.rb +17 -1
- data/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +3 -3
- data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +27 -0
- data/vendor/rails/actionpack/test/controller/caching_test.rb +40 -1
- data/vendor/rails/actionpack/test/controller/cookie_test.rb +16 -0
- data/vendor/rails/actionpack/test/controller/dispatcher_test.rb +59 -18
- data/vendor/rails/actionpack/test/controller/failsafe_test.rb +60 -0
- data/vendor/rails/actionpack/test/controller/filter_params_test.rb +3 -1
- data/vendor/rails/actionpack/test/controller/flash_test.rb +6 -1
- data/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +25 -0
- data/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +63 -9
- data/vendor/rails/actionpack/test/controller/integration_test.rb +31 -3
- data/vendor/rails/actionpack/test/controller/rack_test.rb +18 -1
- data/vendor/rails/actionpack/test/controller/redirect_test.rb +4 -1
- data/vendor/rails/actionpack/test/controller/reloader_test.rb +124 -0
- data/vendor/rails/actionpack/test/controller/render_test.rb +19 -9
- data/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb +24 -4
- data/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb +1 -62
- data/vendor/rails/actionpack/test/controller/request/test_request_test.rb +35 -0
- data/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +0 -38
- data/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb +15 -0
- data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +6 -5
- data/vendor/rails/actionpack/test/controller/request_test.rb +218 -230
- data/vendor/rails/actionpack/test/controller/resources_test.rb +52 -0
- data/vendor/rails/actionpack/test/controller/routing_test.rb +28 -2
- data/vendor/rails/actionpack/test/controller/send_file_test.rb +12 -2
- data/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +9 -32
- data/vendor/rails/actionpack/test/controller/test_test.rb +8 -0
- data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +29 -3
- data/vendor/rails/actionpack/test/fixtures/failsafe/500.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/absolute/test.css +23 -0
- data/vendor/rails/actionpack/test/fixtures/public/absolute/test.js +63 -0
- data/vendor/rails/actionpack/test/template/active_record_helper_test.rb +1 -1
- data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +46 -0
- data/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +29 -0
- data/vendor/rails/actionpack/test/template/form_helper_test.rb +143 -6
- data/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb +27 -0
- data/vendor/rails/actionpack/test/template/form_options_helper_test.rb +56 -0
- data/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +23 -6
- data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +11 -11
- data/vendor/rails/actionpack/test/template/template_test.rb +32 -0
- data/vendor/rails/actionpack/test/template/text_helper_test.rb +23 -0
- data/vendor/rails/actionpack/test/template/url_helper_test.rb +8 -0
- data/vendor/rails/activerecord/CHANGELOG +18 -0
- data/vendor/rails/activerecord/Rakefile +26 -9
- data/vendor/rails/activerecord/examples/performance.rb +162 -0
- data/vendor/rails/activerecord/lib/active_record/associations.rb +104 -35
- data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +10 -5
- data/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +22 -4
- data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -1
- data/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +16 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +1 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +13 -3
- data/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +15 -9
- data/vendor/rails/activerecord/lib/active_record/autosave_association.rb +15 -9
- data/vendor/rails/activerecord/lib/active_record/base.rb +34 -31
- data/vendor/rails/activerecord/lib/active_record/batches.rb +23 -15
- data/vendor/rails/activerecord/lib/active_record/calculations.rb +7 -13
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +16 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +7 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +17 -8
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +98 -35
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -0
- data/vendor/rails/activerecord/lib/active_record/dirty.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/fixtures.rb +14 -11
- data/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/locale/en.yml +4 -0
- data/vendor/rails/activerecord/lib/active_record/named_scope.rb +3 -8
- data/vendor/rails/activerecord/lib/active_record/reflection.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +6 -3
- data/vendor/rails/activerecord/lib/active_record/serialization.rb +3 -2
- data/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +10 -18
- data/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +6 -2
- data/vendor/rails/activerecord/lib/active_record/session_store.rb +9 -1
- data/vendor/rails/activerecord/lib/active_record/timestamp.rb +39 -9
- data/vendor/rails/activerecord/lib/active_record/validations.rb +149 -80
- data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
- data/vendor/rails/activerecord/test/cases/adapter_test.rb +12 -0
- data/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +102 -22
- data/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +5 -5
- data/vendor/rails/activerecord/test/cases/associations/eager_test.rb +12 -0
- data/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb +56 -0
- data/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +62 -2
- data/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +46 -1
- data/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +18 -1
- data/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +5 -0
- data/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +4 -4
- data/vendor/rails/activerecord/test/cases/autosave_association_test.rb +22 -0
- data/vendor/rails/activerecord/test/cases/base_test.rb +51 -6
- data/vendor/rails/activerecord/test/cases/calculations_test.rb +14 -14
- data/vendor/rails/activerecord/test/cases/column_definition_test.rb +34 -0
- data/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +5 -5
- data/vendor/rails/activerecord/test/cases/dirty_test.rb +10 -0
- data/vendor/rails/activerecord/test/cases/finder_test.rb +21 -50
- data/vendor/rails/activerecord/test/cases/fixtures_test.rb +6 -1
- data/vendor/rails/activerecord/test/cases/helper.rb +1 -2
- data/vendor/rails/activerecord/test/cases/i18n_test.rb +5 -0
- data/vendor/rails/activerecord/test/cases/json_serialization_test.rb +57 -57
- data/vendor/rails/activerecord/test/cases/method_scoping_test.rb +14 -4
- data/vendor/rails/activerecord/test/cases/migration_test.rb +39 -11
- data/vendor/rails/activerecord/test/cases/modules_test.rb +42 -0
- data/vendor/rails/activerecord/test/cases/named_scope_test.rb +6 -4
- data/vendor/rails/activerecord/test/cases/pk_test.rb +18 -0
- data/vendor/rails/activerecord/test/cases/reflection_test.rb +7 -7
- data/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +35 -7
- data/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +76 -0
- data/vendor/rails/activerecord/test/cases/timestamp_test.rb +75 -0
- data/vendor/rails/activerecord/test/cases/validations_i18n_test.rb +656 -624
- data/vendor/rails/activerecord/test/cases/validations_test.rb +12 -2
- data/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +20 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite +0 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 +0 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite +0 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 +0 -0
- data/vendor/rails/activerecord/test/fixtures/posts.yml +3 -0
- data/vendor/rails/activerecord/test/models/author.rb +5 -0
- data/vendor/rails/activerecord/test/models/comment.rb +5 -1
- data/vendor/rails/activerecord/test/models/company.rb +9 -7
- data/vendor/rails/activerecord/test/models/company_in_module.rb +1 -1
- data/vendor/rails/activerecord/test/models/contract.rb +5 -0
- data/vendor/rails/activerecord/test/models/developer.rb +10 -0
- data/vendor/rails/activerecord/test/models/essay.rb +3 -0
- data/vendor/rails/activerecord/test/models/organization.rb +2 -0
- data/vendor/rails/activerecord/test/models/pet.rb +1 -1
- data/vendor/rails/activerecord/test/models/project.rb +1 -1
- data/vendor/rails/activerecord/test/models/reply.rb +2 -1
- data/vendor/rails/activerecord/test/models/topic.rb +1 -2
- data/vendor/rails/activerecord/test/models/toy.rb +2 -0
- data/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +13 -2
- data/vendor/rails/activerecord/test/schema/schema.rb +19 -0
- data/vendor/rails/activeresource/CHANGELOG +16 -0
- data/vendor/rails/activeresource/Rakefile +3 -2
- data/vendor/rails/activeresource/lib/active_resource/base.rb +89 -9
- data/vendor/rails/activeresource/lib/active_resource/connection.rb +73 -8
- data/vendor/rails/activeresource/lib/active_resource/exceptions.rb +66 -0
- data/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +2 -2
- data/vendor/rails/activeresource/lib/active_resource/validations.rb +20 -4
- data/vendor/rails/activeresource/lib/active_resource/version.rb +1 -1
- data/vendor/rails/activeresource/test/abstract_unit.rb +1 -3
- data/vendor/rails/activeresource/test/base/load_test.rb +16 -1
- data/vendor/rails/activeresource/test/base_errors_test.rb +56 -19
- data/vendor/rails/activeresource/test/base_test.rb +147 -0
- data/vendor/rails/activeresource/test/connection_test.rb +42 -0
- data/vendor/rails/activeresource/test/debug.log +7974 -0
- data/vendor/rails/activeresource/test/fixtures/proxy.rb +4 -0
- data/vendor/rails/activesupport/CHANGELOG +13 -0
- data/vendor/rails/activesupport/lib/active_support/all.rb +8 -0
- data/vendor/rails/activesupport/lib/active_support/cache.rb +14 -1
- data/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +16 -10
- data/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb +1 -1
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +1 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +2 -1
- data/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +2 -4
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +14 -4
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +2 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +19 -5
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb +8 -6
- data/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +15 -9
- data/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +1 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +29 -5
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +7 -7
- data/vendor/rails/activesupport/lib/active_support/deprecation.rb +9 -9
- data/vendor/rails/activesupport/lib/active_support/duration.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json.rb +1 -22
- data/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb +38 -0
- data/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb +88 -0
- data/vendor/rails/activesupport/lib/active_support/json/decoding.rb +23 -72
- data/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +14 -9
- data/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +21 -11
- data/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +16 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +6 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +4 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +5 -32
- data/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +2 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoding.rb +80 -9
- data/vendor/rails/activesupport/lib/active_support/memoizable.rb +1 -1
- data/vendor/rails/activesupport/lib/active_support/message_verifier.rb +16 -3
- data/vendor/rails/activesupport/lib/active_support/multibyte.rb +30 -6
- data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +23 -17
- data/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb +61 -0
- data/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +28 -0
- data/vendor/rails/activesupport/lib/active_support/test_case.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb +2 -0
- data/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/vendor.rb +6 -7
- data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -1
- data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -1
- data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -1
- data/vendor/rails/activesupport/lib/active_support/vendor/{memcache-client-1.6.5 → memcache-client-1.7.4}/memcache.rb +242 -70
- data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
- data/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb +162 -0
- data/vendor/rails/railties/CHANGELOG +10 -0
- data/vendor/rails/railties/Rakefile +13 -9
- data/vendor/rails/railties/bin/about +2 -2
- data/vendor/rails/railties/bin/console +1 -1
- data/vendor/rails/railties/bin/dbconsole +1 -1
- data/vendor/rails/railties/bin/destroy +1 -1
- data/vendor/rails/railties/bin/generate +1 -1
- data/vendor/rails/railties/bin/performance/benchmarker +1 -1
- data/vendor/rails/railties/bin/performance/profiler +1 -1
- data/vendor/rails/railties/bin/plugin +1 -1
- data/vendor/rails/railties/bin/runner +1 -1
- data/vendor/rails/railties/bin/server +1 -1
- data/vendor/rails/railties/builtin/rails_info/rails/info.rb +4 -2
- data/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +2 -0
- data/vendor/rails/railties/configs/routes.rb +1 -1
- data/vendor/rails/railties/configs/seeds.rb +7 -0
- data/vendor/rails/railties/environments/boot.rb +1 -1
- data/vendor/rails/railties/guides/files/javascripts/code_highlighter.js +188 -0
- data/vendor/rails/railties/guides/files/javascripts/guides.js +8 -0
- data/vendor/rails/railties/guides/files/javascripts/highlighters.js +90 -0
- data/vendor/rails/railties/guides/files/stylesheets/main.css +441 -0
- data/vendor/rails/railties/guides/files/stylesheets/print.css +52 -0
- data/vendor/rails/railties/guides/files/stylesheets/reset.css +43 -0
- data/vendor/rails/railties/guides/files/stylesheets/style.css +13 -0
- data/vendor/rails/railties/guides/files/stylesheets/syntax.css +31 -0
- data/vendor/rails/railties/guides/images/belongs_to.png +0 -0
- data/vendor/rails/railties/guides/images/book_icon.gif +0 -0
- data/vendor/rails/railties/guides/images/bullet.gif +0 -0
- data/vendor/rails/railties/guides/images/chapters_icon.gif +0 -0
- data/vendor/rails/railties/guides/images/check_bullet.gif +0 -0
- data/vendor/rails/railties/guides/images/credits_pic_blank.gif +0 -0
- data/vendor/rails/railties/guides/images/csrf.png +0 -0
- data/vendor/rails/railties/guides/images/customized_error_messages.png +0 -0
- data/vendor/rails/railties/guides/images/error_messages.png +0 -0
- data/vendor/rails/railties/guides/images/feature_tile.gif +0 -0
- data/vendor/rails/railties/guides/images/footer_tile.gif +0 -0
- data/vendor/rails/railties/guides/images/fxn.jpg +0 -0
- data/vendor/rails/railties/guides/images/grey_bullet.gif +0 -0
- data/vendor/rails/railties/guides/images/habtm.png +0 -0
- data/vendor/rails/railties/guides/images/has_many.png +0 -0
- data/vendor/rails/railties/guides/images/has_many_through.png +0 -0
- data/vendor/rails/railties/guides/images/has_one.png +0 -0
- data/vendor/rails/railties/guides/images/has_one_through.png +0 -0
- data/vendor/rails/railties/guides/images/header_backdrop.png +0 -0
- data/vendor/rails/railties/guides/images/header_tile.gif +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_localized_pirate.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_translated_en.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_translated_pirate.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_translation_missing.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_untranslated.png +0 -0
- data/vendor/rails/railties/guides/images/icons/README +5 -0
- data/vendor/rails/railties/guides/images/icons/callouts/1.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/10.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/11.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/12.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/13.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/14.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/15.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/2.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/3.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/4.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/5.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/6.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/7.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/8.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/9.png +0 -0
- data/vendor/rails/railties/guides/images/icons/caution.png +0 -0
- data/vendor/rails/railties/guides/images/icons/example.png +0 -0
- data/vendor/rails/railties/guides/images/icons/home.png +0 -0
- data/vendor/rails/railties/guides/images/icons/important.png +0 -0
- data/vendor/rails/railties/guides/images/icons/next.png +0 -0
- data/vendor/rails/railties/guides/images/icons/note.png +0 -0
- data/vendor/rails/railties/guides/images/icons/prev.png +0 -0
- data/vendor/rails/railties/guides/images/icons/tip.png +0 -0
- data/vendor/rails/railties/guides/images/icons/up.png +0 -0
- data/vendor/rails/railties/guides/images/icons/warning.png +0 -0
- data/vendor/rails/railties/guides/images/nav_arrow.gif +0 -0
- data/vendor/rails/railties/guides/images/polymorphic.png +0 -0
- data/vendor/rails/railties/guides/images/posts_index.png +0 -0
- data/vendor/rails/railties/guides/images/rails_guides_logo.gif +0 -0
- data/vendor/rails/railties/guides/images/rails_logo_remix.gif +0 -0
- data/vendor/rails/railties/guides/images/rails_welcome.png +0 -0
- data/vendor/rails/railties/guides/images/session_fixation.png +0 -0
- data/vendor/rails/railties/guides/images/tab_grey.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_info.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_note.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_red.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_yellow.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_yellow.png +0 -0
- data/vendor/rails/railties/guides/images/validation_error_messages.png +0 -0
- data/vendor/rails/railties/guides/rails_guides.rb +42 -0
- data/vendor/rails/railties/guides/rails_guides/generator.rb +138 -0
- data/vendor/rails/railties/guides/rails_guides/helpers.rb +34 -0
- data/vendor/rails/railties/guides/rails_guides/indexer.rb +55 -0
- data/vendor/rails/railties/guides/rails_guides/textile_extensions.rb +41 -0
- data/vendor/rails/railties/guides/source/2_2_release_notes.textile +422 -0
- data/vendor/rails/railties/guides/source/2_3_release_notes.textile +610 -0
- data/vendor/rails/railties/guides/source/action_controller_overview.textile +776 -0
- data/vendor/rails/railties/guides/source/action_mailer_basics.textile +424 -0
- data/vendor/rails/railties/guides/source/active_record_basics.textile +135 -0
- data/vendor/rails/railties/guides/source/active_record_querying.textile +969 -0
- data/vendor/rails/railties/guides/source/activerecord_validations_callbacks.textile +1086 -0
- data/vendor/rails/railties/guides/source/association_basics.textile +1781 -0
- data/vendor/rails/railties/guides/source/caching_with_rails.textile +524 -0
- data/vendor/rails/railties/guides/source/command_line.textile +589 -0
- data/vendor/rails/railties/guides/source/configuring.textile +234 -0
- data/vendor/rails/railties/guides/source/contribute.textile +71 -0
- data/vendor/rails/railties/guides/source/contributing_to_rails.textile +239 -0
- data/vendor/rails/railties/guides/source/credits.erb.textile +52 -0
- data/vendor/rails/railties/guides/source/debugging_rails_applications.textile +709 -0
- data/vendor/rails/railties/guides/source/form_helpers.textile +766 -0
- data/vendor/rails/railties/guides/source/getting_started.textile +1297 -0
- data/vendor/rails/railties/guides/source/i18n.textile +912 -0
- data/vendor/rails/railties/guides/source/index.erb.textile +124 -0
- data/vendor/rails/railties/guides/source/layout.html.erb +103 -0
- data/vendor/rails/railties/guides/source/layouts_and_rendering.textile +979 -0
- data/vendor/rails/railties/guides/source/migrations.textile +591 -0
- data/vendor/rails/railties/guides/source/nested_model_forms.textile +222 -0
- data/vendor/rails/railties/guides/source/performance_testing.textile +531 -0
- data/vendor/rails/railties/guides/source/plugins.textile +1512 -0
- data/vendor/rails/railties/guides/source/rails_on_rack.textile +309 -0
- data/vendor/rails/railties/guides/source/routing.textile +903 -0
- data/vendor/rails/railties/guides/source/security.textile +986 -0
- data/vendor/rails/railties/guides/source/testing.textile +951 -0
- data/vendor/rails/railties/lib/commands/dbconsole.rb +8 -4
- data/vendor/rails/railties/lib/commands/performance/profiler.rb +1 -1
- data/vendor/rails/railties/lib/initializer.rb +27 -4
- data/vendor/rails/railties/lib/rails/gem_dependency.rb +35 -6
- data/vendor/rails/railties/lib/rails/plugin.rb +12 -0
- data/vendor/rails/railties/lib/rails/plugin/loader.rb +7 -0
- data/vendor/rails/railties/lib/rails/rack/metal.rb +1 -1
- data/vendor/rails/railties/lib/rails/version.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/base.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +5 -0
- data/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +9 -2
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -0
- data/vendor/rails/railties/lib/tasks/databases.rake +17 -4
- data/vendor/rails/railties/lib/tasks/gems.rake +19 -6
- data/vendor/rails/railties/lib/tasks/routes.rake +4 -3
- data/vendor/rails/railties/lib/test_help.rb +4 -1
- metadata +158 -58
- data/spec/lib/local_time_spec.rb +0 -40
- data/vendor/rails/actionpack/lib/action_controller/rewindable_input.rb +0 -28
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack.rb +0 -89
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +0 -22
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +0 -37
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +0 -37
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +0 -58
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +0 -124
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +0 -51
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +0 -55
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +0 -40
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +0 -480
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/builder.rb +0 -63
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +0 -36
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +0 -49
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +0 -61
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +0 -45
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +0 -29
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +0 -23
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +0 -85
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/directory.rb +0 -153
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/file.rb +0 -88
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler.rb +0 -48
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +0 -61
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +0 -8
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +0 -89
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +0 -55
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +0 -84
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +0 -59
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +0 -8
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +0 -18
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +0 -67
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/head.rb +0 -19
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb +0 -462
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +0 -65
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lock.rb +0 -16
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +0 -27
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mime.rb +0 -204
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb +0 -160
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +0 -57
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +0 -64
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb +0 -241
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/response.rb +0 -179
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +0 -142
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +0 -91
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +0 -109
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +0 -100
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +0 -349
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +0 -106
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb +0 -38
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +0 -55
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb +0 -392
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class TemplateTest < Test::Unit::TestCase
|
4
|
+
def test_template_path_parsing
|
5
|
+
with_options :base_path => nil, :name => 'abc', :locale => nil, :format => 'html', :extension => 'erb' do |t|
|
6
|
+
t.assert_parses_template_path 'abc.en.html.erb', :locale => 'en'
|
7
|
+
t.assert_parses_template_path 'abc.en.plain.html.erb', :locale => 'en', :format => 'plain.html'
|
8
|
+
t.assert_parses_template_path 'abc.html.erb'
|
9
|
+
t.assert_parses_template_path 'abc.plain.html.erb', :format => 'plain.html'
|
10
|
+
t.assert_parses_template_path 'abc.erb', :format => nil
|
11
|
+
t.assert_parses_template_path 'abc.html', :extension => nil
|
12
|
+
|
13
|
+
t.assert_parses_template_path '_abc.html.erb', :name => '_abc'
|
14
|
+
|
15
|
+
t.assert_parses_template_path 'test/abc.html.erb', :base_path => 'test'
|
16
|
+
t.assert_parses_template_path './test/abc.html.erb', :base_path => './test'
|
17
|
+
t.assert_parses_template_path '../test/abc.html.erb', :base_path => '../test'
|
18
|
+
|
19
|
+
t.assert_parses_template_path 'abc', :extension => nil, :format => nil, :name => nil
|
20
|
+
t.assert_parses_template_path 'abc.xxx', :extension => nil, :format => 'xxx', :name => 'abc'
|
21
|
+
t.assert_parses_template_path 'abc.html.xxx', :extension => nil, :format => 'xxx', :name => 'abc'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def assert_parses_template_path(path, parse_results)
|
27
|
+
template = ActionView::Template.new(path, '')
|
28
|
+
parse_results.each_pair do |k, v|
|
29
|
+
assert_block(%Q{Expected template to parse #{k.inspect} from "#{path}" as #{v.inspect}, but got #{template.send(k).inspect}}) { v == template.send(k) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,5 +1,10 @@
|
|
1
1
|
require 'abstract_unit'
|
2
2
|
require 'testing_sandbox'
|
3
|
+
begin
|
4
|
+
require 'redcloth'
|
5
|
+
rescue LoadError
|
6
|
+
$stderr.puts "Skipping textilize tests. `gem install RedCloth` to enable."
|
7
|
+
end
|
3
8
|
|
4
9
|
class TextHelperTest < ActionView::TestCase
|
5
10
|
tests ActionView::Helpers::TextHelper
|
@@ -517,4 +522,22 @@ class TextHelperTest < ActionView::TestCase
|
|
517
522
|
assert_equal("red", cycle("red", "blue"))
|
518
523
|
assert_equal(%w{Specialized Fuji Giant}, @cycles)
|
519
524
|
end
|
525
|
+
|
526
|
+
if defined? RedCloth
|
527
|
+
def test_textilize
|
528
|
+
assert_equal("<p><strong>This is Textile!</strong> Rejoice!</p>", textilize("*This is Textile!* Rejoice!"))
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_textilize_with_blank
|
532
|
+
assert_equal("", textilize(""))
|
533
|
+
end
|
534
|
+
|
535
|
+
def test_textilize_with_options
|
536
|
+
assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong>", :filter_html))
|
537
|
+
end
|
538
|
+
|
539
|
+
def test_textilize_with_hard_breaks
|
540
|
+
assert_equal("<p>This is one scary world.<br />\n True.</p>", textilize("This is one scary world.\n True."))
|
541
|
+
end
|
542
|
+
end
|
520
543
|
end
|
@@ -219,6 +219,14 @@ class UrlHelperTest < ActionView::TestCase
|
|
219
219
|
)
|
220
220
|
end
|
221
221
|
|
222
|
+
def test_link_tag_using_delete_javascript_and_href_and_confirm
|
223
|
+
assert_dom_equal(
|
224
|
+
"<a href='\#' onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = 'http://www.example.com';var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;\">Destroy</a>",
|
225
|
+
link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#', :confirm => "Are you serious?"),
|
226
|
+
"When specifying url, form should be generated with it, but not this.href"
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
222
230
|
def test_link_tag_using_post_javascript_and_popup
|
223
231
|
assert_raise(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") }
|
224
232
|
end
|
@@ -1,3 +1,21 @@
|
|
1
|
+
*2.3.4 (September 4, 2009)*
|
2
|
+
|
3
|
+
* PostgreSQL: XML datatype support. #1874 [Leonardo Borges]
|
4
|
+
|
5
|
+
* SQLite: deprecate the 'dbfile' option in favor of 'database.' #2363 [Paul Hinze, Jeremy Kemper]
|
6
|
+
|
7
|
+
|
8
|
+
*2.3.3 (July 12, 2009)*
|
9
|
+
|
10
|
+
* Added :primary_key option to belongs_to associations. #765 [Szymon Nowak, Philip Hallstrom, Noel Rocha]
|
11
|
+
# employees.company_name references companies.name
|
12
|
+
Employee.belongs_to :company, :primary_key => 'name', :foreign_key => 'company_name'
|
13
|
+
|
14
|
+
* Added :touch option to belongs_to associations that will touch the parent record when the current record is saved or destroyed [DHH]
|
15
|
+
|
16
|
+
* Added ActiveRecord::Base#touch to update the updated_at/on attributes (or another specified timestamp) with the current time [DHH]
|
17
|
+
|
18
|
+
|
1
19
|
*2.3.2 [Final] (March 15, 2009)*
|
2
20
|
|
3
21
|
* Added ActiveRecord::Base.find_each and ActiveRecord::Base.find_in_batches for batch processing [DHH/Jamis Buck]
|
@@ -4,7 +4,6 @@ require 'rake/testtask'
|
|
4
4
|
require 'rake/rdoctask'
|
5
5
|
require 'rake/packagetask'
|
6
6
|
require 'rake/gempackagetask'
|
7
|
-
require 'rake/contrib/sshpublisher'
|
8
7
|
|
9
8
|
require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version')
|
10
9
|
require File.expand_path(File.dirname(__FILE__)) + "/test/config"
|
@@ -25,14 +24,30 @@ PKG_FILES = FileList[
|
|
25
24
|
"lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile"
|
26
25
|
].exclude(/\bCVS\b|~$/)
|
27
26
|
|
27
|
+
def run_without_aborting(*tasks)
|
28
|
+
errors = []
|
29
|
+
|
30
|
+
tasks.each do |task|
|
31
|
+
begin
|
32
|
+
Rake::Task[task].invoke
|
33
|
+
rescue Exception
|
34
|
+
errors << task
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
abort "Errors running #{errors.join(', ')}" if errors.any?
|
39
|
+
end
|
28
40
|
|
29
41
|
desc 'Run mysql, sqlite, and postgresql tests by default'
|
30
42
|
task :default => :test
|
31
43
|
|
32
44
|
desc 'Run mysql, sqlite, and postgresql tests'
|
33
|
-
task :test
|
34
|
-
|
35
|
-
|
45
|
+
task :test do
|
46
|
+
tasks = defined?(JRUBY_VERSION) ?
|
47
|
+
%w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) :
|
48
|
+
%w(test_mysql test_sqlite3 test_postgresql)
|
49
|
+
run_without_aborting(*tasks)
|
50
|
+
end
|
36
51
|
|
37
52
|
for adapter in %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb )
|
38
53
|
Rake::TestTask.new("test_#{adapter}") { |t|
|
@@ -54,8 +69,8 @@ end
|
|
54
69
|
namespace :mysql do
|
55
70
|
desc 'Build the MySQL test databases'
|
56
71
|
task :build_databases do
|
57
|
-
%x(
|
58
|
-
%x(
|
72
|
+
%x( echo "create DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
|
73
|
+
%x( echo "create DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
|
59
74
|
end
|
60
75
|
|
61
76
|
desc 'Drop the MySQL test databases'
|
@@ -76,8 +91,8 @@ task :rebuild_mysql_databases => 'mysql:rebuild_databases'
|
|
76
91
|
namespace :postgresql do
|
77
92
|
desc 'Build the PostgreSQL test databases'
|
78
93
|
task :build_databases do
|
79
|
-
%x( createdb activerecord_unittest )
|
80
|
-
%x( createdb activerecord_unittest2 )
|
94
|
+
%x( createdb -E UTF8 activerecord_unittest )
|
95
|
+
%x( createdb -E UTF8 activerecord_unittest2 )
|
81
96
|
end
|
82
97
|
|
83
98
|
desc 'Drop the PostgreSQL test databases'
|
@@ -177,7 +192,7 @@ spec = Gem::Specification.new do |s|
|
|
177
192
|
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
178
193
|
end
|
179
194
|
|
180
|
-
s.add_dependency('activesupport', '= 2.3.
|
195
|
+
s.add_dependency('activesupport', '= 2.3.4' + PKG_BUILD)
|
181
196
|
|
182
197
|
s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite"
|
183
198
|
s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite"
|
@@ -231,12 +246,14 @@ end
|
|
231
246
|
|
232
247
|
desc "Publish the beta gem"
|
233
248
|
task :pgem => [:package] do
|
249
|
+
require 'rake/contrib/sshpublisher'
|
234
250
|
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
235
251
|
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
|
236
252
|
end
|
237
253
|
|
238
254
|
desc "Publish the API documentation"
|
239
255
|
task :pdoc => [:rdoc] do
|
256
|
+
require 'rake/contrib/sshpublisher'
|
240
257
|
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload
|
241
258
|
end
|
242
259
|
|
@@ -0,0 +1,162 @@
|
|
1
|
+
#!/usr/bin/env ruby -KU
|
2
|
+
|
3
|
+
TIMES = (ENV['N'] || 10000).to_i
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
gem 'addressable', '~>2.0'
|
7
|
+
gem 'faker', '~>0.3.1'
|
8
|
+
gem 'rbench', '~>0.2.3'
|
9
|
+
require 'addressable/uri'
|
10
|
+
require 'faker'
|
11
|
+
require 'rbench'
|
12
|
+
|
13
|
+
__DIR__ = File.dirname(__FILE__)
|
14
|
+
$:.unshift "#{__DIR__}/../lib"
|
15
|
+
require 'active_record'
|
16
|
+
|
17
|
+
conn = { :adapter => 'mysql',
|
18
|
+
:database => 'activerecord_unittest',
|
19
|
+
:username => 'rails', :password => '',
|
20
|
+
:encoding => 'utf8' }
|
21
|
+
|
22
|
+
conn[:socket] = Pathname.glob(%w[
|
23
|
+
/opt/local/var/run/mysql5/mysqld.sock
|
24
|
+
/tmp/mysqld.sock
|
25
|
+
/tmp/mysql.sock
|
26
|
+
/var/mysql/mysql.sock
|
27
|
+
/var/run/mysqld/mysqld.sock
|
28
|
+
]).find { |path| path.socket? }
|
29
|
+
|
30
|
+
ActiveRecord::Base.establish_connection(conn)
|
31
|
+
|
32
|
+
class User < ActiveRecord::Base
|
33
|
+
connection.create_table :users, :force => true do |t|
|
34
|
+
t.string :name, :email
|
35
|
+
t.timestamps
|
36
|
+
end
|
37
|
+
|
38
|
+
has_many :exhibits
|
39
|
+
end
|
40
|
+
|
41
|
+
class Exhibit < ActiveRecord::Base
|
42
|
+
connection.create_table :exhibits, :force => true do |t|
|
43
|
+
t.belongs_to :user
|
44
|
+
t.string :name
|
45
|
+
t.text :notes
|
46
|
+
t.timestamps
|
47
|
+
end
|
48
|
+
|
49
|
+
belongs_to :user
|
50
|
+
|
51
|
+
def look; attributes end
|
52
|
+
def feel; look; user.name end
|
53
|
+
|
54
|
+
def self.look(exhibits) exhibits.each { |e| e.look } end
|
55
|
+
def self.feel(exhibits) exhibits.each { |e| e.feel } end
|
56
|
+
end
|
57
|
+
|
58
|
+
sqlfile = "#{__DIR__}/performance.sql"
|
59
|
+
|
60
|
+
if File.exists?(sqlfile)
|
61
|
+
mysql_bin = %w[mysql mysql5].select { |bin| `which #{bin}`.length > 0 }
|
62
|
+
`#{mysql_bin} -u #{conn[:username]} #{"-p#{conn[:password]}" unless conn[:password].blank?} #{conn[:database]} < #{sqlfile}`
|
63
|
+
else
|
64
|
+
puts 'Generating data...'
|
65
|
+
|
66
|
+
# pre-compute the insert statements and fake data compilation,
|
67
|
+
# so the benchmarks below show the actual runtime for the execute
|
68
|
+
# method, minus the setup steps
|
69
|
+
|
70
|
+
# Using the same paragraph for all exhibits because it is very slow
|
71
|
+
# to generate unique paragraphs for all exhibits.
|
72
|
+
notes = Faker::Lorem.paragraphs.join($/)
|
73
|
+
today = Date.today
|
74
|
+
|
75
|
+
puts 'Inserting 10,000 users and exhibits...'
|
76
|
+
10_000.times do
|
77
|
+
user = User.create(
|
78
|
+
:created_at => today,
|
79
|
+
:name => Faker::Name.name,
|
80
|
+
:email => Faker::Internet.email
|
81
|
+
)
|
82
|
+
|
83
|
+
Exhibit.create(
|
84
|
+
:created_at => today,
|
85
|
+
:name => Faker::Company.name,
|
86
|
+
:user => user,
|
87
|
+
:notes => notes
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
mysqldump_bin = %w[mysqldump mysqldump5].select { |bin| `which #{bin}`.length > 0 }
|
92
|
+
`#{mysqldump_bin} -u #{conn[:username]} #{"-p#{conn[:password]}" unless conn[:password].blank?} #{conn[:database]} exhibits users > #{sqlfile}`
|
93
|
+
end
|
94
|
+
|
95
|
+
RBench.run(TIMES) do
|
96
|
+
column :times
|
97
|
+
column :ar
|
98
|
+
|
99
|
+
report 'Model#id', (TIMES * 100).ceil do
|
100
|
+
ar_obj = Exhibit.find(1)
|
101
|
+
|
102
|
+
ar { ar_obj.id }
|
103
|
+
end
|
104
|
+
|
105
|
+
report 'Model.new (instantiation)' do
|
106
|
+
ar { Exhibit.new }
|
107
|
+
end
|
108
|
+
|
109
|
+
report 'Model.new (setting attributes)' do
|
110
|
+
attrs = { :name => 'sam' }
|
111
|
+
ar { Exhibit.new(attrs) }
|
112
|
+
end
|
113
|
+
|
114
|
+
report 'Model.first' do
|
115
|
+
ar { Exhibit.first.look }
|
116
|
+
end
|
117
|
+
|
118
|
+
report 'Model.all limit(100)', (TIMES / 10).ceil do
|
119
|
+
ar { Exhibit.look Exhibit.all(:limit => 100) }
|
120
|
+
end
|
121
|
+
|
122
|
+
report 'Model.all limit(100) with relationship', (TIMES / 10).ceil do
|
123
|
+
ar { Exhibit.feel Exhibit.all(:limit => 100, :include => :user) }
|
124
|
+
end
|
125
|
+
|
126
|
+
report 'Model.all limit(10,000)', (TIMES / 1000).ceil do
|
127
|
+
ar { Exhibit.look Exhibit.all(:limit => 10000) }
|
128
|
+
end
|
129
|
+
|
130
|
+
exhibit = {
|
131
|
+
:name => Faker::Company.name,
|
132
|
+
:notes => Faker::Lorem.paragraphs.join($/),
|
133
|
+
:created_at => Date.today
|
134
|
+
}
|
135
|
+
|
136
|
+
report 'Model.create' do
|
137
|
+
ar { Exhibit.create(exhibit) }
|
138
|
+
end
|
139
|
+
|
140
|
+
report 'Resource#attributes=' do
|
141
|
+
attrs_first = { :name => 'sam' }
|
142
|
+
attrs_second = { :name => 'tom' }
|
143
|
+
ar { exhibit = Exhibit.new(attrs_first); exhibit.attributes = attrs_second }
|
144
|
+
end
|
145
|
+
|
146
|
+
report 'Resource#update' do
|
147
|
+
ar { Exhibit.first.update_attributes(:name => 'bob') }
|
148
|
+
end
|
149
|
+
|
150
|
+
report 'Resource#destroy' do
|
151
|
+
ar { Exhibit.first.destroy }
|
152
|
+
end
|
153
|
+
|
154
|
+
report 'Model.transaction' do
|
155
|
+
ar { Exhibit.transaction { Exhibit.new } }
|
156
|
+
end
|
157
|
+
|
158
|
+
summary 'Total'
|
159
|
+
end
|
160
|
+
|
161
|
+
ActiveRecord::Migration.drop_table "exhibits"
|
162
|
+
ActiveRecord::Migration.drop_table "users"
|
@@ -34,11 +34,13 @@ module ActiveRecord
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
class
|
37
|
+
class HasManyThroughCantAssociateThroughHasOneOrManyReflection < ActiveRecordError #:nodoc:
|
38
38
|
def initialize(owner, reflection)
|
39
39
|
super("Cannot modify association '#{owner.class.name}##{reflection.name}' because the source reflection class '#{reflection.source_reflection.class_name}' is associated to '#{reflection.through_reflection.class_name}' via :#{reflection.source_reflection.macro}.")
|
40
40
|
end
|
41
41
|
end
|
42
|
+
HasManyThroughCantAssociateThroughHasManyReflection = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveRecord::HasManyThroughCantAssociateThroughHasManyReflection', 'ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection')
|
43
|
+
|
42
44
|
class HasManyThroughCantAssociateNewRecords < ActiveRecordError #:nodoc:
|
43
45
|
def initialize(owner, reflection)
|
44
46
|
super("Cannot associate new records through '#{owner.class.name}##{reflection.name}' on '#{reflection.source_reflection.class_name rescue nil}##{reflection.source_reflection.name rescue nil}'. Both records must have an id in order to create the has_many :through record associating them.")
|
@@ -410,6 +412,32 @@ module ActiveRecord
|
|
410
412
|
# @firm.clients.collect { |c| c.invoices }.flatten # select all invoices for all clients of the firm
|
411
413
|
# @firm.invoices # selects all invoices by going through the Client join model.
|
412
414
|
#
|
415
|
+
# Similarly you can go through a +has_one+ association on the join model:
|
416
|
+
#
|
417
|
+
# class Group < ActiveRecord::Base
|
418
|
+
# has_many :users
|
419
|
+
# has_many :avatars, :through => :users
|
420
|
+
# end
|
421
|
+
#
|
422
|
+
# class User < ActiveRecord::Base
|
423
|
+
# belongs_to :group
|
424
|
+
# has_one :avatar
|
425
|
+
# end
|
426
|
+
#
|
427
|
+
# class Avatar < ActiveRecord::Base
|
428
|
+
# belongs_to :user
|
429
|
+
# end
|
430
|
+
#
|
431
|
+
# @group = Group.first
|
432
|
+
# @group.users.collect { |u| u.avatar }.flatten # select all avatars for all users in the group
|
433
|
+
# @group.avatars # selects all avatars by going through the User join model.
|
434
|
+
#
|
435
|
+
# An important caveat with going through +has_one+ or +has_many+ associations on the join model is that these associations are
|
436
|
+
# *read-only*. For example, the following would not work following the previous example:
|
437
|
+
#
|
438
|
+
# @group.avatars << Avatar.new # this would work if User belonged_to Avatar rather than the other way around.
|
439
|
+
# @group.avatars.delete(@group.avatars.last) # so would this
|
440
|
+
#
|
413
441
|
# === Polymorphic Associations
|
414
442
|
#
|
415
443
|
# Polymorphic associations on models are not restricted on what types of models they can be associated with. Rather, they
|
@@ -759,7 +787,7 @@ module ActiveRecord
|
|
759
787
|
# [:through]
|
760
788
|
# Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt> and <tt>:foreign_key</tt>
|
761
789
|
# are ignored, as the association uses the source reflection. You can only use a <tt>:through</tt> query through a <tt>belongs_to</tt>
|
762
|
-
# or <tt>has_many</tt> association on the join model.
|
790
|
+
# <tt>has_one</tt> or <tt>has_many</tt> association on the join model.
|
763
791
|
# [:source]
|
764
792
|
# Specifies the source association name used by <tt>has_many :through</tt> queries. Only use it if the name cannot be
|
765
793
|
# inferred from the association. <tt>has_many :subscribers, :through => :subscriptions</tt> will look for either <tt>:subscribers</tt> or
|
@@ -957,6 +985,8 @@ module ActiveRecord
|
|
957
985
|
# of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :person</tt> association will use
|
958
986
|
# "person_id" as the default <tt>:foreign_key</tt>. Similarly, <tt>belongs_to :favorite_person, :class_name => "Person"</tt>
|
959
987
|
# will use a foreign key of "favorite_person_id".
|
988
|
+
# [:primary_key]
|
989
|
+
# Specify the method that returns the primary key of associated object used for the association. By default this is id.
|
960
990
|
# [:dependent]
|
961
991
|
# If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to
|
962
992
|
# <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method. This option should not be specified when
|
@@ -981,15 +1011,21 @@ module ActiveRecord
|
|
981
1011
|
# If false, don't validate the associated objects when saving the parent object. +false+ by default.
|
982
1012
|
# [:autosave]
|
983
1013
|
# If true, always save the associated object or destroy it if marked for destruction, when saving the parent object. Off by default.
|
1014
|
+
# [:touch]
|
1015
|
+
# If true, the associated object will be touched (the updated_at/on attributes set to now) when this record is either saved or
|
1016
|
+
# destroyed. If you specify a symbol, that attribute will be updated with the current time instead of the updated_at/on attribute.
|
984
1017
|
#
|
985
1018
|
# Option examples:
|
986
1019
|
# belongs_to :firm, :foreign_key => "client_of"
|
1020
|
+
# belongs_to :person, :primary_key => "name", :foreign_key => "person_name"
|
987
1021
|
# belongs_to :author, :class_name => "Person", :foreign_key => "author_id"
|
988
1022
|
# belongs_to :valid_coupon, :class_name => "Coupon", :foreign_key => "coupon_id",
|
989
1023
|
# :conditions => 'discounts > #{payments_count}'
|
990
1024
|
# belongs_to :attachable, :polymorphic => true
|
991
1025
|
# belongs_to :project, :readonly => true
|
992
1026
|
# belongs_to :post, :counter_cache => true
|
1027
|
+
# belongs_to :company, :touch => true
|
1028
|
+
# belongs_to :company, :touch => :employees_last_updated_at
|
993
1029
|
def belongs_to(association_id, options = {})
|
994
1030
|
reflection = create_belongs_to_reflection(association_id, options)
|
995
1031
|
|
@@ -1001,28 +1037,8 @@ module ActiveRecord
|
|
1001
1037
|
association_constructor_method(:create, reflection, BelongsToAssociation)
|
1002
1038
|
end
|
1003
1039
|
|
1004
|
-
|
1005
|
-
if options[:
|
1006
|
-
cache_column = reflection.counter_cache_column
|
1007
|
-
|
1008
|
-
method_name = "belongs_to_counter_cache_after_create_for_#{reflection.name}".to_sym
|
1009
|
-
define_method(method_name) do
|
1010
|
-
association = send(reflection.name)
|
1011
|
-
association.class.increment_counter(cache_column, send(reflection.primary_key_name)) unless association.nil?
|
1012
|
-
end
|
1013
|
-
after_create method_name
|
1014
|
-
|
1015
|
-
method_name = "belongs_to_counter_cache_before_destroy_for_#{reflection.name}".to_sym
|
1016
|
-
define_method(method_name) do
|
1017
|
-
association = send(reflection.name)
|
1018
|
-
association.class.decrement_counter(cache_column, send(reflection.primary_key_name)) unless association.nil?
|
1019
|
-
end
|
1020
|
-
before_destroy method_name
|
1021
|
-
|
1022
|
-
module_eval(
|
1023
|
-
"#{reflection.class_name}.send(:attr_readonly,\"#{cache_column}\".intern) if defined?(#{reflection.class_name}) && #{reflection.class_name}.respond_to?(:attr_readonly)"
|
1024
|
-
)
|
1025
|
-
end
|
1040
|
+
add_counter_cache_callbacks(reflection) if options[:counter_cache]
|
1041
|
+
add_touch_callbacks(reflection, options[:touch]) if options[:touch]
|
1026
1042
|
|
1027
1043
|
configure_dependency_for_belongs_to(reflection)
|
1028
1044
|
end
|
@@ -1253,7 +1269,11 @@ module ActiveRecord
|
|
1253
1269
|
|
1254
1270
|
if association_proxy_class == HasOneThroughAssociation
|
1255
1271
|
association.create_through_record(new_value)
|
1256
|
-
|
1272
|
+
if new_record?
|
1273
|
+
association_instance_set(reflection.name, new_value.nil? ? nil : association)
|
1274
|
+
else
|
1275
|
+
self.send(reflection.name, new_value)
|
1276
|
+
end
|
1257
1277
|
else
|
1258
1278
|
association.replace(new_value)
|
1259
1279
|
association_instance_set(reflection.name, new_value.nil? ? nil : association)
|
@@ -1305,7 +1325,7 @@ module ActiveRecord
|
|
1305
1325
|
|
1306
1326
|
define_method("#{reflection.name.to_s.singularize}_ids=") do |new_value|
|
1307
1327
|
ids = (new_value || []).reject { |nid| nid.blank? }
|
1308
|
-
send("#{reflection.name}=", reflection.
|
1328
|
+
send("#{reflection.name}=", reflection.klass.find(ids))
|
1309
1329
|
end
|
1310
1330
|
end
|
1311
1331
|
end
|
@@ -1329,6 +1349,43 @@ module ActiveRecord
|
|
1329
1349
|
end
|
1330
1350
|
end
|
1331
1351
|
|
1352
|
+
def add_counter_cache_callbacks(reflection)
|
1353
|
+
cache_column = reflection.counter_cache_column
|
1354
|
+
|
1355
|
+
method_name = "belongs_to_counter_cache_after_create_for_#{reflection.name}".to_sym
|
1356
|
+
define_method(method_name) do
|
1357
|
+
association = send(reflection.name)
|
1358
|
+
association.class.increment_counter(cache_column, association.id) unless association.nil?
|
1359
|
+
end
|
1360
|
+
after_create(method_name)
|
1361
|
+
|
1362
|
+
method_name = "belongs_to_counter_cache_before_destroy_for_#{reflection.name}".to_sym
|
1363
|
+
define_method(method_name) do
|
1364
|
+
association = send(reflection.name)
|
1365
|
+
association.class.decrement_counter(cache_column, association.id) unless association.nil?
|
1366
|
+
end
|
1367
|
+
before_destroy(method_name)
|
1368
|
+
|
1369
|
+
module_eval(
|
1370
|
+
"#{reflection.class_name}.send(:attr_readonly,\"#{cache_column}\".intern) if defined?(#{reflection.class_name}) && #{reflection.class_name}.respond_to?(:attr_readonly)"
|
1371
|
+
)
|
1372
|
+
end
|
1373
|
+
|
1374
|
+
def add_touch_callbacks(reflection, touch_attribute)
|
1375
|
+
method_name = "belongs_to_touch_after_save_or_destroy_for_#{reflection.name}".to_sym
|
1376
|
+
define_method(method_name) do
|
1377
|
+
association = send(reflection.name)
|
1378
|
+
|
1379
|
+
if touch_attribute == true
|
1380
|
+
association.touch unless association.nil?
|
1381
|
+
else
|
1382
|
+
association.touch(touch_attribute) unless association.nil?
|
1383
|
+
end
|
1384
|
+
end
|
1385
|
+
after_save(method_name)
|
1386
|
+
after_destroy(method_name)
|
1387
|
+
end
|
1388
|
+
|
1332
1389
|
def find_with_associations(options = {})
|
1333
1390
|
catch :invalid_query do
|
1334
1391
|
join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins])
|
@@ -1353,7 +1410,7 @@ module ActiveRecord
|
|
1353
1410
|
dependent_conditions = []
|
1354
1411
|
dependent_conditions << "#{reflection.primary_key_name} = \#{record.quoted_id}"
|
1355
1412
|
dependent_conditions << "#{reflection.options[:as]}_type = '#{base_class.name}'" if reflection.options[:as]
|
1356
|
-
dependent_conditions << sanitize_sql(reflection.options[:conditions]) if reflection.options[:conditions]
|
1413
|
+
dependent_conditions << sanitize_sql(reflection.options[:conditions], reflection.quoted_table_name) if reflection.options[:conditions]
|
1357
1414
|
dependent_conditions << extra_conditions if extra_conditions
|
1358
1415
|
dependent_conditions = dependent_conditions.collect {|where| "(#{where})" }.join(" AND ")
|
1359
1416
|
dependent_conditions = dependent_conditions.gsub('@', '\@')
|
@@ -1497,9 +1554,9 @@ module ActiveRecord
|
|
1497
1554
|
|
1498
1555
|
mattr_accessor :valid_keys_for_belongs_to_association
|
1499
1556
|
@@valid_keys_for_belongs_to_association = [
|
1500
|
-
:class_name, :foreign_key, :foreign_type, :remote, :select, :conditions,
|
1557
|
+
:class_name, :primary_key, :foreign_key, :foreign_type, :remote, :select, :conditions,
|
1501
1558
|
:include, :dependent, :counter_cache, :extend, :polymorphic, :readonly,
|
1502
|
-
:validate
|
1559
|
+
:validate, :touch
|
1503
1560
|
]
|
1504
1561
|
|
1505
1562
|
def create_belongs_to_reflection(association_id, options)
|
@@ -1643,17 +1700,29 @@ module ActiveRecord
|
|
1643
1700
|
string.scan(/([\.a-zA-Z_]+).?\./).flatten
|
1644
1701
|
end
|
1645
1702
|
|
1703
|
+
def tables_in_hash(hash)
|
1704
|
+
return [] if hash.blank?
|
1705
|
+
tables = hash.map do |key, value|
|
1706
|
+
if value.is_a?(Hash)
|
1707
|
+
key.to_s
|
1708
|
+
else
|
1709
|
+
tables_in_string(key) if key.is_a?(String)
|
1710
|
+
end
|
1711
|
+
end
|
1712
|
+
tables.flatten.compact
|
1713
|
+
end
|
1714
|
+
|
1646
1715
|
def conditions_tables(options)
|
1647
1716
|
# look in both sets of conditions
|
1648
1717
|
conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond|
|
1649
1718
|
case cond
|
1650
1719
|
when nil then all
|
1651
|
-
when Array then all << cond.first
|
1652
|
-
when Hash then all << cond
|
1653
|
-
else all << cond
|
1720
|
+
when Array then all << tables_in_string(cond.first)
|
1721
|
+
when Hash then all << tables_in_hash(cond)
|
1722
|
+
else all << tables_in_string(cond)
|
1654
1723
|
end
|
1655
1724
|
end
|
1656
|
-
|
1725
|
+
conditions.flatten
|
1657
1726
|
end
|
1658
1727
|
|
1659
1728
|
def order_tables(options)
|
@@ -1801,7 +1870,7 @@ module ActiveRecord
|
|
1801
1870
|
descendant
|
1802
1871
|
end.flatten.compact
|
1803
1872
|
|
1804
|
-
remove_duplicate_results!(reflection.
|
1873
|
+
remove_duplicate_results!(reflection.klass, parent_records, associations[name]) unless parent_records.empty?
|
1805
1874
|
end
|
1806
1875
|
end
|
1807
1876
|
end
|
@@ -2101,7 +2170,7 @@ module ActiveRecord
|
|
2101
2170
|
klass.send(:type_condition, aliased_table_name)] unless klass.descends_from_active_record?
|
2102
2171
|
|
2103
2172
|
[through_reflection, reflection].each do |ref|
|
2104
|
-
join << "AND #{interpolate_sql(sanitize_sql(ref.options[:conditions]))} " if ref && ref.options[:conditions]
|
2173
|
+
join << "AND #{interpolate_sql(sanitize_sql(ref.options[:conditions], aliased_table_name))} " if ref && ref.options[:conditions]
|
2105
2174
|
end
|
2106
2175
|
|
2107
2176
|
join
|