From e0a7e0fec760ba12c8067a37e10c96f1f05876e2 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 24 Jun 2026 04:13:16 +0200 Subject: Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade - Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs --- vendor/plugins/acts_as_list/README | 23 - vendor/plugins/acts_as_list/init.rb | 3 - .../acts_as_list/lib/active_record/acts/list.rb | 256 ------- vendor/plugins/acts_as_list/test/list_test.rb | 332 --------- .../plugins/acts_as_taggable_on_steroids/CHANGELOG | 212 ------ .../acts_as_taggable_on_steroids/MIT-LICENSE | 20 - vendor/plugins/acts_as_taggable_on_steroids/README | 151 ----- .../plugins/acts_as_taggable_on_steroids/Rakefile | 22 - .../acts_as_taggable_on_steroids.gemspec | 54 -- .../acts_as_taggable_migration_generator.rb | 11 - .../templates/migration.rb | 26 - .../plugins/acts_as_taggable_on_steroids/init.rb | 1 - .../lib/acts_as_taggable.rb | 230 ------- .../acts_as_taggable_on_steroids/lib/tag.rb | 71 -- .../acts_as_taggable_on_steroids/lib/tag_list.rb | 108 --- .../acts_as_taggable_on_steroids/lib/tagging.rb | 12 - .../lib/tags_helper.rb | 13 - .../test/abstract_unit.rb | 102 --- .../test/acts_as_taggable_test.rb | 384 ----------- .../test/fixtures/magazine.rb | 3 - .../test/fixtures/magazines.yml | 5 - .../test/fixtures/photo.rb | 8 - .../test/fixtures/photos.yml | 19 - .../test/fixtures/post.rb | 7 - .../test/fixtures/posts.yml | 27 - .../test/fixtures/special_post.rb | 2 - .../test/fixtures/subscription.rb | 4 - .../test/fixtures/subscriptions.yml | 3 - .../test/fixtures/taggings.yml | 107 --- .../test/fixtures/tags.yml | 14 - .../test/fixtures/user.rb | 7 - .../test/fixtures/users.yml | 5 - .../test/tag_list_test.rb | 119 ---- .../acts_as_taggable_on_steroids/test/tag_test.rb | 62 -- .../test/tagging_test.rb | 11 - .../test/tags_helper_test.rb | 25 - vendor/plugins/awesome_nested_set/.autotest | 13 - vendor/plugins/awesome_nested_set/MIT-LICENSE | 20 - vendor/plugins/awesome_nested_set/README.rdoc | 79 --- vendor/plugins/awesome_nested_set/Rakefile | 54 -- vendor/plugins/awesome_nested_set/VERSION | 1 - .../awesome_nested_set/awesome_nested_set.gemspec | 68 -- vendor/plugins/awesome_nested_set/init.rb | 1 - .../awesome_nested_set/lib/awesome_nested_set.rb | 577 ---------------- .../lib/awesome_nested_set/helper.rb | 40 -- vendor/plugins/awesome_nested_set/rails/init.rb | 12 - .../plugins/awesome_nested_set/test/application.rb | 1 - .../test/awesome_nested_set/helper_test.rb | 41 -- .../test/awesome_nested_set_test.rb | 748 --------------------- .../test/fixtures/categories.yml | 34 - .../awesome_nested_set/test/fixtures/category.rb | 15 - .../test/fixtures/departments.yml | 3 - .../awesome_nested_set/test/fixtures/notes.yml | 38 -- .../plugins/awesome_nested_set/test/test_helper.rb | 29 - vendor/plugins/exception_notification/README | 111 --- vendor/plugins/exception_notification/init.rb | 4 - .../lib/exception_notifiable.rb | 99 --- .../lib/exception_notifier.rb | 66 -- .../lib/exception_notifier_helper.rb | 78 --- .../test/exception_notifier_helper_test.rb | 61 -- .../exception_notification/test/test_helper.rb | 7 - .../views/exception_notifier/_backtrace.rhtml | 1 - .../views/exception_notifier/_environment.rhtml | 7 - .../views/exception_notifier/_inspect_model.rhtml | 16 - .../views/exception_notifier/_request.rhtml | 4 - .../views/exception_notifier/_session.rhtml | 2 - .../views/exception_notifier/_title.rhtml | 3 - .../exception_notification.rhtml | 6 - vendor/plugins/globalize2/LICENSE | 21 - vendor/plugins/globalize2/README.textile | 65 -- vendor/plugins/globalize2/Rakefile | 39 -- vendor/plugins/globalize2/VERSION | 1 - vendor/plugins/globalize2/generators/db_backend.rb | 0 .../generators/templates/db_backend_migration.rb | 25 - vendor/plugins/globalize2/globalize2.gemspec | 82 --- vendor/plugins/globalize2/init.rb | 1 - vendor/plugins/globalize2/lib/globalize.rb | 15 - .../globalize2/lib/globalize/active_record.rb | 194 ------ .../lib/globalize/active_record/adapter.rb | 80 --- .../lib/globalize/active_record/attributes.rb | 25 - .../lib/globalize/active_record/migration.rb | 40 -- .../lib/i18n/missing_translations_log_handler.rb | 41 -- .../lib/i18n/missing_translations_raise_handler.rb | 25 - .../test/active_record/fallbacks_test.rb | 102 --- .../test/active_record/migration_test.rb | 118 ---- .../test/active_record/sti_translated_test.rb | 49 -- .../test/active_record/translates_test.rb | 87 --- .../test/active_record/translation_class_test.rb | 30 - .../test/active_record/validation_tests.rb | 75 --- .../plugins/globalize2/test/active_record_test.rb | 442 ------------ vendor/plugins/globalize2/test/all.rb | 2 - vendor/plugins/globalize2/test/data/models.rb | 51 -- .../globalize2/test/data/no_globalize_schema.rb | 11 - .../test/i18n/missing_translations_test.rb | 36 - vendor/plugins/globalize2/test/test_helper.rb | 76 --- vendor/plugins/paperclip/LICENSE | 26 - vendor/plugins/paperclip/README.rdoc | 172 ----- vendor/plugins/paperclip/Rakefile | 77 --- .../plugins/paperclip/generators/paperclip/USAGE | 5 - .../generators/paperclip/paperclip_generator.rb | 27 - .../paperclip/templates/paperclip_migration.rb.erb | 19 - vendor/plugins/paperclip/init.rb | 1 - vendor/plugins/paperclip/lib/paperclip.rb | 318 --------- .../plugins/paperclip/lib/paperclip/attachment.rb | 403 ----------- .../lib/paperclip/callback_compatability.rb | 33 - vendor/plugins/paperclip/lib/paperclip/geometry.rb | 116 ---- vendor/plugins/paperclip/lib/paperclip/iostream.rb | 58 -- vendor/plugins/paperclip/lib/paperclip/matchers.rb | 4 - .../matchers/have_attached_file_matcher.rb | 49 -- .../validate_attachment_content_type_matcher.rb | 66 -- .../validate_attachment_presence_matcher.rb | 48 -- .../matchers/validate_attachment_size_matcher.rb | 83 --- .../plugins/paperclip/lib/paperclip/processor.rb | 48 -- vendor/plugins/paperclip/lib/paperclip/storage.rb | 236 ------- .../plugins/paperclip/lib/paperclip/thumbnail.rb | 70 -- vendor/plugins/paperclip/lib/paperclip/upfile.rb | 48 -- vendor/plugins/paperclip/paperclip.gemspec | 40 -- .../plugins/paperclip/shoulda_macros/paperclip.rb | 68 -- .../plugins/paperclip/tasks/paperclip_tasks.rake | 79 --- vendor/plugins/paperclip/test/.gitignore | 1 - vendor/plugins/paperclip/test/attachment_test.rb | 742 -------------------- vendor/plugins/paperclip/test/fixtures/12k.png | Bin 12093 -> 0 bytes vendor/plugins/paperclip/test/fixtures/50x50.png | Bin 1615 -> 0 bytes vendor/plugins/paperclip/test/fixtures/5k.png | Bin 4456 -> 0 bytes vendor/plugins/paperclip/test/fixtures/bad.png | 1 - vendor/plugins/paperclip/test/fixtures/text.txt | 0 vendor/plugins/paperclip/test/fixtures/twopage.pdf | Bin 8775 -> 0 bytes vendor/plugins/paperclip/test/geometry_test.rb | 168 ----- vendor/plugins/paperclip/test/helper.rb | 82 --- vendor/plugins/paperclip/test/integration_test.rb | 481 ------------- vendor/plugins/paperclip/test/iostream_test.rb | 71 -- .../matchers/have_attached_file_matcher_test.rb | 21 - ...alidate_attachment_content_type_matcher_test.rb | 30 - .../validate_attachment_presence_matcher_test.rb | 21 - .../validate_attachment_size_matcher_test.rb | 50 -- vendor/plugins/paperclip/test/paperclip_test.rb | 233 ------- vendor/plugins/paperclip/test/processor_test.rb | 10 - vendor/plugins/paperclip/test/storage_test.rb | 277 -------- vendor/plugins/paperclip/test/thumbnail_test.rb | 177 ----- vendor/plugins/routing-filter/.gitignore | 1 - vendor/plugins/routing-filter/MIT-LICENSE | 20 - vendor/plugins/routing-filter/README.markdown | 123 ---- vendor/plugins/routing-filter/init.rb | 1 - .../plugins/routing-filter/lib/routing_filter.rb | 69 -- .../routing-filter/lib/routing_filter/base.rb | 15 - .../routing-filter/lib/routing_filter/locale.rb | 35 - .../lib/routing_filter/pagination.rb | 19 - .../plugins/routing-filter/spec/generation_spec.rb | 283 -------- .../routing-filter/spec/recognition_spec.rb | 76 --- .../routing-filter/spec/routing_filter_spec.rb | 70 -- vendor/plugins/routing-filter/spec/spec.opts | 4 - vendor/plugins/routing-filter/spec/spec_helper.rb | 49 -- vendor/plugins/will_paginate/.gitignore | 4 - vendor/plugins/will_paginate/.manifest | 49 -- vendor/plugins/will_paginate/CHANGELOG.rdoc | 110 --- vendor/plugins/will_paginate/LICENSE | 18 - vendor/plugins/will_paginate/README.rdoc | 107 --- vendor/plugins/will_paginate/Rakefile | 62 -- .../will_paginate/examples/apple-circle.gif | Bin 178 -> 0 bytes vendor/plugins/will_paginate/examples/index.haml | 69 -- vendor/plugins/will_paginate/examples/index.html | 92 --- .../plugins/will_paginate/examples/pagination.css | 90 --- .../plugins/will_paginate/examples/pagination.sass | 91 --- vendor/plugins/will_paginate/init.rb | 1 - vendor/plugins/will_paginate/lib/will_paginate.rb | 78 --- .../will_paginate/lib/will_paginate/array.rb | 16 - .../will_paginate/lib/will_paginate/collection.rb | 146 ---- .../will_paginate/lib/will_paginate/core_ext.rb | 32 - .../will_paginate/lib/will_paginate/finder.rb | 264 -------- .../will_paginate/lib/will_paginate/named_scope.rb | 170 ----- .../lib/will_paginate/named_scope_patch.rb | 37 - .../will_paginate/lib/will_paginate/version.rb | 9 - .../lib/will_paginate/view_helpers.rb | 389 ----------- vendor/plugins/will_paginate/test/boot.rb | 21 - .../plugins/will_paginate/test/collection_test.rb | 143 ---- vendor/plugins/will_paginate/test/console | 8 - vendor/plugins/will_paginate/test/finder_test.rb | 476 ------------- .../plugins/will_paginate/test/fixtures/admin.rb | 3 - .../will_paginate/test/fixtures/developer.rb | 14 - .../test/fixtures/developers_projects.yml | 13 - .../plugins/will_paginate/test/fixtures/project.rb | 15 - .../will_paginate/test/fixtures/projects.yml | 6 - .../will_paginate/test/fixtures/replies.yml | 29 - .../plugins/will_paginate/test/fixtures/reply.rb | 7 - .../plugins/will_paginate/test/fixtures/topic.rb | 10 - .../plugins/will_paginate/test/fixtures/topics.yml | 30 - vendor/plugins/will_paginate/test/fixtures/user.rb | 2 - .../plugins/will_paginate/test/fixtures/users.yml | 35 - vendor/plugins/will_paginate/test/helper.rb | 37 - .../test/lib/activerecord_test_case.rb | 36 - .../test/lib/activerecord_test_connector.rb | 75 --- .../will_paginate/test/lib/load_fixtures.rb | 11 - .../will_paginate/test/lib/view_test_process.rb | 171 ----- vendor/plugins/will_paginate/test/tasks.rake | 59 -- vendor/plugins/will_paginate/test/view_test.rb | 365 ---------- vendor/plugins/will_paginate/will_paginate.gemspec | 20 - 196 files changed, 15075 deletions(-) delete mode 100644 vendor/plugins/acts_as_list/README delete mode 100644 vendor/plugins/acts_as_list/init.rb delete mode 100644 vendor/plugins/acts_as_list/lib/active_record/acts/list.rb delete mode 100644 vendor/plugins/acts_as_list/test/list_test.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/MIT-LICENSE delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/README delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/Rakefile delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/init.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb delete mode 100644 vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb delete mode 100644 vendor/plugins/awesome_nested_set/.autotest delete mode 100644 vendor/plugins/awesome_nested_set/MIT-LICENSE delete mode 100644 vendor/plugins/awesome_nested_set/README.rdoc delete mode 100644 vendor/plugins/awesome_nested_set/Rakefile delete mode 100644 vendor/plugins/awesome_nested_set/VERSION delete mode 100644 vendor/plugins/awesome_nested_set/awesome_nested_set.gemspec delete mode 100644 vendor/plugins/awesome_nested_set/init.rb delete mode 100644 vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb delete mode 100644 vendor/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb delete mode 100644 vendor/plugins/awesome_nested_set/rails/init.rb delete mode 100644 vendor/plugins/awesome_nested_set/test/application.rb delete mode 100644 vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb delete mode 100644 vendor/plugins/awesome_nested_set/test/awesome_nested_set_test.rb delete mode 100644 vendor/plugins/awesome_nested_set/test/fixtures/categories.yml delete mode 100644 vendor/plugins/awesome_nested_set/test/fixtures/category.rb delete mode 100644 vendor/plugins/awesome_nested_set/test/fixtures/departments.yml delete mode 100644 vendor/plugins/awesome_nested_set/test/fixtures/notes.yml delete mode 100644 vendor/plugins/awesome_nested_set/test/test_helper.rb delete mode 100644 vendor/plugins/exception_notification/README delete mode 100644 vendor/plugins/exception_notification/init.rb delete mode 100644 vendor/plugins/exception_notification/lib/exception_notifiable.rb delete mode 100644 vendor/plugins/exception_notification/lib/exception_notifier.rb delete mode 100644 vendor/plugins/exception_notification/lib/exception_notifier_helper.rb delete mode 100644 vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb delete mode 100644 vendor/plugins/exception_notification/test/test_helper.rb delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml delete mode 100644 vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml delete mode 100644 vendor/plugins/globalize2/LICENSE delete mode 100644 vendor/plugins/globalize2/README.textile delete mode 100644 vendor/plugins/globalize2/Rakefile delete mode 100644 vendor/plugins/globalize2/VERSION delete mode 100644 vendor/plugins/globalize2/generators/db_backend.rb delete mode 100644 vendor/plugins/globalize2/generators/templates/db_backend_migration.rb delete mode 100644 vendor/plugins/globalize2/globalize2.gemspec delete mode 100644 vendor/plugins/globalize2/init.rb delete mode 100644 vendor/plugins/globalize2/lib/globalize.rb delete mode 100644 vendor/plugins/globalize2/lib/globalize/active_record.rb delete mode 100644 vendor/plugins/globalize2/lib/globalize/active_record/adapter.rb delete mode 100644 vendor/plugins/globalize2/lib/globalize/active_record/attributes.rb delete mode 100644 vendor/plugins/globalize2/lib/globalize/active_record/migration.rb delete mode 100644 vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb delete mode 100644 vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb delete mode 100644 vendor/plugins/globalize2/test/active_record/fallbacks_test.rb delete mode 100644 vendor/plugins/globalize2/test/active_record/migration_test.rb delete mode 100644 vendor/plugins/globalize2/test/active_record/sti_translated_test.rb delete mode 100644 vendor/plugins/globalize2/test/active_record/translates_test.rb delete mode 100644 vendor/plugins/globalize2/test/active_record/translation_class_test.rb delete mode 100644 vendor/plugins/globalize2/test/active_record/validation_tests.rb delete mode 100644 vendor/plugins/globalize2/test/active_record_test.rb delete mode 100644 vendor/plugins/globalize2/test/all.rb delete mode 100644 vendor/plugins/globalize2/test/data/models.rb delete mode 100644 vendor/plugins/globalize2/test/data/no_globalize_schema.rb delete mode 100644 vendor/plugins/globalize2/test/i18n/missing_translations_test.rb delete mode 100644 vendor/plugins/globalize2/test/test_helper.rb delete mode 100644 vendor/plugins/paperclip/LICENSE delete mode 100644 vendor/plugins/paperclip/README.rdoc delete mode 100644 vendor/plugins/paperclip/Rakefile delete mode 100644 vendor/plugins/paperclip/generators/paperclip/USAGE delete mode 100644 vendor/plugins/paperclip/generators/paperclip/paperclip_generator.rb delete mode 100644 vendor/plugins/paperclip/generators/paperclip/templates/paperclip_migration.rb.erb delete mode 100644 vendor/plugins/paperclip/init.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/attachment.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/callback_compatability.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/geometry.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/iostream.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/matchers.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/matchers/have_attached_file_matcher.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_size_matcher.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/processor.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/storage.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/thumbnail.rb delete mode 100644 vendor/plugins/paperclip/lib/paperclip/upfile.rb delete mode 100644 vendor/plugins/paperclip/paperclip.gemspec delete mode 100644 vendor/plugins/paperclip/shoulda_macros/paperclip.rb delete mode 100644 vendor/plugins/paperclip/tasks/paperclip_tasks.rake delete mode 100644 vendor/plugins/paperclip/test/.gitignore delete mode 100644 vendor/plugins/paperclip/test/attachment_test.rb delete mode 100644 vendor/plugins/paperclip/test/fixtures/12k.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/50x50.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/5k.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/bad.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/text.txt delete mode 100644 vendor/plugins/paperclip/test/fixtures/twopage.pdf delete mode 100644 vendor/plugins/paperclip/test/geometry_test.rb delete mode 100644 vendor/plugins/paperclip/test/helper.rb delete mode 100644 vendor/plugins/paperclip/test/integration_test.rb delete mode 100644 vendor/plugins/paperclip/test/iostream_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/paperclip_test.rb delete mode 100644 vendor/plugins/paperclip/test/processor_test.rb delete mode 100644 vendor/plugins/paperclip/test/storage_test.rb delete mode 100644 vendor/plugins/paperclip/test/thumbnail_test.rb delete mode 100644 vendor/plugins/routing-filter/.gitignore delete mode 100644 vendor/plugins/routing-filter/MIT-LICENSE delete mode 100644 vendor/plugins/routing-filter/README.markdown delete mode 100644 vendor/plugins/routing-filter/init.rb delete mode 100644 vendor/plugins/routing-filter/lib/routing_filter.rb delete mode 100644 vendor/plugins/routing-filter/lib/routing_filter/base.rb delete mode 100644 vendor/plugins/routing-filter/lib/routing_filter/locale.rb delete mode 100644 vendor/plugins/routing-filter/lib/routing_filter/pagination.rb delete mode 100644 vendor/plugins/routing-filter/spec/generation_spec.rb delete mode 100644 vendor/plugins/routing-filter/spec/recognition_spec.rb delete mode 100644 vendor/plugins/routing-filter/spec/routing_filter_spec.rb delete mode 100644 vendor/plugins/routing-filter/spec/spec.opts delete mode 100644 vendor/plugins/routing-filter/spec/spec_helper.rb delete mode 100644 vendor/plugins/will_paginate/.gitignore delete mode 100644 vendor/plugins/will_paginate/.manifest delete mode 100644 vendor/plugins/will_paginate/CHANGELOG.rdoc delete mode 100644 vendor/plugins/will_paginate/LICENSE delete mode 100644 vendor/plugins/will_paginate/README.rdoc delete mode 100644 vendor/plugins/will_paginate/Rakefile delete mode 100644 vendor/plugins/will_paginate/examples/apple-circle.gif delete mode 100644 vendor/plugins/will_paginate/examples/index.haml delete mode 100644 vendor/plugins/will_paginate/examples/index.html delete mode 100644 vendor/plugins/will_paginate/examples/pagination.css delete mode 100644 vendor/plugins/will_paginate/examples/pagination.sass delete mode 100644 vendor/plugins/will_paginate/init.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/array.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/collection.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/finder.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/version.rb delete mode 100644 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb delete mode 100644 vendor/plugins/will_paginate/test/boot.rb delete mode 100644 vendor/plugins/will_paginate/test/collection_test.rb delete mode 100755 vendor/plugins/will_paginate/test/console delete mode 100644 vendor/plugins/will_paginate/test/finder_test.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/admin.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/developer.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/developers_projects.yml delete mode 100644 vendor/plugins/will_paginate/test/fixtures/project.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/projects.yml delete mode 100644 vendor/plugins/will_paginate/test/fixtures/replies.yml delete mode 100644 vendor/plugins/will_paginate/test/fixtures/reply.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/topic.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/topics.yml delete mode 100644 vendor/plugins/will_paginate/test/fixtures/user.rb delete mode 100644 vendor/plugins/will_paginate/test/fixtures/users.yml delete mode 100644 vendor/plugins/will_paginate/test/helper.rb delete mode 100644 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb delete mode 100644 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb delete mode 100644 vendor/plugins/will_paginate/test/lib/load_fixtures.rb delete mode 100644 vendor/plugins/will_paginate/test/lib/view_test_process.rb delete mode 100644 vendor/plugins/will_paginate/test/tasks.rake delete mode 100644 vendor/plugins/will_paginate/test/view_test.rb delete mode 100644 vendor/plugins/will_paginate/will_paginate.gemspec (limited to 'vendor/plugins') diff --git a/vendor/plugins/acts_as_list/README b/vendor/plugins/acts_as_list/README deleted file mode 100644 index 36ae318..0000000 --- a/vendor/plugins/acts_as_list/README +++ /dev/null @@ -1,23 +0,0 @@ -ActsAsList -========== - -This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a +position+ column defined as an integer on the mapped database table. - - -Example -======= - - class TodoList < ActiveRecord::Base - has_many :todo_items, :order => "position" - end - - class TodoItem < ActiveRecord::Base - belongs_to :todo_list - acts_as_list :scope => :todo_list - end - - todo_list.first.move_to_bottom - todo_list.last.move_higher - - -Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license \ No newline at end of file diff --git a/vendor/plugins/acts_as_list/init.rb b/vendor/plugins/acts_as_list/init.rb deleted file mode 100644 index eb87e87..0000000 --- a/vendor/plugins/acts_as_list/init.rb +++ /dev/null @@ -1,3 +0,0 @@ -$:.unshift "#{File.dirname(__FILE__)}/lib" -require 'active_record/acts/list' -ActiveRecord::Base.class_eval { include ActiveRecord::Acts::List } diff --git a/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb b/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb deleted file mode 100644 index 00d8692..0000000 --- a/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +++ /dev/null @@ -1,256 +0,0 @@ -module ActiveRecord - module Acts #:nodoc: - module List #:nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - # This +acts_as+ extension provides the capabilities for sorting and reordering a number of objects in a list. - # The class that has this specified needs to have a +position+ column defined as an integer on - # the mapped database table. - # - # Todo list example: - # - # class TodoList < ActiveRecord::Base - # has_many :todo_items, :order => "position" - # end - # - # class TodoItem < ActiveRecord::Base - # belongs_to :todo_list - # acts_as_list :scope => :todo_list - # end - # - # todo_list.first.move_to_bottom - # todo_list.last.move_higher - module ClassMethods - # Configuration options are: - # - # * +column+ - specifies the column name to use for keeping the position integer (default: +position+) - # * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach _id - # (if it hasn't already been added) and use that as the foreign key restriction. It's also possible - # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key. - # Example: acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0' - def acts_as_list(options = {}) - configuration = { :column => "position", :scope => "1 = 1" } - configuration.update(options) if options.is_a?(Hash) - - configuration[:scope] = "#{configuration[:scope]}_id".intern if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/ - - if configuration[:scope].is_a?(Symbol) - scope_condition_method = %( - def scope_condition - if #{configuration[:scope].to_s}.nil? - "#{configuration[:scope].to_s} IS NULL" - else - "#{configuration[:scope].to_s} = \#{#{configuration[:scope].to_s}}" - end - end - ) - else - scope_condition_method = "def scope_condition() \"#{configuration[:scope]}\" end" - end - - class_eval <<-EOV - include ActiveRecord::Acts::List::InstanceMethods - - def acts_as_list_class - ::#{self.name} - end - - def position_column - '#{configuration[:column]}' - end - - #{scope_condition_method} - - before_destroy :remove_from_list - before_create :add_to_list_bottom - EOV - end - end - - # All the methods available to a record that has had acts_as_list specified. Each method works - # by assuming the object to be the item in the list, so chapter.move_lower would move that chapter - # lower in the list of all chapters. Likewise, chapter.first? would return +true+ if that chapter is - # the first in the list of all chapters. - module InstanceMethods - # Insert the item at the given position (defaults to the top position of 1). - def insert_at(position = 1) - insert_at_position(position) - end - - # Swap positions with the next lower item, if one exists. - def move_lower - return unless lower_item - - acts_as_list_class.transaction do - lower_item.decrement_position - increment_position - end - end - - # Swap positions with the next higher item, if one exists. - def move_higher - return unless higher_item - - acts_as_list_class.transaction do - higher_item.increment_position - decrement_position - end - end - - # Move to the bottom of the list. If the item is already in the list, the items below it have their - # position adjusted accordingly. - def move_to_bottom - return unless in_list? - acts_as_list_class.transaction do - decrement_positions_on_lower_items - assume_bottom_position - end - end - - # Move to the top of the list. If the item is already in the list, the items above it have their - # position adjusted accordingly. - def move_to_top - return unless in_list? - acts_as_list_class.transaction do - increment_positions_on_higher_items - assume_top_position - end - end - - # Removes the item from the list. - def remove_from_list - if in_list? - decrement_positions_on_lower_items - update_attribute position_column, nil - end - end - - # Increase the position of this item without adjusting the rest of the list. - def increment_position - return unless in_list? - update_attribute position_column, self.send(position_column).to_i + 1 - end - - # Decrease the position of this item without adjusting the rest of the list. - def decrement_position - return unless in_list? - update_attribute position_column, self.send(position_column).to_i - 1 - end - - # Return +true+ if this object is the first in the list. - def first? - return false unless in_list? - self.send(position_column) == 1 - end - - # Return +true+ if this object is the last in the list. - def last? - return false unless in_list? - self.send(position_column) == bottom_position_in_list - end - - # Return the next higher item in the list. - def higher_item - return nil unless in_list? - acts_as_list_class.find(:first, :conditions => - "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}" - ) - end - - # Return the next lower item in the list. - def lower_item - return nil unless in_list? - acts_as_list_class.find(:first, :conditions => - "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}" - ) - end - - # Test if this record is in a list - def in_list? - !send(position_column).nil? - end - - private - def add_to_list_top - increment_positions_on_all_items - end - - def add_to_list_bottom - self[position_column] = bottom_position_in_list.to_i + 1 - end - - # Overwrite this method to define the scope of the list changes - def scope_condition() "1" end - - # Returns the bottom position number in the list. - # bottom_position_in_list # => 2 - def bottom_position_in_list(except = nil) - item = bottom_item(except) - item ? item.send(position_column) : 0 - end - - # Returns the bottom item - def bottom_item(except = nil) - conditions = scope_condition - conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except - acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC") - end - - # Forces item to assume the bottom position in the list. - def assume_bottom_position - update_attribute(position_column, bottom_position_in_list(self).to_i + 1) - end - - # Forces item to assume the top position in the list. - def assume_top_position - update_attribute(position_column, 1) - end - - # This has the effect of moving all the higher items up one. - def decrement_positions_on_higher_items(position) - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}" - ) - end - - # This has the effect of moving all the lower items up one. - def decrement_positions_on_lower_items - return unless in_list? - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}" - ) - end - - # This has the effect of moving all the higher items down one. - def increment_positions_on_higher_items - return unless in_list? - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}" - ) - end - - # This has the effect of moving all the lower items down one. - def increment_positions_on_lower_items(position) - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}" - ) - end - - # Increments position (position_column) of all items in the list. - def increment_positions_on_all_items - acts_as_list_class.update_all( - "#{position_column} = (#{position_column} + 1)", "#{scope_condition}" - ) - end - - def insert_at_position(position) - remove_from_list - increment_positions_on_lower_items(position) - self.update_attribute(position_column, position) - end - end - end - end -end diff --git a/vendor/plugins/acts_as_list/test/list_test.rb b/vendor/plugins/acts_as_list/test/list_test.rb deleted file mode 100644 index e89cb8e..0000000 --- a/vendor/plugins/acts_as_list/test/list_test.rb +++ /dev/null @@ -1,332 +0,0 @@ -require 'test/unit' - -require 'rubygems' -gem 'activerecord', '>= 1.15.4.7794' -require 'active_record' - -require "#{File.dirname(__FILE__)}/../init" - -ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:") - -def setup_db - ActiveRecord::Schema.define(:version => 1) do - create_table :mixins do |t| - t.column :pos, :integer - t.column :parent_id, :integer - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - end -end - -def teardown_db - ActiveRecord::Base.connection.tables.each do |table| - ActiveRecord::Base.connection.drop_table(table) - end -end - -class Mixin < ActiveRecord::Base -end - -class ListMixin < Mixin - acts_as_list :column => "pos", :scope => :parent - - def self.table_name() "mixins" end -end - -class ListMixinSub1 < ListMixin -end - -class ListMixinSub2 < ListMixin -end - -class ListWithStringScopeMixin < ActiveRecord::Base - acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}' - - def self.table_name() "mixins" end -end - - -class ListTest < Test::Unit::TestCase - - def setup - setup_db - (1..4).each { |counter| ListMixin.create! :pos => counter, :parent_id => 5 } - end - - def teardown - teardown_db - end - - def test_reordering - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).move_lower - assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).move_higher - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_bottom - assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_top - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).move_to_bottom - assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(4).move_to_top - assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - end - - def test_move_to_bottom_with_next_to_last_item - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - ListMixin.find(3).move_to_bottom - assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - end - - def test_next_prev - assert_equal ListMixin.find(2), ListMixin.find(1).lower_item - assert_nil ListMixin.find(1).higher_item - assert_equal ListMixin.find(3), ListMixin.find(4).higher_item - assert_nil ListMixin.find(4).lower_item - end - - def test_injection - item = ListMixin.new(:parent_id => 1) - assert_equal "parent_id = 1", item.scope_condition - assert_equal "pos", item.position_column - end - - def test_insert - new = ListMixin.create(:parent_id => 20) - assert_equal 1, new.pos - assert new.first? - assert new.last? - - new = ListMixin.create(:parent_id => 20) - assert_equal 2, new.pos - assert !new.first? - assert new.last? - - new = ListMixin.create(:parent_id => 20) - assert_equal 3, new.pos - assert !new.first? - assert new.last? - - new = ListMixin.create(:parent_id => 0) - assert_equal 1, new.pos - assert new.first? - assert new.last? - end - - def test_insert_at - new = ListMixin.create(:parent_id => 20) - assert_equal 1, new.pos - - new = ListMixin.create(:parent_id => 20) - assert_equal 2, new.pos - - new = ListMixin.create(:parent_id => 20) - assert_equal 3, new.pos - - new4 = ListMixin.create(:parent_id => 20) - assert_equal 4, new4.pos - - new4.insert_at(3) - assert_equal 3, new4.pos - - new.reload - assert_equal 4, new.pos - - new.insert_at(2) - assert_equal 2, new.pos - - new4.reload - assert_equal 4, new4.pos - - new5 = ListMixin.create(:parent_id => 20) - assert_equal 5, new5.pos - - new5.insert_at(1) - assert_equal 1, new5.pos - - new4.reload - assert_equal 5, new4.pos - end - - def test_delete_middle - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).destroy - - assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - - ListMixin.find(1).destroy - - assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(3).pos - assert_equal 2, ListMixin.find(4).pos - end - - def test_with_string_based_scope - new = ListWithStringScopeMixin.create(:parent_id => 500) - assert_equal 1, new.pos - assert new.first? - assert new.last? - end - - def test_nil_scope - new1, new2, new3 = ListMixin.create, ListMixin.create, ListMixin.create - new2.move_higher - assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos') - end - - - def test_remove_from_list_should_then_fail_in_list? - assert_equal true, ListMixin.find(1).in_list? - ListMixin.find(1).remove_from_list - assert_equal false, ListMixin.find(1).in_list? - end - - def test_remove_from_list_should_set_position_to_nil - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).remove_from_list - - assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal nil, ListMixin.find(2).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - end - - def test_remove_before_destroy_does_not_shift_lower_items_twice - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).remove_from_list - ListMixin.find(2).destroy - - assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - end - -end - -class ListSubTest < Test::Unit::TestCase - - def setup - setup_db - (1..4).each { |i| ((i % 2 == 1) ? ListMixinSub1 : ListMixinSub2).create! :pos => i, :parent_id => 5000 } - end - - def teardown - teardown_db - end - - def test_reordering - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).move_lower - assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).move_higher - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_bottom - assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_top - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).move_to_bottom - assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(4).move_to_top - assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - end - - def test_move_to_bottom_with_next_to_last_item - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - ListMixin.find(3).move_to_bottom - assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - end - - def test_next_prev - assert_equal ListMixin.find(2), ListMixin.find(1).lower_item - assert_nil ListMixin.find(1).higher_item - assert_equal ListMixin.find(3), ListMixin.find(4).higher_item - assert_nil ListMixin.find(4).lower_item - end - - def test_injection - item = ListMixin.new("parent_id"=>1) - assert_equal "parent_id = 1", item.scope_condition - assert_equal "pos", item.position_column - end - - def test_insert_at - new = ListMixin.create("parent_id" => 20) - assert_equal 1, new.pos - - new = ListMixinSub1.create("parent_id" => 20) - assert_equal 2, new.pos - - new = ListMixinSub2.create("parent_id" => 20) - assert_equal 3, new.pos - - new4 = ListMixin.create("parent_id" => 20) - assert_equal 4, new4.pos - - new4.insert_at(3) - assert_equal 3, new4.pos - - new.reload - assert_equal 4, new.pos - - new.insert_at(2) - assert_equal 2, new.pos - - new4.reload - assert_equal 4, new4.pos - - new5 = ListMixinSub1.create("parent_id" => 20) - assert_equal 5, new5.pos - - new5.insert_at(1) - assert_equal 1, new5.pos - - new4.reload - assert_equal 5, new4.pos - end - - def test_delete_middle - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).destroy - - assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - - ListMixin.find(1).destroy - - assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(3).pos - assert_equal 2, ListMixin.find(4).pos - end - -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG b/vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG deleted file mode 100644 index 5391c15..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/CHANGELOG +++ /dev/null @@ -1,212 +0,0 @@ -[11 Jun 09] - -* Remove deprecated TagCountsExtension. - -* Update tests to use foxy fixtures [Jonas Wagner] - -* Allow hash conditions to be passed to Tag.counts [Jonas Wagner] - -[3 Jun 09] - -* Upgrade tests for Rails 2.3 - -[18 Mar 09] - -* Change callbacks used to save tags. - -[18 Feb 09] - -* Greatly improve speed when using find_tagged_with and :match_all [notonthehighstreet.com]. - -[17 Sep 08] - -* Sanitize scope conditions in find_options_for_tag_counts [Rémy-Christophe Schermesser] - -[23 Aug 08] - -* Fix tag_counts instance method when no tags are present. - -* Make tag_counts instance_method merge any :conditions passed to it. - -[30 Mar 08] - -* Make TagList.from accept array arguments. - -[29 Mar 08] - -* Improve parsing of quotes inside tags [Arturas Slajus]. - -* Add Tag.counts method. - -[28 Mar 08] - -* Make Tag#taggings :dependent => :destroy. - -[27 Mar 08] - -* Fix documentation for tag_counts. - -[18 Mar 08] - -* Add TagList#toggle [Pete Yandell]. - -# Add find_related_tags method [Austin Foncaier]. - -[30 Jan 08] - -* Fix Tag.destroy_unused on Rails 2.0. - -[23 October 2007] - -* Make find_options_for_tag_counts and find_options_for_tagged_with dup their options. - -* Apply conditions properly in find_options_for_tag_counts. - -* Fix tag_cloud when no tags are present. - -[22 October 2007] - -* Fix find_tagged_with using :match_all and :include. - -* Use inner joins instead of left outer joins. - -[15 October 2007] - -* Make find_tagged_with correctly apply :conditions - -* Add Tag.destroy_unused option. - -[11 October 2007] - -* Make tag_counts work correctly with STI. - -[3 October 2007] - -* Improve documentation. - -* Fix TagsHelper and test. - -[2 October 2007] - -* Remove TagList.parse, use TagList.from instead. - -* Add :parse option to TagList#new, TagList#add, and TagList#remove. - - tag_list = TagList.new("One, Two", :parse => true) # ["One", "Two"] - - tag_list # ["One", "Two"] - tag_list.add("Three, Four", :parse => true) # ["One", "Two", "Three", "Four"] - -* Remove TagList#names. - -[29 September 2007] - -* Add TagsHelper to assist with generating tag clouds and provide a simple example. - -[27 September 2007] - -* Add #tag_counts method to get tag counts for a specific object's tags. - -* BACKWARDS INCOMPATIBILITY: Rename #find_options_for_tagged_with to #find_options_for_find_tagged_with - -[17 September 2007] - -* Fix clearing of cached tag list when all tags removed. - -[12 September 2007] - -* Make the TagList class inherit from Array. - -* Deprecate obsolete TagList#names. - -[6 September 2007] - -* Add TagList#include? and TagList#empty? - -[26 August 2007] - -* Remove deprecated Tag.delimiter. Use TagList.delimiter instead. - -[25 August 2007] - -* Make tag_counts work with has_many :through - -[23 August 2007] - -* Make search comparisons case-insensitive across different databases. [Moisés Machado] - -* Improve compatiblity with STI. [Moisés Machado] - -[25 July 2007] - -* Respect custom table names for the Tag and Tagging classes. - -* Fix the :exclude option for find_tagged_with - -[17 July 2007] - -* Make the migration work on edge rails - -[8 July 2007] - -* find_options_for_tagged_with should not alter its arguments - -[1 July 2007] - -* Fix incorrect tagging when the case of the tag list is changed. - -* Fix deprecated Tag.delimiter accessor. - -[23 June 2007] - -* Add validation to Tag model. - -* find_options_for_tagged_with should always return a hash. - -* find_tagged_with passing in no tags should return an empty array. - -* Improve compatibility with PostgreSQL. - -[21 June 2007] - -* Remove extra .rb from generated migration file name. - -[15 June 2007] - -* Introduce TagList class. - -* Various cleanups and improvements. - -* Use TagList.delimiter now, not Tag.delimiter. Tag.delimiter will be removed at some stage. - -[11 June 2007] - -* Restructure the creation of the options for find_tagged_with [Thijs Cadier] - -* Add an example migration with a generator. - -* Add caching. - -* Fix compatibility with Ruby < 1.8.6 - -[23 April 2007] - -* Make tag_list to respect Tag.delimiter - -[31 March 2007] - -* Add Tag.delimiter accessor to change how tags are parsed. - -* Fix :include => :tags when used with find_tagged_with - -[7 March 2007] - -* Fix tag_counts for SQLServer [Brad Young] - -[21 Feb 2007] - -* Use scoping instead of TagCountsExtension [Michael Schuerig] - -[7 Jan 2007] - -* Add :match_all to find_tagged_with [Michael Sheakoski] diff --git a/vendor/plugins/acts_as_taggable_on_steroids/MIT-LICENSE b/vendor/plugins/acts_as_taggable_on_steroids/MIT-LICENSE deleted file mode 100644 index 602bda2..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2006 Jonathan Viney - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/acts_as_taggable_on_steroids/README b/vendor/plugins/acts_as_taggable_on_steroids/README deleted file mode 100644 index b794030..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/README +++ /dev/null @@ -1,151 +0,0 @@ -= acts_as_taggable_on_steroids - -If you find this plugin useful, please consider a donation to show your support! - - http://www.paypal.com/cgi-bin/webscr?cmd=_send-money - - Email address: jonathan.viney@gmail.com - -== Instructions - -This plugin is based on acts_as_taggable by DHH but includes extras -such as tests, smarter tag assignment, and tag cloud calculations. - -== Installation - - ruby script/plugin install git://github.com/jviney/acts_as_taggable_on_steroids.git - -== Usage - -=== Prepare database - -Generate and apply the migration: - - ruby script/generate acts_as_taggable_migration - rake db:migrate - -=== Basic tagging - -Let's suppose users have many posts and we want those posts to have tags. -The first step is to add +acts_as_taggable+ to the Post class: - - class Post < ActiveRecord::Base - acts_as_taggable - - belongs_to :user - end - -We can now use the tagging methods provided by acts_as_taggable, #tag_list and #tag_list=. Both these -methods work like regular attribute accessors. - - p = Post.find(:first) - p.tag_list # [] - p.tag_list = "Funny, Silly" - p.save - p.tag_list # ["Funny", "Silly"] - -You can also add or remove arrays of tags. - - p.tag_list.add("Great", "Awful") - p.tag_list.remove("Funny") - -In your views you should use something like the following: - - <%= f.label :tag_list %> - <%= f.text_field :tag_list, :size => 80 %> - -=== Finding tagged objects - -To retrieve objects tagged with a certain tag, use find_tagged_with. - - Post.find_tagged_with('Funny, Silly') - -By default, find_tagged_with will find objects that have any of the given tags. To -find only objects that are tagged with all the given tags, use match_all. - - Post.find_tagged_with('Funny, Silly', :match_all => true) - -See ActiveRecord::Acts::Taggable::InstanceMethods for more methods and options. - -=== Tag cloud calculations - -To construct tag clouds, the frequency of each tag needs to be calculated. -Because we specified +acts_as_taggable+ on the Post class, we can -get a calculation of all the tag counts by using Post.tag_counts. But what if we wanted a tag count for -an single user's posts? To achieve this we call tag_counts on the association: - - User.find(:first).posts.tag_counts - -A helper is included to assist with generating tag clouds. Include it in your helper file: - - module ApplicationHelper - include TagsHelper - end - -You can also use the counts method on Tag to get the counts for all tags in the database. - - Tag.counts - -Here is an example that generates a tag cloud. - -Controller: - - class PostController < ApplicationController - def tag_cloud - @tags = Post.tag_counts - end - end - -View: - <% tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %> - <%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %> - <% end %> - -CSS: - - .css1 { font-size: 1.0em; } - .css2 { font-size: 1.2em; } - .css3 { font-size: 1.4em; } - .css4 { font-size: 1.6em; } - -=== Caching - -It is useful to cache the list of tags to reduce the number of queries executed. To do this, -add a column named cached_tag_list to the model which is being tagged. The column should be long enough to hold -the full tag list and must have a default value of null, not an empty string. - - class CachePostTagList < ActiveRecord::Migration - def self.up - add_column :posts, :cached_tag_list, :string - end - end - - class Post < ActiveRecord::Base - acts_as_taggable - - # The caching column defaults to cached_tag_list, but can be changed: - # - # set_cached_tag_list_column_name "my_caching_column_name" - end - -The details of the caching are handled for you. Just continue to use the tag_list accessor as you normally would. -Note that the cached tag list will not be updated if you directly create Tagging objects or manually append to the -tags or taggings associations. To update the cached tag list you should call save_cached_tag_list manually. - -=== Delimiter - -If you want to change the delimiter used to parse and present tags, set TagList.delimiter. -For example, to use spaces instead of commas, add the following to config/environment.rb: - - TagList.delimiter = " " - -=== Unused tags - -Set Tag.destroy_unused to remove tags when they are no longer being -used to tag any objects. Defaults to false. - - Tag.destroy_unused = true - -=== Other - -Problems, comments, and suggestions all welcome. jonathan.viney@gmail.com diff --git a/vendor/plugins/acts_as_taggable_on_steroids/Rakefile b/vendor/plugins/acts_as_taggable_on_steroids/Rakefile deleted file mode 100644 index 93c2706..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the acts_as_taggable_on_steroids plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the acts_as_taggable_on_steroids plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Acts As Taggable On Steroids' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec b/vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec deleted file mode 100644 index f91ad4d..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/acts_as_taggable_on_steroids.gemspec +++ /dev/null @@ -1,54 +0,0 @@ -Gem::Specification.new do |s| - s.name = "acts_as_taggable_on_steroids" - s.version = "1.1" - s.date = "2009-06-11" - s.summary = "Rails plugin that is based on acts_as_taggable by DHH but includes extras such as tests, smarter tag assignment, and tag cloud calculations." - s.email = "jonathan.viney@gmail.com" - s.homepage = "http://github.com/jviney/acts_as_taggable_on_steroids" - s.description = "Rails plugin that is based on acts_as_taggable by DHH but includes extras such as tests, smarter tag assignment, and tag cloud calculations." - s.has_rdoc = true - s.rdoc_options = ["--inline-source", "--charset=UTF-8"] - s.rubyforge_project = "acts_as_taggable_on_steroids" - s.authors = "Jonathan Viney" - s.files = [ - "acts_as_taggable_on_steroids.gemspec", - "CHANGELOG", - "generators/acts_as_taggable_migration", - "generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb", - "generators/acts_as_taggable_migration/templates", - "generators/acts_as_taggable_migration/templates/migration.rb", - "init.rb", - "lib/acts_as_taggable.rb", - "lib/tag.rb", - "lib/tag_list.rb", - "lib/tagging.rb", - "lib/tags_helper.rb", - "MIT-LICENSE", - "Rakefile", - "README", - ] - s.test_files = [ - "test/abstract_unit.rb", - "test/acts_as_taggable_test.rb", - "test/database.yml", - "test/fixtures", - "test/fixtures/magazine.rb", - "test/fixtures/magazines.yml", - "test/fixtures/photo.rb", - "test/fixtures/photos.yml", - "test/fixtures/post.rb", - "test/fixtures/posts.yml", - "test/fixtures/special_post.rb", - "test/fixtures/subscription.rb", - "test/fixtures/subscriptions.yml", - "test/fixtures/taggings.yml", - "test/fixtures/tags.yml", - "test/fixtures/user.rb", - "test/fixtures/users.yml", - "test/schema.rb", - "test/tag_list_test.rb", - "test/tag_test.rb", - "test/tagging_test.rb", - "test/tags_helper_test.rb" - ] -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb b/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb deleted file mode 100644 index be9b39c..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/acts_as_taggable_migration_generator.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ActsAsTaggableMigrationGenerator < Rails::Generator::Base - def manifest - record do |m| - m.migration_template 'migration.rb', 'db/migrate' - end - end - - def file_name - "acts_as_taggable_migration" - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb b/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb deleted file mode 100644 index ea0c2cc..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/generators/acts_as_taggable_migration/templates/migration.rb +++ /dev/null @@ -1,26 +0,0 @@ -class ActsAsTaggableMigration < ActiveRecord::Migration - def self.up - create_table :tags do |t| - t.column :name, :string - end - - create_table :taggings do |t| - t.column :tag_id, :integer - t.column :taggable_id, :integer - - # You should make sure that the column created is - # long enough to store the required class names. - t.column :taggable_type, :string - - t.column :created_at, :datetime - end - - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type] - end - - def self.down - drop_table :taggings - drop_table :tags - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/init.rb b/vendor/plugins/acts_as_taggable_on_steroids/init.rb deleted file mode 100644 index 64505b9..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/init.rb +++ /dev/null @@ -1 +0,0 @@ -require File.dirname(__FILE__) + '/lib/acts_as_taggable' diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb deleted file mode 100644 index 7a96ef0..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb +++ /dev/null @@ -1,230 +0,0 @@ -module ActiveRecord #:nodoc: - module Acts #:nodoc: - module Taggable #:nodoc: - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - def acts_as_taggable - has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag - has_many :tags, :through => :taggings - - before_save :save_cached_tag_list - - after_create :save_tags - after_update :save_tags - - include ActiveRecord::Acts::Taggable::InstanceMethods - extend ActiveRecord::Acts::Taggable::SingletonMethods - - alias_method_chain :reload, :tag_list - end - - def cached_tag_list_column_name - "cached_tag_list" - end - - def set_cached_tag_list_column_name(value = nil, &block) - define_attr_method :cached_tag_list_column_name, value, &block - end - end - - module SingletonMethods - # Returns an array of related tags. - # Related tags are all the other tags that are found on the models tagged with the provided tags. - # - # Pass either a tag, string, or an array of strings or tags. - # - # Options: - # :order - SQL Order how to order the tags. Defaults to "count DESC, tags.name". - def find_related_tags(tags, options = {}) - tags = tags.is_a?(Array) ? TagList.new(tags.map(&:to_s)) : TagList.from(tags) - - related_models = find_tagged_with(tags) - - return [] if related_models.blank? - - related_ids = related_models.to_s(:db) - - Tag.find(:all, options.merge({ - :select => "#{Tag.table_name}.*, COUNT(#{Tag.table_name}.id) AS count", - :joins => "JOIN #{Tagging.table_name} ON #{Tagging.table_name}.taggable_type = '#{base_class.name}' - AND #{Tagging.table_name}.taggable_id IN (#{related_ids}) - AND #{Tagging.table_name}.tag_id = #{Tag.table_name}.id", - :order => options[:order] || "count DESC, #{Tag.table_name}.name", - :group => "#{Tag.table_name}.id, #{Tag.table_name}.name HAVING #{Tag.table_name}.name NOT IN (#{tags.map { |n| quote_value(n) }.join(",")})" - })) - end - - # Pass either a tag, string, or an array of strings or tags. - # - # Options: - # :exclude - Find models that are not tagged with the given tags - # :match_all - Find models that match all of the given tags, not just one - # :conditions - A piece of SQL conditions to add to the query - def find_tagged_with(*args) - options = find_options_for_find_tagged_with(*args) - options.blank? ? [] : find(:all, options) - end - - def find_options_for_find_tagged_with(tags, options = {}) - tags = tags.is_a?(Array) ? TagList.new(tags.map(&:to_s)) : TagList.from(tags) - options = options.dup - - return {} if tags.empty? - - conditions = [] - conditions << sanitize_sql(options.delete(:conditions)) if options[:conditions] - - taggings_alias, tags_alias = "#{table_name}_taggings", "#{table_name}_tags" - - joins = [ - "INNER JOIN #{Tagging.table_name} #{taggings_alias} ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key} AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}", - "INNER JOIN #{Tag.table_name} #{tags_alias} ON #{tags_alias}.id = #{taggings_alias}.tag_id" - ] - - if options.delete(:exclude) - conditions << <<-END - #{table_name}.id NOT IN - (SELECT #{Tagging.table_name}.taggable_id FROM #{Tagging.table_name} - INNER JOIN #{Tag.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id - WHERE #{tags_condition(tags)} AND #{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)}) - END - else - if options.delete(:match_all) - joins << joins_for_match_all_tags(tags) - else - conditions << tags_condition(tags, tags_alias) - end - end - - { :select => "DISTINCT #{table_name}.*", - :joins => joins.join(" "), - :conditions => conditions.join(" AND ") - }.reverse_merge!(options) - end - - def joins_for_match_all_tags(tags) - joins = [] - - tags.each_with_index do |tag, index| - taggings_alias, tags_alias = "taggings_#{index}", "tags_#{index}" - - join = <<-END - INNER JOIN #{Tagging.table_name} #{taggings_alias} ON - #{taggings_alias}.taggable_id = #{table_name}.#{primary_key} AND - #{taggings_alias}.taggable_type = #{quote_value(base_class.name)} - - INNER JOIN #{Tag.table_name} #{tags_alias} ON - #{taggings_alias}.tag_id = #{tags_alias}.id AND - #{tags_alias}.name = ? - END - - joins << sanitize_sql([join, tag]) - end - - joins.join(" ") - end - - # Calculate the tag counts for all tags. - # - # See Tag.counts for available options. - def tag_counts(options = {}) - Tag.find(:all, find_options_for_tag_counts(options)) - end - - def find_options_for_tag_counts(options = {}) - options = options.dup - scope = scope(:find) - - conditions = [] - conditions << send(:sanitize_conditions, options.delete(:conditions)) if options[:conditions] - conditions << send(:sanitize_conditions, scope[:conditions]) if scope && scope[:conditions] - conditions << "#{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)}" - conditions << type_condition unless descends_from_active_record? - conditions.compact! - conditions = conditions.join(" AND ") - - joins = ["INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{Tagging.table_name}.taggable_id"] - joins << options.delete(:joins) if options[:joins] - joins << scope[:joins] if scope && scope[:joins] - joins = joins.join(" ") - - options = { :conditions => conditions, :joins => joins }.update(options) - - Tag.options_for_counts(options) - end - - def caching_tag_list? - column_names.include?(cached_tag_list_column_name) - end - - private - def tags_condition(tags, table_name = Tag.table_name) - condition = tags.map { |t| sanitize_sql(["#{table_name}.name LIKE ?", t]) }.join(" OR ") - "(" + condition + ")" unless condition.blank? - end - end - - module InstanceMethods - def tag_list - return @tag_list if @tag_list - - if self.class.caching_tag_list? and !(cached_value = send(self.class.cached_tag_list_column_name)).nil? - @tag_list = TagList.from(cached_value) - else - @tag_list = TagList.new(*tags.map(&:name)) - end - end - - def tag_list=(value) - @tag_list = TagList.from(value) - end - - def save_cached_tag_list - if self.class.caching_tag_list? - self[self.class.cached_tag_list_column_name] = tag_list.to_s - end - end - - def save_tags - return unless @tag_list - - new_tag_names = @tag_list - tags.map(&:name) - old_tags = tags.reject { |tag| @tag_list.include?(tag.name) } - - self.class.transaction do - if old_tags.any? - taggings.find(:all, :conditions => ["tag_id IN (?)", old_tags.map(&:id)]).each(&:destroy) - taggings.reset - end - - new_tag_names.each do |new_tag_name| - tags << Tag.find_or_create_with_like_by_name(new_tag_name) - end - end - - true - end - - # Calculate the tag counts for the tags used by this model. - # - # The possible options are the same as the tag_counts class method. - def tag_counts(options = {}) - return [] if tag_list.blank? - - options[:conditions] = self.class.send(:merge_conditions, options[:conditions], self.class.send(:tags_condition, tag_list)) - self.class.tag_counts(options) - end - - def reload_with_tag_list(*args) #:nodoc: - @tag_list = nil - reload_without_tag_list(*args) - end - end - end - end -end - -ActiveRecord::Base.send(:include, ActiveRecord::Acts::Taggable) diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb deleted file mode 100644 index 44f0991..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/lib/tag.rb +++ /dev/null @@ -1,71 +0,0 @@ -class Tag < ActiveRecord::Base - has_many :taggings, :dependent => :destroy - - validates_presence_of :name - validates_uniqueness_of :name - - cattr_accessor :destroy_unused - self.destroy_unused = false - - # LIKE is used for cross-database case-insensitivity - def self.find_or_create_with_like_by_name(name) - find(:first, :conditions => ["name LIKE ?", name]) || create(:name => name) - end - - def ==(object) - super || (object.is_a?(Tag) && name == object.name) - end - - def to_s - name - end - - def count - read_attribute(:count).to_i - end - - class << self - # Calculate the tag counts for all tags. - # :start_at - Restrict the tags to those created after a certain time - # :end_at - Restrict the tags to those created before a certain time - # :conditions - A piece of SQL conditions to add to the query - # :limit - The maximum number of tags to return - # :order - A piece of SQL to order by. Eg 'count desc' or 'taggings.created_at desc' - # :at_least - Exclude tags with a frequency less than the given value - # :at_most - Exclude tags with a frequency greater than the given value - def counts(options = {}) - find(:all, options_for_counts(options)) - end - - def options_for_counts(options = {}) - options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :joins - options = options.dup - - start_at = sanitize_sql(["#{Tagging.table_name}.created_at >= ?", options.delete(:start_at)]) if options[:start_at] - end_at = sanitize_sql(["#{Tagging.table_name}.created_at <= ?", options.delete(:end_at)]) if options[:end_at] - - conditions = [ - (sanitize_sql(options.delete(:conditions)) if options[:conditions]), - start_at, - end_at - ].compact - - conditions = conditions.join(' AND ') if conditions.any? - - joins = ["INNER JOIN #{Tagging.table_name} ON #{Tag.table_name}.id = #{Tagging.table_name}.tag_id"] - joins << options.delete(:joins) if options[:joins] - - at_least = sanitize_sql(['COUNT(*) >= ?', options.delete(:at_least)]) if options[:at_least] - at_most = sanitize_sql(['COUNT(*) <= ?', options.delete(:at_most)]) if options[:at_most] - having = [at_least, at_most].compact.join(' AND ') - group_by = "#{Tag.table_name}.id, #{Tag.table_name}.name HAVING COUNT(*) > 0" - group_by << " AND #{having}" unless having.blank? - - { :select => "#{Tag.table_name}.id, #{Tag.table_name}.name, COUNT(*) AS count", - :joins => joins.join(" "), - :conditions => conditions, - :group => group_by - }.update(options) - end - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb deleted file mode 100644 index 700399b..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/lib/tag_list.rb +++ /dev/null @@ -1,108 +0,0 @@ -class TagList < Array - cattr_accessor :delimiter - self.delimiter = ',' - - def initialize(*args) - add(*args) - end - - # Add tags to the tag_list. Duplicate or blank tags will be ignored. - # - # tag_list.add("Fun", "Happy") - # - # Use the :parse option to add an unparsed tag string. - # - # tag_list.add("Fun, Happy", :parse => true) - def add(*names) - extract_and_apply_options!(names) - concat(names) - clean! - self - end - - # Remove specific tags from the tag_list. - # - # tag_list.remove("Sad", "Lonely") - # - # Like #add, the :parse option can be used to remove multiple tags in a string. - # - # tag_list.remove("Sad, Lonely", :parse => true) - def remove(*names) - extract_and_apply_options!(names) - delete_if { |name| names.include?(name) } - self - end - - # Toggle the presence of the given tags. - # If a tag is already in the list it is removed, otherwise it is added. - def toggle(*names) - extract_and_apply_options!(names) - - names.each do |name| - include?(name) ? delete(name) : push(name) - end - - clean! - self - end - - # Transform the tag_list into a tag string suitable for edting in a form. - # The tags are joined with TagList.delimiter and quoted if necessary. - # - # tag_list = TagList.new("Round", "Square,Cube") - # tag_list.to_s # 'Round, "Square,Cube"' - def to_s - clean! - - map do |name| - name.include?(delimiter) ? "\"#{name}\"" : name - end.join(delimiter.ends_with?(" ") ? delimiter : "#{delimiter} ") - end - - private - # Remove whitespace, duplicates, and blanks. - def clean! - reject!(&:blank?) - map!(&:strip) - uniq! - end - - def extract_and_apply_options!(args) - options = args.last.is_a?(Hash) ? args.pop : {} - options.assert_valid_keys :parse - - if options[:parse] - args.map! { |a| self.class.from(a) } - end - - args.flatten! - end - - class << self - # Returns a new TagList using the given tag string. - # - # tag_list = TagList.from("One , Two, Three") - # tag_list # ["One", "Two", "Three"] - def from(source) - returning new do |tag_list| - - case source - when Array - tag_list.add(source) - else - string = source.to_s.dup - - # Parse the quoted tags - [ - /\s*#{delimiter}\s*(['"])(.*?)\1\s*/, - /^\s*(['"])(.*?)\1\s*#{delimiter}?/ - ].each do |re| - string.gsub!(re) { tag_list << $2; "" } - end - - tag_list.add(string.split(delimiter)) - end - end - end - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb deleted file mode 100644 index 87bc44d..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/lib/tagging.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Tagging < ActiveRecord::Base #:nodoc: - belongs_to :tag - belongs_to :taggable, :polymorphic => true - - def after_destroy - if Tag.destroy_unused - if tag.taggings.count.zero? - tag.destroy - end - end - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb b/vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb deleted file mode 100644 index d5644b7..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module TagsHelper - # See the README for an example using tag_cloud. - def tag_cloud(tags, classes) - return if tags.empty? - - max_count = tags.sort_by(&:count).last.count.to_f - - tags.each do |tag| - index = ((tag.count / max_count) * (classes.size - 1)).round - yield tag, classes[index] - end - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb deleted file mode 100644 index f480387..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb +++ /dev/null @@ -1,102 +0,0 @@ -require 'test/unit' - -begin - require File.dirname(__FILE__) + '/../../../../config/environment' -rescue LoadError - require 'rubygems' - gem 'activerecord' - gem 'actionpack' - require 'active_record' - require 'action_controller' -end - -# Search for fixtures first -fixture_path = File.dirname(__FILE__) + '/fixtures/' -ActiveSupport::Dependencies.load_paths.insert(0, fixture_path) - -require "active_record/test_case" -require "active_record/fixtures" - -require File.dirname(__FILE__) + '/../lib/acts_as_taggable' -require_dependency File.dirname(__FILE__) + '/../lib/tag_list' -require_dependency File.dirname(__FILE__) + '/../lib/tags_helper' - -ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log') -ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) -ActiveRecord::Base.establish_connection(ENV['DB'] || 'mysql') - -load(File.dirname(__FILE__) + '/schema.rb') - -class ActiveSupport::TestCase #:nodoc: - include ActiveRecord::TestFixtures - - self.fixture_path = File.dirname(__FILE__) + "/fixtures/" - - self.use_transactional_fixtures = true - self.use_instantiated_fixtures = false - - fixtures :all - - def assert_equivalent(expected, actual, message = nil) - if expected.first.is_a?(ActiveRecord::Base) - assert_equal expected.sort_by(&:id), actual.sort_by(&:id), message - else - assert_equal expected.sort, actual.sort, message - end - end - - def assert_tag_counts(tags, expected_values) - # Map the tag fixture names to real tag names - expected_values = expected_values.inject({}) do |hash, (tag, count)| - hash[tags(tag).name] = count - hash - end - - tags.each do |tag| - value = expected_values.delete(tag.name) - - assert_not_nil value, "Expected count for #{tag.name} was not provided" - assert_equal value, tag.count, "Expected value of #{value} for #{tag.name}, but was #{tag.count}" - end - - unless expected_values.empty? - assert false, "The following tag counts were not present: #{expected_values.inspect}" - end - end - - def assert_queries(num = 1) - $query_count = 0 - yield - ensure - assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed." - end - - def assert_no_queries(&block) - assert_queries(0, &block) - end - - # From Rails trunk - def assert_difference(expressions, difference = 1, message = nil, &block) - expression_evaluations = [expressions].flatten.collect{|expression| lambda { eval(expression, block.binding) } } - - original_values = expression_evaluations.inject([]) { |memo, expression| memo << expression.call } - yield - expression_evaluations.each_with_index do |expression, i| - assert_equal original_values[i] + difference, expression.call, message - end - end - - def assert_no_difference(expressions, message = nil, &block) - assert_difference expressions, 0, message, &block - end -end - -ActiveRecord::Base.connection.class.class_eval do - def execute_with_counting(sql, name = nil, &block) - $query_count ||= 0 - $query_count += 1 - execute_without_counting(sql, name, &block) - end - - alias_method_chain :execute, :counting -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb deleted file mode 100644 index 9766d34..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/acts_as_taggable_test.rb +++ /dev/null @@ -1,384 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -class ActsAsTaggableOnSteroidsTest < ActiveSupport::TestCase - def test_find_related_tags_with - assert_equivalent [tags(:good), tags(:bad), tags(:question)], Post.find_related_tags("nature") - assert_equivalent [tags(:nature)], Post.find_related_tags([tags(:good)]) - assert_equivalent [tags(:bad), tags(:question)], Post.find_related_tags(["Very Good", "Nature"]) - assert_equivalent [tags(:bad), tags(:question)], Post.find_related_tags([tags(:good), tags(:nature)]) - end - - def test_find_tagged_with_include_and_order - assert_equal photos(:sam_sky, :sam_flower, :jonathan_dog), Photo.find_tagged_with("Nature", :order => "photos.title DESC", :include => :user) - end - - def test_find_related_tags_with_non_existent_tags - assert_equal [], Post.find_related_tags("ABCDEFG") - assert_equal [], Post.find_related_tags(['HIJKLM']) - end - - def test_find_related_tags_with_nothing - assert_equal [], Post.find_related_tags("") - assert_equal [], Post.find_related_tags([]) - end - - def test_find_tagged_with - assert_equivalent [posts(:jonathan_sky), posts(:sam_flowers)], Post.find_tagged_with('"Very good"') - assert_equal Post.find_tagged_with('"Very good"'), Post.find_tagged_with(['Very good']) - assert_equal Post.find_tagged_with('"Very good"'), Post.find_tagged_with([tags(:good)]) - - assert_equivalent [photos(:jonathan_dog), photos(:sam_flower), photos(:sam_sky)], Photo.find_tagged_with('Nature') - assert_equal Photo.find_tagged_with('Nature'), Photo.find_tagged_with(['Nature']) - assert_equal Photo.find_tagged_with('Nature'), Photo.find_tagged_with([tags(:nature)]) - - assert_equivalent [photos(:jonathan_bad_cat), photos(:jonathan_dog), photos(:jonathan_questioning_dog)], Photo.find_tagged_with('"Crazy animal" Bad') - assert_equal Photo.find_tagged_with('"Crazy animal" Bad'), Photo.find_tagged_with(['Crazy animal', 'Bad']) - assert_equal Photo.find_tagged_with('"Crazy animal" Bad'), Photo.find_tagged_with([tags(:animal), tags(:bad)]) - end - - def test_find_tagged_with_nothing - assert_equal [], Post.find_tagged_with("") - assert_equal [], Post.find_tagged_with([]) - end - - def test_find_tagged_with_nonexistant_tags - assert_equal [], Post.find_tagged_with('ABCDEFG') - assert_equal [], Photo.find_tagged_with(['HIJKLM']) - assert_equal [], Photo.find_tagged_with([Tag.new(:name => 'unsaved tag')]) - end - - def test_find_tagged_with_match_all - assert_equivalent [photos(:jonathan_dog)], Photo.find_tagged_with('Crazy animal, "Nature"', :match_all => true) - end - - def test_find_tagged_with_match_all_and_include - assert_equivalent [posts(:jonathan_sky), posts(:sam_flowers)], Post.find_tagged_with(['Very good', 'Nature'], :match_all => true, :include => :tags) - end - - def test_find_tagged_with_conditions - assert_equal [], Post.find_tagged_with('"Very good", Nature', :conditions => '1=0') - end - - def test_find_tagged_with_duplicates_options_hash - options = { :conditions => '1=1' }.freeze - assert_nothing_raised { Post.find_tagged_with("Nature", options) } - end - - def test_find_tagged_with_exclusions - assert_equivalent [photos(:jonathan_questioning_dog), photos(:jonathan_bad_cat)], Photo.find_tagged_with("Nature", :exclude => true) - assert_equivalent [posts(:jonathan_grass), posts(:jonathan_rain), posts(:jonathan_cloudy), posts(:jonathan_still_cloudy)], Post.find_tagged_with("'Very good', Bad", :exclude => true) - end - - def test_find_options_for_find_tagged_with_no_tags_returns_empty_hash - assert_equal Hash.new, Post.find_options_for_find_tagged_with("") - assert_equal Hash.new, Post.find_options_for_find_tagged_with([nil]) - end - - def test_find_options_for_find_tagged_with_leaves_arguments_unchanged - original_tags = photos(:jonathan_questioning_dog).tags.dup - Photo.find_options_for_find_tagged_with(photos(:jonathan_questioning_dog).tags) - assert_equal original_tags, photos(:jonathan_questioning_dog).tags - end - - def test_find_options_for_find_tagged_with_respects_custom_table_name - Tagging.table_name = "categorisations" - Tag.table_name = "categories" - - options = Photo.find_options_for_find_tagged_with("Hello") - - assert_no_match(/ taggings /, options[:joins]) - assert_no_match(/ tags /, options[:joins]) - - assert_match(/ categorisations /, options[:joins]) - assert_match(/ categories /, options[:joins]) - ensure - Tagging.table_name = "taggings" - Tag.table_name = "tags" - end - - def test_include_tags_on_find_tagged_with - assert_nothing_raised do - Photo.find_tagged_with('Nature', :include => :tags) - Photo.find_tagged_with("Nature", :include => { :taggings => :tag }) - end - end - - def test_basic_tag_counts_on_class - assert_tag_counts Post.tag_counts, :good => 2, :nature => 7, :question => 1, :bad => 1 - assert_tag_counts Photo.tag_counts, :good => 1, :nature => 3, :question => 1, :bad => 1, :animal => 3 - end - - def test_tag_counts_on_class_with_date_conditions - assert_tag_counts Post.tag_counts(:start_at => Date.new(2006, 8, 4)), :good => 1, :nature => 5, :question => 1, :bad => 1 - assert_tag_counts Post.tag_counts(:end_at => Date.new(2006, 8, 6)), :good => 1, :nature => 4, :question => 1 - assert_tag_counts Post.tag_counts(:start_at => Date.new(2006, 8, 5), :end_at => Date.new(2006, 8, 10)), :good => 1, :nature => 4, :bad => 1 - - assert_tag_counts Photo.tag_counts(:start_at => Date.new(2006, 8, 12), :end_at => Date.new(2006, 8, 19)), :good => 1, :nature => 2, :bad => 1, :question => 1, :animal => 3 - end - - def test_tag_counts_on_class_with_frequencies - assert_tag_counts Photo.tag_counts(:at_least => 2), :nature => 3, :animal => 3 - assert_tag_counts Photo.tag_counts(:at_most => 2), :good => 1, :question => 1, :bad => 1 - end - - def test_tag_counts_on_class_with_frequencies_and_conditions - assert_tag_counts Photo.tag_counts(:at_least => 2, :conditions => '1=1'), :nature => 3, :animal => 3 - end - - def test_tag_counts_duplicates_options_hash - options = { :at_least => 2, :conditions => '1=1' }.freeze - assert_nothing_raised { Photo.tag_counts(options) } - end - - def test_tag_counts_with_limit - assert_equal 2, Photo.tag_counts(:limit => 2).size - assert_equal 1, Post.tag_counts(:at_least => 4, :limit => 2).size - end - - def test_tag_counts_with_limit_and_order - assert_equal [tags(:nature), tags(:good)], Post.tag_counts(:order => 'count desc', :limit => 2) - end - - def test_tag_counts_on_association - assert_tag_counts users(:jonathan).posts.tag_counts, :good => 1, :nature => 5, :question => 1 - assert_tag_counts users(:sam).posts.tag_counts, :good => 1, :nature => 2, :bad => 1 - - assert_tag_counts users(:jonathan).photos.tag_counts, :animal => 3, :nature => 1, :question => 1, :bad => 1 - assert_tag_counts users(:sam).photos.tag_counts, :nature => 2, :good => 1 - end - - def test_tag_counts_on_association_with_options - assert_equal [], users(:jonathan).posts.tag_counts(:conditions => '1=0') - assert_tag_counts users(:jonathan).posts.tag_counts(:at_most => 2), :good => 1, :question => 1 - end - - def test_tag_counts_on_has_many_through - assert_tag_counts users(:jonathan).magazines.tag_counts, :good => 1 - end - - def test_tag_counts_on_model_instance - assert_tag_counts photos(:jonathan_dog).tag_counts, :animal => 3, :nature => 3 - end - - def test_tag_counts_on_model_instance_merges_conditions - assert_tag_counts photos(:jonathan_dog).tag_counts(:conditions => "tags.name = 'Crazy animal'"), :animal => 3 - end - - def test_tag_counts_on_model_instance_with_no_tags - photo = Photo.create! - - assert_tag_counts photo.tag_counts, {} - end - - def test_tag_counts_should_sanitize_scope_conditions - Photo.send :with_scope, :find => { :conditions => ["tags.id = ?", tags(:animal).id] } do - assert_tag_counts Photo.tag_counts, :animal => 3 - end - end - - def test_tag_counts_respects_custom_table_names - Tagging.table_name = "categorisations" - Tag.table_name = "categories" - - options = Photo.find_options_for_tag_counts(:start_at => 2.weeks.ago, :end_at => Date.today) - sql = options.values.join(' ') - - assert_no_match /taggings/, sql - assert_no_match /tags/, sql - - assert_match /categorisations/, sql - assert_match /categories/, sql - ensure - Tagging.table_name = "taggings" - Tag.table_name = "tags" - end - - def test_tag_list_reader - assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list - assert_equivalent ["Bad", "Crazy animal"], photos(:jonathan_bad_cat).tag_list - end - - def test_reassign_tag_list - assert_equivalent ["Nature", "Question"], posts(:jonathan_rain).tag_list - posts(:jonathan_rain).taggings.reload - - # Only an update of the posts table should be executed, the other two queries are for savepoints - assert_queries 3 do - posts(:jonathan_rain).update_attributes!(:tag_list => posts(:jonathan_rain).tag_list.to_s) - end - - assert_equivalent ["Nature", "Question"], posts(:jonathan_rain).tag_list - end - - def test_new_tags - assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list - posts(:jonathan_sky).update_attributes!(:tag_list => "#{posts(:jonathan_sky).tag_list}, One, Two") - assert_equivalent ["Very good", "Nature", "One", "Two"], posts(:jonathan_sky).tag_list - end - - def test_remove_tag - assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list - posts(:jonathan_sky).update_attributes!(:tag_list => "Nature") - assert_equivalent ["Nature"], posts(:jonathan_sky).tag_list - end - - def test_change_case_of_tags - original_tag_names = photos(:jonathan_questioning_dog).tag_list - photos(:jonathan_questioning_dog).update_attributes!(:tag_list => photos(:jonathan_questioning_dog).tag_list.to_s.upcase) - - # The new tag list is not uppercase becuase the AR finders are not case-sensitive - # and find the old tags when re-tagging with the uppercase tags. - assert_equivalent original_tag_names, photos(:jonathan_questioning_dog).reload.tag_list - end - - def test_remove_and_add_tag - assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list - posts(:jonathan_sky).update_attributes!(:tag_list => "Nature, Beautiful") - assert_equivalent ["Nature", "Beautiful"], posts(:jonathan_sky).tag_list - end - - def test_tags_not_saved_if_validation_fails - assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list - assert !posts(:jonathan_sky).update_attributes(:tag_list => "One, Two", :text => "") - assert_equivalent ["Very good", "Nature"], Post.find(posts(:jonathan_sky).id).tag_list - end - - def test_tag_list_accessors_on_new_record - p = Post.new(:text => 'Test') - - assert p.tag_list.blank? - p.tag_list = "One, Two" - assert_equal "One, Two", p.tag_list.to_s - end - - def test_clear_tag_list_with_nil - p = photos(:jonathan_questioning_dog) - - assert !p.tag_list.blank? - assert p.update_attributes(:tag_list => nil) - assert p.tag_list.blank? - - assert p.reload.tag_list.blank? - end - - def test_clear_tag_list_with_string - p = photos(:jonathan_questioning_dog) - - assert !p.tag_list.blank? - assert p.update_attributes(:tag_list => ' ') - assert p.tag_list.blank? - - assert p.reload.tag_list.blank? - end - - def test_tag_list_reset_on_reload - p = photos(:jonathan_questioning_dog) - assert !p.tag_list.blank? - p.tag_list = nil - assert p.tag_list.blank? - assert !p.reload.tag_list.blank? - end - - def test_instance_tag_counts - assert_tag_counts posts(:jonathan_sky).tag_counts, :good => 2, :nature => 7 - end - - def test_tag_list_populated_when_cache_nil - assert_nil posts(:jonathan_sky).cached_tag_list - posts(:jonathan_sky).save! - assert_equal posts(:jonathan_sky).tag_list.to_s, posts(:jonathan_sky).cached_tag_list - end - - def test_cached_tag_list_used - posts(:jonathan_sky).save! - posts(:jonathan_sky).reload - - assert_no_queries do - assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list - end - end - - def test_cached_tag_list_not_used - # Load fixture and column information - posts(:jonathan_sky).taggings(:reload) - - assert_queries 1 do - # Tags association will be loaded - posts(:jonathan_sky).tag_list - end - end - - def test_cached_tag_list_updated - assert_nil posts(:jonathan_sky).cached_tag_list - posts(:jonathan_sky).save! - assert_equivalent ["Very good", "Nature"], TagList.from(posts(:jonathan_sky).cached_tag_list) - posts(:jonathan_sky).update_attributes!(:tag_list => "None") - - assert_equal 'None', posts(:jonathan_sky).cached_tag_list - assert_equal 'None', posts(:jonathan_sky).reload.cached_tag_list - end - - def test_clearing_cached_tag_list - # Generate the cached tag list - posts(:jonathan_sky).save! - - posts(:jonathan_sky).update_attributes!(:tag_list => "") - assert_equal "", posts(:jonathan_sky).cached_tag_list - end - - def test_find_tagged_with_using_sti - special_post = SpecialPost.create!(:text => "Test", :tag_list => "Random") - - assert_equal [special_post], SpecialPost.find_tagged_with("Random") - assert Post.find_tagged_with("Random").include?(special_post) - end - - def test_tag_counts_using_sti - SpecialPost.create!(:text => "Test", :tag_list => "Nature") - - assert_tag_counts SpecialPost.tag_counts, :nature => 1 - end - - def test_case_insensitivity - assert_difference "Tag.count", 1 do - Post.create!(:text => "Test", :tag_list => "one") - Post.create!(:text => "Test", :tag_list => "One") - end - - assert_equal Post.find_tagged_with("Nature"), Post.find_tagged_with("nature") - end - - def test_tag_not_destroyed_when_unused - posts(:jonathan_sky).tag_list.add("Random") - posts(:jonathan_sky).save! - - assert_no_difference 'Tag.count' do - posts(:jonathan_sky).tag_list.remove("Random") - posts(:jonathan_sky).save! - end - end - - def test_tag_destroyed_when_unused - Tag.destroy_unused = true - - posts(:jonathan_sky).tag_list.add("Random") - posts(:jonathan_sky).save! - - assert_difference 'Tag.count', -1 do - posts(:jonathan_sky).tag_list.remove("Random") - posts(:jonathan_sky).save! - end - ensure - Tag.destroy_unused = false - end -end - -class ActsAsTaggableOnSteroidsFormTest < ActiveSupport::TestCase - include ActionView::Helpers::FormHelper - - def test_tag_list_contents - fields_for :post, posts(:jonathan_sky) do |f| - assert_match /Nature, Very good/, f.text_field(:tag_list) - end - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb deleted file mode 100644 index 554afe4..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazine.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Magazine < ActiveRecord::Base - acts_as_taggable -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml deleted file mode 100644 index 7124fd9..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/magazines.yml +++ /dev/null @@ -1,5 +0,0 @@ -ruby: - name: Ruby - -rails: - name: Rails diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb deleted file mode 100644 index 224957f..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photo.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Photo < ActiveRecord::Base - acts_as_taggable - - belongs_to :user -end - -class SpecialPhoto < Photo -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml deleted file mode 100644 index bf078cf..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/photos.yml +++ /dev/null @@ -1,19 +0,0 @@ -jonathan_dog: - user: jonathan - title: A small dog - -jonathan_questioning_dog: - user: jonathan - title: What does this dog want? - -jonathan_bad_cat: - user: jonathan - title: Bad cat - -sam_flower: - user: sam - title: Flower - -sam_sky: - user: sam - title: Sky diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb deleted file mode 100644 index bee100a..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/post.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Post < ActiveRecord::Base - acts_as_taggable - - belongs_to :user - - validates_presence_of :text -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml deleted file mode 100644 index 50e91bc..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/posts.yml +++ /dev/null @@ -1,27 +0,0 @@ -jonathan_sky: - user: jonathan - text: The sky is particularly blue today - -jonathan_grass: - user: jonathan - text: The grass seems very green - -jonathan_rain: - user: jonathan - text: Why does the rain fall? - -jonathan_cloudy: - user: jonathan - text: Is it cloudy? - -jonathan_still_cloudy: - user: jonathan - text: Is it still cloudy? - -sam_ground: - user: sam - text: The ground is looking too brown - -sam_flowers: - user: sam - text: Why are the flowers dead? diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb deleted file mode 100644 index 366a0d5..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/special_post.rb +++ /dev/null @@ -1,2 +0,0 @@ -class SpecialPost < Post -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb deleted file mode 100644 index e975cb7..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscription.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Subscription < ActiveRecord::Base - belongs_to :user - belongs_to :magazine -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml deleted file mode 100644 index d294e51..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/subscriptions.yml +++ /dev/null @@ -1,3 +0,0 @@ -jonathan_rails: - user: jonathan - magazine: ruby diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml deleted file mode 100644 index 1193b56..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/taggings.yml +++ /dev/null @@ -1,107 +0,0 @@ -# Posts -jonathan_sky_good: - tag: good - taggable: jonathan_sky (Post) - created_at: 2006-08-01 - -jonathan_sky_nature: - tag: nature - taggable: jonathan_sky (Post) - created_at: 2006-08-02 - -jonathan_grass_nature: - tag: nature - taggable: jonathan_grass (Post) - created_at: 2006-08-03 - -jonathan_rain_question: - tag: question - taggable: jonathan_rain (Post) - created_at: 2006-08-04 - -jonathan_rain_nature: - tag: nature - taggable: jonathan_rain (Post) - created_at: 2006-08-05 - -jonathan_cloudy_nature: - tag: nature - taggable: jonathan_cloudy (Post) - created_at: 2006-08-06 - -jonathan_still_cloudy_nature: - tag: nature - taggable: jonathan_still_cloudy (Post) - created_at: 2006-08-07 - -sam_ground_nature: - tag: nature - taggable: sam_ground (Post) - created_at: 2006-08-08 - -sam_ground_bad: - tag: bad - taggable: sam_ground (Post) - created_at: 2006-08-09 - -sam_flowers_good: - tag: good - taggable: sam_flowers (Post) - created_at: 2006-08-10 - -sam_flowers_nature: - tag: nature - taggable: sam_flowers (Post) - created_at: 2006-08-11 - -# Photos -jonathan_dog_animal: - tag: animal - taggable: jonathan_dog (Photo) - created_at: 2006-08-12 - -jonathan_dog_nature: - tag: nature - taggable: jonathan_dog (Photo) - created_at: 2006-08-13 - -jonathan_questioning_dog_animal: - tag: animal - taggable: jonathan_questioning_dog (Photo) - created_at: 2006-08-14 - -jonathan_questioning_dog_question: - tag: question - taggable: jonathan_questioning_dog (Photo) - created_at: 2006-08-15 - -jonathan_bad_cat_bad: - tag: bad - taggable: jonathan_bad_cat (Photo) - created_at: 2006-08-16 - -jonathan_bad_cat_animal: - tag: animal - taggable: jonathan_bad_cat (Photo) - created_at: 2006-08-17 - -sam_flower_nature: - tag: nature - taggable: sam_flower (Photo) - created_at: 2006-08-18 - -sam_flower_good: - tag: good - taggable: sam_flower (Photo) - created_at: 2006-08-19 - -sam_sky_nature: - tag: nature - taggable: sam_sky (Photo) - created_at: 2006-08-20 - -# Magazines -ruby_good: - tag: good - taggable: ruby (Magazine) - created_at: 2007-08-25 diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml deleted file mode 100644 index a3c2aa5..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/tags.yml +++ /dev/null @@ -1,14 +0,0 @@ -good: - name: Very good - -bad: - name: Bad - -nature: - name: Nature - -question: - name: Question - -animal: - name: Crazy animal diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb deleted file mode 100644 index 8c0f787..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/user.rb +++ /dev/null @@ -1,7 +0,0 @@ -class User < ActiveRecord::Base - has_many :posts - has_many :photos - - has_many :subscriptions - has_many :magazines, :through => :subscriptions -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml b/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml deleted file mode 100644 index e6f22d3..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/fixtures/users.yml +++ /dev/null @@ -1,5 +0,0 @@ -jonathan: - name: Jonathan - -sam: - name: Sam diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb deleted file mode 100644 index 17d4ab9..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/tag_list_test.rb +++ /dev/null @@ -1,119 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -class TagListTest < ActiveSupport::TestCase - def test_from_leaves_string_unchanged - tags = '"One ", Two' - original = tags.dup - TagList.from(tags) - assert_equal tags, original - end - - def test_from_single_name - assert_equal %w(Fun), TagList.from("Fun") - assert_equal %w(Fun), TagList.from('"Fun"') - end - - def test_from_blank - assert_equal [], TagList.from(nil) - assert_equal [], TagList.from("") - end - - def test_from_single_quoted_tag - assert_equal ['with, comma'], TagList.from('"with, comma"') - end - - def test_spaces_do_not_delineate - assert_equal ['A B', 'C'], TagList.from('A B, C') - end - - def test_from_multiple_tags - assert_equivalent %w(Alpha Beta Delta Gamma), TagList.from("Alpha, Beta, Delta, Gamma") - end - - def test_from_multiple_tags_with_quotes - assert_equivalent %w(Alpha Beta Delta Gamma), TagList.from('Alpha, "Beta", Gamma , "Delta"') - end - - def test_from_with_single_quotes - assert_equivalent ['A B', 'C'], TagList.from("'A B', C") - end - - def test_from_multiple_tags_with_quote_and_commas - assert_equivalent ['Alpha, Beta', 'Delta', 'Gamma, something'], TagList.from('"Alpha, Beta", Delta, "Gamma, something"') - end - - def test_from_with_inner_quotes - assert_equivalent ["House", "Drum 'n' Bass", "Trance"], TagList.from("House, Drum 'n' Bass, Trance") - assert_equivalent ["House", "Drum'n'Bass", "Trance"], TagList.from("House, Drum'n'Bass, Trance") - end - - def test_from_removes_white_space - assert_equivalent %w(Alpha Beta), TagList.from('" Alpha ", "Beta "') - assert_equivalent %w(Alpha Beta), TagList.from(' Alpha, Beta ') - end - - def test_from_and_new_treat_both_accept_arrays - tags = ["One", "Two"] - - assert_equal TagList.from(tags), TagList.new(tags) - end - - def test_alternative_delimiter - TagList.delimiter = " " - - assert_equal %w(One Two), TagList.from("One Two") - assert_equal ['One two', 'three', 'four'], TagList.from('"One two" three four') - ensure - TagList.delimiter = "," - end - - def test_duplicate_tags_removed - assert_equal %w(One), TagList.from("One, One") - end - - def test_to_s_with_commas - assert_equal "Question, Crazy Animal", TagList.new("Question", "Crazy Animal").to_s - end - - def test_to_s_with_alternative_delimiter - TagList.delimiter = " " - - assert_equal '"Crazy Animal" Question', TagList.new("Crazy Animal", "Question").to_s - ensure - TagList.delimiter = "," - end - - def test_add - tag_list = TagList.new("One") - assert_equal %w(One), tag_list - - assert_equal %w(One Two), tag_list.add("Two") - assert_equal %w(One Two Three), tag_list.add(["Three"]) - end - - def test_remove - tag_list = TagList.new("One", "Two") - assert_equal %w(Two), tag_list.remove("One") - assert_equal %w(), tag_list.remove(["Two"]) - end - - def test_new_with_parsing - assert_equal %w(One Two), TagList.new("One, Two", :parse => true) - end - - def test_add_with_parsing - assert_equal %w(One Two), TagList.new.add("One, Two", :parse => true) - end - - def test_remove_with_parsing - tag_list = TagList.from("Three, Four, Five") - assert_equal %w(Four), tag_list.remove("Three, Five", :parse => true) - end - - def test_toggle - tag_list = TagList.new("One", "Two") - assert_equal %w(One Three), tag_list.toggle("Two", "Three") - assert_equal %w(), tag_list.toggle("One", "Three") - assert_equal %w(Four), tag_list.toggle("Four") - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb deleted file mode 100644 index 97dd249..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -class TagTest < ActiveSupport::TestCase - def test_name_required - t = Tag.create - assert_match /blank/, t.errors[:name].to_s - end - - def test_name_unique - t = Tag.create!(:name => "My tag") - duplicate = t.clone - - assert !duplicate.save - assert_match /taken/, duplicate.errors[:name].to_s - end - - def test_taggings - assert_equivalent [taggings(:jonathan_sky_good), taggings(:sam_flowers_good), taggings(:sam_flower_good), taggings(:ruby_good)], tags(:good).taggings - assert_equivalent [taggings(:sam_ground_bad), taggings(:jonathan_bad_cat_bad)], tags(:bad).taggings - end - - def test_to_s - assert_equal tags(:good).name, tags(:good).to_s - end - - def test_equality - assert_equal tags(:good), tags(:good) - assert_equal Tag.find(tags(:good).id), Tag.find(tags(:good).id) - assert_equal Tag.new(:name => 'A'), Tag.new(:name => 'A') - assert_not_equal Tag.new(:name => 'A'), Tag.new(:name => 'B') - end - - def test_taggings_removed_when_tag_destroyed - assert_difference "Tagging.count", -Tagging.count(:conditions => { :tag_id => tags(:good).id }) do - assert tags(:good).destroy - end - end - - def test_all_counts - assert_tag_counts Tag.counts, :good => 4, :bad => 2, :nature => 10, :question => 2, :animal => 3 - end - - def test_all_counts_with_string_conditions - assert_tag_counts Tag.counts(:conditions => 'taggings.created_at >= \'2006-08-15\''), - :question => 1, :bad => 1, :animal => 1, :nature => 2, :good => 2 - end - - def test_all_counts_with_array_conditions - assert_tag_counts Tag.counts(:conditions => ['taggings.created_at >= ?', '2006-08-15']), - :question => 1, :bad => 1, :animal => 1, :nature => 2, :good => 2 - end - - def test_all_counts_with_hash_conditions - tag_counts = Tag.counts( - :conditions => { - :taggings => { :created_at => (DateTime.parse('2006-08-14 23:59') .. DateTime.parse('4000-01-01')) } - } - ) - - assert_tag_counts tag_counts, :question => 1, :bad => 1, :animal => 1, :nature => 2, :good => 2 - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb deleted file mode 100644 index bea4583..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/tagging_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -class TaggingTest < ActiveSupport::TestCase - def test_tag - assert_equal tags(:good), taggings(:jonathan_sky_good).tag - end - - def test_taggable - assert_equal posts(:jonathan_sky), taggings(:jonathan_sky_good).taggable - end -end diff --git a/vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb b/vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb deleted file mode 100644 index c482909..0000000 --- a/vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require File.dirname(__FILE__) + '/abstract_unit' - -class TagsHelperTest < ActiveSupport::TestCase - include TagsHelper - - def test_tag_cloud - cloud_elements = [] - - tag_cloud Post.tag_counts, %w(css1 css2 css3 css4) do |tag, css_class| - cloud_elements << [tag, css_class] - end - - assert cloud_elements.include?([tags(:good), "css2"]) - assert cloud_elements.include?([tags(:bad), "css1"]) - assert cloud_elements.include?([tags(:nature), "css4"]) - assert cloud_elements.include?([tags(:question), "css1"]) - assert_equal 4, cloud_elements.size - end - - def test_tag_cloud_when_no_tags - tag_cloud SpecialPost.tag_counts, %w(css1) do - assert false, "tag_cloud should not yield" - end - end -end diff --git a/vendor/plugins/awesome_nested_set/.autotest b/vendor/plugins/awesome_nested_set/.autotest deleted file mode 100644 index 54518a4..0000000 --- a/vendor/plugins/awesome_nested_set/.autotest +++ /dev/null @@ -1,13 +0,0 @@ -Autotest.add_hook :initialize do |at| - at.clear_mappings - - at.add_mapping %r%^lib/(.*)\.rb$% do |_, m| - at.files_matching %r%^test/#{m[1]}_test.rb$% - end - - at.add_mapping(%r%^test/.*\.rb$%) {|filename, _| filename } - - at.add_mapping %r%^test/fixtures/(.*)s.yml% do |_, _| - at.files_matching %r%^test/.*\.rb$% - end -end \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/MIT-LICENSE b/vendor/plugins/awesome_nested_set/MIT-LICENSE deleted file mode 100644 index 570ecf8..0000000 --- a/vendor/plugins/awesome_nested_set/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2007 [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/awesome_nested_set/README.rdoc b/vendor/plugins/awesome_nested_set/README.rdoc deleted file mode 100644 index 884016d..0000000 --- a/vendor/plugins/awesome_nested_set/README.rdoc +++ /dev/null @@ -1,79 +0,0 @@ -= AwesomeNestedSet - -Awesome Nested Set is an implementation of the nested set pattern for ActiveRecord models. It is replacement for acts_as_nested_set and BetterNestedSet, but awesomer. It supports Rails 2.1 and later. - -== What makes this so awesome? - -This is a new implementation of nested set based off of BetterNestedSet that fixes some bugs, removes tons of duplication, adds a few useful methods, and adds STI support. - -== Installation - -Install as a plugin: - - script/plugin install git://github.com/collectiveidea/awesome_nested_set.git - -== Usage - -To make use of awesome_nested_set, your model needs to have 3 fields: lft, rgt, and parent_id: - - class CreateCategories < ActiveRecord::Migration - def self.up - create_table :categories do |t| - t.string :name - t.integer :parent_id - t.integer :lft - t.integer :rgt - end - end - - def self.down - drop_table :categories - end - end - -Enable the nested set functionality by declaring acts_as_nested_set on your model - - class Category < ActiveRecord::Base - acts_as_nested_set - end - -Run `rake rdoc` to generate the API docs and see CollectiveIdea::Acts::NestedSet::SingletonMethods for more info. - -== View Helper - -The view helper is called #nested_set_options. - -Example usage: - - <%= f.select :parent_id, nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" } %> - - <%= select_tag 'parent_id', options_for_select(nested_set_options(Category) {|i| "#{'-' * i.level} #{i.name}" } ) %> - -See CollectiveIdea::Acts::NestedSet::Helper for more information about the helpers. - -== References - -You can learn more about nested sets at: - - http://www.dbmsmag.com/9603d06.html - http://threebit.net/tutorials/nestedset/tutorial1.html - http://api.rubyonrails.com/classes/ActiveRecord/Acts/NestedSet/ClassMethods.html - http://opensource.symetrie.com/trac/better_nested_set/ - -== How to contribute - -If you find what you might think is a bug: - -1. Check the GitHub issue tracker to see if anyone else has had the same issue. - http://github.com/collectiveidea/awesome_nested_set/issues/ -2. If you don't see anything, create an issue with information on how to reproduce it. - -If you want to contribute an enhancement or a fix: - -1. Fork the project on github. - http://github.com/collectiveidea/awesome_nested_set/ -2. Make your changes with tests. -3. Commit the changes without making changes to the Rakefile, VERSION, or any other files that aren't related to your enhancement or fix -4. Send a pull request. - -Copyright ©2008 Collective Idea, released under the MIT license \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/Rakefile b/vendor/plugins/awesome_nested_set/Rakefile deleted file mode 100644 index ce70813..0000000 --- a/vendor/plugins/awesome_nested_set/Rakefile +++ /dev/null @@ -1,54 +0,0 @@ -begin - require 'jeweler' -rescue LoadError - puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" - exit 1 -end -require 'rake/testtask' -require 'rake/rdoctask' -require 'rcov/rcovtask' -require "load_multi_rails_rake_tasks" - -Jeweler::Tasks.new do |s| - s.name = "awesome_nested_set" - s.summary = "An awesome nested set implementation for Active Record" - s.description = s.summary - s.email = "info@collectiveidea.com" - s.homepage = "http://github.com/collectiveidea/awesome_nested_set" - s.authors = ["Brandon Keepers", "Daniel Morrison"] - s.add_dependency "activerecord", ['>= 1.1'] - s.has_rdoc = true - s.extra_rdoc_files = [ "README.rdoc"] - s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"] - s.test_files = Dir['test/**/*.{yml,rb}'] -end - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the awesome_nested_set plugin.' -Rake::TestTask.new(:test) do |t| - t.libs += ['lib', 'test'] - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the awesome_nested_set plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'AwesomeNestedSet' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README.rdoc') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -namespace :test do - desc "just rcov minus html output" - Rcov::RcovTask.new(:coverage) do |t| - t.libs << 'test' - t.test_files = FileList['test/**/*_test.rb'] - t.output_dir = 'coverage' - t.verbose = true - t.rcov_opts = %w(--exclude test,/usr/lib/ruby,/Library/Ruby,lib/awesome_nested_set/named_scope.rb --sort coverage) - end -end \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/VERSION b/vendor/plugins/awesome_nested_set/VERSION deleted file mode 100644 index 9df886c..0000000 --- a/vendor/plugins/awesome_nested_set/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.4.2 diff --git a/vendor/plugins/awesome_nested_set/awesome_nested_set.gemspec b/vendor/plugins/awesome_nested_set/awesome_nested_set.gemspec deleted file mode 100644 index 81108c5..0000000 --- a/vendor/plugins/awesome_nested_set/awesome_nested_set.gemspec +++ /dev/null @@ -1,68 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{awesome_nested_set} - s.version = "1.4.2" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Brandon Keepers", "Daniel Morrison"] - s.date = %q{2009-09-08} - s.description = %q{An awesome nested set implementation for Active Record} - s.email = %q{info@collectiveidea.com} - s.extra_rdoc_files = [ - "README.rdoc" - ] - s.files = [ - ".autotest", - ".gitignore", - "MIT-LICENSE", - "README.rdoc", - "Rakefile", - "VERSION", - "awesome_nested_set.gemspec", - "init.rb", - "lib/awesome_nested_set.rb", - "lib/awesome_nested_set/helper.rb", - "rails/init.rb", - "test/application.rb", - "test/awesome_nested_set/helper_test.rb", - "test/awesome_nested_set_test.rb", - "test/db/database.yml", - "test/db/schema.rb", - "test/fixtures/categories.yml", - "test/fixtures/category.rb", - "test/fixtures/departments.yml", - "test/fixtures/notes.yml", - "test/test_helper.rb" - ] - s.homepage = %q{http://github.com/collectiveidea/awesome_nested_set} - s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.3} - s.summary = %q{An awesome nested set implementation for Active Record} - s.test_files = [ - "test/db/database.yml", - "test/fixtures/categories.yml", - "test/fixtures/departments.yml", - "test/fixtures/notes.yml", - "test/application.rb", - "test/awesome_nested_set/helper_test.rb", - "test/awesome_nested_set_test.rb", - "test/db/schema.rb", - "test/fixtures/category.rb", - "test/test_helper.rb" - ] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 1.1"]) - else - s.add_dependency(%q, [">= 1.1"]) - end - else - s.add_dependency(%q, [">= 1.1"]) - end -end diff --git a/vendor/plugins/awesome_nested_set/init.rb b/vendor/plugins/awesome_nested_set/init.rb deleted file mode 100644 index 43dc7c2..0000000 --- a/vendor/plugins/awesome_nested_set/init.rb +++ /dev/null @@ -1 +0,0 @@ -require File.dirname(__FILE__) + "/rails/init" diff --git a/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb b/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb deleted file mode 100644 index 015aa0f..0000000 --- a/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb +++ /dev/null @@ -1,577 +0,0 @@ -module CollectiveIdea #:nodoc: - module Acts #:nodoc: - module NestedSet #:nodoc: - def self.included(base) - base.extend(SingletonMethods) - end - - # This acts provides Nested Set functionality. Nested Set is a smart way to implement - # an _ordered_ tree, with the added feature that you can select the children and all of their - # descendants with a single query. The drawback is that insertion or move need some complex - # sql queries. But everything is done here by this module! - # - # Nested sets are appropriate each time you want either an orderd tree (menus, - # commercial categories) or an efficient way of querying big trees (threaded posts). - # - # == API - # - # Methods names are aligned with acts_as_tree as much as possible to make replacment from one - # by another easier. - # - # item.children.create(:name => "child1") - # - module SingletonMethods - # Configuration options are: - # - # * +:parent_column+ - specifies the column name to use for keeping the position integer (default: parent_id) - # * +:left_column+ - column name for left boundry data, default "lft" - # * +:right_column+ - column name for right boundry data, default "rgt" - # * +:scope+ - restricts what is to be considered a list. Given a symbol, it'll attach "_id" - # (if it hasn't been already) and use that as the foreign key restriction. You - # can also pass an array to scope by multiple attributes. - # Example: acts_as_nested_set :scope => [:notable_id, :notable_type] - # * +:dependent+ - behavior for cascading destroy. If set to :destroy, all the - # child objects are destroyed alongside this object by calling their destroy - # method. If set to :delete_all (default), all the child objects are deleted - # without calling their destroy method. - # - # See CollectiveIdea::Acts::NestedSet::ClassMethods for a list of class methods and - # CollectiveIdea::Acts::NestedSet::InstanceMethods for a list of instance methods added - # to acts_as_nested_set models - def acts_as_nested_set(options = {}) - options = { - :parent_column => 'parent_id', - :left_column => 'lft', - :right_column => 'rgt', - :dependent => :delete_all, # or :destroy - }.merge(options) - - if options[:scope].is_a?(Symbol) && options[:scope].to_s !~ /_id$/ - options[:scope] = "#{options[:scope]}_id".intern - end - - write_inheritable_attribute :acts_as_nested_set_options, options - class_inheritable_reader :acts_as_nested_set_options - - unless self.is_a?(ClassMethods) - include Comparable - include Columns - include InstanceMethods - extend Columns - extend ClassMethods - - belongs_to :parent, :class_name => self.base_class.class_name, - :foreign_key => parent_column_name - has_many :children, :class_name => self.base_class.class_name, - :foreign_key => parent_column_name, :order => quoted_left_column_name - - attr_accessor :skip_before_destroy - - # no bulk assignment - attr_protected left_column_name.intern, - right_column_name.intern - - before_create :set_default_left_and_right - before_save :store_new_parent - after_save :move_to_new_parent - before_destroy :destroy_descendants - - # no assignment to structure fields - [left_column_name, right_column_name].each do |column| - module_eval <<-"end_eval", __FILE__, __LINE__ - def #{column}=(x) - raise ActiveRecord::ActiveRecordError, "Unauthorized assignment to #{column}: it's an internal field handled by acts_as_nested_set code, use move_to_* methods instead." - end - end_eval - end - - named_scope :roots, :conditions => {parent_column_name => nil}, :order => quoted_left_column_name - named_scope :leaves, :conditions => "#{quoted_right_column_name} - #{quoted_left_column_name} = 1", :order => quoted_left_column_name - - define_callbacks("before_move", "after_move") if self.respond_to?(:define_callbacks) - end - - end - - end - - module ClassMethods - - # Returns the first root - def root - roots.find(:first) - end - - def valid? - left_and_rights_valid? && no_duplicates_for_columns? && all_roots_valid? - end - - def left_and_rights_valid? - count( - :joins => "LEFT OUTER JOIN #{quoted_table_name} AS parent ON " + - "#{quoted_table_name}.#{quoted_parent_column_name} = parent.#{primary_key}", - :conditions => - "#{quoted_table_name}.#{quoted_left_column_name} IS NULL OR " + - "#{quoted_table_name}.#{quoted_right_column_name} IS NULL OR " + - "#{quoted_table_name}.#{quoted_left_column_name} >= " + - "#{quoted_table_name}.#{quoted_right_column_name} OR " + - "(#{quoted_table_name}.#{quoted_parent_column_name} IS NOT NULL AND " + - "(#{quoted_table_name}.#{quoted_left_column_name} <= parent.#{quoted_left_column_name} OR " + - "#{quoted_table_name}.#{quoted_right_column_name} >= parent.#{quoted_right_column_name}))" - ) == 0 - end - - def no_duplicates_for_columns? - scope_string = Array(acts_as_nested_set_options[:scope]).map do |c| - connection.quote_column_name(c) - end.push(nil).join(", ") - [quoted_left_column_name, quoted_right_column_name].all? do |column| - # No duplicates - find(:first, - :select => "#{scope_string}#{column}, COUNT(#{column})", - :group => "#{scope_string}#{column} - HAVING COUNT(#{column}) > 1").nil? - end - end - - # Wrapper for each_root_valid? that can deal with scope. - def all_roots_valid? - if acts_as_nested_set_options[:scope] - roots(:group => scope_column_names).group_by{|record| scope_column_names.collect{|col| record.send(col.to_sym)}}.all? do |scope, grouped_roots| - each_root_valid?(grouped_roots) - end - else - each_root_valid?(roots) - end - end - - def each_root_valid?(roots_to_validate) - left = right = 0 - roots_to_validate.all? do |root| - returning(root.left > left && root.right > right) do - left = root.left - right = root.right - end - end - end - - # Rebuilds the left & rights if unset or invalid. Also very useful for converting from acts_as_tree. - def rebuild! - # Don't rebuild a valid tree. - return true if valid? - - scope = lambda{|node|} - if acts_as_nested_set_options[:scope] - scope = lambda{|node| - scope_column_names.inject(""){|str, column_name| - str << "AND #{connection.quote_column_name(column_name)} = #{connection.quote(node.send(column_name.to_sym))} " - } - } - end - indices = {} - - set_left_and_rights = lambda do |node| - # set left - node[left_column_name] = indices[scope.call(node)] += 1 - # find - find(:all, :conditions => ["#{quoted_parent_column_name} = ? #{scope.call(node)}", node], :order => "#{quoted_left_column_name}, #{quoted_right_column_name}, id").each{|n| set_left_and_rights.call(n) } - # set right - node[right_column_name] = indices[scope.call(node)] += 1 - node.save! - end - - # Find root node(s) - root_nodes = find(:all, :conditions => "#{quoted_parent_column_name} IS NULL", :order => "#{quoted_left_column_name}, #{quoted_right_column_name}, id").each do |root_node| - # setup index for this scope - indices[scope.call(root_node)] ||= 0 - set_left_and_rights.call(root_node) - end - end - - # Iterates over tree elements and determines the current level in the tree. - # Only accepts default ordering, odering by an other column than lft - # does not work. This method is much more efficent than calling level - # because it doesn't require any additional database queries. - # - # Example: - # Category.each_with_level(Category.root.self_and_descendants) do |o, level| - # - def each_with_level(objects) - path = [nil] - objects.each do |o| - if o.parent_id != path.last - # we are on a new level, did we decent or ascent? - if path.include?(o.parent_id) - # remove wrong wrong tailing paths elements - path.pop while path.last != o.parent_id - else - path << o.parent_id - end - end - yield(o, path.length - 1) - end - end - end - - # Mixed into both classes and instances to provide easy access to the column names - module Columns - def left_column_name - acts_as_nested_set_options[:left_column] - end - - def right_column_name - acts_as_nested_set_options[:right_column] - end - - def parent_column_name - acts_as_nested_set_options[:parent_column] - end - - def scope_column_names - Array(acts_as_nested_set_options[:scope]) - end - - def quoted_left_column_name - connection.quote_column_name(left_column_name) - end - - def quoted_right_column_name - connection.quote_column_name(right_column_name) - end - - def quoted_parent_column_name - connection.quote_column_name(parent_column_name) - end - - def quoted_scope_column_names - scope_column_names.collect {|column_name| connection.quote_column_name(column_name) } - end - end - - # Any instance method that returns a collection makes use of Rails 2.1's named_scope (which is bundled for Rails 2.0), so it can be treated as a finder. - # - # category.self_and_descendants.count - # category.ancestors.find(:all, :conditions => "name like '%foo%'") - module InstanceMethods - # Value of the parent column - def parent_id - self[parent_column_name] - end - - # Value of the left column - def left - self[left_column_name] - end - - # Value of the right column - def right - self[right_column_name] - end - - # Returns true if this is a root node. - def root? - parent_id.nil? - end - - def leaf? - !new_record? && right - left == 1 - end - - # Returns true is this is a child node - def child? - !parent_id.nil? - end - - # order by left column - def <=>(x) - left <=> x.left - end - - # Redefine to act like active record - def ==(comparison_object) - comparison_object.equal?(self) || - (comparison_object.instance_of?(self.class) && - comparison_object.id == id && - !comparison_object.new_record?) - end - - # Returns root - def root - self_and_ancestors.find(:first) - end - - # Returns the array of all parents and self - def self_and_ancestors - nested_set_scope.scoped :conditions => [ - "#{self.class.quoted_table_name}.#{quoted_left_column_name} <= ? AND #{self.class.quoted_table_name}.#{quoted_right_column_name} >= ?", left, right - ] - end - - # Returns an array of all parents - def ancestors - without_self self_and_ancestors - end - - # Returns the array of all children of the parent, including self - def self_and_siblings - nested_set_scope.scoped :conditions => {parent_column_name => parent_id} - end - - # Returns the array of all children of the parent, except self - def siblings - without_self self_and_siblings - end - - # Returns a set of all of its nested children which do not have children - def leaves - descendants.scoped :conditions => "#{self.class.quoted_table_name}.#{quoted_right_column_name} - #{self.class.quoted_table_name}.#{quoted_left_column_name} = 1" - end - - # Returns the level of this object in the tree - # root level is 0 - def level - parent_id.nil? ? 0 : ancestors.count - end - - # Returns a set of itself and all of its nested children - def self_and_descendants - nested_set_scope.scoped :conditions => [ - "#{self.class.quoted_table_name}.#{quoted_left_column_name} >= ? AND #{self.class.quoted_table_name}.#{quoted_right_column_name} <= ?", left, right - ] - end - - # Returns a set of all of its children and nested children - def descendants - without_self self_and_descendants - end - - def is_descendant_of?(other) - other.left < self.left && self.left < other.right && same_scope?(other) - end - - def is_or_is_descendant_of?(other) - other.left <= self.left && self.left < other.right && same_scope?(other) - end - - def is_ancestor_of?(other) - self.left < other.left && other.left < self.right && same_scope?(other) - end - - def is_or_is_ancestor_of?(other) - self.left <= other.left && other.left < self.right && same_scope?(other) - end - - # Check if other model is in the same scope - def same_scope?(other) - Array(acts_as_nested_set_options[:scope]).all? do |attr| - self.send(attr) == other.send(attr) - end - end - - # Find the first sibling to the left - def left_sibling - siblings.find(:first, :conditions => ["#{self.class.quoted_table_name}.#{quoted_left_column_name} < ?", left], - :order => "#{self.class.quoted_table_name}.#{quoted_left_column_name} DESC") - end - - # Find the first sibling to the right - def right_sibling - siblings.find(:first, :conditions => ["#{self.class.quoted_table_name}.#{quoted_left_column_name} > ?", left]) - end - - # Shorthand method for finding the left sibling and moving to the left of it. - def move_left - move_to_left_of left_sibling - end - - # Shorthand method for finding the right sibling and moving to the right of it. - def move_right - move_to_right_of right_sibling - end - - # Move the node to the left of another node (you can pass id only) - def move_to_left_of(node) - move_to node, :left - end - - # Move the node to the left of another node (you can pass id only) - def move_to_right_of(node) - move_to node, :right - end - - # Move the node to the child of another node (you can pass id only) - def move_to_child_of(node) - move_to node, :child - end - - # Move the node to root nodes - def move_to_root - move_to nil, :root - end - - def move_possible?(target) - self != target && # Can't target self - same_scope?(target) && # can't be in different scopes - # !(left..right).include?(target.left..target.right) # this needs tested more - # detect impossible move - !((left <= target.left && right >= target.left) or (left <= target.right && right >= target.right)) - end - - def to_text - self_and_descendants.map do |node| - "#{'*'*(node.level+1)} #{node.id} #{node.to_s} (#{node.parent_id}, #{node.left}, #{node.right})" - end.join("\n") - end - - protected - - def without_self(scope) - scope.scoped :conditions => ["#{self.class.quoted_table_name}.#{self.class.primary_key} != ?", self] - end - - # All nested set queries should use this nested_set_scope, which performs finds on - # the base ActiveRecord class, using the :scope declared in the acts_as_nested_set - # declaration. - def nested_set_scope - options = {:order => quoted_left_column_name} - scopes = Array(acts_as_nested_set_options[:scope]) - options[:conditions] = scopes.inject({}) do |conditions,attr| - conditions.merge attr => self[attr] - end unless scopes.empty? - self.class.base_class.scoped options - end - - def store_new_parent - @move_to_new_parent_id = send("#{parent_column_name}_changed?") ? parent_id : false - true # force callback to return true - end - - def move_to_new_parent - if @move_to_new_parent_id.nil? - move_to_root - elsif @move_to_new_parent_id - move_to_child_of(@move_to_new_parent_id) - end - end - - # on creation, set automatically lft and rgt to the end of the tree - def set_default_left_and_right - maxright = nested_set_scope.maximum(right_column_name) || 0 - # adds the new node to the right of all existing nodes - self[left_column_name] = maxright + 1 - self[right_column_name] = maxright + 2 - end - - # Prunes a branch off of the tree, shifting all of the elements on the right - # back to the left so the counts still work. - def destroy_descendants - return if right.nil? || left.nil? || skip_before_destroy - - self.class.base_class.transaction do - if acts_as_nested_set_options[:dependent] == :destroy - descendants.each do |model| - model.skip_before_destroy = true - model.destroy - end - else - nested_set_scope.delete_all( - ["#{quoted_left_column_name} > ? AND #{quoted_right_column_name} < ?", - left, right] - ) - end - - # update lefts and rights for remaining nodes - diff = right - left + 1 - nested_set_scope.update_all( - ["#{quoted_left_column_name} = (#{quoted_left_column_name} - ?)", diff], - ["#{quoted_left_column_name} > ?", right] - ) - nested_set_scope.update_all( - ["#{quoted_right_column_name} = (#{quoted_right_column_name} - ?)", diff], - ["#{quoted_right_column_name} > ?", right] - ) - - # Don't allow multiple calls to destroy to corrupt the set - self.skip_before_destroy = true - end - end - - # reload left, right, and parent - def reload_nested_set - reload(:select => "#{quoted_left_column_name}, " + - "#{quoted_right_column_name}, #{quoted_parent_column_name}") - end - - def move_to(target, position) - raise ActiveRecord::ActiveRecordError, "You cannot move a new node" if self.new_record? - return if callback(:before_move) == false - transaction do - if target.is_a? self.class.base_class - target.reload_nested_set - elsif position != :root - # load object if node is not an object - target = nested_set_scope.find(target) - end - self.reload_nested_set - - unless position == :root || move_possible?(target) - raise ActiveRecord::ActiveRecordError, "Impossible move, target node cannot be inside moved tree." - end - - bound = case position - when :child; target[right_column_name] - when :left; target[left_column_name] - when :right; target[right_column_name] + 1 - when :root; 1 - else raise ActiveRecord::ActiveRecordError, "Position should be :child, :left, :right or :root ('#{position}' received)." - end - - if bound > self[right_column_name] - bound = bound - 1 - other_bound = self[right_column_name] + 1 - else - other_bound = self[left_column_name] - 1 - end - - # there would be no change - return if bound == self[right_column_name] || bound == self[left_column_name] - - # we have defined the boundaries of two non-overlapping intervals, - # so sorting puts both the intervals and their boundaries in order - a, b, c, d = [self[left_column_name], self[right_column_name], bound, other_bound].sort - - new_parent = case position - when :child; target.id - when :root; nil - else target[parent_column_name] - end - - self.class.base_class.update_all([ - "#{quoted_left_column_name} = CASE " + - "WHEN #{quoted_left_column_name} BETWEEN :a AND :b " + - "THEN #{quoted_left_column_name} + :d - :b " + - "WHEN #{quoted_left_column_name} BETWEEN :c AND :d " + - "THEN #{quoted_left_column_name} + :a - :c " + - "ELSE #{quoted_left_column_name} END, " + - "#{quoted_right_column_name} = CASE " + - "WHEN #{quoted_right_column_name} BETWEEN :a AND :b " + - "THEN #{quoted_right_column_name} + :d - :b " + - "WHEN #{quoted_right_column_name} BETWEEN :c AND :d " + - "THEN #{quoted_right_column_name} + :a - :c " + - "ELSE #{quoted_right_column_name} END, " + - "#{quoted_parent_column_name} = CASE " + - "WHEN #{self.class.base_class.primary_key} = :id THEN :new_parent " + - "ELSE #{quoted_parent_column_name} END", - {:a => a, :b => b, :c => c, :d => d, :id => self.id, :new_parent => new_parent} - ], nested_set_scope.proxy_options[:conditions]) - end - target.reload_nested_set if target - self.reload_nested_set - callback(:after_move) - end - - end - - end - end -end diff --git a/vendor/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb b/vendor/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb deleted file mode 100644 index 09c803f..0000000 --- a/vendor/plugins/awesome_nested_set/lib/awesome_nested_set/helper.rb +++ /dev/null @@ -1,40 +0,0 @@ -module CollectiveIdea #:nodoc: - module Acts #:nodoc: - module NestedSet #:nodoc: - # This module provides some helpers for the model classes using acts_as_nested_set. - # It is included by default in all views. - # - module Helper - # Returns options for select. - # You can exclude some items from the tree. - # You can pass a block receiving an item and returning the string displayed in the select. - # - # == Params - # * +class_or_item+ - Class name or top level times - # * +mover+ - The item that is being move, used to exlude impossible moves - # * +&block+ - a block that will be used to display: { |item| ... item.name } - # - # == Usage - # - # <%= f.select :parent_id, nested_set_options(Category, @category) {|i| - # "#{'–' * i.level} #{i.name}" - # }) %> - # - def nested_set_options(class_or_item, mover = nil) - class_or_item = class_or_item.roots if class_or_item.is_a?(Class) - items = Array(class_or_item) - result = [] - items.each do |root| - result += root.self_and_descendants.map do |i| - if mover.nil? || mover.new_record? || mover.move_possible?(i) - [yield(i), i.id] - end - end.compact - end - result - end - - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/rails/init.rb b/vendor/plugins/awesome_nested_set/rails/init.rb deleted file mode 100644 index 2ff1336..0000000 --- a/vendor/plugins/awesome_nested_set/rails/init.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'awesome_nested_set' - -ActiveRecord::Base.class_eval do - include CollectiveIdea::Acts::NestedSet -end - -if defined?(ActionView) - require 'awesome_nested_set/helper' - ActionView::Base.class_eval do - include CollectiveIdea::Acts::NestedSet::Helper - end -end \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/test/application.rb b/vendor/plugins/awesome_nested_set/test/application.rb deleted file mode 100644 index 0e6eacf..0000000 --- a/vendor/plugins/awesome_nested_set/test/application.rb +++ /dev/null @@ -1 +0,0 @@ -# This file is here to satisfy test_help from Rails < 2.3 \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb b/vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb deleted file mode 100644 index 888323c..0000000 --- a/vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'test_helper' - -module CollectiveIdea - module Acts #:nodoc: - module NestedSet #:nodoc: - class AwesomeNestedSetTest < TestCaseClass - include Helper - fixtures :categories - - def test_nested_set_options - expected = [ - [" Top Level", 1], - ["- Child 1", 2], - ['- Child 2', 3], - ['-- Child 2.1', 4], - ['- Child 3', 5], - [" Top Level 2", 6] - ] - actual = nested_set_options(Category) do |c| - "#{'-' * c.level} #{c.name}" - end - assert_equal expected, actual - end - - def test_nested_set_options_with_mover - expected = [ - [" Top Level", 1], - ["- Child 1", 2], - ['- Child 3', 5], - [" Top Level 2", 6] - ] - actual = nested_set_options(Category, categories(:child_2)) do |c| - "#{'-' * c.level} #{c.name}" - end - assert_equal expected, actual - end - - end - end - end -end diff --git a/vendor/plugins/awesome_nested_set/test/awesome_nested_set_test.rb b/vendor/plugins/awesome_nested_set/test/awesome_nested_set_test.rb deleted file mode 100644 index 7b587de..0000000 --- a/vendor/plugins/awesome_nested_set/test/awesome_nested_set_test.rb +++ /dev/null @@ -1,748 +0,0 @@ -require 'test_helper' - -class Note < ActiveRecord::Base - acts_as_nested_set :scope => [:notable_id, :notable_type] -end -class Default < ActiveRecord::Base - acts_as_nested_set - set_table_name 'categories' -end -class ScopedCategory < ActiveRecord::Base - acts_as_nested_set :scope => :organization - set_table_name 'categories' -end -class RenamedColumns < ActiveRecord::Base - acts_as_nested_set :parent_column => 'mother_id', :left_column => 'red', :right_column => 'black' -end - -class AwesomeNestedSetTest < TestCaseClass - - def test_left_column_default - assert_equal 'lft', Default.acts_as_nested_set_options[:left_column] - end - - def test_right_column_default - assert_equal 'rgt', Default.acts_as_nested_set_options[:right_column] - end - - def test_parent_column_default - assert_equal 'parent_id', Default.acts_as_nested_set_options[:parent_column] - end - - def test_scope_default - assert_nil Default.acts_as_nested_set_options[:scope] - end - - def test_left_column_name - assert_equal 'lft', Default.left_column_name - assert_equal 'lft', Default.new.left_column_name - assert_equal 'red', RenamedColumns.left_column_name - assert_equal 'red', RenamedColumns.new.left_column_name - end - - def test_right_column_name - assert_equal 'rgt', Default.right_column_name - assert_equal 'rgt', Default.new.right_column_name - assert_equal 'black', RenamedColumns.right_column_name - assert_equal 'black', RenamedColumns.new.right_column_name - end - - def test_parent_column_name - assert_equal 'parent_id', Default.parent_column_name - assert_equal 'parent_id', Default.new.parent_column_name - assert_equal 'mother_id', RenamedColumns.parent_column_name - assert_equal 'mother_id', RenamedColumns.new.parent_column_name - end - - def test_creation_with_altered_column_names - assert_nothing_raised do - RenamedColumns.create!() - end - end - - def test_quoted_left_column_name - quoted = Default.connection.quote_column_name('lft') - assert_equal quoted, Default.quoted_left_column_name - assert_equal quoted, Default.new.quoted_left_column_name - end - - def test_quoted_right_column_name - quoted = Default.connection.quote_column_name('rgt') - assert_equal quoted, Default.quoted_right_column_name - assert_equal quoted, Default.new.quoted_right_column_name - end - - def test_left_column_protected_from_assignment - assert_raises(ActiveRecord::ActiveRecordError) { Category.new.lft = 1 } - end - - def test_right_column_protected_from_assignment - assert_raises(ActiveRecord::ActiveRecordError) { Category.new.rgt = 1 } - end - - def test_colums_protected_on_initialize - c = Category.new(:lft => 1, :rgt => 2) - assert_nil c.lft - assert_nil c.rgt - end - - def test_scoped_appends_id - assert_equal :organization_id, ScopedCategory.acts_as_nested_set_options[:scope] - end - - def test_roots_class_method - assert_equal Category.find_all_by_parent_id(nil), Category.roots - end - - def test_root_class_method - assert_equal categories(:top_level), Category.root - end - - def test_root - assert_equal categories(:top_level), categories(:child_3).root - end - - def test_root? - assert categories(:top_level).root? - assert categories(:top_level_2).root? - end - - def test_leaves_class_method - assert_equal Category.find(:all, :conditions => "#{Category.right_column_name} - #{Category.left_column_name} = 1"), Category.leaves - assert_equal Category.leaves.count, 4 - assert (Category.leaves.include? categories(:child_1)) - assert (Category.leaves.include? categories(:child_2_1)) - assert (Category.leaves.include? categories(:child_3)) - assert (Category.leaves.include? categories(:top_level_2)) - end - - def test_leaf - assert categories(:child_1).leaf? - assert categories(:child_2_1).leaf? - assert categories(:child_3).leaf? - assert categories(:top_level_2).leaf? - - assert !categories(:top_level).leaf? - assert !categories(:child_2).leaf? - assert !Category.new.leaf? - end - - - def test_parent - assert_equal categories(:child_2), categories(:child_2_1).parent - end - - def test_self_and_ancestors - child = categories(:child_2_1) - self_and_ancestors = [categories(:top_level), categories(:child_2), child] - assert_equal self_and_ancestors, child.self_and_ancestors - end - - def test_ancestors - child = categories(:child_2_1) - ancestors = [categories(:top_level), categories(:child_2)] - assert_equal ancestors, child.ancestors - end - - def test_self_and_siblings - child = categories(:child_2) - self_and_siblings = [categories(:child_1), child, categories(:child_3)] - assert_equal self_and_siblings, child.self_and_siblings - assert_nothing_raised do - tops = [categories(:top_level), categories(:top_level_2)] - assert_equal tops, categories(:top_level).self_and_siblings - end - end - - def test_siblings - child = categories(:child_2) - siblings = [categories(:child_1), categories(:child_3)] - assert_equal siblings, child.siblings - end - - def test_leaves - leaves = [categories(:child_1), categories(:child_2_1), categories(:child_3), categories(:top_level_2)] - assert categories(:top_level).leaves, leaves - end - - def test_level - assert_equal 0, categories(:top_level).level - assert_equal 1, categories(:child_1).level - assert_equal 2, categories(:child_2_1).level - end - - def test_has_children? - assert categories(:child_2_1).children.empty? - assert !categories(:child_2).children.empty? - assert !categories(:top_level).children.empty? - end - - def test_self_and_descendents - parent = categories(:top_level) - self_and_descendants = [parent, categories(:child_1), categories(:child_2), - categories(:child_2_1), categories(:child_3)] - assert_equal self_and_descendants, parent.self_and_descendants - assert_equal self_and_descendants, parent.self_and_descendants.count - end - - def test_descendents - lawyers = Category.create!(:name => "lawyers") - us = Category.create!(:name => "United States") - us.move_to_child_of(lawyers) - patent = Category.create!(:name => "Patent Law") - patent.move_to_child_of(us) - lawyers.reload - - assert_equal 1, lawyers.children.size - assert_equal 1, us.children.size - assert_equal 2, lawyers.descendants.size - end - - def test_self_and_descendents - parent = categories(:top_level) - descendants = [categories(:child_1), categories(:child_2), - categories(:child_2_1), categories(:child_3)] - assert_equal descendants, parent.descendants - end - - def test_children - category = categories(:top_level) - category.children.each {|c| assert_equal category.id, c.parent_id } - end - - def test_order_of_children - categories(:child_2).move_left - assert_equal categories(:child_2), categories(:top_level).children[0] - assert_equal categories(:child_1), categories(:top_level).children[1] - assert_equal categories(:child_3), categories(:top_level).children[2] - end - - def test_is_or_is_ancestor_of? - assert categories(:top_level).is_or_is_ancestor_of?(categories(:child_1)) - assert categories(:top_level).is_or_is_ancestor_of?(categories(:child_2_1)) - assert categories(:child_2).is_or_is_ancestor_of?(categories(:child_2_1)) - assert !categories(:child_2_1).is_or_is_ancestor_of?(categories(:child_2)) - assert !categories(:child_1).is_or_is_ancestor_of?(categories(:child_2)) - assert categories(:child_1).is_or_is_ancestor_of?(categories(:child_1)) - end - - def test_is_ancestor_of? - assert categories(:top_level).is_ancestor_of?(categories(:child_1)) - assert categories(:top_level).is_ancestor_of?(categories(:child_2_1)) - assert categories(:child_2).is_ancestor_of?(categories(:child_2_1)) - assert !categories(:child_2_1).is_ancestor_of?(categories(:child_2)) - assert !categories(:child_1).is_ancestor_of?(categories(:child_2)) - assert !categories(:child_1).is_ancestor_of?(categories(:child_1)) - end - - def test_is_or_is_ancestor_of_with_scope - root = ScopedCategory.root - child = root.children.first - assert root.is_or_is_ancestor_of?(child) - child.update_attribute :organization_id, 'different' - assert !root.is_or_is_ancestor_of?(child) - end - - def test_is_or_is_descendant_of? - assert categories(:child_1).is_or_is_descendant_of?(categories(:top_level)) - assert categories(:child_2_1).is_or_is_descendant_of?(categories(:top_level)) - assert categories(:child_2_1).is_or_is_descendant_of?(categories(:child_2)) - assert !categories(:child_2).is_or_is_descendant_of?(categories(:child_2_1)) - assert !categories(:child_2).is_or_is_descendant_of?(categories(:child_1)) - assert categories(:child_1).is_or_is_descendant_of?(categories(:child_1)) - end - - def test_is_descendant_of? - assert categories(:child_1).is_descendant_of?(categories(:top_level)) - assert categories(:child_2_1).is_descendant_of?(categories(:top_level)) - assert categories(:child_2_1).is_descendant_of?(categories(:child_2)) - assert !categories(:child_2).is_descendant_of?(categories(:child_2_1)) - assert !categories(:child_2).is_descendant_of?(categories(:child_1)) - assert !categories(:child_1).is_descendant_of?(categories(:child_1)) - end - - def test_is_or_is_descendant_of_with_scope - root = ScopedCategory.root - child = root.children.first - assert child.is_or_is_descendant_of?(root) - child.update_attribute :organization_id, 'different' - assert !child.is_or_is_descendant_of?(root) - end - - def test_same_scope? - root = ScopedCategory.root - child = root.children.first - assert child.same_scope?(root) - child.update_attribute :organization_id, 'different' - assert !child.same_scope?(root) - end - - def test_left_sibling - assert_equal categories(:child_1), categories(:child_2).left_sibling - assert_equal categories(:child_2), categories(:child_3).left_sibling - end - - def test_left_sibling_of_root - assert_nil categories(:top_level).left_sibling - end - - def test_left_sibling_without_siblings - assert_nil categories(:child_2_1).left_sibling - end - - def test_left_sibling_of_leftmost_node - assert_nil categories(:child_1).left_sibling - end - - def test_right_sibling - assert_equal categories(:child_3), categories(:child_2).right_sibling - assert_equal categories(:child_2), categories(:child_1).right_sibling - end - - def test_right_sibling_of_root - assert_equal categories(:top_level_2), categories(:top_level).right_sibling - assert_nil categories(:top_level_2).right_sibling - end - - def test_right_sibling_without_siblings - assert_nil categories(:child_2_1).right_sibling - end - - def test_right_sibling_of_rightmost_node - assert_nil categories(:child_3).right_sibling - end - - def test_move_left - categories(:child_2).move_left - assert_nil categories(:child_2).left_sibling - assert_equal categories(:child_1), categories(:child_2).right_sibling - assert Category.valid? - end - - def test_move_right - categories(:child_2).move_right - assert_nil categories(:child_2).right_sibling - assert_equal categories(:child_3), categories(:child_2).left_sibling - assert Category.valid? - end - - def test_move_to_left_of - categories(:child_3).move_to_left_of(categories(:child_1)) - assert_nil categories(:child_3).left_sibling - assert_equal categories(:child_1), categories(:child_3).right_sibling - assert Category.valid? - end - - def test_move_to_right_of - categories(:child_1).move_to_right_of(categories(:child_3)) - assert_nil categories(:child_1).right_sibling - assert_equal categories(:child_3), categories(:child_1).left_sibling - assert Category.valid? - end - - def test_move_to_root - categories(:child_2).move_to_root - assert_nil categories(:child_2).parent - assert_equal 0, categories(:child_2).level - assert_equal 1, categories(:child_2_1).level - assert_equal 1, categories(:child_2).left - assert_equal 4, categories(:child_2).right - assert Category.valid? - end - - def test_move_to_child_of - categories(:child_1).move_to_child_of(categories(:child_3)) - assert_equal categories(:child_3).id, categories(:child_1).parent_id - assert Category.valid? - end - - def test_move_to_child_of_appends_to_end - child = Category.create! :name => 'New Child' - child.move_to_child_of categories(:top_level) - assert_equal child, categories(:top_level).children.last - end - - def test_subtree_move_to_child_of - assert_equal 4, categories(:child_2).left - assert_equal 7, categories(:child_2).right - - assert_equal 2, categories(:child_1).left - assert_equal 3, categories(:child_1).right - - categories(:child_2).move_to_child_of(categories(:child_1)) - assert Category.valid? - assert_equal categories(:child_1).id, categories(:child_2).parent_id - - assert_equal 3, categories(:child_2).left - assert_equal 6, categories(:child_2).right - assert_equal 2, categories(:child_1).left - assert_equal 7, categories(:child_1).right - end - - def test_slightly_difficult_move_to_child_of - assert_equal 11, categories(:top_level_2).left - assert_equal 12, categories(:top_level_2).right - - # create a new top-level node and move single-node top-level tree inside it. - new_top = Category.create(:name => 'New Top') - assert_equal 13, new_top.left - assert_equal 14, new_top.right - - categories(:top_level_2).move_to_child_of(new_top) - - assert Category.valid? - assert_equal new_top.id, categories(:top_level_2).parent_id - - assert_equal 12, categories(:top_level_2).left - assert_equal 13, categories(:top_level_2).right - assert_equal 11, new_top.left - assert_equal 14, new_top.right - end - - def test_difficult_move_to_child_of - assert_equal 1, categories(:top_level).left - assert_equal 10, categories(:top_level).right - assert_equal 5, categories(:child_2_1).left - assert_equal 6, categories(:child_2_1).right - - # create a new top-level node and move an entire top-level tree inside it. - new_top = Category.create(:name => 'New Top') - categories(:top_level).move_to_child_of(new_top) - categories(:child_2_1).reload - assert Category.valid? - assert_equal new_top.id, categories(:top_level).parent_id - - assert_equal 4, categories(:top_level).left - assert_equal 13, categories(:top_level).right - assert_equal 8, categories(:child_2_1).left - assert_equal 9, categories(:child_2_1).right - end - - #rebuild swaps the position of the 2 children when added using move_to_child twice onto same parent - def test_move_to_child_more_than_once_per_parent_rebuild - root1 = Category.create(:name => 'Root1') - root2 = Category.create(:name => 'Root2') - root3 = Category.create(:name => 'Root3') - - root2.move_to_child_of root1 - root3.move_to_child_of root1 - - output = Category.roots.last.to_text - Category.update_all('lft = null, rgt = null') - Category.rebuild! - - assert_equal Category.roots.last.to_text, output - end - - # doing move_to_child twice onto same parent from the furthest right first - def test_move_to_child_more_than_once_per_parent_outside_in - node1 = Category.create(:name => 'Node-1') - node2 = Category.create(:name => 'Node-2') - node3 = Category.create(:name => 'Node-3') - - node2.move_to_child_of node1 - node3.move_to_child_of node1 - - output = Category.roots.last.to_text - Category.update_all('lft = null, rgt = null') - Category.rebuild! - - assert_equal Category.roots.last.to_text, output - end - - - def test_valid_with_null_lefts - assert Category.valid? - Category.update_all('lft = null') - assert !Category.valid? - end - - def test_valid_with_null_rights - assert Category.valid? - Category.update_all('rgt = null') - assert !Category.valid? - end - - def test_valid_with_missing_intermediate_node - # Even though child_2_1 will still exist, it is a sign of a sloppy delete, not an invalid tree. - assert Category.valid? - Category.delete(categories(:child_2).id) - assert Category.valid? - end - - def test_valid_with_overlapping_and_rights - assert Category.valid? - categories(:top_level_2)['lft'] = 0 - categories(:top_level_2).save - assert !Category.valid? - end - - def test_rebuild - assert Category.valid? - before_text = Category.root.to_text - Category.update_all('lft = null, rgt = null') - Category.rebuild! - assert Category.valid? - assert_equal before_text, Category.root.to_text - end - - def test_move_possible_for_sibling - assert categories(:child_2).move_possible?(categories(:child_1)) - end - - def test_move_not_possible_to_self - assert !categories(:top_level).move_possible?(categories(:top_level)) - end - - def test_move_not_possible_to_parent - categories(:top_level).descendants.each do |descendant| - assert !categories(:top_level).move_possible?(descendant) - assert descendant.move_possible?(categories(:top_level)) - end - end - - def test_is_or_is_ancestor_of? - [:child_1, :child_2, :child_2_1, :child_3].each do |c| - assert categories(:top_level).is_or_is_ancestor_of?(categories(c)) - end - assert !categories(:top_level).is_or_is_ancestor_of?(categories(:top_level_2)) - end - - def test_left_and_rights_valid_with_blank_left - assert Category.left_and_rights_valid? - categories(:child_2)[:lft] = nil - categories(:child_2).save(false) - assert !Category.left_and_rights_valid? - end - - def test_left_and_rights_valid_with_blank_right - assert Category.left_and_rights_valid? - categories(:child_2)[:rgt] = nil - categories(:child_2).save(false) - assert !Category.left_and_rights_valid? - end - - def test_left_and_rights_valid_with_equal - assert Category.left_and_rights_valid? - categories(:top_level_2)[:lft] = categories(:top_level_2)[:rgt] - categories(:top_level_2).save(false) - assert !Category.left_and_rights_valid? - end - - def test_left_and_rights_valid_with_left_equal_to_parent - assert Category.left_and_rights_valid? - categories(:child_2)[:lft] = categories(:top_level)[:lft] - categories(:child_2).save(false) - assert !Category.left_and_rights_valid? - end - - def test_left_and_rights_valid_with_right_equal_to_parent - assert Category.left_and_rights_valid? - categories(:child_2)[:rgt] = categories(:top_level)[:rgt] - categories(:child_2).save(false) - assert !Category.left_and_rights_valid? - end - - def test_moving_dirty_objects_doesnt_invalidate_tree - r1 = Category.create - r2 = Category.create - r3 = Category.create - r4 = Category.create - nodes = [r1, r2, r3, r4] - - r2.move_to_child_of(r1) - assert Category.valid? - - r3.move_to_child_of(r1) - assert Category.valid? - - r4.move_to_child_of(r2) - assert Category.valid? - end - - def test_multi_scoped_no_duplicates_for_columns? - assert_nothing_raised do - Note.no_duplicates_for_columns? - end - end - - def test_multi_scoped_all_roots_valid? - assert_nothing_raised do - Note.all_roots_valid? - end - end - - def test_multi_scoped - note1 = Note.create!(:body => "A", :notable_id => 2, :notable_type => 'Category') - note2 = Note.create!(:body => "B", :notable_id => 2, :notable_type => 'Category') - note3 = Note.create!(:body => "C", :notable_id => 2, :notable_type => 'Default') - - assert_equal [note1, note2], note1.self_and_siblings - assert_equal [note3], note3.self_and_siblings - end - - def test_multi_scoped_rebuild - root = Note.create!(:body => "A", :notable_id => 3, :notable_type => 'Category') - child1 = Note.create!(:body => "B", :notable_id => 3, :notable_type => 'Category') - child2 = Note.create!(:body => "C", :notable_id => 3, :notable_type => 'Category') - - child1.move_to_child_of root - child2.move_to_child_of root - - Note.update_all('lft = null, rgt = null') - Note.rebuild! - - assert_equal Note.roots.find_by_body('A'), root - assert_equal [child1, child2], Note.roots.find_by_body('A').children - end - - def test_same_scope_with_multi_scopes - assert_nothing_raised do - notes(:scope1).same_scope?(notes(:child_1)) - end - assert notes(:scope1).same_scope?(notes(:child_1)) - assert notes(:child_1).same_scope?(notes(:scope1)) - assert !notes(:scope1).same_scope?(notes(:scope2)) - end - - def test_quoting_of_multi_scope_column_names - assert_equal ["\"notable_id\"", "\"notable_type\""], Note.quoted_scope_column_names - end - - def test_equal_in_same_scope - assert_equal notes(:scope1), notes(:scope1) - assert_not_equal notes(:scope1), notes(:child_1) - end - - def test_equal_in_different_scopes - assert_not_equal notes(:scope1), notes(:scope2) - end - - def test_delete_does_not_invalidate - Category.acts_as_nested_set_options[:dependent] = :delete - categories(:child_2).destroy - assert Category.valid? - end - - def test_destroy_does_not_invalidate - Category.acts_as_nested_set_options[:dependent] = :destroy - categories(:child_2).destroy - assert Category.valid? - end - - def test_destroy_multiple_times_does_not_invalidate - Category.acts_as_nested_set_options[:dependent] = :destroy - categories(:child_2).destroy - categories(:child_2).destroy - assert Category.valid? - end - - def test_assigning_parent_id_on_create - category = Category.create!(:name => "Child", :parent_id => categories(:child_2).id) - assert_equal categories(:child_2), category.parent - assert_equal categories(:child_2).id, category.parent_id - assert_not_nil category.left - assert_not_nil category.right - assert Category.valid? - end - - def test_assigning_parent_on_create - category = Category.create!(:name => "Child", :parent => categories(:child_2)) - assert_equal categories(:child_2), category.parent - assert_equal categories(:child_2).id, category.parent_id - assert_not_nil category.left - assert_not_nil category.right - assert Category.valid? - end - - def test_assigning_parent_id_to_nil_on_create - category = Category.create!(:name => "New Root", :parent_id => nil) - assert_nil category.parent - assert_nil category.parent_id - assert_not_nil category.left - assert_not_nil category.right - assert Category.valid? - end - - def test_assigning_parent_id_on_update - category = categories(:child_2_1) - category.parent_id = categories(:child_3).id - category.save - assert_equal categories(:child_3), category.parent - assert_equal categories(:child_3).id, category.parent_id - assert Category.valid? - end - - def test_assigning_parent_on_update - category = categories(:child_2_1) - category.parent = categories(:child_3) - category.save - assert_equal categories(:child_3), category.parent - assert_equal categories(:child_3).id, category.parent_id - assert Category.valid? - end - - def test_assigning_parent_id_to_nil_on_update - category = categories(:child_2_1) - category.parent_id = nil - category.save - assert_nil category.parent - assert_nil category.parent_id - assert Category.valid? - end - - def test_creating_child_from_parent - category = categories(:child_2).children.create!(:name => "Child") - assert_equal categories(:child_2), category.parent - assert_equal categories(:child_2).id, category.parent_id - assert_not_nil category.left - assert_not_nil category.right - assert Category.valid? - end - - def check_structure(entries, structure) - structure = structure.dup - Category.each_with_level(entries) do |category, level| - expected_level, expected_name = structure.shift - assert_equal expected_name, category.name, "wrong category" - assert_equal expected_level, level, "wrong level for #{category.name}" - end - end - - def test_each_with_level - levels = [ - [0, "Top Level"], - [1, "Child 1"], - [1, "Child 2"], - [2, "Child 2.1"], - [1, "Child 3" ]] - - check_structure(Category.root.self_and_descendants, levels) - - # test some deeper structures - category = Category.find_by_name("Child 1") - c1 = Category.new(:name => "Child 1.1") - c2 = Category.new(:name => "Child 1.1.1") - c3 = Category.new(:name => "Child 1.1.1.1") - c4 = Category.new(:name => "Child 1.2") - [c1, c2, c3, c4].each(&:save!) - - c1.move_to_child_of(category) - c2.move_to_child_of(c1) - c3.move_to_child_of(c2) - c4.move_to_child_of(category) - - levels = [ - [0, "Top Level"], - [1, "Child 1"], - [2, "Child 1.1"], - [3, "Child 1.1.1"], - [4, "Child 1.1.1.1"], - [2, "Child 1.2"], - [1, "Child 2"], - [2, "Child 2.1"], - [1, "Child 3" ]] - - check_structure(Category.root.self_and_descendants, levels) - end -end diff --git a/vendor/plugins/awesome_nested_set/test/fixtures/categories.yml b/vendor/plugins/awesome_nested_set/test/fixtures/categories.yml deleted file mode 100644 index bc8e078..0000000 --- a/vendor/plugins/awesome_nested_set/test/fixtures/categories.yml +++ /dev/null @@ -1,34 +0,0 @@ -top_level: - id: 1 - name: Top Level - lft: 1 - rgt: 10 -child_1: - id: 2 - name: Child 1 - parent_id: 1 - lft: 2 - rgt: 3 -child_2: - id: 3 - name: Child 2 - parent_id: 1 - lft: 4 - rgt: 7 -child_2_1: - id: 4 - name: Child 2.1 - parent_id: 3 - lft: 5 - rgt: 6 -child_3: - id: 5 - name: Child 3 - parent_id: 1 - lft: 8 - rgt: 9 -top_level_2: - id: 6 - name: Top Level 2 - lft: 11 - rgt: 12 diff --git a/vendor/plugins/awesome_nested_set/test/fixtures/category.rb b/vendor/plugins/awesome_nested_set/test/fixtures/category.rb deleted file mode 100644 index 506b0da..0000000 --- a/vendor/plugins/awesome_nested_set/test/fixtures/category.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Category < ActiveRecord::Base - acts_as_nested_set - - def to_s - name - end - - def recurse &block - block.call self, lambda{ - self.children.each do |child| - child.recurse &block - end - } - end -end \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/test/fixtures/departments.yml b/vendor/plugins/awesome_nested_set/test/fixtures/departments.yml deleted file mode 100644 index e50a944..0000000 --- a/vendor/plugins/awesome_nested_set/test/fixtures/departments.yml +++ /dev/null @@ -1,3 +0,0 @@ -top: - id: 1 - name: Top \ No newline at end of file diff --git a/vendor/plugins/awesome_nested_set/test/fixtures/notes.yml b/vendor/plugins/awesome_nested_set/test/fixtures/notes.yml deleted file mode 100644 index 004a533..0000000 --- a/vendor/plugins/awesome_nested_set/test/fixtures/notes.yml +++ /dev/null @@ -1,38 +0,0 @@ -scope1: - id: 1 - body: Top Level - lft: 1 - rgt: 10 - notable_id: 1 - notable_type: Category -child_1: - id: 2 - body: Child 1 - parent_id: 1 - lft: 2 - rgt: 3 - notable_id: 1 - notable_type: Category -child_2: - id: 3 - body: Child 2 - parent_id: 1 - lft: 4 - rgt: 7 - notable_id: 1 - notable_type: Category -child_3: - id: 4 - body: Child 3 - parent_id: 1 - lft: 8 - rgt: 9 - notable_id: 1 - notable_type: Category -scope2: - id: 5 - body: Top Level 2 - lft: 1 - rgt: 2 - notable_id: 1 - notable_type: Departments diff --git a/vendor/plugins/awesome_nested_set/test/test_helper.rb b/vendor/plugins/awesome_nested_set/test/test_helper.rb deleted file mode 100644 index 05d8855..0000000 --- a/vendor/plugins/awesome_nested_set/test/test_helper.rb +++ /dev/null @@ -1,29 +0,0 @@ -$:.unshift(File.dirname(__FILE__) + '/../lib') -plugin_test_dir = File.dirname(__FILE__) -RAILS_ROOT = plugin_test_dir - -require 'rubygems' -require 'test/unit' -require 'multi_rails_init' -require 'test_help' - -require plugin_test_dir + '/../init.rb' - -TestCaseClass = ActiveSupport::TestCase rescue Test::Unit::TestCase - -ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log") - -ActiveRecord::Base.configurations = YAML::load(IO.read(plugin_test_dir + "/db/database.yml")) -ActiveRecord::Base.establish_connection(ENV["DB"] || "sqlite3mem") -ActiveRecord::Migration.verbose = false -load(File.join(plugin_test_dir, "db", "schema.rb")) - -Dir["#{plugin_test_dir}/fixtures/*.rb"].each {|file| require file } - -class TestCaseClass #:nodoc: - self.fixture_path = File.dirname(__FILE__) + "/fixtures/" - self.use_transactional_fixtures = true - self.use_instantiated_fixtures = false - - fixtures :categories, :notes, :departments -end diff --git a/vendor/plugins/exception_notification/README b/vendor/plugins/exception_notification/README deleted file mode 100644 index 9a47c41..0000000 --- a/vendor/plugins/exception_notification/README +++ /dev/null @@ -1,111 +0,0 @@ -= Exception Notifier Plugin for Rails - -The Exception Notifier plugin provides a mailer object and a default set of -templates for sending email notifications when errors occur in a Rails -application. The plugin is configurable, allowing programmers to specify: - -* the sender address of the email -* the recipient addresses -* the text used to prefix the subject line - -The email includes information about the current request, session, and -environment, and also gives a backtrace of the exception. - -== Usage - -First, include the ExceptionNotifiable mixin in whichever controller you want -to generate error emails (typically ApplicationController): - - class ApplicationController < ActionController::Base - include ExceptionNotifiable - ... - end - -Then, specify the email recipients in your environment: - - ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com) - -And that's it! The defaults take care of the rest. - -== Configuration - -You can tweak other values to your liking, as well. In your environment file, -just set any or all of the following values: - - # defaults to exception.notifier@default.com - ExceptionNotifier.sender_address = - %("Application Error" ) - - # defaults to "[ERROR] " - ExceptionNotifier.email_prefix = "[APP] " - -Email notifications will only occur when the IP address is determined not to -be local. You can specify certain addresses to always be local so that you'll -get a detailed error instead of the generic error page. You do this in your -controller (or even per-controller): - - consider_local "64.72.18.143", "14.17.21.25" - -You can specify subnet masks as well, so that all matching addresses are -considered local: - - consider_local "64.72.18.143/24" - -The address "127.0.0.1" is always considered local. If you want to completely -reset the list of all addresses (for instance, if you wanted "127.0.0.1" to -NOT be considered local), you can simply do, somewhere in your controller: - - local_addresses.clear - -== Customization - -By default, the notification email includes four parts: request, session, -environment, and backtrace (in that order). You can customize how each of those -sections are rendered by placing a partial named for that part in your -app/views/exception_notifier directory (e.g., _session.rhtml). Each partial has -access to the following variables: - -* @controller: the controller that caused the error -* @request: the current request object -* @exception: the exception that was raised -* @host: the name of the host that made the request -* @backtrace: a sanitized version of the exception's backtrace -* @rails_root: a sanitized version of RAILS_ROOT -* @data: a hash of optional data values that were passed to the notifier -* @sections: the array of sections to include in the email - -You can reorder the sections, or exclude sections completely, by altering the -ExceptionNotifier.sections variable. You can even add new sections that -describe application-specific data--just add the section's name to the list -(whereever you'd like), and define the corresponding partial. Then, if your -new section requires information that isn't available by default, make sure -it is made available to the email using the exception_data macro: - - class ApplicationController < ActionController::Base - ... - protected - exception_data :additional_data - - def additional_data - { :document => @document, - :person => @person } - end - ... - end - -In the above case, @document and @person would be made available to the email -renderer, allowing your new section(s) to access and display them. See the -existing sections defined by the plugin for examples of how to write your own. - -== Advanced Customization - -By default, the email notifier will only notify on critical errors. For -ActiveRecord::RecordNotFound and ActionController::UnknownAction, it will -simply render the contents of your public/404.html file. Other exceptions -will render public/500.html and will send the email notification. If you want -to use different rules for the notification, you will need to implement your -own rescue_action_in_public method. You can look at the default implementation -in ExceptionNotifiable for an example of how to go about that. - - -Copyright (c) 2005 Jamis Buck, released under the MIT license \ No newline at end of file diff --git a/vendor/plugins/exception_notification/init.rb b/vendor/plugins/exception_notification/init.rb deleted file mode 100644 index 4d9d76e..0000000 --- a/vendor/plugins/exception_notification/init.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "action_mailer" -require "exception_notifier" -require "exception_notifiable" -require "exception_notifier_helper" diff --git a/vendor/plugins/exception_notification/lib/exception_notifiable.rb b/vendor/plugins/exception_notification/lib/exception_notifiable.rb deleted file mode 100644 index d5e28fc..0000000 --- a/vendor/plugins/exception_notification/lib/exception_notifiable.rb +++ /dev/null @@ -1,99 +0,0 @@ -require 'ipaddr' - -# Copyright (c) 2005 Jamis Buck -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -module ExceptionNotifiable - def self.included(target) - target.extend(ClassMethods) - end - - module ClassMethods - def consider_local(*args) - local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) }) - end - - def local_addresses - addresses = read_inheritable_attribute(:local_addresses) - unless addresses - addresses = [IPAddr.new("127.0.0.1")] - write_inheritable_attribute(:local_addresses, addresses) - end - addresses - end - - def exception_data(deliverer=self) - if deliverer == self - read_inheritable_attribute(:exception_data) - else - write_inheritable_attribute(:exception_data, deliverer) - end - end - - def exceptions_to_treat_as_404 - exceptions = [ActiveRecord::RecordNotFound, - ActionController::UnknownController, - ActionController::UnknownAction] - exceptions << ActionController::RoutingError if ActionController.const_defined?(:RoutingError) - exceptions - end - end - - private - - def local_request? - remote = IPAddr.new(request.remote_ip) - !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil? - end - - def render_404 - respond_to do |type| - type.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" } - type.all { render :nothing => true, :status => "404 Not Found" } - end - end - - def render_500 - respond_to do |type| - type.html { render :file => "#{RAILS_ROOT}/public/500.html", :status => "500 Error" } - type.all { render :nothing => true, :status => "500 Error" } - end - end - - def rescue_action_in_public(exception) - case exception - when *self.class.exceptions_to_treat_as_404 - render_404 - - else - render_500 - - deliverer = self.class.exception_data - data = case deliverer - when nil then {} - when Symbol then send(deliverer) - when Proc then deliverer.call(self) - end - - ExceptionNotifier.deliver_exception_notification(exception, self, - request, data) - end - end -end diff --git a/vendor/plugins/exception_notification/lib/exception_notifier.rb b/vendor/plugins/exception_notification/lib/exception_notifier.rb deleted file mode 100644 index 72e2e1a..0000000 --- a/vendor/plugins/exception_notification/lib/exception_notifier.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'pathname' - -# Copyright (c) 2005 Jamis Buck -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -class ExceptionNotifier < ActionMailer::Base - @@sender_address = %("Exception Notifier" ) - cattr_accessor :sender_address - - @@exception_recipients = [] - cattr_accessor :exception_recipients - - @@email_prefix = "[ERROR] " - cattr_accessor :email_prefix - - @@sections = %w(request session environment backtrace) - cattr_accessor :sections - - self.template_root = "#{File.dirname(__FILE__)}/../views" - - def self.reloadable?() false end - - def exception_notification(exception, controller, request, data={}) - content_type "text/plain" - - subject "#{email_prefix}#{controller.controller_name}##{controller.action_name} (#{exception.class}) #{exception.message.inspect}" - - recipients exception_recipients - from sender_address - - body data.merge({ :controller => controller, :request => request, - :exception => exception, :host => (request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"]), - :backtrace => sanitize_backtrace(exception.backtrace), - :rails_root => rails_root, :data => data, - :sections => sections }) - end - - private - - def sanitize_backtrace(trace) - re = Regexp.new(/^#{Regexp.escape(rails_root)}/) - trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s } - end - - def rails_root - @rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s - end - -end diff --git a/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb b/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb deleted file mode 100644 index d3dc63a..0000000 --- a/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'pp' - -# Copyright (c) 2005 Jamis Buck -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -module ExceptionNotifierHelper - VIEW_PATH = "views/exception_notifier" - APP_PATH = "#{RAILS_ROOT}/app/#{VIEW_PATH}" - PARAM_FILTER_REPLACEMENT = "[FILTERED]" - - def render_section(section) - RAILS_DEFAULT_LOGGER.info("rendering section #{section.inspect}") - summary = render_overridable(section).strip - unless summary.blank? - title = render_overridable(:title, :locals => { :title => section }).strip - "#{title}\n\n#{summary.gsub(/^/, " ")}\n\n" - end - end - - def render_overridable(partial, options={}) - if File.exist?(path = "#{APP_PATH}/_#{partial}.rhtml") - render(options.merge(:file => path, :use_full_path => false)) - elsif File.exist?(path = "#{File.dirname(__FILE__)}/../#{VIEW_PATH}/_#{partial}.rhtml") - render(options.merge(:file => path, :use_full_path => false)) - else - "" - end - end - - def inspect_model_object(model, locals={}) - render_overridable(:inspect_model, - :locals => { :inspect_model => model, - :show_instance_variables => true, - :show_attributes => true }.merge(locals)) - end - - def inspect_value(value) - len = 512 - result = object_to_yaml(value).gsub(/\n/, "\n ").strip - result = result[0,len] + "... (#{result.length-len} bytes more)" if result.length > len+20 - result - end - - def object_to_yaml(object) - object.to_yaml.sub(/^---\s*/m, "") - end - - def exclude_raw_post_parameters? - @controller && @controller.respond_to?(:filter_parameters) - end - - def filter_sensitive_post_data_parameters(parameters) - exclude_raw_post_parameters? ? @controller.__send__(:filter_parameters, parameters) : parameters - end - - def filter_sensitive_post_data_from_env(env_key, env_value) - return env_value unless exclude_raw_post_parameters? - return PARAM_FILTER_REPLACEMENT if (env_key =~ /RAW_POST_DATA/i) - return @controller.__send__(:filter_parameters, {env_key => env_value}).values[0] - end -end diff --git a/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb b/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb deleted file mode 100644 index dd47637..0000000 --- a/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test_helper' -require 'exception_notifier_helper' - -class ExceptionNotifierHelperTest < Test::Unit::TestCase - - class ExceptionNotifierHelperIncludeTarget - include ExceptionNotifierHelper - end - - def setup - @helper = ExceptionNotifierHelperIncludeTarget.new - end - - # No controller - - def test_should_not_exclude_raw_post_parameters_if_no_controller - assert !@helper.exclude_raw_post_parameters? - end - - # Controller, no filtering - - class ControllerWithoutFilterParameters; end - - def test_should_not_filter_env_values_for_raw_post_data_keys_if_controller_can_not_filter_parameters - stub_controller(ControllerWithoutFilterParameters.new) - assert @helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret") - end - def test_should_not_exclude_raw_post_parameters_if_controller_can_not_filter_parameters - stub_controller(ControllerWithoutFilterParameters.new) - assert !@helper.exclude_raw_post_parameters? - end - def test_should_return_params_if_controller_can_not_filter_parameters - stub_controller(ControllerWithoutFilterParameters.new) - assert_equal :params, @helper.filter_sensitive_post_data_parameters(:params) - end - - # Controller with filtering - - class ControllerWithFilterParameters - def filter_parameters(params); :filtered end - end - - def test_should_filter_env_values_for_raw_post_data_keys_if_controller_can_filter_parameters - stub_controller(ControllerWithFilterParameters.new) - assert !@helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret") - assert @helper.filter_sensitive_post_data_from_env("SOME_OTHER_KEY", "secret").include?("secret") - end - def test_should_exclude_raw_post_parameters_if_controller_can_filter_parameters - stub_controller(ControllerWithFilterParameters.new) - assert @helper.exclude_raw_post_parameters? - end - def test_should_delegate_param_filtering_to_controller_if_controller_can_filter_parameters - stub_controller(ControllerWithFilterParameters.new) - assert_equal :filtered, @helper.filter_sensitive_post_data_parameters(:params) - end - - private - def stub_controller(controller) - @helper.instance_variable_set(:@controller, controller) - end -end \ No newline at end of file diff --git a/vendor/plugins/exception_notification/test/test_helper.rb b/vendor/plugins/exception_notification/test/test_helper.rb deleted file mode 100644 index bbe6fc5..0000000 --- a/vendor/plugins/exception_notification/test/test_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test/unit' -require 'rubygems' -require 'active_support' - -$:.unshift File.join(File.dirname(__FILE__), '../lib') - -RAILS_ROOT = '.' unless defined?(RAILS_ROOT) diff --git a/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml deleted file mode 100644 index 7d13ba0..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%= @backtrace.join "\n" %> diff --git a/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml deleted file mode 100644 index 42dd803..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +++ /dev/null @@ -1,7 +0,0 @@ -<% max = @request.env.keys.max { |a,b| a.length <=> b.length } -%> -<% @request.env.keys.sort.each do |key| -%> -* <%= "%-*s: %s" % [max.length, key, filter_sensitive_post_data_from_env(key, @request.env[key].to_s.strip)] %> -<% end -%> - -* Process: <%= $$ %> -* Server : <%= `hostname -s`.chomp %> diff --git a/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml deleted file mode 100644 index e817847..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +++ /dev/null @@ -1,16 +0,0 @@ -<% if show_attributes -%> -[attributes] -<% attrs = inspect_model.attributes -%> -<% max = attrs.keys.max { |a,b| a.length <=> b.length } -%> -<% attrs.keys.sort.each do |attr| -%> -* <%= "%*-s: %s" % [max.length, attr, object_to_yaml(attrs[attr]).gsub(/\n/, "\n ").strip] %> -<% end -%> -<% end -%> - -<% if show_instance_variables -%> -[instance variables] -<% inspect_model.instance_variables.sort.each do |variable| -%> -<%- next if variable == "@attributes" -%> -* <%= variable %>: <%= inspect_value(inspect_model.instance_variable_get(variable)) %> -<% end -%> -<% end -%> diff --git a/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml deleted file mode 100644 index 2542309..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +++ /dev/null @@ -1,4 +0,0 @@ -* URL : <%= @request.protocol %><%= @host %><%= @request.request_uri %> -* IP address: <%= @request.env["HTTP_X_FORWARDED_FOR"] || @request.env["REMOTE_ADDR"] %> -* Parameters: <%= filter_sensitive_post_data_parameters(@request.parameters).inspect %> -* Rails root: <%= @rails_root %> diff --git a/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml deleted file mode 100644 index 283c862..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +++ /dev/null @@ -1,2 +0,0 @@ -* session id: <%= @request.session.instance_variable_get(:@session_id).inspect %> -* data: <%= PP.pp(@request.session.instance_variable_get(:@data),"").gsub(/\n/, "\n ").strip %> diff --git a/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml deleted file mode 100644 index 1ed5a3f..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -------------------------------- -<%= title.to_s.humanize %>: -------------------------------- diff --git a/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml b/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml deleted file mode 100644 index ec30c4a..0000000 --- a/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -A <%= @exception.class %> occurred in <%= @controller.controller_name %>#<%= @controller.action_name %>: - - <%= @exception.message %> - <%= @backtrace.first %> - -<%= @sections.map { |section| render_section(section) }.join %> diff --git a/vendor/plugins/globalize2/LICENSE b/vendor/plugins/globalize2/LICENSE deleted file mode 100644 index 94a6b81..0000000 --- a/vendor/plugins/globalize2/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2008, 2009 Joshua Harvey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/vendor/plugins/globalize2/README.textile b/vendor/plugins/globalize2/README.textile deleted file mode 100644 index 7155a7c..0000000 --- a/vendor/plugins/globalize2/README.textile +++ /dev/null @@ -1,65 +0,0 @@ -h1. Globalize2 - -Globalize2 is the successor of Globalize for Rails. - -It is compatible with and builds on the new "I18n api in Ruby on Rails":http://guides.rubyonrails.org/i18n.html. and adds model translations to ActiveRecord. - -Globalize2 is much more lightweight and compatible than its predecessor was. Model translations in Globalize2 use default ActiveRecord features and do not limit any ActiveRecord functionality any more. - -h2. Requirements - -ActiveRecord -I18n - -(or Rails > 2.2) - -h2. Installation - -To install Globalize2 with its default setup just use: - -

-script/plugin install git://github.com/joshmh/globalize2.git
-
- -h2. Model translations - -Model translations allow you to translate your models' attribute values. E.g. - -

-class Post < ActiveRecord::Base
-  translates :title, :text
-end
-
- -Allows you to values for the attributes :title and :text per locale: - -

-I18n.locale = :en
-post.title # => Globalize2 rocks!
-
-I18n.locale = :he
-post.title # => גלובאלייז2 שולט!
-
- -In order to make this work, you'll need to add the appropriate translation tables. Globalize2 comes with a handy helper method to help you do this. It's called @create_translation_table!@. Here's an example: - -

-class CreatePosts < ActiveRecord::Migration
-  def self.up
-    create_table :posts do |t|
-      t.timestamps
-    end
-    Post.create_translation_table! :title => :string, :text => :text
-  end
-  def self.down
-    drop_table :posts
-    Post.drop_translation_table!
-  end
-end
-
- -Note that the ActiveRecord model @Post@ must already exist and have a @translates@ directive listing the translated fields. - -h2. Migration from Globalize - -See this script by Tomasz Stachewicz: http://gist.github.com/120867 diff --git a/vendor/plugins/globalize2/Rakefile b/vendor/plugins/globalize2/Rakefile deleted file mode 100644 index ee80713..0000000 --- a/vendor/plugins/globalize2/Rakefile +++ /dev/null @@ -1,39 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the globalize2 plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the globalize2 plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Globalize2' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -begin - require 'jeweler' - Jeweler::Tasks.new do |s| - s.name = "globalize2" - s.summary = "Rails I18n: de-facto standard library for ActiveRecord data translation" - s.description = "Rails I18n: de-facto standard library for ActiveRecord data translation" - s.email = "joshmh@gmail.com" - s.homepage = "http://github.com/joshmh/globalize2" - # s.rubyforge_project = '' - s.authors = ["Sven Fuchs, Joshua Harvey, Clemens Kofler"] - # s.add_development_dependency '' - end - Jeweler::GemcutterTasks.new -rescue LoadError - puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" -end diff --git a/vendor/plugins/globalize2/VERSION b/vendor/plugins/globalize2/VERSION deleted file mode 100644 index 0ea3a94..0000000 --- a/vendor/plugins/globalize2/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.0 diff --git a/vendor/plugins/globalize2/generators/db_backend.rb b/vendor/plugins/globalize2/generators/db_backend.rb deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/plugins/globalize2/generators/templates/db_backend_migration.rb b/vendor/plugins/globalize2/generators/templates/db_backend_migration.rb deleted file mode 100644 index 0f02611..0000000 --- a/vendor/plugins/globalize2/generators/templates/db_backend_migration.rb +++ /dev/null @@ -1,25 +0,0 @@ -class ActsAsTaggableMigration < ActiveRecord::Migration - def self.up - create_table :globalize_translations do |t| - t.string :locale, :null => false - t.string :key, :null => false - t.string :translation - t.timestamps - end - -# TODO: FINISH DOING MIGRATION -- stopped in the middle - - create_table :globalize_translations_map do |t| - t.string :key, :null => false - t.integer :translation_id, :null => false - end - - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type] - end - - def self.down - drop_table :globalize_translations - drop_table :tags - end -end diff --git a/vendor/plugins/globalize2/globalize2.gemspec b/vendor/plugins/globalize2/globalize2.gemspec deleted file mode 100644 index 6ad93d3..0000000 --- a/vendor/plugins/globalize2/globalize2.gemspec +++ /dev/null @@ -1,82 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{globalize2} - s.version = "0.2.0" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Sven Fuchs, Joshua Harvey, Clemens Kofler"] - s.date = %q{2009-12-25} - s.description = %q{Rails I18n: de-facto standard library for ActiveRecord data translation} - s.email = %q{joshmh@gmail.com} - s.extra_rdoc_files = [ - "LICENSE", - "README.textile" - ] - s.files = [ - ".gitignore", - "LICENSE", - "README.textile", - "Rakefile", - "VERSION", - "generators/db_backend.rb", - "generators/templates/db_backend_migration.rb", - "globalize2.gemspec", - "init.rb", - "lib/globalize.rb", - "lib/globalize/active_record.rb", - "lib/globalize/active_record/adapter.rb", - "lib/globalize/active_record/attributes.rb", - "lib/globalize/active_record/migration.rb", - "lib/i18n/missing_translations_log_handler.rb", - "lib/i18n/missing_translations_raise_handler.rb", - "notes.textile", - "test/active_record/fallbacks_test.rb", - "test/active_record/migration_test.rb", - "test/active_record/sti_translated_test.rb", - "test/active_record/translates_test.rb", - "test/active_record/translation_class_test.rb", - "test/active_record/validation_tests.rb", - "test/active_record_test.rb", - "test/all.rb", - "test/data/models.rb", - "test/data/no_globalize_schema.rb", - "test/data/schema.rb", - "test/i18n/missing_translations_test.rb", - "test/test_helper.rb" - ] - s.homepage = %q{http://github.com/joshmh/globalize2} - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.5} - s.summary = %q{Rails I18n: de-facto standard library for ActiveRecord data translation} - s.test_files = [ - "test/active_record/fallbacks_test.rb", - "test/active_record/migration_test.rb", - "test/active_record/sti_translated_test.rb", - "test/active_record/translates_test.rb", - "test/active_record/translation_class_test.rb", - "test/active_record/validation_tests.rb", - "test/active_record_test.rb", - "test/all.rb", - "test/data/models.rb", - "test/data/no_globalize_schema.rb", - "test/data/schema.rb", - "test/i18n/missing_translations_test.rb", - "test/test_helper.rb" - ] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - else - end - else - end -end - diff --git a/vendor/plugins/globalize2/init.rb b/vendor/plugins/globalize2/init.rb deleted file mode 100644 index a408925..0000000 --- a/vendor/plugins/globalize2/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'globalize' diff --git a/vendor/plugins/globalize2/lib/globalize.rb b/vendor/plugins/globalize2/lib/globalize.rb deleted file mode 100644 index 67c1878..0000000 --- a/vendor/plugins/globalize2/lib/globalize.rb +++ /dev/null @@ -1,15 +0,0 @@ -module Globalize - autoload :ActiveRecord, 'globalize/active_record' - - class << self - def fallbacks? - I18n.respond_to?(:fallbacks) - end - - def fallbacks(locale) - fallbacks? ? I18n.fallbacks[locale] : [locale.to_sym] - end - end -end - -ActiveRecord::Base.send(:include, Globalize::ActiveRecord) diff --git a/vendor/plugins/globalize2/lib/globalize/active_record.rb b/vendor/plugins/globalize2/lib/globalize/active_record.rb deleted file mode 100644 index d2a843f..0000000 --- a/vendor/plugins/globalize2/lib/globalize/active_record.rb +++ /dev/null @@ -1,194 +0,0 @@ -module Globalize - class MigrationError < StandardError; end - class MigrationMissingTranslatedField < MigrationError; end - class BadMigrationFieldType < MigrationError; end - - module ActiveRecord - autoload :Adapter, 'globalize/active_record/adapter' - autoload :Attributes, 'globalize/active_record/attributes' - autoload :Migration, 'globalize/active_record/migration' - - def self.included(base) - base.extend ActMacro - end - - class << self - def build_translation_class(target, options) - options[:table_name] ||= "#{target.table_name.singularize}_translations" - - klass = target.const_defined?(:Translation) ? - target.const_get(:Translation) : - target.const_set(:Translation, Class.new(::ActiveRecord::Base)) - - klass.class_eval do - set_table_name(options[:table_name]) - belongs_to target.name.underscore.gsub('/', '_') - def locale; read_attribute(:locale).to_sym; end - def locale=(locale); write_attribute(:locale, locale.to_s); end - end - - klass - end - end - - module ActMacro - def locale - (defined?(@@locale) && @@locale) - end - - def locale=(locale) - @@locale = locale - end - - def translates(*attr_names) - return if translates? - options = attr_names.extract_options! - - class_inheritable_accessor :translation_class, :translated_attribute_names - self.translation_class = ActiveRecord.build_translation_class(self, options) - self.translated_attribute_names = attr_names.map(&:to_sym) - - include InstanceMethods - extend ClassMethods, Migration - - after_save :save_translations! - has_many :translations, :class_name => translation_class.name, - :foreign_key => class_name.foreign_key, - :dependent => :delete_all, - :extend => HasManyExtensions - - named_scope :with_translations, lambda { |locale| - conditions = required_attributes.map do |attribute| - "#{quoted_translation_table_name}.#{attribute} IS NOT NULL" - end - conditions << "#{quoted_translation_table_name}.locale = ?" - { :include => :translations, :conditions => [conditions.join(' AND '), locale] } - } - - attr_names.each { |attr_name| translated_attr_accessor(attr_name) } - end - - def translates? - included_modules.include?(InstanceMethods) - end - end - - module HasManyExtensions - def by_locale(locale) - first(:conditions => { :locale => locale.to_s }) - end - - def by_locales(locales) - all(:conditions => { :locale => locales.map(&:to_s) }) - end - end - - module ClassMethods - delegate :set_translation_table_name, :to => :translation_class - - def with_locale(locale) - previous_locale, self.locale = self.locale, locale - result = yield - self.locale = previous_locale - result - end - - def translation_table_name - translation_class.table_name - end - - def quoted_translation_table_name - translation_class.quoted_table_name - end - - def required_attributes - validations = reflect_on_all_validations.select do |validation| - validation.macro == :validates_presence_of - end.map(&:name) - end - - def respond_to?(method, *args, &block) - method.to_s =~ /^find_by_(\w+)$/ && translated_attribute_names.include?($1.to_sym) || super - end - - def method_missing(method, *args) - if method.to_s =~ /^find_by_(\w+)$/ && translated_attribute_names.include?($1.to_sym) - find_first_by_translated_attr_and_locales($1, args.first) - else - super - end - end - - protected - - def find_first_by_translated_attr_and_locales(name, value) - query = "#{translated_attr_name(name)} = ? AND #{translated_attr_name('locale')} IN (?)" - locales = Globalize.fallbacks(locale || I18n.locale).map(&:to_s) - find(:first, :joins => :translations, :conditions => [query, value, locales]) - end - - def translated_attr_accessor(name) - define_method "#{name}=", lambda { |value| - globalize.write(self.class.locale || I18n.locale, name, value) - self[name] = value - } - define_method name, lambda { |*args| - globalize.fetch(args.first || self.class.locale || I18n.locale, name) - } - alias_method "#{name}_before_type_cast", name - end - - def translated_attr_name(name) - "#{translation_class.table_name}.#{name}" - end - end - - module InstanceMethods - def globalize - @globalize ||= Adapter.new self - end - - def attributes=(attributes, *args) - if attributes.respond_to?(:delete) && locale = attributes.delete(:locale) - self.class.with_locale(locale) { super } - else - super - end - end - - def available_locales - translations.scoped(:select => 'DISTINCT locale').map(&:locale) - end - - def translated_locales - translations.map(&:locale) - end - - def translated_attributes - translated_attribute_names.inject({}) do |attributes, name| - attributes.merge(name => send(name)) - end - end - - def set_translations(options) - options.keys.each do |locale| - translation = translations.find_by_locale(locale.to_s) || - translations.build(:locale => locale.to_s) - translation.update_attributes!(options[locale]) - end - end - - def reload(options = nil) - translated_attribute_names.each { |name| @attributes.delete(name.to_s) } - globalize.reset - super(options) - end - - protected - - def save_translations! - globalize.save_translations! - end - end - end -end diff --git a/vendor/plugins/globalize2/lib/globalize/active_record/adapter.rb b/vendor/plugins/globalize2/lib/globalize/active_record/adapter.rb deleted file mode 100644 index 12f89ec..0000000 --- a/vendor/plugins/globalize2/lib/globalize/active_record/adapter.rb +++ /dev/null @@ -1,80 +0,0 @@ -module Globalize - module ActiveRecord - class Adapter - # The cache caches attributes that already were looked up for read access. - # The stash keeps track of new or changed values that need to be saved. - attr_reader :record, :cache, :stash - - def initialize(record) - @record = record - @cache = Attributes.new - @stash = Attributes.new - end - - def fetch(locale, attr_name) - cache.contains?(locale, attr_name) ? - cache.read(locale, attr_name) : - cache.write(locale, attr_name, fetch_attribute(locale, attr_name)) - end - - def write(locale, attr_name, value) - stash.write(locale, attr_name, value) - cache.write(locale, attr_name, value) - end - - def save_translations! - stash.each do |locale, attrs| - translation = record.translations.find_or_initialize_by_locale(locale.to_s) - attrs.each { |attr_name, value| translation[attr_name] = value } - translation.save! - end - stash.clear - end - - def reset - cache.clear - # stash.clear - end - - protected - - def fetch_translation(locale) - locale = locale.to_sym - record.translations.loaded? ? record.translations.detect { |t| t.locale == locale } : - record.translations.by_locale(locale) - end - - def fetch_translations(locale) - # only query if not already included with :include => translations - record.translations.loaded? ? record.translations : - record.translations.by_locales(Globalize.fallbacks(locale)) - end - - def fetch_attribute(locale, attr_name) - translations = fetch_translations(locale) - value, requested_locale = nil, locale - - Globalize.fallbacks(locale).each do |fallback| - translation = translations.detect { |t| t.locale == fallback } - value = translation && translation.send(attr_name) - locale = fallback && break if value - end - - set_metadata(value, :locale => locale, :requested_locale => requested_locale) - value - end - - def set_metadata(object, metadata) - if object.respond_to?(:translation_metadata) - object.translation_metadata.merge!(meta_data) - end - end - - def translation_metadata_accessor(object) - return if obj.respond_to?(:translation_metadata) - class << object; attr_accessor :translation_metadata end - object.translation_metadata ||= {} - end - end - end -end diff --git a/vendor/plugins/globalize2/lib/globalize/active_record/attributes.rb b/vendor/plugins/globalize2/lib/globalize/active_record/attributes.rb deleted file mode 100644 index 7bd923c..0000000 --- a/vendor/plugins/globalize2/lib/globalize/active_record/attributes.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Helper class for storing values per locale. Used by Globalize::Adapter -# to stash and cache attribute values. -module Globalize - module ActiveRecord - class Attributes < Hash - def [](locale) - locale = locale.to_sym - self[locale] = {} unless has_key?(locale) - self.fetch(locale) - end - - def contains?(locale, attr_name) - self[locale].has_key?(attr_name) - end - - def read(locale, attr_name) - self[locale][attr_name] - end - - def write(locale, attr_name, value) - self[locale][attr_name] = value - end - end - end -end diff --git a/vendor/plugins/globalize2/lib/globalize/active_record/migration.rb b/vendor/plugins/globalize2/lib/globalize/active_record/migration.rb deleted file mode 100644 index ebff3b6..0000000 --- a/vendor/plugins/globalize2/lib/globalize/active_record/migration.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Globalize - module ActiveRecord - module Migration - def create_translation_table!(fields) - translated_attribute_names.each do |f| - raise MigrationMissingTranslatedField, "Missing translated field #{f}" unless fields[f] - end - - fields.each do |name, type| - if translated_attribute_names.include?(name) && ![:string, :text].include?(type) - raise BadMigrationFieldType, "Bad field type for #{name}, should be :string or :text" - end - end - - self.connection.create_table(translation_table_name) do |t| - t.references self.table_name.singularize - t.string :locale - fields.each do |name, type| - t.column name, type - end - t.timestamps - end - - self.connection.add_index(translation_table_name, "#{self.table_name.singularize}_id", :name => translation_index_name) - end - - def translation_index_name - require 'digest/sha1' - # FIXME what's the max size of an index name? - index_name = "index_#{translation_table_name}_on_#{self.table_name.singularize}_id" - index_name.size < 50 ? index_name : "index_#{Digest::SHA1.hexdigest(index_name)}" - end - - def drop_translation_table! - self.connection.remove_index(translation_table_name, :name => translation_index_name) rescue nil - self.connection.drop_table(translation_table_name) - end - end - end -end diff --git a/vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb b/vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb deleted file mode 100644 index 24c1089..0000000 --- a/vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb +++ /dev/null @@ -1,41 +0,0 @@ -# A simple exception handler that behaves like the default exception handler -# but additionally logs missing translations to a given log. -# -# Useful for identifying missing translations during testing. -# -# E.g. -# -# require 'globalize/i18n/missing_translations_log_handler' -# I18n.missing_translations_logger = RAILS_DEFAULT_LOGGER -# I18n.exception_handler = :missing_translations_log_handler -# -# To set up a different log file: -# -# logger = Logger.new("#{RAILS_ROOT}/log/missing_translations.log") -# I18n.missing_translations_logger = logger - -module I18n - @@missing_translations_logger = nil - - class << self - def missing_translations_logger - @@missing_translations_logger ||= begin - require 'logger' unless defined?(Logger) - Logger.new(STDOUT) - end - end - - def missing_translations_logger=(logger) - @@missing_translations_logger = logger - end - - def missing_translations_log_handler(exception, locale, key, options) - if MissingTranslationData === exception - missing_translations_logger.warn(exception.message) - return exception.message - else - raise exception - end - end - end -end diff --git a/vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb b/vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb deleted file mode 100644 index 18237b1..0000000 --- a/vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb +++ /dev/null @@ -1,25 +0,0 @@ -# A simple exception handler that behaves like the default exception handler -# but also raises on missing translations. -# -# Useful for identifying missing translations during testing. -# -# E.g. -# -# require 'globalize/i18n/missing_translations_raise_handler' -# I18n.exception_handler = :missing_translations_raise_handler -module I18n - class << self - def missing_translations_raise_handler(exception, locale, key, options) - raise exception - end - end -end - -I18n.exception_handler = :missing_translations_raise_handler - -ActionView::Helpers::TranslationHelper.module_eval do - def translate(key, options = {}) - I18n.translate(key, options) - end - alias :t :translate -end diff --git a/vendor/plugins/globalize2/test/active_record/fallbacks_test.rb b/vendor/plugins/globalize2/test/active_record/fallbacks_test.rb deleted file mode 100644 index 449ec8b..0000000 --- a/vendor/plugins/globalize2/test/active_record/fallbacks_test.rb +++ /dev/null @@ -1,102 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require File.expand_path(File.dirname(__FILE__) + '/../data/models') - -if I18n.respond_to?(:fallbacks) - class TranslatedTest < ActiveSupport::TestCase - def setup - I18n.locale = :'en-US' - I18n.fallbacks.clear - reset_db! - ActiveRecord::Base.locale = nil - end - - def teardown - I18n.fallbacks.clear - end - - test "keeping one field in new locale when other field is changed" do - I18n.fallbacks.map 'de-DE' => [ 'en-US' ] - post = Post.create :subject => 'foo' - I18n.locale = 'de-DE' - post.content = 'bar' - assert_equal 'foo', post.subject - end - - test "modifying non-required field in a new locale" do - I18n.fallbacks.map 'de-DE' => [ 'en-US' ] - post = Post.create :subject => 'foo' - I18n.locale = 'de-DE' - post.content = 'bar' - assert post.save - end - - test "resolves a simple fallback" do - I18n.locale = 'de-DE' - post = Post.create :subject => 'foo' - I18n.locale = 'de' - post.subject = 'baz' - post.content = 'bar' - post.save - I18n.locale = 'de-DE' - assert_equal 'foo', post.subject - assert_equal 'bar', post.content - end - - test "resolves a simple fallback without reloading" do - I18n.locale = 'de-DE' - post = Post.new :subject => 'foo' - I18n.locale = 'de' - post.subject = 'baz' - post.content = 'bar' - I18n.locale = 'de-DE' - assert_equal 'foo', post.subject - assert_equal 'bar', post.content - end - - test "resolves a complex fallback without reloading" do - I18n.fallbacks.map 'de' => %w(en he) - I18n.locale = 'de' - post = Post.new - I18n.locale = 'en' - post.subject = 'foo' - I18n.locale = 'he' - post.subject = 'baz' - post.content = 'bar' - I18n.locale = 'de' - assert_equal 'foo', post.subject - assert_equal 'bar', post.content - end - - test 'fallbacks with lots of locale switching' do - I18n.fallbacks.map :'de-DE' => [ :'en-US' ] - post = Post.create :subject => 'foo' - - I18n.locale = :'de-DE' - assert_equal 'foo', post.subject - - I18n.locale = :'en-US' - post.update_attribute :subject, 'bar' - - I18n.locale = :'de-DE' - assert_equal 'bar', post.subject - end - - test 'fallbacks with lots of locale switching' do - I18n.fallbacks.map :'de-DE' => [ :'en-US' ] - child = Child.create :content => 'foo' - - I18n.locale = :'de-DE' - assert_equal 'foo', child.content - - I18n.locale = :'en-US' - child.update_attribute :content, 'bar' - - I18n.locale = :'de-DE' - assert_equal 'bar', child.content - end - end -end - -# TODO should validate_presence_of take fallbacks into account? maybe we need -# an extra validation call, or more options for validate_presence_of. - diff --git a/vendor/plugins/globalize2/test/active_record/migration_test.rb b/vendor/plugins/globalize2/test/active_record/migration_test.rb deleted file mode 100644 index 359d811..0000000 --- a/vendor/plugins/globalize2/test/active_record/migration_test.rb +++ /dev/null @@ -1,118 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require File.expand_path(File.dirname(__FILE__) + '/../data/models') - -class MigrationTest < ActiveSupport::TestCase - def setup - reset_db! - Post.drop_translation_table! - end - - test 'globalize table added' do - assert !Post.connection.table_exists?(:post_translations) - assert !Post.connection.index_exists?(:post_translations, :post_id) - - Post.create_translation_table!(:subject => :string, :content => :text) - assert Post.connection.table_exists?(:post_translations) - assert Post.connection.index_exists?(:post_translations, :post_id) - - columns = Post.connection.columns(:post_translations) - assert locale = columns.detect { |c| c.name == 'locale' } - assert_equal :string, locale.type - assert subject = columns.detect { |c| c.name == 'subject' } - assert_equal :string, subject.type - assert content = columns.detect { |c| c.name == 'content' } - assert_equal :text, content.type - assert post_id = columns.detect { |c| c.name == 'post_id' } - assert_equal :integer, post_id.type - assert created_at = columns.detect { |c| c.name == 'created_at' } - assert_equal :datetime, created_at.type - assert updated_at = columns.detect { |c| c.name == 'updated_at' } - assert_equal :datetime, updated_at.type - end - - test 'globalize table dropped' do - assert !Post.connection.table_exists?( :post_translations ) - assert !Post.connection.index_exists?( :post_translations, :post_id ) - Post.create_translation_table! :subject => :string, :content => :text - assert Post.connection.table_exists?( :post_translations ) - assert Post.connection.index_exists?( :post_translations, :post_id ) - Post.drop_translation_table! - assert !Post.connection.table_exists?( :post_translations ) - assert !Post.connection.index_exists?( :post_translations, :post_id ) - end - - test 'exception on missing field inputs' do - assert_raise Globalize::MigrationMissingTranslatedField do - Post.create_translation_table! :content => :text - end - end - - test 'exception on bad input type' do - assert_raise Globalize::BadMigrationFieldType do - Post.create_translation_table! :subject => :string, :content => :integer - end - end - - test "exception on bad input type isn't raised for untranslated fields" do - assert_nothing_raised do - Post.create_translation_table! :subject => :string, :content => :string, :views_count => :integer - end - end - - test 'create_translation_table! should not be called on non-translated models' do - assert_raise NoMethodError do - Blog.create_translation_table! :name => :string - end - end - - test 'drop_translation_table! should not be called on non-translated models' do - assert_raise NoMethodError do - Blog.drop_translation_table! - end - end - - test "translation_index_name returns a readable index name when it's not longer than 50 characters" do - assert_equal 'index_post_translations_on_post_id', Post.send(:translation_index_name) - end - - test "translation_index_name returns a hashed index name when it's longer than 50 characters" do - class UltraLongModelNameWithoutProper < ActiveRecord::Base - translates :foo - end - name = UltraLongModelNameWithoutProper.send(:translation_index_name) - assert_match /^index_[a-z0-9]{40}$/, name - end - - test 'globalize table added when table has long name' do - UltraLongModelNameWithoutProper.create_translation_table!( - :subject => :string, :content => :text - ) - - assert UltraLongModelNameWithoutProper.connection.table_exists?( - :ultra_long_model_name_without_proper_translations - ) - assert UltraLongModelNameWithoutProper.connection.index_exists?( - :ultra_long_model_name_without_proper_translations, - :name => UltraLongModelNameWithoutProper.send( - :translation_index_name - ) - ) - end - - test 'globalize table dropped when table has long name' do - UltraLongModelNameWithoutProper.drop_translation_table! - UltraLongModelNameWithoutProper.create_translation_table!( - :subject => :string, :content => :text - ) - UltraLongModelNameWithoutProper.drop_translation_table! - - assert !UltraLongModelNameWithoutProper.connection.table_exists?( - :ultra_long_model_name_without_proper_translations - ) - assert !UltraLongModelNameWithoutProper.connection.index_exists?( - :ultra_long_model_name_without_proper_translations, - :ultra_long_model_name_without_proper_id - ) - end - -end diff --git a/vendor/plugins/globalize2/test/active_record/sti_translated_test.rb b/vendor/plugins/globalize2/test/active_record/sti_translated_test.rb deleted file mode 100644 index f529b8d..0000000 --- a/vendor/plugins/globalize2/test/active_record/sti_translated_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require File.expand_path(File.dirname(__FILE__) + '/../data/models') - -class StiTranslatedTest < ActiveSupport::TestCase - def setup - I18n.locale = :'en-US' - reset_db! - end - - test "works with simple dynamic finders" do - foo = Child.create :content => 'foo' - Child.create :content => 'bar' - child = Child.find_by_content('foo') - assert_equal foo, child - end - - test 'change attribute on globalized model' do - child = Child.create :content => 'foo' - assert_equal [], child.changed - child.content = 'bar' - assert_equal [ 'content' ], child.changed - child.content = 'baz' - assert_member 'content', child.changed - end - - test 'change attribute on globalized model after locale switching' do - child = Child.create :content => 'foo' - assert_equal [], child.changed - child.content = 'bar' - I18n.locale = :de - assert_equal [ 'content' ], child.changed - end - - test "saves all locales, even after locale switching" do - child = Child.new :content => 'foo' - I18n.locale = 'de-DE' - child.content = 'bar' - I18n.locale = 'he-IL' - child.content = 'baz' - child.save - I18n.locale = 'en-US' - child = Child.first - assert_equal 'foo', child.content - I18n.locale = 'de-DE' - assert_equal 'bar', child.content - I18n.locale = 'he-IL' - assert_equal 'baz', child.content - end -end diff --git a/vendor/plugins/globalize2/test/active_record/translates_test.rb b/vendor/plugins/globalize2/test/active_record/translates_test.rb deleted file mode 100644 index 4207bc4..0000000 --- a/vendor/plugins/globalize2/test/active_record/translates_test.rb +++ /dev/null @@ -1,87 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require File.expand_path(File.dirname(__FILE__) + '/../data/models') - -class TranslatesTest < ActiveSupport::TestCase - def setup - I18n.locale = nil - ActiveRecord::Base.locale = nil - reset_db! - end - - test 'defines a :locale accessors on ActiveRecord::Base' do - ActiveRecord::Base.locale = :de - assert_equal :de, ActiveRecord::Base.locale - end - - test 'the :locale reader on ActiveRecord::Base does not default to I18n.locale (anymore)' do - I18n.locale = :en - assert_nil ActiveRecord::Base.locale - end - - test 'ActiveRecord::Base.with_locale temporarily sets the given locale and yields the block' do - I18n.locale = :en - post = Post.with_locale(:de) do - Post.create!(:subject => 'Titel', :content => 'Inhalt') - end - assert_nil Post.locale - assert_equal :en, I18n.locale - - I18n.locale = :de - assert_equal 'Titel', post.subject - end - - test 'translation_class returns the Translation class' do - assert_equal Post::Translation, Post.translation_class - end - - test 'defines a has_many association on the model class' do - assert_has_many Post, :translations - end - - test 'defines a scope for retrieving locales that have complete translations' do - post = Post.create!(:subject => 'subject', :content => 'content') - assert_equal [:en], post.translated_locales - end - - test 'sets the given attributes to translated_attribute_names' do - assert_equal [:subject, :content], Post.translated_attribute_names - end - - test 'defines accessors for the translated attributes' do - post = Post.new - assert post.respond_to?(:subject) - assert post.respond_to?(:subject=) - end - - test 'attribute reader without arguments will use the current locale on ActiveRecord::Base or I18n' do - post = Post.with_locale(:de) do - Post.create!(:subject => 'Titel', :content => 'Inhalt') - end - I18n.locale = :de - assert_equal 'Titel', post.subject - - I18n.locale = :en - ActiveRecord::Base.locale = :de - assert_equal 'Titel', post.subject - end - - test 'attribute reader when passed a locale will use the given locale' do - post = Post.with_locale(:de) do - Post.create!(:subject => 'Titel', :content => 'Inhalt') - end - assert_equal 'Titel', post.subject(:de) - end - - test 'attribute reader will use the current locale on ActiveRecord::Base or I18n' do - post = Post.with_locale(:en) do - Post.create!(:subject => 'title', :content => 'content') - end - I18n.locale = :de - post.subject = 'Titel' - assert_equal 'Titel', post.subject - - ActiveRecord::Base.locale = :en - post.subject = 'title' - assert_equal 'title', post.subject - end -end diff --git a/vendor/plugins/globalize2/test/active_record/translation_class_test.rb b/vendor/plugins/globalize2/test/active_record/translation_class_test.rb deleted file mode 100644 index 1628416..0000000 --- a/vendor/plugins/globalize2/test/active_record/translation_class_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require File.expand_path(File.dirname(__FILE__) + '/../data/models') - -class TranlationClassTest < ActiveSupport::TestCase - def setup - reset_db! - end - - test 'defines a Translation class nested in the model class' do - assert Post.const_defined?(:Translation) - end - - test 'defines a belongs_to association' do - assert_belongs_to Post::Translation, :post - end - - test 'defines a reader for :locale that always returns a symbol' do - post = Post::Translation.new - post.write_attribute('locale', 'de') - assert_equal :de, post.locale - end - - test 'defines a write for :locale that always writes a string' do - post = Post::Translation.new - post.locale = :de - assert_equal 'de', post.read_attribute('locale') - end -end - - diff --git a/vendor/plugins/globalize2/test/active_record/validation_tests.rb b/vendor/plugins/globalize2/test/active_record/validation_tests.rb deleted file mode 100644 index 0148fa3..0000000 --- a/vendor/plugins/globalize2/test/active_record/validation_tests.rb +++ /dev/null @@ -1,75 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -require File.expand_path(File.dirname(__FILE__) + '/../data/models') - -class ValidationTest < ActiveSupport::TestCase - def setup - reset_db! - end - - def teardown - Validatee.instance_variable_set(:@validate_callbacks, CallbackChain.new) - end - - test "validates_presence_of" do - Validatee.class_eval { validates_presence_of :string } - assert !Validatee.new.valid? - assert Validatee.new(:string => 'foo').valid? - end - - test "validates_confirmation_of" do - Validatee.class_eval { validates_confirmation_of :string } - assert !Validatee.new(:string => 'foo', :string_confirmation => 'bar').valid? - assert Validatee.new(:string => 'foo', :string_confirmation => 'foo').valid? - end - - test "validates_acceptance_of" do - Validatee.class_eval { validates_acceptance_of :string, :accept => '1' } - assert !Validatee.new(:string => '0').valid? - assert Validatee.new(:string => '1').valid? - end - - test "validates_length_of (:is)" do - Validatee.class_eval { validates_length_of :string, :is => 1 } - assert !Validatee.new(:string => 'aa').valid? - assert Validatee.new(:string => 'a').valid? - end - - test "validates_format_of" do - Validatee.class_eval { validates_format_of :string, :with => /^\d+$/ } - assert !Validatee.new(:string => 'a').valid? - assert Validatee.new(:string => '1').valid? - end - - test "validates_inclusion_of" do - Validatee.class_eval { validates_inclusion_of :string, :in => %(a) } - assert !Validatee.new(:string => 'b').valid? - assert Validatee.new(:string => 'a').valid? - end - - test "validates_exclusion_of" do - Validatee.class_eval { validates_exclusion_of :string, :in => %(b) } - assert !Validatee.new(:string => 'b').valid? - assert Validatee.new(:string => 'a').valid? - end - - test "validates_numericality_of" do - Validatee.class_eval { validates_numericality_of :string } - assert !Validatee.new(:string => 'a').valid? - assert Validatee.new(:string => '1').valid? - end - - # This doesn't pass and Rails' validates_uniqueness_of implementation doesn't - # seem to be extensible easily. One can work around that by either defining - # a custom validation on the Validatee model itself, or by using validates_uniqueness_of - # on Validatee::Translation. - # - # test "validates_uniqueness_of" do - # Validatee.class_eval { validates_uniqueness_of :string } - # Validatee.create!(:string => 'a') - # assert !Validatee.new(:string => 'a').valid? - # assert Validatee.new(:string => 'b').valid? - # end - - # test "validates_associated" do - # end -end \ No newline at end of file diff --git a/vendor/plugins/globalize2/test/active_record_test.rb b/vendor/plugins/globalize2/test/active_record_test.rb deleted file mode 100644 index e6b54f0..0000000 --- a/vendor/plugins/globalize2/test/active_record_test.rb +++ /dev/null @@ -1,442 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/test_helper') -require File.expand_path(File.dirname(__FILE__) + '/data/models') - -# Higher level tests. - -class ActiveRecordTest < ActiveSupport::TestCase - def setup - I18n.locale = :en - reset_db! - ActiveRecord::Base.locale = nil - end - - def assert_translated(locale, record, names, expected) - I18n.locale = locale - assert_equal Array(expected), Array(names).map { |name| record.send(name) } - end - - test "a translated record has translations" do - assert_equal [], Post.new.translations - end - - test "saves a translated version of the record for each locale" do - post = Post.create(:subject => 'title') - I18n.locale = :de - post.update_attributes(:subject => 'Titel') - - assert_equal 2, post.translations.size - assert_equal %w(de en), post.translations.map(&:locale).map(&:to_s).sort - assert_equal %w(Titel title), post.translations.map(&:subject).sort - end - - test "a translated record has German translations" do - I18n.locale = :de - post = Post.create(:subject => 'foo') - assert_equal 1, post.translations.size - assert_equal [:de], post.translations.map { |t| t.locale } - end - - test "modifiying translated fields while switching locales" do - post = Post.create(:subject => 'title', :content => 'content') - assert_equal %w(title content), [post.subject, post.content] - - I18n.locale = :de - post.subject, post.content = 'Titel', 'Inhalt' - - assert_translated(:de, post, [:subject, :content], %w(Titel Inhalt)) - assert_translated(:en, post, [:subject, :content], %w(title content)) - assert_translated(:de, post, [:subject, :content], %w(Titel Inhalt)) - - post.save - post.reload - - assert_translated(:en, post, [:subject, :content], %w(title content)) - assert_translated(:de, post, [:subject, :content], %w(Titel Inhalt)) - end - - test "attribute writers do return their argument" do - value = Post.new.subject = 'foo' - assert_equal 'foo', value - end - - test "update_attribute succeeds with valid values" do - post = Post.create(:subject => 'foo', :content => 'bar') - post.update_attribute(:subject, 'baz') - assert_equal 'baz', Post.first.subject - end - - test "update_attributes fails with invalid values" do - post = Post.create(:subject => 'foo', :content => 'bar') - assert !post.update_attributes(:subject => '') - assert_nil post.reload.attributes['subject'] - assert_equal 'foo', post.subject - end - - test "passing the locale to create uses the given locale" do - post = Post.create(:subject => 'Titel', :content => 'Inhalt', :locale => :de) - assert_equal :en, I18n.locale - assert_nil ActiveRecord::Base.locale - - I18n.locale = :de - assert_equal 'Titel', post.subject - end - - test "passing the locale to attributes= uses the given locale" do - post = Post.create(:subject => 'title', :content => 'content') - post.update_attributes(:subject => 'Titel', :content => 'Inhalt', :locale => :de) - post.reload - - assert_equal :en, I18n.locale - assert_nil ActiveRecord::Base.locale - - assert_equal 'title', post.subject - I18n.locale = :de - assert_equal 'Titel', post.subject - end - - test 'reload works' do - post = Post.create(:subject => 'foo', :content => 'bar') - post.subject = 'baz' - post.reload - assert_equal 'foo', post.subject - end - - test "returns nil if no translations are found (unsaved record)" do - post = Post.new(:subject => 'foo') - assert_equal 'foo', post.subject - assert_nil post.content - end - - test "returns nil if no translations are found (saved record)" do - post = Post.create(:subject => 'foo') - post.reload - assert_equal 'foo', post.subject - assert_nil post.content - end - - test "finds a German post" do - post = Post.create(:subject => 'foo (en)', :content => 'bar') - I18n.locale = :de - post = Post.first - post.subject = 'baz (de)' - post.save - assert_equal 'baz (de)', Post.first.subject - I18n.locale = :en - assert_equal 'foo (en)', Post.first.subject - end - - test "saves an English post and loads correctly" do - post = Post.create(:subject => 'foo', :content => 'bar') - assert post.save - post = Post.first - assert_equal 'foo', post.subject - assert_equal 'bar', post.content - end - - test "returns the value for the correct locale, after locale switching" do - post = Post.create(:subject => 'foo') - I18n.locale = :de - post.subject = 'bar' - post.save - I18n.locale = :en - post = Post.first - assert_equal 'foo', post.subject - I18n.locale = :de - assert_equal 'bar', post.subject - end - - test "returns the value for the correct locale, after locale switching, without saving" do - post = Post.create :subject => 'foo' - I18n.locale = :de - post.subject = 'bar' - I18n.locale = :en - assert_equal 'foo', post.subject - I18n.locale = :de - assert_equal 'bar', post.subject - end - - test "saves all locales, even after locale switching" do - post = Post.new :subject => 'foo' - I18n.locale = :de - post.subject = 'bar' - I18n.locale = :he - post.subject = 'baz' - post.save - I18n.locale = :en - post = Post.first - assert_equal 'foo', post.subject - I18n.locale = :de - assert_equal 'bar', post.subject - I18n.locale = :he - assert_equal 'baz', post.subject - end - - test "works with associations" do - blog = Blog.create - post1 = blog.posts.create(:subject => 'foo') - - I18n.locale = :de - post2 = blog.posts.create(:subject => 'bar') - assert_equal 2, blog.posts.size - - I18n.locale = :en - assert_equal 'foo', blog.posts.first.subject - assert_nil blog.posts.last.subject - - I18n.locale = :de - assert_equal 'bar', blog.posts.last.subject - end - - test "works with simple dynamic finders" do - foo = Post.create(:subject => 'foo') - Post.create(:subject => 'bar') - post = Post.find_by_subject('foo') - assert_equal foo, post - end - - test 'change attribute on globalized model' do - post = Post.create(:subject => 'foo', :content => 'bar') - assert_equal [], post.changed - post.subject = 'baz' - assert_equal ['subject'], post.changed - post.content = 'quux' - assert_member 'subject', post.changed - assert_member 'content', post.changed - end - - test 'change attribute on globalized model after locale switching' do - post = Post.create(:subject => 'foo', :content => 'bar') - assert_equal [], post.changed - post.subject = 'baz' - I18n.locale = :de - assert_equal ['subject'], post.changed - end - - test 'complex writing and stashing' do - post = Post.create(:subject => 'foo', :content => 'bar') - post.subject = nil - assert_nil post.subject - assert !post.valid? - post.subject = 'stashed_foo' - assert_equal 'stashed_foo', post.subject - end - - test 'translated class locale setting' do - assert ActiveRecord::Base.respond_to?(:locale) - assert_equal :en, I18n.locale - assert_nil ActiveRecord::Base.locale - - I18n.locale = :de - assert_equal :de, I18n.locale - assert_nil ActiveRecord::Base.locale - - ActiveRecord::Base.locale = :es - assert_equal :de, I18n.locale - assert_equal :es, ActiveRecord::Base.locale - - I18n.locale = :fr - assert_equal :fr, I18n.locale - assert_equal :es, ActiveRecord::Base.locale - end - - test "untranslated class responds to locale" do - assert Blog.respond_to?(:locale) - end - - test "to ensure locales in different classes are the same" do - ActiveRecord::Base.locale = :de - assert_equal :de, ActiveRecord::Base.locale - assert_equal :de, Parent.locale - - Parent.locale = :es - assert_equal :es, ActiveRecord::Base.locale - assert_equal :es, Parent.locale - end - - test "attribute saving goes by content locale and not global locale" do - ActiveRecord::Base.locale = :de - assert_equal :en, I18n.locale - Post.create :subject => 'foo' - assert_equal :de, Post.first.translations.first.locale - end - - test "attribute loading goes by content locale and not global locale" do - post = Post.create(:subject => 'foo') - assert_nil ActiveRecord::Base.locale - - ActiveRecord::Base.locale = :de - assert_equal :en, I18n.locale - post.update_attribute(:subject, 'foo [de]') - assert_equal 'foo [de]', Post.first.subject - - ActiveRecord::Base.locale = :en - assert_equal 'foo', Post.first.subject - end - - test "access content locale before setting" do - Globalize::ActiveRecord::ActMacro.class_eval "remove_class_variable(:@@locale)" - assert_nothing_raised { ActiveRecord::Base.locale } - end - - test "available_locales" do - Post.locale = :de - post = Post.create(:subject => 'foo') - Post.locale = :es - post.update_attribute(:subject, 'bar') - Post.locale = :fr - post.update_attribute(:subject, 'baz') - assert_equal [:de, :es, :fr], post.available_locales - assert_equal [:de, :es, :fr], Post.first.available_locales - end - - test "saving record correctly after post-save reload" do - reloader = Reloader.create(:content => 'foo') - assert_equal 'foo', reloader.content - end - - test "including translations" do - I18n.locale = :de - Post.create(:subject => "Foo1", :content => "Bar1") - Post.create(:subject => "Foo2", :content => "Bar2") - - class << Post - def translations_included - self.all(:include => :translations) - end - end - - default = Post.all.map { |x| [x.subject, x.content] } - with_include = Post.translations_included.map { |x| [x.subject, x.content] } - assert_equal default, with_include - end - - test "setting multiple translations at once with options hash" do - Post.locale = :de - post = Post.create(:subject => "foo1", :content => "foo1") - Post.locale = :en - post.update_attributes(:subject => "bar1", :content => "bar1") - - options = { :de => {:subject => "foo2", :content => "foo2"}, - :en => {:subject => "bar2", :content => "bar2"} } - post.set_translations options - post.reload - - assert ["bar2", "bar2"], [post.subject, post.content] - Post.locale = :de - assert ["foo2", "foo2"], [post.subject, post.content] - end - - test "setting only one translation with set_translations" do - Post.locale = :de - post = Post.create(:subject => "foo1", :content => "foo1") - Post.locale = :en - post.update_attributes(:subject => "bar1", :content => "bar1") - - options = { :en => { :subject => "bar2", :content => "bar2" } } - post.set_translations options - post.reload - - assert ["bar2", "bar2"], [post.subject, post.content] - Post.locale = :de - assert ["foo1", "foo1"], [post.subject, post.content] - end - - test "setting only selected attributes with set_translations" do - Post.locale = :de - post = Post.create(:subject => "foo1", :content => "foo1") - Post.locale = :en - post.update_attributes(:subject => "bar1", :content => "bar1") - - options = { :de => { :content => "foo2" }, :en => { :subject => "bar2" } } - post.set_translations options - post.reload - - assert ["bar2", "bar1"], [post.subject, post.content] - Post.locale = :de - assert ["foo1", "foo2"], [post.subject, post.content] - end - - test "setting invalid attributes raises ArgumentError" do - Post.locale = :de - post = Post.create(:subject => "foo1", :content => "foo1") - Post.locale = :en - post.update_attributes(:subject => "bar1", :content => "bar1") - - options = { :de => {:fake => "foo2"} } - exception = assert_raise(ActiveRecord::UnknownAttributeError) do - post.set_translations options - end - assert_equal "unknown attribute: fake", exception.message - end - - test "reload accepting find options" do - p = Post.create(:subject => "Foo", :content => "Bar") - assert p.reload(:readonly => true, :lock => true) - assert_raise(ArgumentError) { p.reload(:foo => :bar) } - end - - test "dependent destroy of translation" do - p = Post.create(:subject => "Foo", :content => "Bar") - assert_equal 1, PostTranslation.count - p.destroy - assert_equal 0, PostTranslation.count - end - - test "translating subclass of untranslated comment model" do - translated_comment = TranslatedComment.create(:post => @post) - assert_nothing_raised { translated_comment.translations } - end - - test "modifiying translated comments works as expected" do - I18n.locale = :en - translated_comment = TranslatedComment.create(:post => @post, :content => 'foo') - assert_equal 'foo', translated_comment.content - - I18n.locale = :de - translated_comment.content = 'bar' - assert translated_comment.save - assert_equal 'bar', translated_comment.content - - I18n.locale = :en - assert_equal 'foo', translated_comment.content - - assert_equal 2, translated_comment.translations.size - end - - test "can create a proxy class for a namespaced model" do - assert_nothing_raised do - module Foo - module Bar - class Baz < ActiveRecord::Base - translates :bumm - end - end - end - end - end - - test "attribute translated before type cast" do - Post.locale = :en - post = Post.create(:subject => 'foo', :content => 'bar') - Post.locale = :de - post.update_attribute(:subject, "German foo") - assert_equal 'German foo', post.subject_before_type_cast - Post.locale = :en - assert_equal 'foo', post.subject_before_type_cast - end - - test "don't override existing translation class" do - assert PostTranslation.new.respond_to?(:existing_method) - end - - test "has_many and named scopes work with globalize" do - blog = Blog.create - assert_nothing_raised { blog.posts.foobar } - end -end - -# TODO error checking for fields that exist in main table, don't exist in -# proxy table, aren't strings or text -# -# TODO allow finding by translated attributes in conditions? -# TODO generate advanced dynamic finders? diff --git a/vendor/plugins/globalize2/test/all.rb b/vendor/plugins/globalize2/test/all.rb deleted file mode 100644 index ff467a1..0000000 --- a/vendor/plugins/globalize2/test/all.rb +++ /dev/null @@ -1,2 +0,0 @@ -files = Dir[File.dirname(__FILE__) + '/**/*_test.rb'] -files.each { |file| require file } \ No newline at end of file diff --git a/vendor/plugins/globalize2/test/data/models.rb b/vendor/plugins/globalize2/test/data/models.rb deleted file mode 100644 index 553fca3..0000000 --- a/vendor/plugins/globalize2/test/data/models.rb +++ /dev/null @@ -1,51 +0,0 @@ -#require 'ruby2ruby' -#require 'parse_tree' -#require 'parse_tree_extensions' -#require 'pp' - -class PostTranslation < ActiveRecord::Base - def existing_method ; end -end - -class Post < ActiveRecord::Base - translates :subject, :content - validates_presence_of :subject - named_scope :foobar, :conditions => { :title => "foobar" } -end - -class Blog < ActiveRecord::Base - has_many :posts, :order => 'id ASC' -end - -class Parent < ActiveRecord::Base - translates :content -end - -class Child < Parent -end - -class Comment < ActiveRecord::Base - validates_presence_of :content - belongs_to :post -end - -class TranslatedComment < Comment - translates :content -end - -class UltraLongModelNameWithoutProper < ActiveRecord::Base - translates :subject, :content - validates_presence_of :subject -end - -class Reloader < Parent - after_create :do_reload - - def do_reload - reload - end -end - -class Validatee < ActiveRecord::Base - translates :string -end diff --git a/vendor/plugins/globalize2/test/data/no_globalize_schema.rb b/vendor/plugins/globalize2/test/data/no_globalize_schema.rb deleted file mode 100644 index 379455d..0000000 --- a/vendor/plugins/globalize2/test/data/no_globalize_schema.rb +++ /dev/null @@ -1,11 +0,0 @@ -# This schema creates tables without columns for the translated fields -ActiveRecord::Schema.define do - create_table :blogs, :force => true do |t| - t.string :name - end - - create_table :posts, :force => true do |t| - t.references :blog - end -end - diff --git a/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb b/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb deleted file mode 100644 index 5d0ecd6..0000000 --- a/vendor/plugins/globalize2/test/i18n/missing_translations_test.rb +++ /dev/null @@ -1,36 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'i18n/missing_translations_log_handler' - -class MissingTranslationsTest < ActiveSupport::TestCase - test "defines I18n.missing_translations_logger accessor" do - assert I18n.respond_to?(:missing_translations_logger) - end - - test "defines I18n.missing_translations_logger= writer" do - assert I18n.respond_to?(:missing_translations_logger=) - end -end - -class TestLogger < String - def warn(msg) self.concat msg; end -end - -class LogMissingTranslationsTest < ActiveSupport::TestCase - def setup - @locale, @key, @options = :en, :foo, {} - @exception = I18n::MissingTranslationData.new(@locale, @key, @options) - - @logger = TestLogger.new - I18n.missing_translations_logger = @logger - end - - test "still returns the exception message for MissingTranslationData exceptions" do - result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options) - assert_equal 'translation missing: en, foo', result - end - - test "logs the missing translation to I18n.missing_translations_logger" do - I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options) - assert_equal 'translation missing: en, foo', @logger - end -end diff --git a/vendor/plugins/globalize2/test/test_helper.rb b/vendor/plugins/globalize2/test/test_helper.rb deleted file mode 100644 index 195907d..0000000 --- a/vendor/plugins/globalize2/test/test_helper.rb +++ /dev/null @@ -1,76 +0,0 @@ -$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' ) - -require 'rubygems' -require 'test/unit' -require 'active_record' -require 'active_support' -require 'active_support/test_case' -require 'mocha' -require 'globalize' -require 'validation_reflection' - -config = { :adapter => 'sqlite3', :database => ':memory:' } -ActiveRecord::Base.establish_connection(config) - -class ActiveSupport::TestCase - def reset_db!(schema_path = nil) - schema_path ||= File.expand_path(File.dirname(__FILE__) + '/data/schema.rb') - ActiveRecord::Migration.verbose = false - ActiveRecord::Base.silence { load(schema_path) } - end - - def assert_member(item, array) - assert_block "Item #{item} is not in array #{array}" do - array.member?(item) - end - end - - def assert_belongs_to(model, associated) - assert model.reflect_on_all_associations(:belongs_to).detect { |association| - association.name.to_s == associated.to_s - } - end - - def assert_has_many(model, associated) - assert model.reflect_on_all_associations(:has_many).detect { |association| - association.name.to_s == associated.to_s - } - end -end - -module ActiveRecord - module ConnectionAdapters - class AbstractAdapter - def index_exists?(table_name, column_name) - indexes(table_name).any? { |index| index.name == index_name(table_name, column_name) } - end - end - end -end - -# module ActiveRecord -# class BaseWithoutTable < Base -# self.abstract_class = true -# -# def create_or_update -# errors.empty? -# end -# -# class << self -# def columns() -# @columns ||= [] -# end -# -# def column(name, sql_type = nil, default = nil, null = true) -# columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) -# reset_column_information -# end -# -# # Do not reset @columns -# def reset_column_information -# read_methods.each { |name| undef_method(name) } -# @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil -# end -# end -# end -# end \ No newline at end of file diff --git a/vendor/plugins/paperclip/LICENSE b/vendor/plugins/paperclip/LICENSE deleted file mode 100644 index 299b9ed..0000000 --- a/vendor/plugins/paperclip/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ - -LICENSE - -The MIT License - -Copyright (c) 2008 Jon Yurek and thoughtbot, inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - diff --git a/vendor/plugins/paperclip/README.rdoc b/vendor/plugins/paperclip/README.rdoc deleted file mode 100644 index 85fcf4b..0000000 --- a/vendor/plugins/paperclip/README.rdoc +++ /dev/null @@ -1,172 +0,0 @@ -=Paperclip - -Paperclip is intended as an easy file attachment library for ActiveRecord. The -intent behind it was to keep setup as easy as possible and to treat files as -much like other attributes as possible. This means they aren't saved to their -final locations on disk, nor are they deleted if set to nil, until -ActiveRecord::Base#save is called. It manages validations based on size and -presence, if required. It can transform its assigned image into thumbnails if -needed, and the prerequisites are as simple as installing ImageMagick (which, -for most modern Unix-based systems, is as easy as installing the right -packages). Attached files are saved to the filesystem and referenced in the -browser by an easily understandable specification, which has sensible and -useful defaults. - -See the documentation for +has_attached_file+ in Paperclip::ClassMethods for -more detailed options. - -==Quick Start - -In your model: - - class User < ActiveRecord::Base - has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" } - end - -In your migrations: - - class AddAvatarColumnsToUser < ActiveRecord::Migration - def self.up - add_column :users, :avatar_file_name, :string - add_column :users, :avatar_content_type, :string - add_column :users, :avatar_file_size, :integer - add_column :users, :avatar_updated_at, :datetime - end - - def self.down - remove_column :users, :avatar_file_name - remove_column :users, :avatar_content_type - remove_column :users, :avatar_file_size - remove_column :users, :avatar_updated_at - end - end - -In your edit and new views: - - <% form_for :user, @user, :url => user_path, :html => { :multipart => true } do |form| %> - <%= form.file_field :avatar %> - <% end %> - -In your controller: - - def create - @user = User.create( params[:user] ) - end - -In your show view: - - <%= image_tag @user.avatar.url %> - <%= image_tag @user.avatar.url(:medium) %> - <%= image_tag @user.avatar.url(:thumb) %> - -==Usage - -The basics of paperclip are quite simple: Declare that your model has an -attachment with the has_attached_file method, and give it a name. Paperclip -will wrap up up to four attributes (all prefixed with that attachment's name, -so you can have multiple attachments per model if you wish) and give the a -friendly front end. The attributes are _file_name, -_file_size, _content_type, and _updated_at. -Only _file_name is required for paperclip to operate. More -information about the options to has_attached_file is available in the -documentation of Paperclip::ClassMethods. - -Attachments can be validated with Paperclip's validation methods, -validates_attachment_presence, validates_attachment_content_type, and -validates_attachment_size. - -==Storage - -The files that are assigned as attachments are, by default, placed in the -directory specified by the :path option to has_attached_file. By default, this -location is -":rails_root/public/system/:attachment/:id/:style/:basename.:extension". This -location was chosen because on standard Capistrano deployments, the -public/system directory is symlinked to the app's shared directory, meaning it -will survive between deployments. For example, using that :path, you may have a -file at - - /data/myapp/releases/20081229172410/public/system/avatars/13/small/my_pic.png - -NOTE: This is a change from previous versions of Paperclip, but is overall a -safer choice for the defaul file store. - -You may also choose to store your files using Amazon's S3 service. You can find -more information about S3 storage at the description for -Paperclip::Storage::S3. - -Files on the local filesystem (and in the Rails app's public directory) will be -available to the internet at large. If you require access control, it's -possible to place your files in a different location. You will need to change -both the :path and :url options in order to make sure the files are unavailable -to the public. Both :path and :url allow the same set of interpolated -variables. - -==Post Processing - -Paperclip supports an extendible selection of post-processors. When you define -a set of styles for an attachment, by default it is expected that those -"styles" are actually "thumbnails". However, you can do more than just -thumbnail images. By defining a subclass of Paperclip::Processor, you can -perform any processing you want on the files that are attached. Any file in -your Rails app's lib/paperclip_processors directory is automatically loaded by -paperclip, allowing you to easily define custom processors. You can specify a -processor with the :processors option to has_attached_file: - - has_attached_file :scan, :styles => { :text => { :quality => :better } }, - :processors => [:ocr] - -This would load the hypothetical class Paperclip::Ocr, which would have the -hash "{ :quality => :better }" passed to it along with the uploaded file. For -more information about defining processors, see Paperclip::Processor. - -The default processor is Paperclip::Thumbnail. For backwards compatability -reasons, you can pass a single geometry string or an array containing a -geometry and a format, which the file will be converted to, like so: - - has_attached_file :avatar, :styles => { :thumb => ["32x32#", :png] } - -This will convert the "thumb" style to a 32x32 square in png format, regardless -of what was uploaded. If the format is not specified, it is kept the same (i.e. -jpgs will remain jpgs). - -Multiple processors can be specified, and they will be invoked in the order -they are defined in the :processors array. Each successive processor will -be given the result of the previous processor's execution. All processors will -receive the same parameters, which are what you define in the :styles hash. -For example, assuming we had this definition: - - has_attached_file :scan, :styles => { :text => { :quality => :better } }, - :processors => [:rotator, :ocr] - -then both the :rotator processor and the :ocr processor would receive the -options "{ :quality => :better }". This parameter may not mean anything to one -or more or the processors, and they are free to ignore it. - -==Events - -Before and after the Post Processing step, Paperclip calls back to the model -with a few callbacks, allowing the model to change or cancel the processing -step. The callbacks are "before_post_process" and "after_post_process" (which -are called before and after the processing of each attachment), and the -attachment-specific "before__post_process" and -"after__post_process". The callbacks are intended to be as close to -normal ActiveRecord callbacks as possible, so if you return false (specifically -- returning nil is not the same) in a before_ filter, the post processing step -will halt. Returning false in an after_ filter will not halt anything, but you -can access the model and the attachment if necessary. - -NOTE: Post processing will not even *start* if the attachment is not valid -according to the validations. Your callbacks (and processors) will only be -called with valid attachments. - -==Contributing - -If you'd like to contribute a feature or bugfix: Thanks! To make sure your -fix/feature has a high chance of being included, please read the following -guidelines: - -1. Ask on the mailing list, or post a ticket in Lighthouse. -2. Make sure there are tests! We will not accept any patch that is not tested. - It's a rare time when explicit tests aren't needed. If you have questions - about writing tests for paperclip, please ask the mailing list. diff --git a/vendor/plugins/paperclip/Rakefile b/vendor/plugins/paperclip/Rakefile deleted file mode 100644 index 91f1687..0000000 --- a/vendor/plugins/paperclip/Rakefile +++ /dev/null @@ -1,77 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') -require 'paperclip' - -desc 'Default: run unit tests.' -task :default => [:clean, :test] - -desc 'Test the paperclip plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' << 'profile' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Start an IRB session with all necessary files required.' -task :shell do |t| - chdir File.dirname(__FILE__) - exec 'irb -I lib/ -I lib/paperclip -r rubygems -r active_record -r tempfile -r init' -end - -desc 'Generate documentation for the paperclip plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'doc' - rdoc.title = 'Paperclip' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -desc 'Update documentation on website' -task :sync_docs => 'rdoc' do - `rsync -ave ssh doc/ dev@dev.thoughtbot.com:/home/dev/www/dev.thoughtbot.com/paperclip` -end - -desc 'Clean up files.' -task :clean do |t| - FileUtils.rm_rf "doc" - FileUtils.rm_rf "tmp" - FileUtils.rm_rf "pkg" - FileUtils.rm "test/debug.log" rescue nil - FileUtils.rm "test/paperclip.db" rescue nil -end - -spec = Gem::Specification.new do |s| - s.name = "paperclip" - s.version = Paperclip::VERSION - s.author = "Jon Yurek" - s.email = "jyurek@thoughtbot.com" - s.homepage = "http://www.thoughtbot.com/projects/paperclip" - s.platform = Gem::Platform::RUBY - s.summary = "File attachments as attributes for ActiveRecord" - s.files = FileList["README*", - "LICENSE", - "Rakefile", - "init.rb", - "{generators,lib,tasks,test,shoulda_macros}/**/*"].to_a - s.require_path = "lib" - s.test_files = FileList["test/**/test_*.rb"].to_a - s.rubyforge_project = "paperclip" - s.has_rdoc = true - s.extra_rdoc_files = FileList["README*"].to_a - s.rdoc_options << '--line-numbers' << '--inline-source' - s.requirements << "ImageMagick" - s.add_runtime_dependency 'right_aws' - s.add_development_dependency 'thoughtbot-shoulda' - s.add_development_dependency 'mocha' -end - -desc "Generate a gemspec file for GitHub" -task :gemspec do - File.open("#{spec.name}.gemspec", 'w') do |f| - f.write spec.to_ruby - end -end diff --git a/vendor/plugins/paperclip/generators/paperclip/USAGE b/vendor/plugins/paperclip/generators/paperclip/USAGE deleted file mode 100644 index 2d611d7..0000000 --- a/vendor/plugins/paperclip/generators/paperclip/USAGE +++ /dev/null @@ -1,5 +0,0 @@ -Usage: - - script/generate paperclip Class attachment1 (attachment2 ...) - -This will create a migration that will add the proper columns to your class's table. \ No newline at end of file diff --git a/vendor/plugins/paperclip/generators/paperclip/paperclip_generator.rb b/vendor/plugins/paperclip/generators/paperclip/paperclip_generator.rb deleted file mode 100644 index 77ee5a2..0000000 --- a/vendor/plugins/paperclip/generators/paperclip/paperclip_generator.rb +++ /dev/null @@ -1,27 +0,0 @@ -class PaperclipGenerator < Rails::Generator::NamedBase - attr_accessor :attachments, :migration_name - - def initialize(args, options = {}) - super - @class_name, @attachments = args[0], args[1..-1] - end - - def manifest - file_name = generate_file_name - @migration_name = file_name.camelize - record do |m| - m.migration_template "paperclip_migration.rb.erb", - File.join('db', 'migrate'), - :migration_file_name => file_name - end - end - - private - - def generate_file_name - names = attachments.map{|a| a.underscore } - names = names[0..-2] + ["and", names[-1]] if names.length > 1 - "add_attachments_#{names.join("_")}_to_#{@class_name.underscore}" - end - -end diff --git a/vendor/plugins/paperclip/generators/paperclip/templates/paperclip_migration.rb.erb b/vendor/plugins/paperclip/generators/paperclip/templates/paperclip_migration.rb.erb deleted file mode 100644 index eebb0e5..0000000 --- a/vendor/plugins/paperclip/generators/paperclip/templates/paperclip_migration.rb.erb +++ /dev/null @@ -1,19 +0,0 @@ -class <%= migration_name %> < ActiveRecord::Migration - def self.up -<% attachments.each do |attachment| -%> - add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string - add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string - add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer - add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime -<% end -%> - end - - def self.down -<% attachments.each do |attachment| -%> - remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name - remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type - remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size - remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at -<% end -%> - end -end diff --git a/vendor/plugins/paperclip/init.rb b/vendor/plugins/paperclip/init.rb deleted file mode 100644 index 5a07dda..0000000 --- a/vendor/plugins/paperclip/init.rb +++ /dev/null @@ -1 +0,0 @@ -require File.join(File.dirname(__FILE__), "lib", "paperclip") diff --git a/vendor/plugins/paperclip/lib/paperclip.rb b/vendor/plugins/paperclip/lib/paperclip.rb deleted file mode 100644 index 74c3d79..0000000 --- a/vendor/plugins/paperclip/lib/paperclip.rb +++ /dev/null @@ -1,318 +0,0 @@ -# Paperclip allows file attachments that are stored in the filesystem. All graphical -# transformations are done using the Graphics/ImageMagick command line utilities and -# are stored in Tempfiles until the record is saved. Paperclip does not require a -# separate model for storing the attachment's information, instead adding a few simple -# columns to your table. -# -# Author:: Jon Yurek -# Copyright:: Copyright (c) 2008 thoughtbot, inc. -# License:: MIT License (http://www.opensource.org/licenses/mit-license.php) -# -# Paperclip defines an attachment as any file, though it makes special considerations -# for image files. You can declare that a model has an attached file with the -# +has_attached_file+ method: -# -# class User < ActiveRecord::Base -# has_attached_file :avatar, :styles => { :thumb => "100x100" } -# end -# -# user = User.new -# user.avatar = params[:user][:avatar] -# user.avatar.url -# # => "/users/avatars/4/original_me.jpg" -# user.avatar.url(:thumb) -# # => "/users/avatars/4/thumb_me.jpg" -# -# See the +has_attached_file+ documentation for more details. - -require 'tempfile' -require 'paperclip/upfile' -require 'paperclip/iostream' -require 'paperclip/geometry' -require 'paperclip/processor' -require 'paperclip/thumbnail' -require 'paperclip/storage' -require 'paperclip/attachment' -if defined? RAILS_ROOT - Dir.glob(File.join(File.expand_path(RAILS_ROOT), "lib", "paperclip_processors", "*.rb")).each do |processor| - require processor - end -end - -# The base module that gets included in ActiveRecord::Base. See the -# documentation for Paperclip::ClassMethods for more useful information. -module Paperclip - - VERSION = "2.2.8" - - class << self - # Provides configurability to Paperclip. There are a number of options available, such as: - # * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of - # an uploaded image. Defaults to true. - # * log: Logs progress to the Rails log. Uses ActiveRecord's logger, so honors - # log levels, etc. Defaults to true. - # * command_path: Defines the path at which to find the command line - # programs if they are not visible to Rails the system's search path. Defaults to - # nil, which uses the first executable found in the user's search path. - # * image_magick_path: Deprecated alias of command_path. - def options - @options ||= { - :whiny_thumbnails => true, - :image_magick_path => nil, - :command_path => nil, - :log => true, - :swallow_stderr => true - } - end - - def path_for_command command #:nodoc: - if options[:image_magick_path] - warn("[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead") - end - path = [options[:command_path] || options[:image_magick_path], command].compact - File.join(*path) - end - - def interpolates key, &block - Paperclip::Attachment.interpolations[key] = block - end - - # The run method takes a command to execute and a string of parameters - # that get passed to it. The command is prefixed with the :command_path - # option from Paperclip.options. If you have many commands to run and - # they are in different paths, the suggested course of action is to - # symlink them so they are all in the same directory. - # - # If the command returns with a result code that is not one of the - # expected_outcodes, a PaperclipCommandLineError will be raised. Generally - # a code of 0 is expected, but a list of codes may be passed if necessary. - def run cmd, params = "", expected_outcodes = 0 - command = %Q<#{%Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")}> - command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr] - output = `#{command}` - unless [expected_outcodes].flatten.include?($?.exitstatus) - raise PaperclipCommandLineError, "Error while running #{cmd}" - end - output - end - - def bit_bucket #:nodoc: - File.exists?("/dev/null") ? "/dev/null" : "NUL" - end - - def included base #:nodoc: - base.extend ClassMethods - unless base.respond_to?(:define_callbacks) - base.send(:include, Paperclip::CallbackCompatability) - end - end - - def processor name #:nodoc: - name = name.to_s.camelize - processor = Paperclip.const_get(name) - unless processor.ancestors.include?(Paperclip::Processor) - raise PaperclipError.new("Processor #{name} was not found") - end - processor - end - end - - class PaperclipError < StandardError #:nodoc: - end - - class PaperclipCommandLineError < StandardError #:nodoc: - end - - class NotIdentifiedByImageMagickError < PaperclipError #:nodoc: - end - - module ClassMethods - # +has_attached_file+ gives the class it is called on an attribute that maps to a file. This - # is typically a file stored somewhere on the filesystem and has been uploaded by a user. - # The attribute returns a Paperclip::Attachment object which handles the management of - # that file. The intent is to make the attachment as much like a normal attribute. The - # thumbnails will be created when the new file is assigned, but they will *not* be saved - # until +save+ is called on the record. Likewise, if the attribute is set to +nil+ is - # called on it, the attachment will *not* be deleted until +save+ is called. See the - # Paperclip::Attachment documentation for more specifics. There are a number of options - # you can set to change the behavior of a Paperclip attachment: - # * +url+: The full URL of where the attachment is publically accessible. This can just - # as easily point to a directory served directly through Apache as it can to an action - # that can control permissions. You can specify the full domain and path, but usually - # just an absolute path is sufficient. The leading slash *must* be included manually for - # absolute paths. The default value is - # "/system/:attachment/:id/:style/:basename.:extension". See - # Paperclip::Attachment#interpolate for more information on variable interpolaton. - # :url => "/:class/:attachment/:id/:style_:basename.:extension" - # :url => "http://some.other.host/stuff/:class/:id_:extension" - # * +default_url+: The URL that will be returned if there is no attachment assigned. - # This field is interpolated just as the url is. The default value is - # "/:attachment/:style/missing.png" - # has_attached_file :avatar, :default_url => "/images/default_:style_avatar.png" - # User.new.avatar_url(:small) # => "/images/default_small_avatar.png" - # * +styles+: A hash of thumbnail styles and their geometries. You can find more about - # geometry strings at the ImageMagick website - # (http://www.imagemagick.org/script/command-line-options.php#resize). Paperclip - # also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally - # inside the dimensions and then crop the rest off (weighted at the center). The - # default value is to generate no thumbnails. - # * +default_style+: The thumbnail style that will be used by default URLs. - # Defaults to +original+. - # has_attached_file :avatar, :styles => { :normal => "100x100#" }, - # :default_style => :normal - # user.avatar.url # => "/avatars/23/normal_me.png" - # * +whiny_thumbnails+: Will raise an error if Paperclip cannot post_process an uploaded file due - # to a command line error. This will override the global setting for this attachment. - # Defaults to true. - # * +convert_options+: When creating thumbnails, use this free-form options - # field to pass in various convert command options. Typical options are "-strip" to - # remove all Exif data from the image (save space for thumbnails and avatars) or - # "-depth 8" to specify the bit depth of the resulting conversion. See ImageMagick - # convert documentation for more options: (http://www.imagemagick.org/script/convert.php) - # Note that this option takes a hash of options, each of which correspond to the style - # of thumbnail being generated. You can also specify :all as a key, which will apply - # to all of the thumbnails being generated. If you specify options for the :original, - # it would be best if you did not specify destructive options, as the intent of keeping - # the original around is to regenerate all the thumbnails when requirements change. - # has_attached_file :avatar, :styles => { :large => "300x300", :negative => "100x100" } - # :convert_options => { - # :all => "-strip", - # :negative => "-negate" - # } - # * +storage+: Chooses the storage backend where the files will be stored. The current - # choices are :filesystem and :s3. The default is :filesystem. Make sure you read the - # documentation for Paperclip::Storage::Filesystem and Paperclip::Storage::S3 - # for backend-specific options. - def has_attached_file name, options = {} - include InstanceMethods - - write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil? - attachment_definitions[name] = {:validations => {}}.merge(options) - - after_save :save_attached_files - before_destroy :destroy_attached_files - - define_callbacks :before_post_process, :after_post_process - define_callbacks :"before_#{name}_post_process", :"after_#{name}_post_process" - - define_method name do |*args| - a = attachment_for(name) - (args.length > 0) ? a.to_s(args.first) : a - end - - define_method "#{name}=" do |file| - attachment_for(name).assign(file) - end - - define_method "#{name}?" do - attachment_for(name).file? - end - - validates_each(name) do |record, attr, value| - attachment = record.attachment_for(name) - attachment.send(:flush_errors) unless attachment.valid? - end - end - - # Places ActiveRecord-style validations on the size of the file assigned. The - # possible options are: - # * +in+: a Range of bytes (i.e. +1..1.megabyte+), - # * +less_than+: equivalent to :in => 0..options[:less_than] - # * +greater_than+: equivalent to :in => options[:greater_than]..Infinity - # * +message+: error message to display, use :min and :max as replacements - def validates_attachment_size name, options = {} - min = options[:greater_than] || (options[:in] && options[:in].first) || 0 - max = options[:less_than] || (options[:in] && options[:in].last) || (1.0/0) - range = (min..max) - message = options[:message] || "file size must be between :min and :max bytes." - - attachment_definitions[name][:validations][:size] = lambda do |attachment, instance| - if attachment.file? && !range.include?(attachment.size.to_i) - message.gsub(/:min/, min.to_s).gsub(/:max/, max.to_s) - end - end - end - - # Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true. - def validates_attachment_thumbnails name, options = {} - attachment_definitions[name][:whiny_thumbnails] = true - end - - # Places ActiveRecord-style validations on the presence of a file. - def validates_attachment_presence name, options = {} - message = options[:message] || "must be set." - attachment_definitions[name][:validations][:presence] = lambda do |attachment, instance| - message unless attachment.file? - end - end - - # Places ActiveRecord-style validations on the content type of the file - # assigned. The possible options are: - # * +content_type+: Allowed content types. Can be a single content type - # or an array. Each type can be a String or a Regexp. It should be - # noted that Internet Explorer upload files with content_types that you - # may not expect. For example, JPEG images are given image/pjpeg and - # PNGs are image/x-png, so keep that in mind when determining how you - # match. Allows all by default. - # * +message+: The message to display when the uploaded file has an invalid - # content type. - # NOTE: If you do not specify an [attachment]_content_type field on your - # model, content_type validation will work _ONLY upon assignment_ and - # re-validation after the instance has been reloaded will always succeed. - def validates_attachment_content_type name, options = {} - attachment_definitions[name][:validations][:content_type] = lambda do |attachment, instance| - valid_types = [options[:content_type]].flatten - - unless attachment.original_filename.blank? - unless valid_types.blank? - content_type = attachment.instance_read(:content_type) - unless valid_types.any?{|t| content_type.nil? || t === content_type } - options[:message] || "is not one of the allowed file types." - end - end - end - end - end - - # Returns the attachment definitions defined by each call to - # has_attached_file. - def attachment_definitions - read_inheritable_attribute(:attachment_definitions) - end - end - - module InstanceMethods #:nodoc: - def attachment_for name - @_paperclip_attachments ||= {} - @_paperclip_attachments[name] ||= Attachment.new(name, self, self.class.attachment_definitions[name]) - end - - def each_attachment - self.class.attachment_definitions.each do |name, definition| - yield(name, attachment_for(name)) - end - end - - def save_attached_files - logger.info("[paperclip] Saving attachments.") - each_attachment do |name, attachment| - attachment.send(:save) - end - end - - def destroy_attached_files - logger.info("[paperclip] Deleting attachments.") - each_attachment do |name, attachment| - attachment.send(:queue_existing_for_delete) - attachment.send(:flush_deletes) - end - end - end - -end - -# Set it all up. -if Object.const_defined?("ActiveRecord") - ActiveRecord::Base.send(:include, Paperclip) - File.send(:include, Paperclip::Upfile) -end diff --git a/vendor/plugins/paperclip/lib/paperclip/attachment.rb b/vendor/plugins/paperclip/lib/paperclip/attachment.rb deleted file mode 100644 index 897c67e..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/attachment.rb +++ /dev/null @@ -1,403 +0,0 @@ -module Paperclip - # The Attachment class manages the files for a given attachment. It saves - # when the model saves, deletes when the model is destroyed, and processes - # the file upon assignment. - class Attachment - - def self.default_options - @default_options ||= { - :url => "/system/:attachment/:id/:style/:basename.:extension", - :path => ":rails_root/public/system/:attachment/:id/:style/:basename.:extension", - :styles => {}, - :default_url => "/:attachment/:style/missing.png", - :default_style => :original, - :validations => {}, - :storage => :filesystem - } - end - - attr_reader :name, :instance, :styles, :default_style, :convert_options, :queued_for_write - - # Creates an Attachment object. +name+ is the name of the attachment, - # +instance+ is the ActiveRecord object instance it's attached to, and - # +options+ is the same as the hash passed to +has_attached_file+. - def initialize name, instance, options = {} - @name = name - @instance = instance - - options = self.class.default_options.merge(options) - - @url = options[:url] - @url = @url.call(self) if @url.is_a?(Proc) - @path = options[:path] - @path = @path.call(self) if @path.is_a?(Proc) - @styles = options[:styles] - @styles = @styles.call(self) if @styles.is_a?(Proc) - @default_url = options[:default_url] - @validations = options[:validations] - @default_style = options[:default_style] - @storage = options[:storage] - @whiny = options[:whiny_thumbnails] - @convert_options = options[:convert_options] || {} - @processors = options[:processors] || [:thumbnail] - @options = options - @queued_for_delete = [] - @queued_for_write = {} - @errors = {} - @validation_errors = nil - @dirty = false - - normalize_style_definition - initialize_storage - end - - # What gets called when you call instance.attachment = File. It clears - # errors, assigns attributes, processes the file, and runs validations. It - # also queues up the previous file for deletion, to be flushed away on - # #save of its host. In addition to form uploads, you can also assign - # another Paperclip attachment: - # new_user.avatar = old_user.avatar - # If the file that is assigned is not valid, the processing (i.e. - # thumbnailing, etc) will NOT be run. - def assign uploaded_file - %w(file_name).each do |field| - unless @instance.class.column_names.include?("#{name}_#{field}") - raise PaperclipError.new("#{@instance.class} model does not have required column '#{name}_#{field}'") - end - end - - if uploaded_file.is_a?(Paperclip::Attachment) - uploaded_file = uploaded_file.to_file(:original) - close_uploaded_file = uploaded_file.respond_to?(:close) - end - - return nil unless valid_assignment?(uploaded_file) - - uploaded_file.binmode if uploaded_file.respond_to? :binmode - self.clear - - return nil if uploaded_file.nil? - - @queued_for_write[:original] = uploaded_file.to_tempfile - instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_')) - instance_write(:content_type, uploaded_file.content_type.to_s.strip) - instance_write(:file_size, uploaded_file.size.to_i) - instance_write(:updated_at, Time.now) - - @dirty = true - - post_process if valid? - - # Reset the file size if the original file was reprocessed. - instance_write(:file_size, @queued_for_write[:original].size.to_i) - ensure - uploaded_file.close if close_uploaded_file - validate - end - - # Returns the public URL of the attachment, with a given style. Note that - # this does not necessarily need to point to a file that your web server - # can access and can point to an action in your app, if you need fine - # grained security. This is not recommended if you don't need the - # security, however, for performance reasons. set - # include_updated_timestamp to false if you want to stop the attachment - # update time appended to the url - def url style = default_style, include_updated_timestamp = true - url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style) - include_updated_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url - end - - # Returns the path of the attachment as defined by the :path option. If the - # file is stored in the filesystem the path refers to the path of the file - # on disk. If the file is stored in S3, the path is the "key" part of the - # URL, and the :bucket option refers to the S3 bucket. - def path style = nil #:nodoc: - original_filename.nil? ? nil : interpolate(@path, style) - end - - # Alias to +url+ - def to_s style = nil - url(style) - end - - # Returns true if there are no errors on this attachment. - def valid? - validate - errors.empty? - end - - # Returns an array containing the errors on this attachment. - def errors - @errors - end - - # Returns true if there are changes that need to be saved. - def dirty? - @dirty - end - - # Saves the file, if there are no errors. If there are, it flushes them to - # the instance's errors and returns false, cancelling the save. - def save - if valid? - flush_deletes - flush_writes - @dirty = false - true - else - flush_errors - false - end - end - - # Clears out the attachment. Has the same effect as previously assigning - # nil to the attachment. Does NOT save. If you wish to clear AND save, - # use #destroy. - def clear - queue_existing_for_delete - @errors = {} - @validation_errors = nil - end - - # Destroys the attachment. Has the same effect as previously assigning - # nil to the attachment *and saving*. This is permanent. If you wish to - # wipe out the existing attachment but not save, use #clear. - def destroy - clear - save - end - - # Returns the name of the file as originally assigned, and lives in the - # _file_name attribute of the model. - def original_filename - instance_read(:file_name) - end - - # Returns the size of the file as originally assigned, and lives in the - # _file_size attribute of the model. - def size - instance_read(:file_size) || (@queued_for_write[:original] && @queued_for_write[:original].size) - end - - # Returns the content_type of the file as originally assigned, and lives - # in the _content_type attribute of the model. - def content_type - instance_read(:content_type) - end - - # Returns the last modified time of the file as originally assigned, and - # lives in the _updated_at attribute of the model. - def updated_at - time = instance_read(:updated_at) - time && time.to_i - end - - # A hash of procs that are run during the interpolation of a path or url. - # A variable of the format :name will be replaced with the return value of - # the proc named ":name". Each lambda takes the attachment and the current - # style as arguments. This hash can be added to with your own proc if - # necessary. - def self.interpolations - @interpolations ||= { - :rails_root => lambda{|attachment,style| RAILS_ROOT }, - :rails_env => lambda{|attachment,style| RAILS_ENV }, - :class => lambda do |attachment,style| - attachment.instance.class.name.underscore.pluralize - end, - :basename => lambda do |attachment,style| - attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "") - end, - :extension => lambda do |attachment,style| - ((style = attachment.styles[style]) && style[:format]) || - File.extname(attachment.original_filename).gsub(/^\.+/, "") - end, - :id => lambda{|attachment,style| attachment.instance.id }, - :id_partition => lambda do |attachment, style| - ("%09d" % attachment.instance.id).scan(/\d{3}/).join("/") - end, - :attachment => lambda{|attachment,style| attachment.name.to_s.downcase.pluralize }, - :style => lambda{|attachment,style| style || attachment.default_style }, - } - end - - # This method really shouldn't be called that often. It's expected use is - # in the paperclip:refresh rake task and that's it. It will regenerate all - # thumbnails forcefully, by reobtaining the original file and going through - # the post-process again. - def reprocess! - new_original = Tempfile.new("paperclip-reprocess") - new_original.binmode - if old_original = to_file(:original) - new_original.write( old_original.read ) - new_original.rewind - - @queued_for_write = { :original => new_original } - post_process - - old_original.close if old_original.respond_to?(:close) - - save - else - true - end - end - - # Returns true if a file has been assigned. - def file? - !original_filename.blank? - end - - # Writes the attachment-specific attribute on the instance. For example, - # instance_write(:file_name, "me.jpg") will write "me.jpg" to the instance's - # "avatar_file_name" field (assuming the attachment is called avatar). - def instance_write(attr, value) - setter = :"#{name}_#{attr}=" - responds = instance.respond_to?(setter) - self.instance_variable_set("@_#{setter.to_s.chop}", value) - instance.send(setter, value) if responds || attr.to_s == "file_name" - end - - # Reads the attachment-specific attribute on the instance. See instance_write - # for more details. - def instance_read(attr) - getter = :"#{name}_#{attr}" - responds = instance.respond_to?(getter) - cached = self.instance_variable_get("@_#{getter}") - return cached if cached - instance.send(getter) if responds || attr.to_s == "file_name" - end - - private - - def logger #:nodoc: - instance.logger - end - - def log message #:nodoc: - logger.info("[paperclip] #{message}") if logging? - end - - def logging? #:nodoc: - Paperclip.options[:log] - end - - def valid_assignment? file #:nodoc: - file.nil? || (file.respond_to?(:original_filename) && file.respond_to?(:content_type)) - end - - def validate #:nodoc: - unless @validation_errors - @validation_errors = @validations.inject({}) do |errors, validation| - name, block = validation - errors[name] = block.call(self, instance) if block - errors - end - @validation_errors.reject!{|k,v| v == nil } - @errors.merge!(@validation_errors) - end - @validation_errors - end - - def normalize_style_definition #:nodoc: - @styles.each do |name, args| - unless args.is_a? Hash - dimensions, format = *args - @styles[name] = { - :processors => @processors, - :geometry => dimensions, - :format => format, - :whiny => @whiny, - :convert_options => extra_options_for(name) - } - else - @styles[name] = { - :processors => @processors, - :whiny => @whiny, - :convert_options => extra_options_for(name) - }.merge(@styles[name]) - end - end - end - - def solidify_style_definitions #:nodoc: - @styles.each do |name, args| - @styles[name][:geometry] = @styles[name][:geometry].call(instance) if @styles[name][:geometry].respond_to?(:call) - @styles[name][:processors] = @styles[name][:processors].call(instance) if @styles[name][:processors].respond_to?(:call) - end - end - - def initialize_storage #:nodoc: - @storage_module = Paperclip::Storage.const_get(@storage.to_s.capitalize) - self.extend(@storage_module) - end - - def extra_options_for(style) #:nodoc: - all_options = convert_options[:all] - all_options = all_options.call(instance) if all_options.respond_to?(:call) - style_options = convert_options[style] - style_options = style_options.call(instance) if style_options.respond_to?(:call) - - [ style_options, all_options ].compact.join(" ") - end - - def post_process #:nodoc: - return if @queued_for_write[:original].nil? - solidify_style_definitions - return if fire_events(:before) - post_process_styles - return if fire_events(:after) - end - - def fire_events(which) - return true if callback(:"#{which}_post_process") == false - return true if callback(:"#{which}_#{name}_post_process") == false - end - - def callback which #:nodoc: - instance.run_callbacks(which, @queued_for_write){|result, obj| result == false } - end - - def post_process_styles - @styles.each do |name, args| - begin - raise RuntimeError.new("Style #{name} has no processors defined.") if args[:processors].blank? - @queued_for_write[name] = args[:processors].inject(@queued_for_write[:original]) do |file, processor| - Paperclip.processor(processor).make(file, args, self) - end - rescue PaperclipError => e - log("An error was received while processing: #{e.inspect}") - (@errors[:processing] ||= []) << e.message if @whiny - end - end - end - - def interpolate pattern, style = default_style #:nodoc: - interpolations = self.class.interpolations.sort{|a,b| a.first.to_s <=> b.first.to_s } - interpolations.reverse.inject( pattern.dup ) do |result, interpolation| - tag, blk = interpolation - result.gsub(/:#{tag}/) do |match| - blk.call( self, style ) - end - end - end - - def queue_existing_for_delete #:nodoc: - return unless file? - @queued_for_delete += [:original, *@styles.keys].uniq.map do |style| - path(style) if exists?(style) - end.compact - instance_write(:file_name, nil) - instance_write(:content_type, nil) - instance_write(:file_size, nil) - instance_write(:updated_at, nil) - end - - def flush_errors #:nodoc: - @errors.each do |error, message| - [message].flatten.each {|m| instance.errors.add(name, m) } - end - end - - end -end - diff --git a/vendor/plugins/paperclip/lib/paperclip/callback_compatability.rb b/vendor/plugins/paperclip/lib/paperclip/callback_compatability.rb deleted file mode 100644 index 10b08fc..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/callback_compatability.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Paperclip - # This module is intended as a compatability shim for the differences in - # callbacks between Rails 2.0 and Rails 2.1. - module CallbackCompatability - def self.included(base) - base.extend(ClassMethods) - base.send(:include, InstanceMethods) - end - - module ClassMethods - # The implementation of this method is taken from the Rails 1.2.6 source, - # from rails/activerecord/lib/active_record/callbacks.rb, line 192. - def define_callbacks(*args) - args.each do |method| - self.class_eval <<-"end_eval" - def self.#{method}(*callbacks, &block) - callbacks << block if block_given? - write_inheritable_array(#{method.to_sym.inspect}, callbacks) - end - end_eval - end - end - end - - module InstanceMethods - # The callbacks in < 2.1 don't worry about the extra options or the - # block, so just run what we have available. - def run_callbacks(meth, opts = nil, &blk) - callback(meth) - end - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/geometry.rb b/vendor/plugins/paperclip/lib/paperclip/geometry.rb deleted file mode 100644 index 37ba706..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/geometry.rb +++ /dev/null @@ -1,116 +0,0 @@ -module Paperclip - - # Defines the geometry of an image. - class Geometry - attr_accessor :height, :width, :modifier - - # Gives a Geometry representing the given height and width - def initialize width = nil, height = nil, modifier = nil - @height = height.to_f - @width = width.to_f - @modifier = modifier - end - - # Uses ImageMagick to determing the dimensions of a file, passed in as either a - # File or path. - def self.from_file file - file = file.path if file.respond_to? "path" - geometry = begin - Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]]) - rescue PaperclipCommandLineError - "" - end - puts(geometry) - parse(geometry) || - raise(NotIdentifiedByImageMagickError.new("#{file} is not recognized by the 'identify' command.")) - end - - # Parses a "WxH" formatted string, where W is the width and H is the height. - def self.parse string - if match = (string && string.match(/\b(\d*)x?(\d*)\b([\>\<\#\@\%^!])?/)) - Geometry.new(*match[1,3]) - end - end - - # True if the dimensions represent a square - def square? - height == width - end - - # True if the dimensions represent a horizontal rectangle - def horizontal? - height < width - end - - # True if the dimensions represent a vertical rectangle - def vertical? - height > width - end - - # The aspect ratio of the dimensions. - def aspect - width / height - end - - # Returns the larger of the two dimensions - def larger - [height, width].max - end - - # Returns the smaller of the two dimensions - def smaller - [height, width].min - end - - # Returns the width and height in a format suitable to be passed to Geometry.parse - def to_s - s = "" - s << width.to_i.to_s if width > 0 - s << "x#{height.to_i}" if height > 0 - s << modifier.to_s - s - end - - # Same as to_s - def inspect - to_s - end - - # Returns the scaling and cropping geometries (in string-based ImageMagick format) - # neccessary to transform this Geometry into the Geometry given. If crop is true, - # then it is assumed the destination Geometry will be the exact final resolution. - # In this case, the source Geometry is scaled so that an image containing the - # destination Geometry would be completely filled by the source image, and any - # overhanging image would be cropped. Useful for square thumbnail images. The cropping - # is weighted at the center of the Geometry. - def transformation_to dst, crop = false - if crop - ratio = Geometry.new( dst.width / self.width, dst.height / self.height ) - scale_geometry, scale = scaling(dst, ratio) - crop_geometry = cropping(dst, ratio, scale) - else - scale_geometry = dst.to_s - end - - [ scale_geometry, crop_geometry ] - end - - private - - def scaling dst, ratio - if ratio.horizontal? || ratio.square? - [ "%dx" % dst.width, ratio.width ] - else - [ "x%d" % dst.height, ratio.height ] - end - end - - def cropping dst, ratio, scale - if ratio.horizontal? || ratio.square? - "%dx%d+%d+%d" % [ dst.width, dst.height, 0, (self.height * scale - dst.height) / 2 ] - else - "%dx%d+%d+%d" % [ dst.width, dst.height, (self.width * scale - dst.width) / 2, 0 ] - end - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/iostream.rb b/vendor/plugins/paperclip/lib/paperclip/iostream.rb deleted file mode 100644 index 74e2014..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/iostream.rb +++ /dev/null @@ -1,58 +0,0 @@ -# Provides method that can be included on File-type objects (IO, StringIO, Tempfile, etc) to allow stream copying -# and Tempfile conversion. -module IOStream - - # Returns a Tempfile containing the contents of the readable object. - def to_tempfile - tempfile = Tempfile.new("stream") - tempfile.binmode - self.stream_to(tempfile) - end - - # Copies one read-able object from one place to another in blocks, obviating the need to load - # the whole thing into memory. Defaults to 8k blocks. If this module is included in both - # StringIO and Tempfile, then either can have its data copied anywhere else without typing - # worries or memory overhead worries. Returns a File if a String is passed in as the destination - # and returns the IO or Tempfile as passed in if one is sent as the destination. - def stream_to path_or_file, in_blocks_of = 8192 - dstio = case path_or_file - when String then File.new(path_or_file, "wb+") - when IO then path_or_file - when Tempfile then path_or_file - end - buffer = "" - self.rewind - while self.read(in_blocks_of, buffer) do - dstio.write(buffer) - end - dstio.rewind - dstio - end -end - -class IO #:nodoc: - include IOStream -end - -%w( Tempfile StringIO ).each do |klass| - if Object.const_defined? klass - Object.const_get(klass).class_eval do - include IOStream - end - end -end - -# Corrects a bug in Windows when asking for Tempfile size. -if defined? Tempfile - class Tempfile - def size - if @tmpfile - @tmpfile.fsync - @tmpfile.flush - @tmpfile.stat.size - else - 0 - end - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/matchers.rb b/vendor/plugins/paperclip/lib/paperclip/matchers.rb deleted file mode 100644 index ca24b5e..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/matchers.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'paperclip/matchers/have_attached_file_matcher' -require 'paperclip/matchers/validate_attachment_presence_matcher' -require 'paperclip/matchers/validate_attachment_content_type_matcher' -require 'paperclip/matchers/validate_attachment_size_matcher' diff --git a/vendor/plugins/paperclip/lib/paperclip/matchers/have_attached_file_matcher.rb b/vendor/plugins/paperclip/lib/paperclip/matchers/have_attached_file_matcher.rb deleted file mode 100644 index da0dd8b..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/matchers/have_attached_file_matcher.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Paperclip - module Shoulda - module Matchers - def have_attached_file name - HaveAttachedFileMatcher.new(name) - end - - class HaveAttachedFileMatcher - def initialize attachment_name - @attachment_name = attachment_name - end - - def matches? subject - @subject = subject - responds? && has_column? && included? - end - - def failure_message - "Should have an attachment named #{@attachment_name}" - end - - def negative_failure_message - "Should not have an attachment named #{@attachment_name}" - end - - def description - "have an attachment named #{@attachment_name}" - end - - protected - - def responds? - methods = @subject.instance_methods - methods.include?("#{@attachment_name}") && - methods.include?("#{@attachment_name}=") && - methods.include?("#{@attachment_name}?") - end - - def has_column? - @subject.column_names.include?("#{@attachment_name}_file_name") - end - - def included? - @subject.ancestors.include?(Paperclip::InstanceMethods) - end - end - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb b/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb deleted file mode 100644 index b4e97fd..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +++ /dev/null @@ -1,66 +0,0 @@ -module Paperclip - module Shoulda - module Matchers - def validate_attachment_content_type name - ValidateAttachmentContentTypeMatcher.new(name) - end - - class ValidateAttachmentContentTypeMatcher - def initialize attachment_name - @attachment_name = attachment_name - end - - def allowing *types - @allowed_types = types.flatten - self - end - - def rejecting *types - @rejected_types = types.flatten - self - end - - def matches? subject - @subject = subject - @allowed_types && @rejected_types && - allowed_types_allowed? && rejected_types_rejected? - end - - def failure_message - "Content types #{@allowed_types.join(", ")} should be accepted" + - " and #{@rejected_types.join(", ")} rejected by #{@attachment_name}" - end - - def negative_failure_message - "Content types #{@allowed_types.join(", ")} should be rejected" + - " and #{@rejected_types.join(", ")} accepted by #{@attachment_name}" - end - - def description - "validate the content types allowed on attachment #{@attachment_name}" - end - - protected - - def allow_types?(types) - types.all? do |type| - file = StringIO.new(".") - file.content_type = type - attachment = @subject.new.attachment_for(@attachment_name) - attachment.assign(file) - attachment.errors[:content_type].nil? - end - end - - def allowed_types_allowed? - allow_types?(@allowed_types) - end - - def rejected_types_rejected? - not allow_types?(@rejected_types) - end - end - end - end -end - diff --git a/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb b/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb deleted file mode 100644 index 61dc0ea..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Paperclip - module Shoulda - module Matchers - def validate_attachment_presence name - ValidateAttachmentPresenceMatcher.new(name) - end - - class ValidateAttachmentPresenceMatcher - def initialize attachment_name - @attachment_name = attachment_name - end - - def matches? subject - @subject = subject - error_when_not_valid? && no_error_when_valid? - end - - def failure_message - "Attachment #{@attachment_name} should be required" - end - - def negative_failure_message - "Attachment #{@attachment_name} should not be required" - end - - def description - "require presence of attachment #{@attachment_name}" - end - - protected - - def error_when_not_valid? - @attachment = @subject.new.send(@attachment_name) - @attachment.assign(nil) - not @attachment.errors[:presence].nil? - end - - def no_error_when_valid? - @file = StringIO.new(".") - @attachment = @subject.new.send(@attachment_name) - @attachment.assign(@file) - @attachment.errors[:presence].nil? - end - end - end - end -end - diff --git a/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_size_matcher.rb b/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_size_matcher.rb deleted file mode 100644 index f84c479..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_size_matcher.rb +++ /dev/null @@ -1,83 +0,0 @@ -module Paperclip - module Shoulda - module Matchers - def validate_attachment_size name - ValidateAttachmentSizeMatcher.new(name) - end - - class ValidateAttachmentSizeMatcher - def initialize attachment_name - @attachment_name = attachment_name - @low, @high = 0, (1.0/0) - end - - def less_than size - @high = size - self - end - - def greater_than size - @low = size - self - end - - def in range - @low, @high = range.first, range.last - self - end - - def matches? subject - @subject = subject - lower_than_low? && higher_than_low? && lower_than_high? && higher_than_high? - end - - def failure_message - "Attachment #{@attachment_name} must be between #{@low} and #{@high} bytes" - end - - def negative_failure_message - "Attachment #{@attachment_name} cannot be between #{@low} and #{@high} bytes" - end - - def description - "validate the size of attachment #{@attachment_name}" - end - - protected - - def override_method object, method, &replacement - (class << object; self; end).class_eval do - define_method(method, &replacement) - end - end - - def passes_validation_with_size(new_size) - file = StringIO.new(".") - override_method(file, :size){ new_size } - attachment = @subject.new.attachment_for(@attachment_name) - attachment.assign(file) - attachment.errors[:size].nil? - end - - def lower_than_low? - not passes_validation_with_size(@low - 1) - end - - def higher_than_low? - passes_validation_with_size(@low + 1) - end - - def lower_than_high? - return true if @high == (1.0/0) - passes_validation_with_size(@high - 1) - end - - def higher_than_high? - return true if @high == (1.0/0) - not passes_validation_with_size(@high + 1) - end - end - end - end -end - diff --git a/vendor/plugins/paperclip/lib/paperclip/processor.rb b/vendor/plugins/paperclip/lib/paperclip/processor.rb deleted file mode 100644 index 9082bfd..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/processor.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Paperclip - # Paperclip processors allow you to modify attached files when they are - # attached in any way you are able. Paperclip itself uses command-line - # programs for its included Thumbnail processor, but custom processors - # are not required to follow suit. - # - # Processors are required to be defined inside the Paperclip module and - # are also required to be a subclass of Paperclip::Processor. There are - # only two methods you must implement to properly be a subclass: - # #initialize and #make. Initialize's arguments are the file that will - # be operated on (which is an instance of File), and a hash of options - # that were defined in has_attached_file's style hash. - # - # All #make needs to do is return an instance of File (Tempfile is - # acceptable) which contains the results of the processing. - # - # See Paperclip.run for more information about using command-line - # utilities from within Processors. - class Processor - attr_accessor :file, :options, :attachment - - def initialize file, options = {}, attachment = nil - @file = file - @options = options - @attachment = attachment - end - - def make - end - - def self.make file, options = {}, attachment = nil - new(file, options, attachment).make - end - end - - # Due to how ImageMagick handles its image format conversion and how Tempfile - # handles its naming scheme, it is necessary to override how Tempfile makes - # its names so as to allow for file extensions. Idea taken from the comments - # on this blog post: - # http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions - class Tempfile < ::Tempfile - # Replaces Tempfile's +make_tmpname+ with one that honors file extensions. - def make_tmpname(basename, n) - extension = File.extname(basename) - sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n, extension) - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/storage.rb b/vendor/plugins/paperclip/lib/paperclip/storage.rb deleted file mode 100644 index 58913ad..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/storage.rb +++ /dev/null @@ -1,236 +0,0 @@ -module Paperclip - module Storage - - # The default place to store attachments is in the filesystem. Files on the local - # filesystem can be very easily served by Apache without requiring a hit to your app. - # They also can be processed more easily after they've been saved, as they're just - # normal files. There is one Filesystem-specific option for has_attached_file. - # * +path+: The location of the repository of attachments on disk. This can (and, in - # almost all cases, should) be coordinated with the value of the +url+ option to - # allow files to be saved into a place where Apache can serve them without - # hitting your app. Defaults to - # ":rails_root/public/:attachment/:id/:style/:basename.:extension" - # By default this places the files in the app's public directory which can be served - # directly. If you are using capistrano for deployment, a good idea would be to - # make a symlink to the capistrano-created system directory from inside your app's - # public directory. - # See Paperclip::Attachment#interpolate for more information on variable interpolaton. - # :path => "/var/app/attachments/:class/:id/:style/:basename.:extension" - module Filesystem - def self.extended base - end - - def exists?(style = default_style) - if original_filename - File.exist?(path(style)) - else - false - end - end - - # Returns representation of the data of the file assigned to the given - # style, in the format most representative of the current storage. - def to_file style = default_style - @queued_for_write[style] || (File.new(path(style), 'rb') if exists?(style)) - end - alias_method :to_io, :to_file - - def flush_writes #:nodoc: - @queued_for_write.each do |style, file| - file.close - FileUtils.mkdir_p(File.dirname(path(style))) - logger.info("[paperclip] saving #{path(style)}") - FileUtils.mv(file.path, path(style)) - FileUtils.chmod(0644, path(style)) - end - @queued_for_write = {} - end - - def flush_deletes #:nodoc: - @queued_for_delete.each do |path| - begin - logger.info("[paperclip] deleting #{path}") - FileUtils.rm(path) if File.exist?(path) - rescue Errno::ENOENT => e - # ignore file-not-found, let everything else pass - end - begin - while(true) - path = File.dirname(path) - FileUtils.rmdir(path) - end - rescue Errno::EEXIST, Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL, Errno::ENOTDIR - # Stop trying to remove parent directories - rescue SystemCallError => e - logger.info("[paperclip] There was an unexpected error while deleting directories: #{e.class}") - # Ignore it - end - end - @queued_for_delete = [] - end - end - - # Amazon's S3 file hosting service is a scalable, easy place to store files for - # distribution. You can find out more about it at http://aws.amazon.com/s3 - # There are a few S3-specific options for has_attached_file: - # * +s3_credentials+: Takes a path, a File, or a Hash. The path (or File) must point - # to a YAML file containing the +access_key_id+ and +secret_access_key+ that Amazon - # gives you. You can 'environment-space' this just like you do to your - # database.yml file, so different environments can use different accounts: - # development: - # access_key_id: 123... - # secret_access_key: 123... - # test: - # access_key_id: abc... - # secret_access_key: abc... - # production: - # access_key_id: 456... - # secret_access_key: 456... - # This is not required, however, and the file may simply look like this: - # access_key_id: 456... - # secret_access_key: 456... - # In which case, those access keys will be used in all environments. You can also - # put your bucket name in this file, instead of adding it to the code directly. - # This is useful when you want the same account but a different bucket for - # development versus production. - # * +s3_permissions+: This is a String that should be one of the "canned" access - # policies that S3 provides (more information can be found here: - # http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html#RESTCannedAccessPolicies) - # The default for Paperclip is "public-read". - # * +s3_protocol+: The protocol for the URLs generated to your S3 assets. Can be either - # 'http' or 'https'. Defaults to 'http' when your :s3_permissions are 'public-read' (the - # default), and 'https' when your :s3_permissions are anything else. - # * +s3_headers+: A hash of headers such as {'Expires' => 1.year.from_now.httpdate} - # * +bucket+: This is the name of the S3 bucket that will store your files. Remember - # that the bucket must be unique across all of Amazon S3. If the bucket does not exist - # Paperclip will attempt to create it. The bucket name will not be interpolated. - # You can define the bucket as a Proc if you want to determine it's name at runtime. - # Paperclip will call that Proc with attachment as the only argument. - # * +s3_host_alias+: The fully-qualified domain name (FQDN) that is the alias to the - # S3 domain of your bucket. Used with the :s3_alias_url url interpolation. See the - # link in the +url+ entry for more information about S3 domains and buckets. - # * +url+: There are three options for the S3 url. You can choose to have the bucket's name - # placed domain-style (bucket.s3.amazonaws.com) or path-style (s3.amazonaws.com/bucket). - # Lastly, you can specify a CNAME (which requires the CNAME to be specified as - # :s3_alias_url. You can read more about CNAMEs and S3 at - # http://docs.amazonwebservices.com/AmazonS3/latest/index.html?VirtualHosting.html - # Normally, this won't matter in the slightest and you can leave the default (which is - # path-style, or :s3_path_url). But in some cases paths don't work and you need to use - # the domain-style (:s3_domain_url). Anything else here will be treated like path-style. - # NOTE: If you use a CNAME for use with CloudFront, you can NOT specify https as your - # :s3_protocol; This is *not supported* by S3/CloudFront. Finally, when using the host - # alias, the :bucket parameter is ignored, as the hostname is used as the bucket name - # by S3. - # * +path+: This is the key under the bucket in which the file will be stored. The - # URL will be constructed from the bucket and the path. This is what you will want - # to interpolate. Keys should be unique, like filenames, and despite the fact that - # S3 (strictly speaking) does not support directories, you can still use a / to - # separate parts of your file name. - module S3 - def self.extended base - require 'right_aws' - base.instance_eval do - @s3_credentials = parse_credentials(@options[:s3_credentials]) - @bucket = @options[:bucket] || @s3_credentials[:bucket] - @bucket = @bucket.call(self) if @bucket.is_a?(Proc) - @s3_options = @options[:s3_options] || {} - @s3_permissions = @options[:s3_permissions] || 'public-read' - @s3_protocol = @options[:s3_protocol] || (@s3_permissions == 'public-read' ? 'http' : 'https') - @s3_headers = @options[:s3_headers] || {} - @s3_host_alias = @options[:s3_host_alias] - @url = ":s3_path_url" unless @url.to_s.match(/^:s3.*url$/) - end - base.class.interpolations[:s3_alias_url] = lambda do |attachment, style| - "#{attachment.s3_protocol}://#{attachment.s3_host_alias}/#{attachment.path(style).gsub(%r{^/}, "")}" - end - base.class.interpolations[:s3_path_url] = lambda do |attachment, style| - "#{attachment.s3_protocol}://s3.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}" - end - base.class.interpolations[:s3_domain_url] = lambda do |attachment, style| - "#{attachment.s3_protocol}://#{attachment.bucket_name}.s3.amazonaws.com/#{attachment.path(style).gsub(%r{^/}, "")}" - end - end - - def s3 - @s3 ||= RightAws::S3.new(@s3_credentials[:access_key_id], - @s3_credentials[:secret_access_key], - @s3_options) - end - - def s3_bucket - @s3_bucket ||= s3.bucket(@bucket, true, @s3_permissions) - end - - def bucket_name - @bucket - end - - def s3_host_alias - @s3_host_alias - end - - def parse_credentials creds - creds = find_credentials(creds).stringify_keys - (creds[ENV['RAILS_ENV']] || creds).symbolize_keys - end - - def exists?(style = default_style) - s3_bucket.key(path(style)) ? true : false - end - - def s3_protocol - @s3_protocol - end - - # Returns representation of the data of the file assigned to the given - # style, in the format most representative of the current storage. - def to_file style = default_style - @queued_for_write[style] || s3_bucket.key(path(style)) - end - alias_method :to_io, :to_file - - def flush_writes #:nodoc: - @queued_for_write.each do |style, file| - begin - logger.info("[paperclip] saving #{path(style)}") - key = s3_bucket.key(path(style)) - key.data = file - key.put(nil, @s3_permissions, {'Content-type' => instance_read(:content_type)}.merge(@s3_headers)) - rescue RightAws::AwsError => e - raise - end - end - @queued_for_write = {} - end - - def flush_deletes #:nodoc: - @queued_for_delete.each do |path| - begin - logger.info("[paperclip] deleting #{path}") - if file = s3_bucket.key(path) - file.delete - end - rescue RightAws::AwsError - # Ignore this. - end - end - @queued_for_delete = [] - end - - def find_credentials creds - case creds - when File - YAML.load_file(creds.path) - when String - YAML.load_file(creds) - when Hash - creds - else - raise ArgumentError, "Credentials are not a path, file, or hash." - end - end - private :find_credentials - - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/thumbnail.rb b/vendor/plugins/paperclip/lib/paperclip/thumbnail.rb deleted file mode 100644 index 2178a9c..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/thumbnail.rb +++ /dev/null @@ -1,70 +0,0 @@ -module Paperclip - # Handles thumbnailing images that are uploaded. - class Thumbnail < Processor - - attr_accessor :current_geometry, :target_geometry, :format, :whiny, :convert_options - - # Creates a Thumbnail object set to work on the +file+ given. It - # will attempt to transform the image into one defined by +target_geometry+ - # which is a "WxH"-style string. +format+ will be inferred from the +file+ - # unless specified. Thumbnail creation will raise no errors unless - # +whiny+ is true (which it is, by default. If +convert_options+ is - # set, the options will be appended to the convert command upon image conversion - def initialize file, options = {}, attachment = nil - super - geometry = options[:geometry] - @file = file - @crop = geometry[-1,1] == '#' - @target_geometry = Geometry.parse geometry - @current_geometry = Geometry.from_file @file - @convert_options = options[:convert_options] - @whiny = options[:whiny].nil? ? true : options[:whiny] - @format = options[:format] - - @current_format = File.extname(@file.path) - @basename = File.basename(@file.path, @current_format) - end - - # Returns true if the +target_geometry+ is meant to crop. - def crop? - @crop - end - - # Returns true if the image is meant to make use of additional convert options. - def convert_options? - not @convert_options.blank? - end - - # Performs the conversion of the +file+ into a thumbnail. Returns the Tempfile - # that contains the new image. - def make - src = @file - dst = Tempfile.new([@basename, @format].compact.join(".")) - dst.binmode - - command = <<-end_command - "#{ File.expand_path(src.path) }[0]" - #{ transformation_command } - "#{ File.expand_path(dst.path) }" - end_command - - begin - success = Paperclip.run("convert", command.gsub(/\s+/, " ")) - rescue PaperclipCommandLineError - raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny - end - - dst - end - - # Returns the command ImageMagick's +convert+ needs to transform the image - # into the thumbnail. - def transformation_command - scale, crop = @current_geometry.transformation_to(@target_geometry, crop?) - trans = "-resize \"#{scale}\"" - trans << " -crop \"#{crop}\" +repage" if crop - trans << " #{convert_options}" if convert_options? - trans - end - end -end diff --git a/vendor/plugins/paperclip/lib/paperclip/upfile.rb b/vendor/plugins/paperclip/lib/paperclip/upfile.rb deleted file mode 100644 index f0c8a44..0000000 --- a/vendor/plugins/paperclip/lib/paperclip/upfile.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Paperclip - # The Upfile module is a convenience module for adding uploaded-file-type methods - # to the +File+ class. Useful for testing. - # user.avatar = File.new("test/test_avatar.jpg") - module Upfile - - # Infer the MIME-type of the file from the extension. - def content_type - type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase - case type - when %r"jpe?g" then "image/jpeg" - when %r"tiff?" then "image/tiff" - when %r"png", "gif", "bmp" then "image/#{type}" - when "txt" then "text/plain" - when %r"html?" then "text/html" - when "csv", "xml", "css", "js" then "text/#{type}" - else "application/x-#{type}" - end - end - - # Returns the file's normal name. - def original_filename - File.basename(self.path) - end - - # Returns the size of the file. - def size - File.size(self) - end - end -end - -if defined? StringIO - class StringIO - attr_accessor :original_filename, :content_type - def original_filename - @original_filename ||= "stringio.txt" - end - def content_type - @content_type ||= "text/plain" - end - end -end - -class File #:nodoc: - include Paperclip::Upfile -end - diff --git a/vendor/plugins/paperclip/paperclip.gemspec b/vendor/plugins/paperclip/paperclip.gemspec deleted file mode 100644 index 12ce4c2..0000000 --- a/vendor/plugins/paperclip/paperclip.gemspec +++ /dev/null @@ -1,40 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{paperclip} - s.version = "2.2.8" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Jon Yurek"] - s.date = %q{2009-04-02} - s.email = %q{jyurek@thoughtbot.com} - s.extra_rdoc_files = ["README.rdoc"] - s.files = ["README.rdoc", "LICENSE", "Rakefile", "init.rb", "generators/paperclip", "generators/paperclip/paperclip_generator.rb", "generators/paperclip/templates", "generators/paperclip/templates/paperclip_migration.rb.erb", "generators/paperclip/USAGE", "lib/paperclip", "lib/paperclip/attachment.rb", "lib/paperclip/callback_compatability.rb", "lib/paperclip/geometry.rb", "lib/paperclip/iostream.rb", "lib/paperclip/matchers", "lib/paperclip/matchers/have_attached_file_matcher.rb", "lib/paperclip/matchers/validate_attachment_content_type_matcher.rb", "lib/paperclip/matchers/validate_attachment_presence_matcher.rb", "lib/paperclip/matchers/validate_attachment_size_matcher.rb", "lib/paperclip/matchers.rb", "lib/paperclip/processor.rb", "lib/paperclip/storage.rb", "lib/paperclip/thumbnail.rb", "lib/paperclip/upfile.rb", "lib/paperclip.rb", "tasks/paperclip_tasks.rake", "test/attachment_test.rb", "test/database.yml", "test/debug.log", "test/fixtures", "test/fixtures/12k.png", "test/fixtures/50x50.png", "test/fixtures/5k.png", "test/fixtures/bad.png", "test/fixtures/s3.yml", "test/fixtures/text.txt", "test/fixtures/twopage.pdf", "test/geometry_test.rb", "test/helper.rb", "test/integration_test.rb", "test/iostream_test.rb", "test/matchers", "test/matchers/have_attached_file_matcher_test.rb", "test/matchers/validate_attachment_content_type_matcher_test.rb", "test/matchers/validate_attachment_presence_matcher_test.rb", "test/matchers/validate_attachment_size_matcher_test.rb", "test/paperclip_test.rb", "test/processor_test.rb", "test/s3.yml", "test/storage_test.rb", "test/thumbnail_test.rb", "test/tmp", "test/tmp/storage.txt", "shoulda_macros/paperclip.rb"] - s.has_rdoc = true - s.homepage = %q{http://www.thoughtbot.com/projects/paperclip} - s.rdoc_options = ["--line-numbers", "--inline-source"] - s.require_paths = ["lib"] - s.requirements = ["ImageMagick"] - s.rubyforge_project = %q{paperclip} - s.rubygems_version = %q{1.3.1} - s.summary = %q{File attachments as attributes for ActiveRecord} - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/plugins/paperclip/shoulda_macros/paperclip.rb b/vendor/plugins/paperclip/shoulda_macros/paperclip.rb deleted file mode 100644 index d690357..0000000 --- a/vendor/plugins/paperclip/shoulda_macros/paperclip.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'paperclip/matchers' - -module Paperclip - # =Paperclip Shoulda Macros - # - # These macros are intended for use with shoulda, and will be included into - # your tests automatically. All of the macros use the standard shoulda - # assumption that the name of the test is based on the name of the model - # you're testing (that is, UserTest is the test for the User model), and - # will load that class for testing purposes. - module Shoulda - include Matchers - # This will test whether you have defined your attachment correctly by - # checking for all the required fields exist after the definition of the - # attachment. - def should_have_attached_file name - klass = self.name.gsub(/Test$/, '').constantize - matcher = have_attached_file name - should matcher.description do - assert_accepts(matcher, klass) - end - end - - # Tests for validations on the presence of the attachment. - def should_validate_attachment_presence name - klass = self.name.gsub(/Test$/, '').constantize - matcher = validate_attachment_presence name - should matcher.description do - assert_accepts(matcher, klass) - end - end - - # Tests that you have content_type validations specified. There are two - # options, :valid and :invalid. Both accept an array of strings. The - # strings should be a list of content types which will pass and fail - # validation, respectively. - def should_validate_attachment_content_type name, options = {} - klass = self.name.gsub(/Test$/, '').constantize - valid = [options[:valid]].flatten - invalid = [options[:invalid]].flatten - matcher = validate_attachment_content_type(name).allowing(valid).rejecting(invalid) - should matcher.description do - assert_accepts(matcher, klass) - end - end - - # Tests to ensure that you have file size validations turned on. You - # can pass the same options to this that you can to - # validate_attachment_file_size - :less_than, :greater_than, and :in. - # :less_than checks that a file is less than a certain size, :greater_than - # checks that a file is more than a certain size, and :in takes a Range or - # Array which specifies the lower and upper limits of the file size. - def should_validate_attachment_size name, options = {} - klass = self.name.gsub(/Test$/, '').constantize - min = options[:greater_than] || (options[:in] && options[:in].first) || 0 - max = options[:less_than] || (options[:in] && options[:in].last) || (1.0/0) - range = (min..max) - matcher = validate_attachment_size(name).in(range) - should matcher.description do - assert_accepts(matcher, klass) - end - end - end -end - -class Test::Unit::TestCase #:nodoc: - extend Paperclip::Shoulda -end diff --git a/vendor/plugins/paperclip/tasks/paperclip_tasks.rake b/vendor/plugins/paperclip/tasks/paperclip_tasks.rake deleted file mode 100644 index 23e4c11..0000000 --- a/vendor/plugins/paperclip/tasks/paperclip_tasks.rake +++ /dev/null @@ -1,79 +0,0 @@ -def obtain_class - class_name = ENV['CLASS'] || ENV['class'] - raise "Must specify CLASS" unless class_name - @klass = Object.const_get(class_name) -end - -def obtain_attachments - name = ENV['ATTACHMENT'] || ENV['attachment'] - raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_definitions) - if !name.blank? && @klass.attachment_definitions.keys.include?(name) - [ name ] - else - @klass.attachment_definitions.keys - end -end - -def for_all_attachments - klass = obtain_class - names = obtain_attachments - ids = klass.connection.select_values(klass.send(:construct_finder_sql, :select => 'id')) - - ids.each do |id| - instance = klass.find(id) - names.each do |name| - result = if instance.send("#{ name }?") - yield(instance, name) - else - true - end - print result ? "." : "x"; $stdout.flush - end - end - puts " Done." -end - -namespace :paperclip do - desc "Refreshes both metadata and thumbnails." - task :refresh => ["paperclip:refresh:metadata", "paperclip:refresh:thumbnails"] - - namespace :refresh do - desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)." - task :thumbnails => :environment do - errors = [] - for_all_attachments do |instance, name| - result = instance.send(name).reprocess! - errors << [instance.id, instance.errors] unless instance.errors.blank? - result - end - errors.each{|e| puts "#{e.first}: #{e.last.full_messages.inspect}" } - end - - desc "Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT)." - task :metadata => :environment do - for_all_attachments do |instance, name| - if file = instance.send(name).to_file - instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip) - instance.send("#{name}_content_type=", file.content_type.strip) - instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size") - instance.save(false) - else - true - end - end - end - end - - desc "Cleans out invalid attachments. Useful after you've added new validations." - task :clean => :environment do - for_all_attachments do |instance, name| - instance.send(name).send(:validate) - if instance.send(name).valid? - true - else - instance.send("#{name}=", nil) - instance.save - end - end - end -end diff --git a/vendor/plugins/paperclip/test/.gitignore b/vendor/plugins/paperclip/test/.gitignore deleted file mode 100644 index b14c548..0000000 --- a/vendor/plugins/paperclip/test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -debug.log diff --git a/vendor/plugins/paperclip/test/attachment_test.rb b/vendor/plugins/paperclip/test/attachment_test.rb deleted file mode 100644 index 61ab2a2..0000000 --- a/vendor/plugins/paperclip/test/attachment_test.rb +++ /dev/null @@ -1,742 +0,0 @@ -require 'test/helper' - -class Dummy - # This is a dummy class -end - -class AttachmentTest < Test::Unit::TestCase - context "Attachment default_options" do - setup do - rebuild_model - @old_default_options = Paperclip::Attachment.default_options.dup - @new_default_options = @old_default_options.merge({ - :path => "argle/bargle", - :url => "fooferon", - :default_url => "not here.png" - }) - end - - teardown do - Paperclip::Attachment.default_options.merge! @old_default_options - end - - should "be overrideable" do - Paperclip::Attachment.default_options.merge!(@new_default_options) - @new_default_options.keys.each do |key| - assert_equal @new_default_options[key], - Paperclip::Attachment.default_options[key] - end - end - - context "without an Attachment" do - setup do - @dummy = Dummy.new - end - - should "return false when asked exists?" do - assert !@dummy.avatar.exists? - end - end - - context "on an Attachment" do - setup do - @dummy = Dummy.new - @attachment = @dummy.avatar - end - - Paperclip::Attachment.default_options.keys.each do |key| - should "be the default_options for #{key}" do - assert_equal @old_default_options[key], - @attachment.instance_variable_get("@#{key}"), - key - end - end - - context "when redefined" do - setup do - Paperclip::Attachment.default_options.merge!(@new_default_options) - @dummy = Dummy.new - @attachment = @dummy.avatar - end - - Paperclip::Attachment.default_options.keys.each do |key| - should "be the new default_options for #{key}" do - assert_equal @new_default_options[key], - @attachment.instance_variable_get("@#{key}"), - key - end - end - end - end - end - - context "An attachment with similarly named interpolations" do - setup do - rebuild_model :path => ":id.omg/:id-bbq/:idwhat/:id_partition.wtf" - @dummy = Dummy.new - @dummy.stubs(:id).returns(1024) - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - end - - teardown { @file.close } - - should "make sure that they are interpolated correctly" do - assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path - end - end - - context "An attachment with a :rails_env interpolation" do - setup do - @rails_env = "blah" - @id = 1024 - rebuild_model :path => ":rails_env/:id.png" - @dummy = Dummy.new - @dummy.stubs(:id).returns(@id) - @file = StringIO.new(".") - @dummy.avatar = @file - end - - should "return the proper path" do - temporary_rails_env(@rails_env) { - assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path - } - end - end - - context "An attachment with :convert_options" do - setup do - rebuild_model :styles => { - :thumb => "100x100", - :large => "400x400" - }, - :convert_options => { - :all => "-do_stuff", - :thumb => "-thumbnailize" - } - @dummy = Dummy.new - @dummy.avatar - end - - should "report the correct options when sent #extra_options_for(:thumb)" do - assert_equal "-thumbnailize -do_stuff", @dummy.avatar.send(:extra_options_for, :thumb), @dummy.avatar.convert_options.inspect - end - - should "report the correct options when sent #extra_options_for(:large)" do - assert_equal "-do_stuff", @dummy.avatar.send(:extra_options_for, :large) - end - - before_should "call extra_options_for(:thumb/:large)" do - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:thumb) - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:large) - end - end - - context "An attachment with :convert_options that is a proc" do - setup do - rebuild_model :styles => { - :thumb => "100x100", - :large => "400x400" - }, - :convert_options => { - :all => lambda{|i| i.all }, - :thumb => lambda{|i| i.thumb } - } - Dummy.class_eval do - def all; "-all"; end - def thumb; "-thumb"; end - end - @dummy = Dummy.new - @dummy.avatar - end - - should "report the correct options when sent #extra_options_for(:thumb)" do - assert_equal "-thumb -all", @dummy.avatar.send(:extra_options_for, :thumb), @dummy.avatar.convert_options.inspect - end - - should "report the correct options when sent #extra_options_for(:large)" do - assert_equal "-all", @dummy.avatar.send(:extra_options_for, :large) - end - - before_should "call extra_options_for(:thumb/:large)" do - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:thumb) - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:large) - end - end - - context "An attachment with :path that is a proc" do - setup do - rebuild_model :path => lambda{ |attachment| "path/#{attachment.instance.other}.:extension" } - - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummyA = Dummy.new(:other => 'a') - @dummyA.avatar = @file - @dummyB = Dummy.new(:other => 'b') - @dummyB.avatar = @file - end - - teardown { @file.close } - - should "return correct path" do - assert_equal "path/a.png", @dummyA.avatar.path - assert_equal "path/b.png", @dummyB.avatar.path - end - end - - context "An attachment with :styles that is a proc" do - setup do - rebuild_model :styles => lambda{ |attachment| {:thumb => "50x50#", :large => "400x400"} } - - @attachment = Dummy.new.avatar - end - - should "have the correct geometry" do - assert_equal "50x50#", @attachment.styles[:thumb][:geometry] - end - end - - context "An attachment with :url that is a proc" do - setup do - rebuild_model :url => lambda{ |attachment| "path/#{attachment.instance.other}.:extension" } - - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummyA = Dummy.new(:other => 'a') - @dummyA.avatar = @file - @dummyB = Dummy.new(:other => 'b') - @dummyB.avatar = @file - end - - teardown { @file.close } - - should "return correct url" do - assert_equal "path/a.png", @dummyA.avatar.url(:original, false) - assert_equal "path/b.png", @dummyB.avatar.url(:original, false) - end - end - - geometry_specs = [ - [ lambda{|z| "50x50#" }, :png ], - lambda{|z| "50x50#" }, - { :geometry => lambda{|z| "50x50#" } } - ] - geometry_specs.each do |geometry_spec| - context "An attachment geometry like #{geometry_spec}" do - setup do - rebuild_model :styles => { :normal => geometry_spec } - @attachment = Dummy.new.avatar - end - - should "not run the procs immediately" do - assert_kind_of Proc, @attachment.styles[:normal][:geometry] - end - - context "when assigned" do - setup do - @file = StringIO.new(".") - @attachment.assign(@file) - end - - should "have the correct geometry" do - assert_equal "50x50#", @attachment.styles[:normal][:geometry] - end - end - end - end - - context "An attachment with both 'normal' and hash-style styles" do - setup do - rebuild_model :styles => { - :normal => ["50x50#", :png], - :hash => { :geometry => "50x50#", :format => :png } - } - @dummy = Dummy.new - @attachment = @dummy.avatar - end - - [:processors, :whiny, :convert_options, :geometry, :format].each do |field| - should "have the same #{field} field" do - assert_equal @attachment.styles[:normal][field], @attachment.styles[:hash][field] - end - end - end - - context "An attachment with :processors that is a proc" do - setup do - rebuild_model :styles => { :normal => '' }, :processors => lambda { |a| [ :test ] } - @attachment = Dummy.new.avatar - end - - should "not run the proc immediately" do - assert_kind_of Proc, @attachment.styles[:normal][:processors] - end - - context "when assigned" do - setup do - @attachment.assign(StringIO.new(".")) - end - - should "have the correct processors" do - assert_equal [ :test ], @attachment.styles[:normal][:processors] - end - end - end - - context "An attachment with erroring processor" do - setup do - rebuild_model :processor => [:thumbnail], :styles => { :small => '' }, :whiny_thumbnails => true - @dummy = Dummy.new - Paperclip::Thumbnail.expects(:make).raises(Paperclip::PaperclipError, "cannot be processed.") - @file = StringIO.new("...") - @file.stubs(:to_tempfile).returns(@file) - @dummy.avatar = @file - end - - should "correctly forward processing error message to the instance" do - @dummy.valid? - assert_contains @dummy.errors.full_messages, "Avatar cannot be processed." - end - end - - context "An attachment with multiple processors" do - setup do - class Paperclip::Test < Paperclip::Processor; end - @style_params = { :once => {:one => 1, :two => 2} } - rebuild_model :processors => [:thumbnail, :test], :styles => @style_params - @dummy = Dummy.new - @file = StringIO.new("...") - @file.stubs(:to_tempfile).returns(@file) - Paperclip::Test.stubs(:make).returns(@file) - Paperclip::Thumbnail.stubs(:make).returns(@file) - end - - context "when assigned" do - setup { @dummy.avatar = @file } - - before_should "call #make on all specified processors" do - expected_params = @style_params[:once].merge({:processors => [:thumbnail, :test], :whiny => nil, :convert_options => ""}) - Paperclip::Thumbnail.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file) - Paperclip::Test.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file) - end - - before_should "call #make with attachment passed as third argument" do - expected_params = @style_params[:once].merge({:processors => [:thumbnail, :test], :whiny => nil, :convert_options => ""}) - Paperclip::Test.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file) - end - end - end - - context "An attachment with no processors defined" do - setup do - rebuild_model :processors => [], :styles => {:something => 1} - @dummy = Dummy.new - @file = StringIO.new("...") - end - should "raise when assigned to" do - assert_raises(RuntimeError){ @dummy.avatar = @file } - end - end - - context "Assigning an attachment with post_process hooks" do - setup do - rebuild_model :styles => { :something => "100x100#" } - Dummy.class_eval do - before_avatar_post_process :do_before_avatar - after_avatar_post_process :do_after_avatar - before_post_process :do_before_all - after_post_process :do_after_all - def do_before_avatar; end - def do_after_avatar; end - def do_before_all; end - def do_after_all; end - end - @file = StringIO.new(".") - @file.stubs(:to_tempfile).returns(@file) - @dummy = Dummy.new - Paperclip::Thumbnail.stubs(:make).returns(@file) - @attachment = @dummy.avatar - end - - should "call the defined callbacks when assigned" do - @dummy.expects(:do_before_avatar).with() - @dummy.expects(:do_after_avatar).with() - @dummy.expects(:do_before_all).with() - @dummy.expects(:do_after_all).with() - Paperclip::Thumbnail.expects(:make).returns(@file) - @dummy.avatar = @file - end - - should "not cancel the processing if a before_post_process returns nil" do - @dummy.expects(:do_before_avatar).with().returns(nil) - @dummy.expects(:do_after_avatar).with() - @dummy.expects(:do_before_all).with().returns(nil) - @dummy.expects(:do_after_all).with() - Paperclip::Thumbnail.expects(:make).returns(@file) - @dummy.avatar = @file - end - - should "cancel the processing if a before_post_process returns false" do - @dummy.expects(:do_before_avatar).never - @dummy.expects(:do_after_avatar).never - @dummy.expects(:do_before_all).with().returns(false) - @dummy.expects(:do_after_all).never - Paperclip::Thumbnail.expects(:make).never - @dummy.avatar = @file - end - - should "cancel the processing if a before_avatar_post_process returns false" do - @dummy.expects(:do_before_avatar).with().returns(false) - @dummy.expects(:do_after_avatar).never - @dummy.expects(:do_before_all).with().returns(true) - @dummy.expects(:do_after_all).never - Paperclip::Thumbnail.expects(:make).never - @dummy.avatar = @file - end - end - - context "Assigning an attachment" do - setup do - rebuild_model :styles => { :something => "100x100#" } - @file = StringIO.new(".") - @file.expects(:original_filename).returns("5k.png\n\n") - @file.expects(:content_type).returns("image/png\n\n") - @file.stubs(:to_tempfile).returns(@file) - @dummy = Dummy.new - Paperclip::Thumbnail.expects(:make).returns(@file) - @dummy.expects(:run_callbacks).with(:before_avatar_post_process, {:original => @file}) - @dummy.expects(:run_callbacks).with(:before_post_process, {:original => @file}) - @dummy.expects(:run_callbacks).with(:after_avatar_post_process, {:original => @file, :something => @file}) - @dummy.expects(:run_callbacks).with(:after_post_process, {:original => @file, :something => @file}) - @attachment = @dummy.avatar - @dummy.avatar = @file - end - - should "strip whitespace from original_filename field" do - assert_equal "5k.png", @dummy.avatar.original_filename - end - - should "strip whitespace from content_type field" do - assert_equal "image/png", @dummy.avatar.instance.avatar_content_type - end - end - - context "Attachment with strange letters" do - setup do - rebuild_model - - @not_file = mock - @tempfile = mock - @not_file.stubs(:nil?).returns(false) - @not_file.expects(:size).returns(10) - @tempfile.expects(:size).returns(10) - @not_file.expects(:to_tempfile).returns(@tempfile) - @not_file.expects(:original_filename).returns("sheep_say_bæ.png\r\n") - @not_file.expects(:content_type).returns("image/png\r\n") - - @dummy = Dummy.new - @attachment = @dummy.avatar - @attachment.expects(:valid_assignment?).with(@not_file).returns(true) - @attachment.expects(:queue_existing_for_delete) - @attachment.expects(:post_process) - @attachment.expects(:valid?).returns(true) - @attachment.expects(:validate) - @dummy.avatar = @not_file - end - - should "remove strange letters and replace with underscore (_)" do - assert_equal "sheep_say_b_.png", @dummy.avatar.original_filename - end - - end - - context "An attachment" do - setup do - Paperclip::Attachment.default_options.merge!({ - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - }) - FileUtils.rm_rf("tmp") - rebuild_model - @instance = Dummy.new - @attachment = Paperclip::Attachment.new(:avatar, @instance) - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - end - - teardown { @file.close } - - should "raise if there are not the correct columns when you try to assign" do - @other_attachment = Paperclip::Attachment.new(:not_here, @instance) - assert_raises(Paperclip::PaperclipError) do - @other_attachment.assign(@file) - end - end - - should "return its default_url when no file assigned" do - assert @attachment.to_file.nil? - assert_equal "/avatars/original/missing.png", @attachment.url - assert_equal "/avatars/blah/missing.png", @attachment.url(:blah) - end - - should "return nil as path when no file assigned" do - assert @attachment.to_file.nil? - assert_equal nil, @attachment.path - assert_equal nil, @attachment.path(:blah) - end - - context "with a file assigned in the database" do - setup do - @attachment.stubs(:instance_read).with(:file_name).returns("5k.png") - @attachment.stubs(:instance_read).with(:content_type).returns("image/png") - @attachment.stubs(:instance_read).with(:file_size).returns(12345) - now = Time.now - Time.stubs(:now).returns(now) - @attachment.stubs(:instance_read).with(:updated_at).returns(Time.now) - end - - should "return a correct url even if the file does not exist" do - assert_nil @attachment.to_file - assert_match %r{^/system/avatars/#{@instance.id}/blah/5k\.png}, @attachment.url(:blah) - end - - should "make sure the updated_at mtime is in the url if it is defined" do - assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah) - end - - should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do - assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false) - end - - context "with the updated_at field removed" do - setup do - @attachment.stubs(:instance_read).with(:updated_at).returns(nil) - end - - should "only return the url without the updated_at when sent #url" do - assert_match "/avatars/#{@instance.id}/blah/5k.png", @attachment.url(:blah) - end - end - - should "return the proper path when filename has a single .'s" do - assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png", @attachment.path - end - - should "return the proper path when filename has multiple .'s" do - @attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png") - assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png", @attachment.path - end - - context "when expecting three styles" do - setup do - styles = {:styles => { :large => ["400x400", :png], - :medium => ["100x100", :gif], - :small => ["32x32#", :jpg]}} - @attachment = Paperclip::Attachment.new(:avatar, - @instance, - styles) - end - - context "and assigned a file" do - setup do - now = Time.now - Time.stubs(:now).returns(now) - @attachment.assign(@file) - end - - should "be dirty" do - assert @attachment.dirty? - end - - context "and saved" do - setup do - @attachment.save - end - - should "return the real url" do - file = @attachment.to_file - assert file - assert_match %r{^/system/avatars/#{@instance.id}/original/5k\.png}, @attachment.url - assert_match %r{^/system/avatars/#{@instance.id}/small/5k\.jpg}, @attachment.url(:small) - file.close - end - - should "commit the files to disk" do - [:large, :medium, :small].each do |style| - io = @attachment.to_io(style) - assert File.exists?(io) - assert ! io.is_a?(::Tempfile) - io.close - end - end - - should "save the files as the right formats and sizes" do - [[:large, 400, 61, "PNG"], - [:medium, 100, 15, "GIF"], - [:small, 32, 32, "JPEG"]].each do |style| - cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"] - out = `#{cmd}` - width, height, size, format = out.split(" ") - assert_equal style[1].to_s, width.to_s - assert_equal style[2].to_s, height.to_s - assert_equal style[3].to_s, format.to_s - end - end - - should "still have its #file attribute not be nil" do - assert ! (file = @attachment.to_file).nil? - file.close - end - - context "and trying to delete" do - setup do - @existing_names = @attachment.styles.keys.collect do |style| - @attachment.path(style) - end - end - - should "delete the files after assigning nil" do - @attachment.expects(:instance_write).with(:file_name, nil) - @attachment.expects(:instance_write).with(:content_type, nil) - @attachment.expects(:instance_write).with(:file_size, nil) - @attachment.expects(:instance_write).with(:updated_at, nil) - @attachment.assign nil - @attachment.save - @existing_names.each{|f| assert ! File.exists?(f) } - end - - should "delete the files when you call #clear and #save" do - @attachment.expects(:instance_write).with(:file_name, nil) - @attachment.expects(:instance_write).with(:content_type, nil) - @attachment.expects(:instance_write).with(:file_size, nil) - @attachment.expects(:instance_write).with(:updated_at, nil) - @attachment.clear - @attachment.save - @existing_names.each{|f| assert ! File.exists?(f) } - end - - should "delete the files when you call #delete" do - @attachment.expects(:instance_write).with(:file_name, nil) - @attachment.expects(:instance_write).with(:content_type, nil) - @attachment.expects(:instance_write).with(:file_size, nil) - @attachment.expects(:instance_write).with(:updated_at, nil) - @attachment.destroy - @existing_names.each{|f| assert ! File.exists?(f) } - end - end - end - end - end - - end - - context "when trying a nonexistant storage type" do - setup do - rebuild_model :storage => :not_here - end - - should "not be able to find the module" do - assert_raise(NameError){ Dummy.new.avatar } - end - end - end - - context "An attachment with only a avatar_file_name column" do - setup do - ActiveRecord::Base.connection.create_table :dummies, :force => true do |table| - table.column :avatar_file_name, :string - end - rebuild_class - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') - end - - teardown { @file.close } - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the time when sent #avatar_updated_at" do - now = Time.now - Time.stubs(:now).returns(now) - @dummy.avatar = @file - assert now, @dummy.avatar.updated_at - end - - should "return nil when reloaded and sent #avatar_updated_at" do - @dummy.save - @dummy.reload - assert_nil @dummy.avatar.updated_at - end - - should "return the right value when sent #avatar_file_size" do - @dummy.avatar = @file - assert_equal @file.size, @dummy.avatar.size - end - - context "and avatar_updated_at column" do - setup do - ActiveRecord::Base.connection.add_column :dummies, :avatar_updated_at, :timestamp - rebuild_class - @dummy = Dummy.new - end - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the right value when sent #avatar_updated_at" do - now = Time.now - Time.stubs(:now).returns(now) - @dummy.avatar = @file - assert_equal now.to_i, @dummy.avatar.updated_at - end - end - - context "and avatar_content_type column" do - setup do - ActiveRecord::Base.connection.add_column :dummies, :avatar_content_type, :string - rebuild_class - @dummy = Dummy.new - end - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the right value when sent #avatar_content_type" do - @dummy.avatar = @file - assert_equal "image/png", @dummy.avatar.content_type - end - end - - context "and avatar_file_size column" do - setup do - ActiveRecord::Base.connection.add_column :dummies, :avatar_file_size, :integer - rebuild_class - @dummy = Dummy.new - end - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the right value when sent #avatar_file_size" do - @dummy.avatar = @file - assert_equal @file.size, @dummy.avatar.size - end - - should "return the right value when saved, reloaded, and sent #avatar_file_size" do - @dummy.avatar = @file - @dummy.save - @dummy = Dummy.find(@dummy.id) - assert_equal @file.size, @dummy.avatar.size - end - end - end -end diff --git a/vendor/plugins/paperclip/test/fixtures/12k.png b/vendor/plugins/paperclip/test/fixtures/12k.png deleted file mode 100644 index f819d45..0000000 Binary files a/vendor/plugins/paperclip/test/fixtures/12k.png and /dev/null differ diff --git a/vendor/plugins/paperclip/test/fixtures/50x50.png b/vendor/plugins/paperclip/test/fixtures/50x50.png deleted file mode 100644 index 63f5646..0000000 Binary files a/vendor/plugins/paperclip/test/fixtures/50x50.png and /dev/null differ diff --git a/vendor/plugins/paperclip/test/fixtures/5k.png b/vendor/plugins/paperclip/test/fixtures/5k.png deleted file mode 100644 index 75d9f04..0000000 Binary files a/vendor/plugins/paperclip/test/fixtures/5k.png and /dev/null differ diff --git a/vendor/plugins/paperclip/test/fixtures/bad.png b/vendor/plugins/paperclip/test/fixtures/bad.png deleted file mode 100644 index 7ba4f07..0000000 --- a/vendor/plugins/paperclip/test/fixtures/bad.png +++ /dev/null @@ -1 +0,0 @@ -This is not an image. diff --git a/vendor/plugins/paperclip/test/fixtures/text.txt b/vendor/plugins/paperclip/test/fixtures/text.txt deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/plugins/paperclip/test/fixtures/twopage.pdf b/vendor/plugins/paperclip/test/fixtures/twopage.pdf deleted file mode 100644 index 0c34a51..0000000 Binary files a/vendor/plugins/paperclip/test/fixtures/twopage.pdf and /dev/null differ diff --git a/vendor/plugins/paperclip/test/geometry_test.rb b/vendor/plugins/paperclip/test/geometry_test.rb deleted file mode 100644 index 134372d..0000000 --- a/vendor/plugins/paperclip/test/geometry_test.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'test/helper' - -class GeometryTest < Test::Unit::TestCase - context "Paperclip::Geometry" do - should "correctly report its given dimensions" do - assert @geo = Paperclip::Geometry.new(1024, 768) - assert_equal 1024, @geo.width - assert_equal 768, @geo.height - end - - should "set height to 0 if height dimension is missing" do - assert @geo = Paperclip::Geometry.new(1024) - assert_equal 1024, @geo.width - assert_equal 0, @geo.height - end - - should "set width to 0 if width dimension is missing" do - assert @geo = Paperclip::Geometry.new(nil, 768) - assert_equal 0, @geo.width - assert_equal 768, @geo.height - end - - should "be generated from a WxH-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x600") - assert_equal 800, @geo.width - assert_equal 600, @geo.height - end - - should "be generated from a xH-formatted string" do - assert @geo = Paperclip::Geometry.parse("x600") - assert_equal 0, @geo.width - assert_equal 600, @geo.height - end - - should "be generated from a Wx-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x") - assert_equal 800, @geo.width - assert_equal 0, @geo.height - end - - should "be generated from a W-formatted string" do - assert @geo = Paperclip::Geometry.parse("800") - assert_equal 800, @geo.width - assert_equal 0, @geo.height - end - - should "ensure the modifier is nil if not present" do - assert @geo = Paperclip::Geometry.parse("123x456") - assert_nil @geo.modifier - end - - ['>', '<', '#', '@', '%', '^', '!', nil].each do |mod| - should "ensure the modifier #{mod.inspect} is preserved" do - assert @geo = Paperclip::Geometry.parse("123x456#{mod}") - assert_equal mod, @geo.modifier - assert_equal "123x456#{mod}", @geo.to_s - end - end - - ['>', '<', '#', '@', '%', '^', '!', nil].each do |mod| - should "ensure the modifier #{mod.inspect} is preserved with no height" do - assert @geo = Paperclip::Geometry.parse("123x#{mod}") - assert_equal mod, @geo.modifier - assert_equal "123#{mod}", @geo.to_s - end - end - - should "make sure the modifier gets passed during transformation_to" do - assert @src = Paperclip::Geometry.parse("123x456") - assert @dst = Paperclip::Geometry.parse("123x456>") - assert_equal "123x456>", @src.transformation_to(@dst).to_s - end - - should "generate correct ImageMagick formatting string for W-formatted string" do - assert @geo = Paperclip::Geometry.parse("800") - assert_equal "800", @geo.to_s - end - - should "generate correct ImageMagick formatting string for Wx-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x") - assert_equal "800", @geo.to_s - end - - should "generate correct ImageMagick formatting string for xH-formatted string" do - assert @geo = Paperclip::Geometry.parse("x600") - assert_equal "x600", @geo.to_s - end - - should "generate correct ImageMagick formatting string for WxH-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x600") - assert_equal "800x600", @geo.to_s - end - - should "be generated from a file" do - file = File.join(File.dirname(__FILE__), "fixtures", "5k.png") - file = File.new(file, 'rb') - assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) } - assert @geo.height > 0 - assert @geo.width > 0 - end - - should "be generated from a file path" do - file = File.join(File.dirname(__FILE__), "fixtures", "5k.png") - assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) } - assert @geo.height > 0 - assert @geo.width > 0 - end - - should "not generate from a bad file" do - file = "/home/This File Does Not Exist.omg" - assert_raise(Paperclip::NotIdentifiedByImageMagickError){ @geo = Paperclip::Geometry.from_file(file) } - end - - [['vertical', 900, 1440, true, false, false, 1440, 900, 0.625], - ['horizontal', 1024, 768, false, true, false, 1024, 768, 1.3333], - ['square', 100, 100, false, false, true, 100, 100, 1]].each do |args| - context "performing calculations on a #{args[0]} viewport" do - setup do - @geo = Paperclip::Geometry.new(args[1], args[2]) - end - - should "#{args[3] ? "" : "not"} be vertical" do - assert_equal args[3], @geo.vertical? - end - - should "#{args[4] ? "" : "not"} be horizontal" do - assert_equal args[4], @geo.horizontal? - end - - should "#{args[5] ? "" : "not"} be square" do - assert_equal args[5], @geo.square? - end - - should "report that #{args[6]} is the larger dimension" do - assert_equal args[6], @geo.larger - end - - should "report that #{args[7]} is the smaller dimension" do - assert_equal args[7], @geo.smaller - end - - should "have an aspect ratio of #{args[8]}" do - assert_in_delta args[8], @geo.aspect, 0.0001 - end - end - end - - [[ [1000, 100], [64, 64], "x64", "64x64+288+0" ], - [ [100, 1000], [50, 950], "x950", "50x950+22+0" ], - [ [100, 1000], [50, 25], "50x", "50x25+0+237" ]]. each do |args| - context "of #{args[0].inspect} and given a Geometry #{args[1].inspect} and sent transform_to" do - setup do - @geo = Paperclip::Geometry.new(*args[0]) - @dst = Paperclip::Geometry.new(*args[1]) - @scale, @crop = @geo.transformation_to @dst, true - end - - should "be able to return the correct scaling transformation geometry #{args[2]}" do - assert_equal args[2], @scale - end - - should "be able to return the correct crop transformation geometry #{args[3]}" do - assert_equal args[3], @crop - end - end - end - end -end diff --git a/vendor/plugins/paperclip/test/helper.rb b/vendor/plugins/paperclip/test/helper.rb deleted file mode 100644 index 3e7e6a1..0000000 --- a/vendor/plugins/paperclip/test/helper.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rubygems' -require 'test/unit' -gem 'thoughtbot-shoulda', ">= 2.9.0" -require 'shoulda' -require 'mocha' -require 'tempfile' - -gem 'sqlite3-ruby' - -require 'active_record' -require 'active_support' -begin - require 'ruby-debug' -rescue LoadError - puts "ruby-debug not loaded" -end - -ROOT = File.join(File.dirname(__FILE__), '..') -RAILS_ROOT = ROOT - -$LOAD_PATH << File.join(ROOT, 'lib') -$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip') - -require File.join(ROOT, 'lib', 'paperclip.rb') - -require 'shoulda_macros/paperclip' - -ENV['RAILS_ENV'] ||= 'test' - -FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures") -config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) -ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") -ActiveRecord::Base.establish_connection(config['test']) - -def reset_class class_name - ActiveRecord::Base.send(:include, Paperclip) - Object.send(:remove_const, class_name) rescue nil - klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) - klass.class_eval{ include Paperclip } - klass -end - -def reset_table table_name, &block - block ||= lambda{ true } - ActiveRecord::Base.connection.create_table :dummies, {:force => true}, &block -end - -def modify_table table_name, &block - ActiveRecord::Base.connection.change_table :dummies, &block -end - -def rebuild_model options = {} - ActiveRecord::Base.connection.create_table :dummies, :force => true do |table| - table.column :other, :string - table.column :avatar_file_name, :string - table.column :avatar_content_type, :string - table.column :avatar_file_size, :integer - table.column :avatar_updated_at, :datetime - end - rebuild_class options -end - -def rebuild_class options = {} - ActiveRecord::Base.send(:include, Paperclip) - Object.send(:remove_const, "Dummy") rescue nil - Object.const_set("Dummy", Class.new(ActiveRecord::Base)) - Dummy.class_eval do - include Paperclip - has_attached_file :avatar, options - end -end - -def temporary_rails_env(new_env) - old_env = defined?(RAILS_ENV) ? RAILS_ENV : nil - silence_warnings do - Object.const_set("RAILS_ENV", new_env) - end - yield - silence_warnings do - Object.const_set("RAILS_ENV", old_env) - end -end diff --git a/vendor/plugins/paperclip/test/integration_test.rb b/vendor/plugins/paperclip/test/integration_test.rb deleted file mode 100644 index f7014ac..0000000 --- a/vendor/plugins/paperclip/test/integration_test.rb +++ /dev/null @@ -1,481 +0,0 @@ -require 'test/helper' - -class IntegrationTest < Test::Unit::TestCase - context "Many models at once" do - setup do - rebuild_model - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - 300.times do |i| - Dummy.create! :avatar => @file - end - end - - should "not exceed the open file limit" do - assert_nothing_raised do - dummies = Dummy.find(:all) - dummies.each { |dummy| dummy.avatar } - end - end - end - - context "An attachment" do - setup do - rebuild_model :styles => { :thumb => "50x50#" } - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - assert @dummy.save - end - - teardown { @file.close } - - should "create its thumbnails properly" do - assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"` - end - - context "redefining its attachment styles" do - setup do - Dummy.class_eval do - has_attached_file :avatar, :styles => { :thumb => "150x25#" } - has_attached_file :avatar, :styles => { :thumb => "150x25#", :dynamic => lambda { |a| '50x50#' } } - end - @d2 = Dummy.find(@dummy.id) - @d2.avatar.reprocess! - @d2.save - end - - should "create its thumbnails properly" do - assert_match /\b150x25\b/, `identify "#{@dummy.avatar.path(:thumb)}"` - assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:dynamic)}"` - end - end - end - - context "A model that modifies its original" do - setup do - rebuild_model :styles => { :original => "2x2#" } - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - end - - should "report the file size of the processed file and not the original" do - assert_not_equal @file.size, @dummy.avatar.size - end - - teardown { @file.close } - end - - context "A model with attachments scoped under an id" do - setup do - rebuild_model :styles => { :large => "100x100", - :medium => "50x50" }, - :path => ":rails_root/tmp/:id/:attachments/:style.:extension" - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - end - - teardown { @file.close } - - context "when saved" do - setup do - @dummy.save - @saved_path = @dummy.avatar.path(:large) - end - - should "have a large file in the right place" do - assert File.exists?(@dummy.avatar.path(:large)) - end - - context "and deleted" do - setup do - @dummy.avatar.clear - @dummy.save - end - - should "not have a large file in the right place anymore" do - assert ! File.exists?(@saved_path) - end - - should "not have its next two parent directories" do - assert ! File.exists?(File.dirname(@saved_path)) - assert ! File.exists?(File.dirname(File.dirname(@saved_path))) - end - - before_should "not die if an unexpected SystemCallError happens" do - FileUtils.stubs(:rmdir).raises(Errno::EPIPE) - end - end - end - end - - context "A model with no attachment validation" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - @dummy = Dummy.new - end - - should "have its definition return false when asked about whiny_thumbnails" do - assert ! Dummy.attachment_definitions[:avatar][:whiny_thumbnails] - end - - context "when validates_attachment_thumbnails is called" do - setup do - Dummy.validates_attachment_thumbnails :avatar - end - - should "have its definition return true when asked about whiny_thumbnails" do - assert_equal true, Dummy.attachment_definitions[:avatar][:whiny_thumbnails] - end - end - - context "redefined to have attachment validations" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :whiny_thumbnails => true, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - end - - should "have its definition return true when asked about whiny_thumbnails" do - assert_equal true, Dummy.attachment_definitions[:avatar][:whiny_thumbnails] - end - end - end - - context "A model with no convert_options setting" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - @dummy = Dummy.new - end - - should "have its definition return nil when asked about convert_options" do - assert ! Dummy.attachment_definitions[:avatar][:convert_options] - end - - context "redefined to have convert_options setting" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :convert_options => "-strip -depth 8", - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - end - - should "have its definition return convert_options value when asked about convert_options" do - assert_equal "-strip -depth 8", Dummy.attachment_definitions[:avatar][:convert_options] - end - end - end - - context "A model with a filesystem attachment" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :whiny_thumbnails => true, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - @dummy = Dummy.new - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - @bad_file = File.new(File.join(FIXTURES_DIR, "bad.png"), 'rb') - - assert @dummy.avatar = @file - assert @dummy.valid? - assert @dummy.save - end - - should "write and delete its files" do - [["434x66", :original], - ["300x46", :large], - ["100x15", :medium], - ["32x32", :thumb]].each do |geo, style| - cmd = %Q[identify -format "%wx%h" "#{@dummy.avatar.path(style)}"] - assert_equal geo, `#{cmd}`.chomp, cmd - end - - saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.path(s) } - - @d2 = Dummy.find(@dummy.id) - assert_equal "100x15", `identify -format "%wx%h" "#{@d2.avatar.path}"`.chomp - assert_equal "434x66", `identify -format "%wx%h" "#{@d2.avatar.path(:original)}"`.chomp - assert_equal "300x46", `identify -format "%wx%h" "#{@d2.avatar.path(:large)}"`.chomp - assert_equal "100x15", `identify -format "%wx%h" "#{@d2.avatar.path(:medium)}"`.chomp - assert_equal "32x32", `identify -format "%wx%h" "#{@d2.avatar.path(:thumb)}"`.chomp - - @dummy.avatar = "not a valid file but not nil" - assert_equal File.basename(@file.path), @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_paths.each do |p| - assert File.exists?(p) - end - - @dummy.avatar.clear - assert_nil @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_paths.each do |p| - assert ! File.exists?(p) - end - - @d2 = Dummy.find(@dummy.id) - assert_nil @d2.avatar_file_name - end - - should "work exactly the same when new as when reloaded" do - @d2 = Dummy.find(@dummy.id) - - assert_equal @dummy.avatar_file_name, @d2.avatar_file_name - [:thumb, :medium, :large, :original].each do |style| - assert_equal @dummy.avatar.path(style), @d2.avatar.path(style) - end - - saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.path(s) } - - @d2.avatar.clear - assert @d2.save - - saved_paths.each do |p| - assert ! File.exists?(p) - end - end - - should "know the difference between good files, bad files, and not files" do - expected = @dummy.avatar.to_file - @dummy.avatar = "not a file" - assert @dummy.valid? - assert_equal expected.path, @dummy.avatar.path - expected.close - - @dummy.avatar = @bad_file - assert ! @dummy.valid? - end - - should "know the difference between good files, bad files, and not files when validating" do - Dummy.validates_attachment_presence :avatar - @d2 = Dummy.find(@dummy.id) - @d2.avatar = @file - assert @d2.valid?, @d2.errors.full_messages.inspect - @d2.avatar = @bad_file - assert ! @d2.valid? - end - - should "be able to reload without saving and not have the file disappear" do - @dummy.avatar = @file - assert @dummy.save - @dummy.avatar.clear - assert_nil @dummy.avatar_file_name - @dummy.reload - assert_equal "5k.png", @dummy.avatar_file_name - end - - context "that is assigned its file from another Paperclip attachment" do - setup do - @dummy2 = Dummy.new - @file2 = File.new(File.join(FIXTURES_DIR, "12k.png"), 'rb') - assert @dummy2.avatar = @file2 - @dummy2.save - end - - should "work when assigned a file" do - assert_not_equal `identify -format "%wx%h" "#{@dummy.avatar.path(:original)}"`, - `identify -format "%wx%h" "#{@dummy2.avatar.path(:original)}"` - - assert @dummy.avatar = @dummy2.avatar - @dummy.save - assert_equal `identify -format "%wx%h" "#{@dummy.avatar.path(:original)}"`, - `identify -format "%wx%h" "#{@dummy2.avatar.path(:original)}"` - end - end - - end - - context "A model with an attachments association and a Paperclip attachment" do - setup do - Dummy.class_eval do - has_many :attachments, :class_name => 'Dummy' - end - - @dummy = Dummy.new - @dummy.avatar = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - end - - should "should not error when saving" do - assert_nothing_raised do - @dummy.save! - end - end - end - - if ENV['S3_TEST_BUCKET'] - def s3_files_for attachment - [:thumb, :medium, :large, :original].inject({}) do |files, style| - data = `curl "#{attachment.url(style)}" 2>/dev/null`.chomp - t = Tempfile.new("paperclip-test") - t.binmode - t.write(data) - t.rewind - files[style] = t - files - end - end - - def s3_headers_for attachment, style - `curl --head "#{attachment.url(style)}" 2>/dev/null`.split("\n").inject({}) do |h,head| - split_head = head.chomp.split(/\s*:\s*/, 2) - h[split_head.first.downcase] = split_head.last unless split_head.empty? - h - end - end - - context "A model with an S3 attachment" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :storage => :s3, - :whiny_thumbnails => true, - # :s3_options => {:logger => Logger.new(StringIO.new)}, - :s3_credentials => File.new(File.join(File.dirname(__FILE__), "s3.yml")), - :default_style => :medium, - :bucket => ENV['S3_TEST_BUCKET'], - :path => ":class/:attachment/:id/:style/:basename.:extension" - @dummy = Dummy.new - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - @bad_file = File.new(File.join(FIXTURES_DIR, "bad.png"), 'rb') - - assert @dummy.avatar = @file - assert @dummy.valid? - assert @dummy.save - - @files_on_s3 = s3_files_for @dummy.avatar - end - - should "write and delete its files" do - [["434x66", :original], - ["300x46", :large], - ["100x15", :medium], - ["32x32", :thumb]].each do |geo, style| - cmd = %Q[identify -format "%wx%h" "#{@files_on_s3[style].path}"] - assert_equal geo, `#{cmd}`.chomp, cmd - end - - @d2 = Dummy.find(@dummy.id) - @d2_files = s3_files_for @d2.avatar - [["434x66", :original], - ["300x46", :large], - ["100x15", :medium], - ["32x32", :thumb]].each do |geo, style| - cmd = %Q[identify -format "%wx%h" "#{@d2_files[style].path}"] - assert_equal geo, `#{cmd}`.chomp, cmd - end - - @dummy.avatar = "not a valid file but not nil" - assert_equal File.basename(@file.path), @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_keys = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_file(s) } - - saved_keys.each do |key| - assert key.exists? - end - - @dummy.avatar.clear - assert_nil @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_keys.each do |key| - assert ! key.exists? - end - - @d2 = Dummy.find(@dummy.id) - assert_nil @d2.avatar_file_name - end - - should "work exactly the same when new as when reloaded" do - @d2 = Dummy.find(@dummy.id) - - assert_equal @dummy.avatar_file_name, @d2.avatar_file_name - [:thumb, :medium, :large, :original].each do |style| - assert_equal @dummy.avatar.to_file(style).to_s, @d2.avatar.to_file(style).to_s - end - - saved_keys = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_file(s) } - - @d2.avatar.clear - assert @d2.save - - saved_keys.each do |key| - assert ! key.exists? - end - end - - should "know the difference between good files, bad files, not files, and nil" do - expected = @dummy.avatar.to_file - @dummy.avatar = "not a file" - assert @dummy.valid? - assert_equal expected.full_name, @dummy.avatar.to_file.full_name - - @dummy.avatar = @bad_file - assert ! @dummy.valid? - @dummy.avatar = nil - assert @dummy.valid? - - Dummy.validates_attachment_presence :avatar - @d2 = Dummy.find(@dummy.id) - @d2.avatar = @file - assert @d2.valid? - @d2.avatar = @bad_file - assert ! @d2.valid? - @d2.avatar = nil - assert ! @d2.valid? - end - - should "be able to reload without saving and not have the file disappear" do - @dummy.avatar = @file - assert @dummy.save - @dummy.avatar = nil - assert_nil @dummy.avatar_file_name - @dummy.reload - assert_equal "5k.png", @dummy.avatar_file_name - end - - should "have the right content type" do - headers = s3_headers_for(@dummy.avatar, :original) - p headers - assert_equal 'image/png', headers['content-type'] - end - end - end -end - diff --git a/vendor/plugins/paperclip/test/iostream_test.rb b/vendor/plugins/paperclip/test/iostream_test.rb deleted file mode 100644 index 97030b5..0000000 --- a/vendor/plugins/paperclip/test/iostream_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'test/helper' - -class IOStreamTest < Test::Unit::TestCase - context "IOStream" do - should "be included in IO, File, Tempfile, and StringIO" do - [IO, File, Tempfile, StringIO].each do |klass| - assert klass.included_modules.include?(IOStream), "Not in #{klass}" - end - end - end - - context "A file" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') - end - - teardown { @file.close } - - context "that is sent #stream_to" do - - context "and given a String" do - setup do - FileUtils.mkdir_p(File.join(ROOT, 'tmp')) - assert @result = @file.stream_to(File.join(ROOT, 'tmp', 'iostream.string.test')) - end - - should "return a File" do - assert @result.is_a?(File) - end - - should "contain the same data as the original file" do - @file.rewind; @result.rewind - assert_equal @file.read, @result.read - end - end - - context "and given a Tempfile" do - setup do - tempfile = Tempfile.new('iostream.test') - tempfile.binmode - assert @result = @file.stream_to(tempfile) - end - - should "return a Tempfile" do - assert @result.is_a?(Tempfile) - end - - should "contain the same data as the original file" do - @file.rewind; @result.rewind - assert_equal @file.read, @result.read - end - end - - end - - context "that is sent #to_tempfile" do - setup do - assert @tempfile = @file.to_tempfile - end - - should "convert it to a Tempfile" do - assert @tempfile.is_a?(Tempfile) - end - - should "have the Tempfile contain the same data as the file" do - @file.rewind; @tempfile.rewind - assert_equal @file.read, @tempfile.read - end - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb deleted file mode 100644 index b29ec37..0000000 --- a/vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/helper' - -class HaveAttachedFileMatcherTest < Test::Unit::TestCase - context "have_attached_file" do - setup do - @dummy_class = reset_class "Dummy" - reset_table "dummies" - @matcher = self.class.have_attached_file(:avatar) - end - - should "reject a class with no attachment" do - assert_rejects @matcher, @dummy_class - end - - should "accept a class with an attachment" do - modify_table("dummies"){|d| d.string :avatar_file_name } - @dummy_class.has_attached_file :avatar - assert_accepts @matcher, @dummy_class - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb deleted file mode 100644 index 241eb5f..0000000 --- a/vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'test/helper' - -class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase - context "validate_attachment_content_type" do - setup do - reset_table("dummies") do |d| - d.string :avatar_file_name - end - @dummy_class = reset_class "Dummy" - @dummy_class.has_attached_file :avatar - @matcher = self.class.validate_attachment_content_type(:avatar). - allowing(%w(image/png image/jpeg)). - rejecting(%w(audio/mp3 application/octet-stream)) - end - - should "reject a class with no validation" do - assert_rejects @matcher, @dummy_class - end - - should "reject a class with a validation that doesn't match" do - @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{audio/.*} - assert_rejects @matcher, @dummy_class - end - - should "accept a class with a validation" do - @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{image/.*} - assert_accepts @matcher, @dummy_class - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb deleted file mode 100644 index 860a760..0000000 --- a/vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/helper' - -class ValidateAttachmentPresenceMatcherTest < Test::Unit::TestCase - context "validate_attachment_presence" do - setup do - reset_table("dummies"){|d| d.string :avatar_file_name } - @dummy_class = reset_class "Dummy" - @dummy_class.has_attached_file :avatar - @matcher = self.class.validate_attachment_presence(:avatar) - end - - should "reject a class with no validation" do - assert_rejects @matcher, @dummy_class - end - - should "accept a class with a validation" do - @dummy_class.validates_attachment_presence :avatar - assert_accepts @matcher, @dummy_class - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb deleted file mode 100644 index 7e4c9b4..0000000 --- a/vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'test/helper' - -class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase - context "validate_attachment_size" do - setup do - reset_table("dummies") do |d| - d.string :avatar_file_name - end - @dummy_class = reset_class "Dummy" - @dummy_class.has_attached_file :avatar - end - - context "of limited size" do - setup{ @matcher = self.class.validate_attachment_size(:avatar).in(256..1024) } - - should "reject a class with no validation" do - assert_rejects @matcher, @dummy_class - end - - should "reject a class with a validation that's too high" do - @dummy_class.validates_attachment_size :avatar, :in => 256..2048 - assert_rejects @matcher, @dummy_class - end - - should "reject a class with a validation that's too low" do - @dummy_class.validates_attachment_size :avatar, :in => 0..1024 - assert_rejects @matcher, @dummy_class - end - - should "accept a class with a validation that matches" do - @dummy_class.validates_attachment_size :avatar, :in => 256..1024 - assert_accepts @matcher, @dummy_class - end - end - - context "validates_attachment_size with infinite range" do - setup{ @matcher = self.class.validate_attachment_size(:avatar) } - - should "accept a class with an upper limit" do - @dummy_class.validates_attachment_size :avatar, :less_than => 1 - assert_accepts @matcher, @dummy_class - end - - should "accept a class with no upper limit" do - @dummy_class.validates_attachment_size :avatar, :greater_than => 1 - assert_accepts @matcher, @dummy_class - end - end - end -end diff --git a/vendor/plugins/paperclip/test/paperclip_test.rb b/vendor/plugins/paperclip/test/paperclip_test.rb deleted file mode 100644 index 8365649..0000000 --- a/vendor/plugins/paperclip/test/paperclip_test.rb +++ /dev/null @@ -1,233 +0,0 @@ -require 'test/helper' - -class PaperclipTest < Test::Unit::TestCase - [:image_magick_path, :convert_path].each do |path| - context "Calling Paperclip.run with an #{path} specified" do - setup do - Paperclip.options[:image_magick_path] = nil - Paperclip.options[:convert_path] = nil - Paperclip.options[path] = "/usr/bin" - end - - should "execute the right command" do - Paperclip.expects(:path_for_command).with("convert").returns("/usr/bin/convert") - Paperclip.expects(:bit_bucket).returns("/dev/null") - Paperclip.expects(:"`").with("/usr/bin/convert one.jpg two.jpg 2>/dev/null") - Paperclip.run("convert", "one.jpg two.jpg") - end - end - end - - context "Calling Paperclip.run with no path specified" do - setup do - Paperclip.options[:image_magick_path] = nil - Paperclip.options[:convert_path] = nil - end - - should "execute the right command" do - Paperclip.expects(:path_for_command).with("convert").returns("convert") - Paperclip.expects(:bit_bucket).returns("/dev/null") - Paperclip.expects(:"`").with("convert one.jpg two.jpg 2>/dev/null") - Paperclip.run("convert", "one.jpg two.jpg") - end - end - - should "raise when sent #processor and the name of a class that exists but isn't a subclass of Processor" do - assert_raises(Paperclip::PaperclipError){ Paperclip.processor(:attachment) } - end - - should "raise when sent #processor and the name of a class that doesn't exist" do - assert_raises(NameError){ Paperclip.processor(:boogey_man) } - end - - should "return a class when sent #processor and the name of a class under Paperclip" do - assert_equal ::Paperclip::Thumbnail, Paperclip.processor(:thumbnail) - end - - context "Paperclip.bit_bucket" do - context "on systems without /dev/null" do - setup do - File.expects(:exists?).with("/dev/null").returns(false) - end - - should "return 'NUL'" do - assert_equal "NUL", Paperclip.bit_bucket - end - end - - context "on systems with /dev/null" do - setup do - File.expects(:exists?).with("/dev/null").returns(true) - end - - should "return '/dev/null'" do - assert_equal "/dev/null", Paperclip.bit_bucket - end - end - end - - context "An ActiveRecord model with an 'avatar' attachment" do - setup do - rebuild_model :path => "tmp/:class/omg/:style.:extension" - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - end - - teardown { @file.close } - - should "not error when trying to also create a 'blah' attachment" do - assert_nothing_raised do - Dummy.class_eval do - has_attached_file :blah - end - end - end - - context "that is attr_protected" do - setup do - Dummy.class_eval do - attr_protected :avatar - end - @dummy = Dummy.new - end - - should "not assign the avatar on mass-set" do - @dummy.attributes = { :other => "I'm set!", - :avatar => @file } - - assert_equal "I'm set!", @dummy.other - assert ! @dummy.avatar? - end - - should "still allow assigment on normal set" do - @dummy.other = "I'm set!" - @dummy.avatar = @file - - assert_equal "I'm set!", @dummy.other - assert @dummy.avatar? - end - end - - context "with a subclass" do - setup do - class ::SubDummy < Dummy; end - end - - should "be able to use the attachment from the subclass" do - assert_nothing_raised do - @subdummy = SubDummy.create(:avatar => @file) - end - end - - should "be able to see the attachment definition from the subclass's class" do - assert_equal "tmp/:class/omg/:style.:extension", SubDummy.attachment_definitions[:avatar][:path] - end - - teardown do - Object.send(:remove_const, "SubDummy") rescue nil - end - end - - should "have an #avatar method" do - assert Dummy.new.respond_to?(:avatar) - end - - should "have an #avatar= method" do - assert Dummy.new.respond_to?(:avatar=) - end - - context "that is valid" do - setup do - @dummy = Dummy.new - @dummy.avatar = @file - end - - should "be valid" do - assert @dummy.valid? - end - - context "then has a validation added that makes it invalid" do - setup do - assert @dummy.save - Dummy.class_eval do - validates_attachment_content_type :avatar, :content_type => ["text/plain"] - end - @dummy2 = Dummy.find(@dummy.id) - end - - should "be invalid when reloaded" do - assert ! @dummy2.valid?, @dummy2.errors.inspect - end - - should "be able to call #valid? twice without having duplicate errors" do - @dummy2.avatar.valid? - first_errors = @dummy2.avatar.errors - @dummy2.avatar.valid? - assert_equal first_errors, @dummy2.avatar.errors - end - end - end - - def self.should_validate validation, options, valid_file, invalid_file - context "with #{validation} validation and #{options.inspect} options" do - setup do - Dummy.send(:"validates_attachment_#{validation}", :avatar, options) - @dummy = Dummy.new - end - context "and assigning nil" do - setup do - @dummy.avatar = nil - @dummy.valid? - end - if validation == :presence - should "have an error on the attachment" do - assert @dummy.errors.on(:avatar) - end - else - should "not have an error on the attachment" do - assert_nil @dummy.errors.on(:avatar) - end - end - end - context "and assigned a valid file" do - setup do - @dummy.avatar = valid_file - @dummy.valid? - end - should "not have an error when assigned a valid file" do - assert ! @dummy.avatar.errors.key?(validation) - end - should "not have an error on the attachment" do - assert_nil @dummy.errors.on(:avatar) - end - end - context "and assigned an invalid file" do - setup do - @dummy.avatar = invalid_file - @dummy.valid? - end - should "have an error when assigned a valid file" do - assert_not_nil @dummy.avatar.errors[validation] - end - should "have an error on the attachment" do - assert @dummy.errors.on(:avatar) - end - end - end - end - - [[:presence, {}, "5k.png", nil], - [:size, {:in => 1..10240}, nil, "12k.png"], - [:size, {:less_than => 10240}, "5k.png", "12k.png"], - [:size, {:greater_than => 8096}, "12k.png", "5k.png"], - [:content_type, {:content_type => "image/png"}, "5k.png", "text.txt"], - [:content_type, {:content_type => "text/plain"}, "text.txt", "5k.png"], - [:content_type, {:content_type => %r{image/.*}}, "5k.png", "text.txt"]].each do |args| - validation, options, valid_file, invalid_file = args - valid_file &&= File.open(File.join(FIXTURES_DIR, valid_file), "rb") - invalid_file &&= File.open(File.join(FIXTURES_DIR, invalid_file), "rb") - - should_validate validation, options, valid_file, invalid_file - end - - end -end diff --git a/vendor/plugins/paperclip/test/processor_test.rb b/vendor/plugins/paperclip/test/processor_test.rb deleted file mode 100644 index a05f0a9..0000000 --- a/vendor/plugins/paperclip/test/processor_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test/helper' - -class ProcessorTest < Test::Unit::TestCase - should "instantiate and call #make when sent #make to the class" do - processor = mock - processor.expects(:make).with() - Paperclip::Processor.expects(:new).with(:one, :two, :three).returns(processor) - Paperclip::Processor.make(:one, :two, :three) - end -end diff --git a/vendor/plugins/paperclip/test/storage_test.rb b/vendor/plugins/paperclip/test/storage_test.rb deleted file mode 100644 index e2ed8a4..0000000 --- a/vendor/plugins/paperclip/test/storage_test.rb +++ /dev/null @@ -1,277 +0,0 @@ -require 'test/helper' - -class StorageTest < Test::Unit::TestCase - context "Parsing S3 credentials" do - setup do - rebuild_model :storage => :s3, - :bucket => "testing", - :s3_credentials => {:not => :important} - - @dummy = Dummy.new - @avatar = @dummy.avatar - - @current_env = ENV['RAILS_ENV'] - end - - teardown do - ENV['RAILS_ENV'] = @current_env - end - - should "get the correct credentials when RAILS_ENV is production" do - ENV['RAILS_ENV'] = 'production' - assert_equal({:key => "12345"}, - @avatar.parse_credentials('production' => {:key => '12345'}, - :development => {:key => "54321"})) - end - - should "get the correct credentials when RAILS_ENV is development" do - ENV['RAILS_ENV'] = 'development' - assert_equal({:key => "54321"}, - @avatar.parse_credentials('production' => {:key => '12345'}, - :development => {:key => "54321"})) - end - - should "return the argument if the key does not exist" do - ENV['RAILS_ENV'] = "not really an env" - assert_equal({:test => "12345"}, @avatar.parse_credentials(:test => "12345")) - end - end - - context "" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => {}, - :bucket => "bucket", - :path => ":attachment/:basename.:extension", - :url => ":s3_path_url" - @dummy = Dummy.new - @dummy.avatar = StringIO.new(".") - end - - should "return a url based on an S3 path" do - assert_match %r{^http://s3.amazonaws.com/bucket/avatars/stringio.txt}, @dummy.avatar.url - end - end - context "" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => {}, - :bucket => "bucket", - :path => ":attachment/:basename.:extension", - :url => ":s3_domain_url" - @dummy = Dummy.new - @dummy.avatar = StringIO.new(".") - end - - should "return a url based on an S3 subdomain" do - assert_match %r{^http://bucket.s3.amazonaws.com/avatars/stringio.txt}, @dummy.avatar.url - end - end - context "" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => { - :production => { :bucket => "prod_bucket" }, - :development => { :bucket => "dev_bucket" } - }, - :s3_host_alias => "something.something.com", - :path => ":attachment/:basename.:extension", - :url => ":s3_alias_url" - @dummy = Dummy.new - @dummy.avatar = StringIO.new(".") - end - - should "return a url based on the host_alias" do - assert_match %r{^http://something.something.com/avatars/stringio.txt}, @dummy.avatar.url - end - end - - context "Parsing S3 credentials with a bucket in them" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => { - :production => { :bucket => "prod_bucket" }, - :development => { :bucket => "dev_bucket" } - } - @dummy = Dummy.new - end - - should "get the right bucket in production", :before => lambda{ ENV.expects(:[]).returns('production') } do - assert_equal "prod_bucket", @dummy.avatar.bucket_name - end - - should "get the right bucket in development", :before => lambda{ ENV.expects(:[]).returns('development') } do - assert_equal "dev_bucket", @dummy.avatar.bucket_name - end - end - - context "An attachment with S3 storage" do - setup do - rebuild_model :storage => :s3, - :bucket => "testing", - :path => ":attachment/:style/:basename.:extension", - :s3_credentials => { - 'access_key_id' => "12345", - 'secret_access_key' => "54321" - } - end - - should "be extended by the S3 module" do - assert Dummy.new.avatar.is_a?(Paperclip::Storage::S3) - end - - should "not be extended by the Filesystem module" do - assert ! Dummy.new.avatar.is_a?(Paperclip::Storage::Filesystem) - end - - context "when assigned" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb') - @dummy = Dummy.new - @dummy.avatar = @file - end - - teardown { @file.close } - - should "not get a bucket to get a URL" do - @dummy.avatar.expects(:s3).never - @dummy.avatar.expects(:s3_bucket).never - assert_match %r{^http://s3\.amazonaws\.com/testing/avatars/original/5k\.png}, @dummy.avatar.url - end - - context "and saved" do - setup do - @s3_mock = stub - @bucket_mock = stub - RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock) - @s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock) - @key_mock = stub - @bucket_mock.expects(:key).returns(@key_mock) - @key_mock.expects(:data=) - @key_mock.expects(:put).with(nil, 'public-read', 'Content-type' => 'image/png') - @dummy.save - end - - should "succeed" do - assert true - end - end - - context "and remove" do - setup do - @s3_mock = stub - @bucket_mock = stub - RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock) - @s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock) - @key_mock = stub - @bucket_mock.expects(:key).at_least(2).returns(@key_mock) - @key_mock.expects(:delete) - @dummy.destroy_attached_files - end - - should "succeed" do - assert true - end - end - end - end - - context "An attachment with S3 storage and bucket defined as a Proc" do - setup do - rebuild_model :storage => :s3, - :bucket => lambda { |attachment| "bucket_#{attachment.instance.other}" }, - :s3_credentials => {:not => :important} - end - - should "get the right bucket name" do - assert "bucket_a", Dummy.new(:other => 'a').avatar.bucket_name - assert "bucket_b", Dummy.new(:other => 'b').avatar.bucket_name - end - end - - context "An attachment with S3 storage and specific s3 headers set" do - setup do - rebuild_model :storage => :s3, - :bucket => "testing", - :path => ":attachment/:style/:basename.:extension", - :s3_credentials => { - 'access_key_id' => "12345", - 'secret_access_key' => "54321" - }, - :s3_headers => {'Cache-Control' => 'max-age=31557600'} - end - - context "when assigned" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb') - @dummy = Dummy.new - @dummy.avatar = @file - end - - teardown { @file.close } - - context "and saved" do - setup do - @s3_mock = stub - @bucket_mock = stub - RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock) - @s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock) - @key_mock = stub - @bucket_mock.expects(:key).returns(@key_mock) - @key_mock.expects(:data=) - @key_mock.expects(:put).with(nil, - 'public-read', - 'Content-type' => 'image/png', - 'Cache-Control' => 'max-age=31557600') - @dummy.save - end - - should "succeed" do - assert true - end - end - end - end - - unless ENV["S3_TEST_BUCKET"].blank? - context "Using S3 for real, an attachment with S3 storage" do - setup do - rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, - :storage => :s3, - :bucket => ENV["S3_TEST_BUCKET"], - :path => ":class/:attachment/:id/:style.:extension", - :s3_credentials => File.new(File.join(File.dirname(__FILE__), "s3.yml")) - - Dummy.delete_all - @dummy = Dummy.new - end - - should "be extended by the S3 module" do - assert Dummy.new.avatar.is_a?(Paperclip::Storage::S3) - end - - context "when assigned" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb') - @dummy.avatar = @file - end - - teardown { @file.close } - - should "still return a Tempfile when sent #to_io" do - assert_equal Tempfile, @dummy.avatar.to_io.class - end - - context "and saved" do - setup do - @dummy.save - end - - should "be on S3" do - assert true - end - end - end - end - end -end diff --git a/vendor/plugins/paperclip/test/thumbnail_test.rb b/vendor/plugins/paperclip/test/thumbnail_test.rb deleted file mode 100644 index 624e7fa..0000000 --- a/vendor/plugins/paperclip/test/thumbnail_test.rb +++ /dev/null @@ -1,177 +0,0 @@ -require 'test/helper' - -class ThumbnailTest < Test::Unit::TestCase - - context "A Paperclip Tempfile" do - setup do - @tempfile = Paperclip::Tempfile.new("file.jpg") - end - - should "have its path contain a real extension" do - assert_equal ".jpg", File.extname(@tempfile.path) - end - - should "be a real Tempfile" do - assert @tempfile.is_a?(::Tempfile) - end - end - - context "Another Paperclip Tempfile" do - setup do - @tempfile = Paperclip::Tempfile.new("file") - end - - should "not have an extension if not given one" do - assert_equal "", File.extname(@tempfile.path) - end - - should "still be a real Tempfile" do - assert @tempfile.is_a?(::Tempfile) - end - end - - context "An image" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') - end - - teardown { @file.close } - - [["600x600>", "434x66"], - ["400x400>", "400x61"], - ["32x32<", "434x66"] - ].each do |args| - context "being thumbnailed with a geometry of #{args[0]}" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, :geometry => args[0]) - end - - should "start with dimensions of 434x66" do - cmd = %Q[identify -format "%wx%h" "#{@file.path}"] - assert_equal "434x66", `#{cmd}`.chomp - end - - should "report the correct target geometry" do - assert_equal args[0], @thumb.target_geometry.to_s - end - - context "when made" do - setup do - @thumb_result = @thumb.make - end - - should "be the size we expect it to be" do - cmd = %Q[identify -format "%wx%h" "#{@thumb_result.path}"] - assert_equal args[1], `#{cmd}`.chomp - end - end - end - end - - context "being thumbnailed at 100x50 with cropping" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x50#") - end - - should "report its correct current and target geometries" do - assert_equal "100x50#", @thumb.target_geometry.to_s - assert_equal "434x66", @thumb.current_geometry.to_s - end - - should "report its correct format" do - assert_nil @thumb.format - end - - should "have whiny turned on by default" do - assert @thumb.whiny - end - - should "have convert_options set to nil by default" do - assert_equal nil, @thumb.convert_options - end - - should "send the right command to convert when sent #make" do - Paperclip.expects(:"`").with do |arg| - arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-resize\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+".*?"} - end - @thumb.make - end - - should "create the thumbnail when sent #make" do - dst = @thumb.make - assert_match /100x50/, `identify "#{dst.path}"` - end - end - - context "being thumbnailed with convert options set" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, - :geometry => "100x50#", - :convert_options => "-strip -depth 8") - end - - should "have convert_options value set" do - assert_equal "-strip -depth 8", @thumb.convert_options - end - - should "send the right command to convert when sent #make" do - Paperclip.expects(:"`").with do |arg| - arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-resize\s+"x50"\s+-crop\s+"100x50\+114\+0"\s+\+repage\s+-strip\s+-depth\s+8\s+".*?"} - end - @thumb.make - end - - should "create the thumbnail when sent #make" do - dst = @thumb.make - assert_match /100x50/, `identify "#{dst.path}"` - end - - context "redefined to have bad convert_options setting" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, - :geometry => "100x50#", - :convert_options => "-this-aint-no-option") - end - - should "error when trying to create the thumbnail" do - assert_raises(Paperclip::PaperclipError) do - @thumb.make - end - end - end - end - end - - context "A multipage PDF" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "twopage.pdf"), 'rb') - end - - teardown { @file.close } - - should "start with two pages with dimensions 612x792" do - cmd = %Q[identify -format "%wx%h" "#{@file.path}"] - assert_equal "612x792"*2, `#{cmd}`.chomp - end - - context "being thumbnailed at 100x100 with cropping" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x100#", :format => :png) - end - - should "report its correct current and target geometries" do - assert_equal "100x100#", @thumb.target_geometry.to_s - assert_equal "612x792", @thumb.current_geometry.to_s - end - - should "report its correct format" do - assert_equal :png, @thumb.format - end - - should "create the thumbnail when sent #make" do - dst = @thumb.make - assert_match /100x100/, `identify "#{dst.path}"` - end - end - end -end diff --git a/vendor/plugins/routing-filter/.gitignore b/vendor/plugins/routing-filter/.gitignore deleted file mode 100644 index 5657f6e..0000000 --- a/vendor/plugins/routing-filter/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor \ No newline at end of file diff --git a/vendor/plugins/routing-filter/MIT-LICENSE b/vendor/plugins/routing-filter/MIT-LICENSE deleted file mode 100644 index ac93a58..0000000 --- a/vendor/plugins/routing-filter/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 Sven Fuchs - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/plugins/routing-filter/README.markdown b/vendor/plugins/routing-filter/README.markdown deleted file mode 100644 index 77ee55d..0000000 --- a/vendor/plugins/routing-filter/README.markdown +++ /dev/null @@ -1,123 +0,0 @@ -## Routing Filter - -This plugin is a wild hack that wraps around the complex beast that the Rails -routing system is to allow for unseen flexibility and power in Rails URL -recognition and generation. - -As powerful and awesome the Rails' routes are, when you need to design your -URLs in a manner that only slightly leaves the paved cowpaths of Rails -conventions, you're usually unable to use all the goodness of helpers and -convenience that Rails ships with. - -## Usage - -This plugin comes with a locale routing filter that demonstrates the -implementation of a custom filter. - -The following would be a sceleton of an empty filter: - - module RoutingFilter - class Awesomeness < Base - def around_recognize(route, path, env) - # Alter the path here before it gets recognized. - # Make sure to yield (calls the next around filter if present and - # eventually `recognize_path` on the routeset): - returning yield do |params| - # You can additionally modify the params here before they get passed - # to the controller. - end - end - - def around_generate(controller, *args, &block) - # Alter arguments here before they are passed to `url_for`. - # Make sure to yield (calls the next around filter if present and - # eventually `url_for` on the controller): - returning yield do |result| - # You can change the generated url_or_path here. Make sure to use - # one of the "in-place" modifying String methods though (like sub! - # and friends). - end - end - end - end - -You then have to specify the filter explicitely in your routes.rb: - - ActionController::Routing::Routes.draw do |map| - map.filter 'awesomeness' - end - -(I am not sure if it makes sense to provide more technical information than -this because the usage of this plugin definitely requires some advanced -knowledge about Rails internals and especially its routing system. So, I -figure, anyone who could use this should also be able to read the code and -figure out what it's doing much better then from any lengthy documentation. - -If I'm mistaken on this please drop me an email with your suggestions.) - - -## Rationale: Two example usecases - -An early usecase from which this originated was the need to define a locale -at the beginning of an URL in a way so that - -* the locale can be omitted when it is the default locale -* all the url\_helpers that are generated by named routes continue to work in -a concise manner (i.e. without specifying all parameters again and again) -* ideally also plays nicely with default route helpers in tests/specs - -You can read about this struggle and two possible, yet unsatisfying solutions -[here](http://www.artweb-design.de/2007/5/13/concise-localized-rails-url-helpers-solved-twice). -The conclusion so far is that Rails itself does not provide the tools to solve -this problem in a clean and dry way. - -Another usecase that eventually spawned the manifestation of this plugin was -the need to map an arbitrary count of path segments to a certain model -instance. In an application that I've been working on recently I needed to -map URL paths to a nested tree of models like so: - - root - + docs - + api - + wiki - -E.g. the docs section should map to the path `/docs`, the api section to -the path `/docs/api` and so on. Furthermore, after these paths there need to be -more things to be specified. E.g. the wiki needs to define a whole Rails -resource with URLs like `/docs/wiki/pages/1/edit`. - -The only way to solve this problem with Rails' routing toolkit is to map -a big, bold `/*everything` catch-all ("globbing") route and process the whole -path in a custom dispatcher. - -This, of course, is a really unsatisfying solution because one has to -reimplement everything that Rails routes are here to help with: regarding both -URL recognition (like parameter mappings, resources, ...) and generation -(url\_helpers). - -## Solution - -This plugin offers a solution that takes exactly the opposite route. - -Instead of trying to change things *between* the URL recognition and -generation stages to achieve the desired result it *wraps around* the whole -routing system and allows to pre- and post-filter both what goes into it -(URL recognition) and what comes out of it (URL generation). - -This way we can leave *everything* else completely untouched. - -* We can tinker with the URLs that we receive from the server and feed URLs to -Rails that perfectly match the best breed of Rails' conventions. -* Inside of the application we can use all the nice helper goodness and -conveniences that rely on these conventions being followed. -* Finally we can accept URLs that have been generated by the url\_helpers and, -again, mutate them in the way that matches our requirements. - -So, even though the plugin itself is a blatant monkey-patch to one of the -most complex area of Rails internals, this solution seems to be effectively -less intrusive and pricey than others are. - -## Etc - -Authors: [Sven Fuchs](http://www.artweb-design.de) -License: MIT \ No newline at end of file diff --git a/vendor/plugins/routing-filter/init.rb b/vendor/plugins/routing-filter/init.rb deleted file mode 100644 index 1189921..0000000 --- a/vendor/plugins/routing-filter/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'routing_filter' \ No newline at end of file diff --git a/vendor/plugins/routing-filter/lib/routing_filter.rb b/vendor/plugins/routing-filter/lib/routing_filter.rb deleted file mode 100644 index d67be14..0000000 --- a/vendor/plugins/routing-filter/lib/routing_filter.rb +++ /dev/null @@ -1,69 +0,0 @@ -module RoutingFilter - mattr_accessor :active - @@active = true - - class Chain < Array - def << (filter) - filter.successor = last - super - end - - def run(method, *args, &final) - RoutingFilter.active ? last.run(method, *args, &final) : final.call - end - end -end - -# allows to install a filter to the route set by calling: map.filter 'locale' -ActionController::Routing::RouteSet::Mapper.class_eval do - def filter(name, options = {}) - require "routing_filter/#{name}" - klass = RoutingFilter.const_get name.to_s.camelize - @set.filters << klass.new(options) - end -end - -# same here for the optimized url generation in named routes -ActionController::Routing::RouteSet::NamedRouteCollection.class_eval do - # gosh. monkey engineering optimization code - def generate_optimisation_block_with_filtering(*args) - code = generate_optimisation_block_without_filtering *args - if match = code.match(%r(^return (.*) if (.*))) - # returned string must not contain newlines, or we'll spill out of inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806) - "returning(#{match[1]}) { |result| ActionController::Routing::Routes.filters.run :around_generate, *args, &lambda{ result } } if #{match[2]}" - end - end - alias_method_chain :generate_optimisation_block, :filtering -end - -ActionController::Routing::RouteSet.class_eval do - def filters - @filters ||= RoutingFilter::Chain.new - end - - def recognize_path_with_filtering(path, env) - path = path.dup # string is frozen due to memoize - filters.run :around_recognize, path, env, &lambda{ recognize_path_without_filtering(path, env) } - end - alias_method_chain :recognize_path, :filtering - - def generate_with_filtering(*args) - filters.run :around_generate, args.first, &lambda{ generate_without_filtering(*args) } - end - alias_method_chain :generate, :filtering - - # add some useful information to the request environment - # right, this is from jamis buck's excellent article about routes internals - # http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2 - # TODO move this ... where? - alias_method :extract_request_environment_without_host, :extract_request_environment unless method_defined? :extract_request_environment_without_host - def extract_request_environment(request) - returning extract_request_environment_without_host(request) do |env| - env.merge! :host => request.host, - :port => request.port, - :host_with_port => request.host_with_port, - :domain => request.domain, - :subdomain => request.subdomains.first - end - end -end \ No newline at end of file diff --git a/vendor/plugins/routing-filter/lib/routing_filter/base.rb b/vendor/plugins/routing-filter/lib/routing_filter/base.rb deleted file mode 100644 index bc60ba5..0000000 --- a/vendor/plugins/routing-filter/lib/routing_filter/base.rb +++ /dev/null @@ -1,15 +0,0 @@ -module RoutingFilter - class Base - attr_accessor :successor, :options - - def initialize(options) - @options = options - options.each{|name, value| instance_variable_set :"@#{name}", value } - end - - def run(method, *args, &block) - successor = @successor ? lambda { @successor.run(method, *args, &block) } : block - send method, *args, &successor - end - end -end \ No newline at end of file diff --git a/vendor/plugins/routing-filter/lib/routing_filter/locale.rb b/vendor/plugins/routing-filter/lib/routing_filter/locale.rb deleted file mode 100644 index 7c86a40..0000000 --- a/vendor/plugins/routing-filter/lib/routing_filter/locale.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'i18n' -require 'routing_filter/base' - -module RoutingFilter - class Locale < Base - @@default_locale = :he - cattr_reader :default_locale - - class << self - def default_locale=(locale) - @@default_locale = locale.to_sym - end - end - - # remove the locale from the beginning of the path, pass the path - # to the given block and set it to the resulting params hash - def around_recognize(path, env, &block) - locale = nil - path.sub! %r(^/([a-zA-Z]{2})(?=/|$)) do locale = $1; '' end - yield.tap do |params| - params[:locale] = locale if locale - end - end - - def around_generate(*args, &block) - locale = args.extract_options!.delete(:locale) || I18n.locale - yield.tap do |result| - if locale.to_sym != @@default_locale - target = result.is_a?(Array) ? result.first : result - target.sub!(%r(^(http.?://[^/]*)?(.*))){ "#{$1}/#{locale}#{$2}" } - end - end - end - end -end diff --git a/vendor/plugins/routing-filter/lib/routing_filter/pagination.rb b/vendor/plugins/routing-filter/lib/routing_filter/pagination.rb deleted file mode 100644 index a5bd7aa..0000000 --- a/vendor/plugins/routing-filter/lib/routing_filter/pagination.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'routing_filter/base' - -module RoutingFilter - class Pagination < Base - def around_recognize(path, env, &block) - path.gsub! %r(/pages/([\d]+)/?$), '' - returning yield(path, env) do |params| - params[:page] = $1.to_i if $1 - end - end - - def around_generate(*args, &block) - page = args.extract_options!.delete(:page) - returning yield do |result| - result.replace "#{result}/pages/#{page}" if page && page != 1 - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/routing-filter/spec/generation_spec.rb b/vendor/plugins/routing-filter/spec/generation_spec.rb deleted file mode 100644 index 224cd4e..0000000 --- a/vendor/plugins/routing-filter/spec/generation_spec.rb +++ /dev/null @@ -1,283 +0,0 @@ -require File.dirname(__FILE__) + '/spec_helper.rb' - -describe 'RoutingFilter', 'url generation' do - include RoutingFilterHelpers - - before :each do - RoutingFilter::Locale.default_locale = :en - I18n.default_locale = :en - I18n.locale = :en - - @controller = instantiate_controller :locale => 'de', :id => 1 - @set = draw_routes do |map| - map.section 'sections/:id', :controller => 'sections', :action => "show" - map.section_article 'sections/:section_id/articles/:id', :controller => 'articles', :action => "show" - - map.filter 'locale' - map.filter 'pagination' - end - - @site = Site.new - @section = Section.new - @article = Article.new - - @params = {:controller => 'sections', :action => "show", :id => "1"} - @article_params = {:controller => 'articles', :action => 'show', :section_id => "1", :id => "1"} - @locale_filter = @set.filters.first - - Section.stub!(:types).and_return ['Section'] - Section.stub!(:find).and_return @section - end - - def should_recognize_path(path, params) - @set.recognize_path(path, {}).should == params - end - - def section_path(*args) - @controller.send :section_path, *args - end - - def section_article_path(*args) - @controller.send :section_article_path, *args - end - - def url_for(*args) - @controller.send :url_for, *args - end - - describe "named route url_helpers" do - describe "a not nested resource" do - it 'does not change the section_path when the current locale is the default locale and no page option given' do - section_path(:id => 1).should == '/sections/1' - end - - it 'does not change the section_path when given page option equals 1' do - section_path(:id => 1, :page => 1).should == '/sections/1' - end - - it 'appends the pages segments to section_path when given page option does not equal 1' do - section_path(:id => 1, :page => 2).should == '/sections/1/pages/2' - end - - it 'prepends the current locale to section_path when it is not the default locale' do - I18n.locale = :de - section_path(:id => 1).should == '/de/sections/1' - end - - it 'prepends a given locale param to section_path when it is not the default locale' do - I18n.locale = :de - section_path(:id => 1, :locale => :fi).should == '/fi/sections/1' - end - - it 'works on section_path with both a locale and page option' do - section_path(:id => 1, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2' - end - end - - describe "a nested resource" do - it 'does not change the section_article_path when the current locale is the default locale and no page option given' do - section_article_path(:section_id => 1, :id => 1).should == '/sections/1/articles/1' - end - - it 'does not change the section_article_path when given page option equals 1' do - section_article_path(:section_id => 1, :id => 1, :page => 1).should == '/sections/1/articles/1' - end - - it 'appends the pages segments to section_article_path when given page option does not equal 1' do - section_article_path(:section_id => 1, :id => 1, :page => 2).should == '/sections/1/articles/1/pages/2' - end - - it 'prepends the current locale to section_article_path when it is not the default locale' do - I18n.locale = :de - section_article_path(:section_id => 1, :id => 1).should == '/de/sections/1/articles/1' - end - - it 'prepends a given locale param to section_article_path when it is not the default locale' do - I18n.locale = :de - section_article_path(:section_id => 1, :id => 1, :locale => :fi).should == '/fi/sections/1/articles/1' - end - - it 'works on section_article_path with both a locale and page option' do - section_article_path(:section_id => 1, :id => 1, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2' - end - end - end - - describe 'when used with named route url_helper with "optimized" generation blocks' do - describe "a not nested resource" do - # uses optimization - it 'does not change the section_path when the current locale is the default locale and no page option given' do - section_path(1).should == '/sections/1' - end - - # uses optimization - it 'prepends the current locale to section_path when it is not the default locale' do - I18n.locale = :de - section_path(1).should == '/de/sections/1' - end - - it 'prepends a given locale param to section_path when it is not the default locale' do - I18n.locale = :de - section_path(1, :locale => :fi).should == '/fi/sections/1' - end - - it 'does not change the section_path when given page option equals 1' do - section_path(1, :page => 1).should == '/sections/1' - end - - it 'appends the pages segments to section_path when given page option does not equal 1' do - section_path(1, :page => 2).should == '/sections/1/pages/2' - end - - it 'works for section_path with both a locale and page option' do - section_path(1, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2' - end - end - - describe "a nested resource" do - # uses optimization - it 'does not change the section_article_path when the current locale is the default locale and no page option given' do - section_article_path(1, 1).should == '/sections/1/articles/1' - end - - # uses optimization - it 'prepends the current locale to section_article_path when it is not the default locale' do - I18n.locale = :de - section_article_path(1, 1).should == '/de/sections/1/articles/1' - end - - it 'prepends a given locale param when it is not the default locale' do - I18n.locale = :de - section_article_path(1, 1, :locale => :fi).should == '/fi/sections/1/articles/1' - end - - it 'does not change the section_article_path when given page option equals 1' do - section_article_path(1, 1, :page => 1).should == '/sections/1/articles/1' - end - - it 'appends the pages segments to section_article_path when given page option does not equal 1' do - section_article_path(1, 1, :page => 2).should == '/sections/1/articles/1/pages/2' - end - - it 'works for section_article_path with both a locale and page option' do - section_article_path(1, 1, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2' - end - end - end - - describe 'when used with a polymorphic_path' do - describe "a not nested resource" do - # uses optimization - it 'does not change the section_path when the current locale is the default locale and no page option given' do - section_path(@section).should == '/sections/1' - end - - # uses optimization - it 'prepends the current locale to section_path when it is not the default locale' do - I18n.locale = :de - section_path(@section).should == '/de/sections/1' - end - - it 'prepends a given locale param to section_path when it is not the default locale' do - I18n.locale = :de - section_path(@section, :locale => :fi).should == '/fi/sections/1' - end - - it 'does not change the section_path when given page option equals 1' do - section_path(@section, :page => 1).should == '/sections/1' - end - - it 'appends the pages segments to section_path when given page option does not equal 1' do - section_path(@section, :page => 2).should == '/sections/1/pages/2' - end - - it 'works for section_path with both a locale and page option' do - section_path(@section, :locale => :fi, :page => 2).should == '/fi/sections/1/pages/2' - end - end - - describe "a nested resource" do - # uses optimization - it 'does not change the section_article_path when the current locale is the default locale and no page option given' do - section_article_path(@section, @article).should == '/sections/1/articles/1' - end - - # uses optimization - it 'prepends the current locale to section_article_path when it is not the default locale' do - I18n.locale = :de - section_article_path(@section, @article).should == '/de/sections/1/articles/1' - end - - it 'prepends a given locale param to section_article_path when it is not the default locale' do - I18n.locale = :de - section_article_path(@section, @article, :locale => :fi).should == '/fi/sections/1/articles/1' - end - - it 'does not change the section_article_path when given page option equals 1' do - section_article_path(@section, @article, :page => 1).should == '/sections/1/articles/1' - end - - it 'appends the pages segments to section_article_path when given page option does not equal 1' do - section_article_path(@section, @article, :page => 2).should == '/sections/1/articles/1/pages/2' - end - - it 'works for section_article_path with both a locale and page option' do - section_article_path(@section, @article, :locale => :fi, :page => 2).should == '/fi/sections/1/articles/1/pages/2' - end - end - end - - describe 'when used with url_for and an ActivRecord instance' do - describe "a not nested resource" do - it 'prepends the current locale to section_path when it is not the default locale' do - I18n.locale = :de - url_for(@section).should == 'http://test.host/de/sections/1' - end - - it 'does not change the section_path when no page option given' do - url_for(@section).should == 'http://test.host/sections/1' - end - - it 'does not change the section_path when given page option equals 1' do - params = @params.update :id => @section, :page => 1 - url_for(params).should == 'http://test.host/sections/1' - end - - it 'appends the pages segments to section_path when given page option does not equal 1' do - params = @params.update :id => @section, :page => 2 - url_for(params).should == 'http://test.host/sections/1/pages/2' - end - - it 'works for section_path with both a locale and page option' do - params = @params.update :id => @section, :locale => :fi, :page => 2 - url_for(params).should == 'http://test.host/fi/sections/1/pages/2' - end - end - - describe "a nested resource" do - it 'prepends the current locale to section_article_path when it is not the default locale' do - I18n.locale = :de - url_for([@section, @article]).should == 'http://test.host/de/sections/1/articles/1' - end - - it 'does not change the section_article_path when no page option given' do - url_for([@section, @article]).should == 'http://test.host/sections/1/articles/1' - end - - it 'does not change the section_article_path when given page option equals 1' do - params = @article_params.update :section_id => @section, :id => @article, :page => 1 - url_for(params).should == 'http://test.host/sections/1/articles/1' - end - - it 'appends the pages segments to section_article_path when given page option does not equal 1' do - params = @article_params.update :section_id => @section, :id => @article, :page => 2 - url_for(params).should == 'http://test.host/sections/1/articles/1/pages/2' - end - - it 'works for section_article_path with both a locale and page option' do - params = @article_params.update :section_id => @section, :id => @article, :locale => :fi, :page => 2 - url_for(params).should == 'http://test.host/fi/sections/1/articles/1/pages/2' - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/routing-filter/spec/recognition_spec.rb b/vendor/plugins/routing-filter/spec/recognition_spec.rb deleted file mode 100644 index 11f0892..0000000 --- a/vendor/plugins/routing-filter/spec/recognition_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -require File.dirname(__FILE__) + '/spec_helper.rb' - -describe 'RoutingFilter', 'url recognition' do - include RoutingFilterHelpers - - before :each do - RoutingFilter::Locale.default_locale = :en - I18n.default_locale = :en - I18n.locale = :en - - @controller = instantiate_controller :locale => 'de', :id => 1 - @set = draw_routes do |map| - map.filter 'locale' - map.filter 'pagination' - - map.section 'sections/:id', :controller => 'sections', :action => "show" - map.article 'sections/:section_id/articles/:id', :controller => 'articles', :action => "show" - end - - @section_params = {:controller => 'sections', :action => "show", :id => "1"} - @article_params = {:controller => 'articles', :action => "show", :section_id => "1", :id => "1"} - @locale_filter = @set.filters.first - end - - def should_recognize_path(path, params) - @set.recognize_path(path, {}).should == params - end - - def section_path(*args) - @controller.send :section_path, *args - end - - def url_for(*args) - @controller.send :url_for, *args - end - - it 'recognizes the path /de/sections/1 and sets the :locale param' do - should_recognize_path '/de/sections/1', @section_params.update(:locale => 'de') - end - - it 'recognizes the path /sections/1/pages/1 and sets the :page param' do - should_recognize_path '/sections/1/pages/1', @section_params.update(:page => 1) - end - - it 'recognizes the path /de/sections/1/pages/1 and sets the :locale param' do - should_recognize_path '/de/sections/1/pages/1', @section_params.update(:locale => 'de', :page => 1) - end - - it 'recognizes the path /sections/1/articles/1 and sets the :locale param' do - should_recognize_path '/sections/1/articles/1', @article_params - end - - it 'recognizes the path /de/sections/1/articles/1 and sets the :locale param' do - should_recognize_path '/de/sections/1/articles/1', @article_params.update(:locale => 'de') - end - - it 'recognizes the path /de/sections/1/articles/1/pages/1 and sets the :locale param' do - should_recognize_path '/de/sections/1/articles/1/pages/1', @article_params.update(:locale => 'de', :page => 1) - end - - it 'recognizes the path /sections/1 and does not set a :locale param' do - should_recognize_path '/sections/1', @section_params - end - - it 'recognizes the path /sections/1 and does not set a :page param' do - should_recognize_path '/sections/1', @section_params - end - - it 'recognizes the path /sections/1/articles/1 and does not set a :locale param' do - should_recognize_path '/sections/1/articles/1', @article_params - end - - it 'recognizes the path /sections/1/articles/1 and does not set a :page param' do - should_recognize_path '/sections/1/articles/1', @article_params - end -end \ No newline at end of file diff --git a/vendor/plugins/routing-filter/spec/routing_filter_spec.rb b/vendor/plugins/routing-filter/spec/routing_filter_spec.rb deleted file mode 100644 index f919c29..0000000 --- a/vendor/plugins/routing-filter/spec/routing_filter_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require File.dirname(__FILE__) + '/spec_helper.rb' - -describe 'RoutingFilter' do - include RoutingFilterHelpers - - before :each do - @controller = instantiate_controller :locale => 'de', :section_id => 1 - @set = draw_routes do |map| - map.section 'sections/:section_id', :controller => 'sections', :action => "show" - map.filter 'locale' - map.filter 'pagination' - end - @locale_filter = @set.filters.first - @pagination_filter = @set.filters.last - end - - def recognize_path(path = '/de/sections/1', options = {}) - @set.recognize_path path, options - end - - def url_for(options) - @controller.send :url_for, options - end - - def section_path(*args) - @controller.send :section_path, *args - end - - it 'installs filters to the route set' do - @locale_filter.should be_instance_of(RoutingFilter::Locale) - @pagination_filter.should be_instance_of(RoutingFilter::Pagination) - end - - it 'calls the first filter for route recognition' do - @locale_filter.should_receive(:around_recognize).and_return :foo => :bar - recognize_path.should == {:foo => :bar} - end - - it 'calls the second filter for route recognition' do - @pagination_filter.should_receive(:around_recognize).and_return :foo => :bar - recognize_path.should == {:foo => :bar} - end - - it 'calls the first filter for url generation' do - @locale_filter.should_receive(:around_generate).and_return '/sections/1' - url_for :controller => 'sections', :action => 'show', :section_id => 1 - end - - it 'calls the second filter for url generation' do - @pagination_filter.should_receive(:around_generate).and_return '/sections/1' - url_for :controller => 'sections', :action => 'show', :section_id => 1 - end - - it 'calls the first filter for named route url_helper' do - @locale_filter.should_receive(:around_generate).and_return '/sections/1' - section_path :section_id => 1 - end - - it 'calls the filter for named route url_helper with "optimized" generation blocks' do - # at_least(1) since the inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper also call us (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806) - @locale_filter.should_receive(:around_generate).at_least(1).and_return '/sections/1' - section_path 1 - end - - it 'calls the filter for named route polymorphic_path' do - # at_least(1) since the inline code comments in ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper also call us (as of http://github.com/rails/rails/commit/a2270ef2594b97891994848138614657363f2806) - @locale_filter.should_receive(:around_generate).at_least(1).and_return '/sections/1' - section_path Section.new - end -end \ No newline at end of file diff --git a/vendor/plugins/routing-filter/spec/spec.opts b/vendor/plugins/routing-filter/spec/spec.opts deleted file mode 100644 index 391705b..0000000 --- a/vendor/plugins/routing-filter/spec/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/vendor/plugins/routing-filter/spec/spec_helper.rb b/vendor/plugins/routing-filter/spec/spec_helper.rb deleted file mode 100644 index a92a3d9..0000000 --- a/vendor/plugins/routing-filter/spec/spec_helper.rb +++ /dev/null @@ -1,49 +0,0 @@ -$: << File.dirname(__FILE__) -$: << File.dirname(__FILE__) + '/../lib/' -$: << File.dirname(__FILE__) + '/../vendor/rails/actionpack/lib' -$: << File.dirname(__FILE__) + '/../vendor/rails/activesupport/lib' - -require 'action_controller' -require 'action_controller/test_process' -require 'active_support/vendor' - -require 'routing_filter' -require 'routing_filter/locale' -require 'routing_filter/pagination' - -class Site -end - -class Section - def id; 1 end - alias :to_param :id - - def type; 'Section' end - - def path; 'section' end -end - -class Article - def to_param; 1 end -end - -module RoutingFilterHelpers - def draw_routes(&block) - set = returning ActionController::Routing::RouteSet.new do |set| - class << set; def clear!; end; end - set.draw &block - silence_warnings{ ActionController::Routing.const_set 'Routes', set } - end - set - end - - def instantiate_controller(params) - returning ActionController::Base.new do |controller| - request = ActionController::TestRequest.new - url = ActionController::UrlRewriter.new(request, params) - controller.stub!(:request).and_return request - controller.instance_variable_set :@url, url - controller - end - end -end \ No newline at end of file diff --git a/vendor/plugins/will_paginate/.gitignore b/vendor/plugins/will_paginate/.gitignore deleted file mode 100644 index 2b437b9..0000000 --- a/vendor/plugins/will_paginate/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/doc -/rails -*.gem -/coverage diff --git a/vendor/plugins/will_paginate/.manifest b/vendor/plugins/will_paginate/.manifest deleted file mode 100644 index cda4af44..0000000 --- a/vendor/plugins/will_paginate/.manifest +++ /dev/null @@ -1,49 +0,0 @@ -CHANGELOG.rdoc -LICENSE -README.rdoc -Rakefile -examples -examples/apple-circle.gif -examples/index.haml -examples/index.html -examples/pagination.css -examples/pagination.sass -init.rb -lib -lib/will_paginate -lib/will_paginate.rb -lib/will_paginate/array.rb -lib/will_paginate/collection.rb -lib/will_paginate/core_ext.rb -lib/will_paginate/finder.rb -lib/will_paginate/named_scope.rb -lib/will_paginate/named_scope_patch.rb -lib/will_paginate/version.rb -lib/will_paginate/view_helpers.rb -test -test/boot.rb -test/collection_test.rb -test/console -test/database.yml -test/finder_test.rb -test/fixtures -test/fixtures/admin.rb -test/fixtures/developer.rb -test/fixtures/developers_projects.yml -test/fixtures/project.rb -test/fixtures/projects.yml -test/fixtures/replies.yml -test/fixtures/reply.rb -test/fixtures/schema.rb -test/fixtures/topic.rb -test/fixtures/topics.yml -test/fixtures/user.rb -test/fixtures/users.yml -test/helper.rb -test/lib -test/lib/activerecord_test_case.rb -test/lib/activerecord_test_connector.rb -test/lib/load_fixtures.rb -test/lib/view_test_process.rb -test/tasks.rake -test/view_test.rb \ No newline at end of file diff --git a/vendor/plugins/will_paginate/CHANGELOG.rdoc b/vendor/plugins/will_paginate/CHANGELOG.rdoc deleted file mode 100644 index 01aea3a..0000000 --- a/vendor/plugins/will_paginate/CHANGELOG.rdoc +++ /dev/null @@ -1,110 +0,0 @@ -== 2.3.6, released 2008-10-26 - -* Rails 2.2 fix: stop using `extract_attribute_names_from_match` inernal AR method, it no longer exists - -== 2.3.5, released 2008-10-07 - -* update the backported named_scope implementation for Rails versions older than 2.1 -* break out of scope of paginated_each() yielded block when used on named scopes -* fix paginate(:from) - -== 2.3.4, released 2008-09-16 - -* Removed gem dependency to Active Support (causes trouble with vendored rails). -* Rails 2.1: fix a failing test and a deprecation warning. -* Cope with scoped :select when counting. - -== 2.3.3, released 2008-08-29 - -* Ensure that paginate_by_sql doesn't change the original SQL query. -* RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/) -* Rename :prev_label to :previous_label for consistency. old name still functions but is deprecated -* ActiveRecord 2.1: Remove :include option from count_all query when it's possible. - -== 2.3.2, released 2008-05-16 - -* Fixed LinkRenderer#stringified_merge by removing "return" from iterator block -* Ensure that 'href' values in pagination links are escaped URLs - -== 2.3.1, released 2008-05-04 - -* Fixed page numbers not showing with custom routes and implicit first page -* Try to use Hanna for documentation (falls back to default RDoc template if not) - -== 2.3.0, released 2008-04-29 - -* Changed LinkRenderer to receive collection, options and reference to view template NOT in - constructor, but with the #prepare method. This is a step towards supporting passing of - LinkRenderer (or subclass) instances that may be preconfigured in some way -* LinkRenderer now has #page_link and #page_span methods for easier customization of output in - subclasses -* Changed page_entries_info() method to adjust its output according to humanized class name of - collection items. Override this with :entry_name parameter (singular). - - page_entries_info(@posts) - #-> "Displaying all 12 posts" - page_entries_info(@posts, :entry_name => 'item') - #-> "Displaying all 12 items" - -== 2.2.3, released 2008-04-26 - -* will_paginate gem is no longer published on RubyForge, but on - gems.github.com: - - gem sources -a http://gems.github.com/ (you only need to do this once) - gem install mislav-will_paginate - -* extract reusable pagination testing stuff into WillPaginate::View -* rethink the page URL construction mechanizm to be more bulletproof when - combined with custom routing for page parameter -* test that anchor parameter can be used in pagination links - -== 2.2.2, released 2008-04-21 - -* Add support for page parameter in custom routes like "/foo/page/2" -* Change output of "page_entries_info" on single-page collection and erraneous - output with empty collection as reported by Tim Chater - -== 2.2.1, released 2008-04-08 - -* take less risky path when monkeypatching named_scope; fix that it no longer - requires ActiveRecord::VERSION -* use strings in "respond_to?" calls to work around a bug in acts_as_ferret - stable (ugh) -* add rake release task - - -== 2.2.0, released 2008-04-07 - -=== API changes -* Rename WillPaginate::Collection#page_count to "total_pages" for consistency. - If you implemented this interface, change your implementation accordingly. -* Remove old, deprecated style of calling Array#paginate as "paginate(page, - per_page)". If you want to specify :page, :per_page or :total_entries, use a - parameter hash. -* Rename LinkRenderer#url_options to "url_for" and drastically optimize it - -=== View changes -* Added "prev_page" and "next_page" CSS classes on previous/next page buttons -* Add examples of pagination links styling in "examples/index.html" -* Change gap in pagination links from "..." to - "". -* Add "paginated_section", a block helper that renders pagination both above and - below content in the block -* Add rel="prev|next|start" to page links - -=== Other - -* Add ability to opt-in for Rails 2.1 feature "named_scope" by calling - WillPaginate.enable_named_scope (tested in Rails 1.2.6 and 2.0.2) -* Support complex page parameters like "developers[page]" -* Move Array#paginate definition to will_paginate/array.rb. You can now easily - use pagination on arrays outside of Rails: - - gem 'will_paginate' - require 'will_paginate/array' - -* Add "paginated_each" method for iterating through every record by loading only - one page of records at the time -* Rails 2: Rescue from WillPaginate::InvalidPage error with 404 Not Found by - default diff --git a/vendor/plugins/will_paginate/LICENSE b/vendor/plugins/will_paginate/LICENSE deleted file mode 100644 index 96a48cb..0000000 --- a/vendor/plugins/will_paginate/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2007 PJ Hyett and Mislav Marohnić - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/will_paginate/README.rdoc b/vendor/plugins/will_paginate/README.rdoc deleted file mode 100644 index 2a412f5..0000000 --- a/vendor/plugins/will_paginate/README.rdoc +++ /dev/null @@ -1,107 +0,0 @@ -= WillPaginate - -Pagination is just limiting the number of records displayed. Why should you let -it get in your way while developing, then? This plugin makes magic happen. Did -you ever want to be able to do just this on a model: - - Post.paginate :page => 1, :order => 'created_at DESC' - -... and then render the page links with a single view helper? Well, now you -can. - -Some resources to get you started: - -* {Installation instructions}[http://github.com/mislav/will_paginate/wikis/installation] - on {the wiki}[http://github.com/mislav/will_paginate/wikis] -* Your mind reels with questions? Join our - {Google group}[http://groups.google.com/group/will_paginate]. -* {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs] - - -== Example usage - -Use a paginate finder in the controller: - - @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC' - -Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the -records. Don't forget to tell it which page you want, or it will complain! -Read more on WillPaginate::Finder::ClassMethods. - -Render the posts in your view like you would normally do. When you need to render -pagination, just stick this in: - - <%= will_paginate @posts %> - -You're done. (You can find the option list at WillPaginate::ViewHelpers.) - -How does it know how much items to fetch per page? It asks your model by calling -its per_page class method. You can define it like this: - - class Post < ActiveRecord::Base - cattr_reader :per_page - @@per_page = 50 - end - -... or like this: - - class Post < ActiveRecord::Base - def self.per_page - 50 - end - end - -... or don't worry about it at all. WillPaginate defines it to be 30 by default. -But you can always specify the count explicitly when calling +paginate+: - - @posts = Post.paginate :page => params[:page], :per_page => 50 - -The +paginate+ finder wraps the original finder and returns your resultset that now has -some new properties. You can use the collection as you would with any ActiveRecord -resultset. WillPaginate view helpers also need that object to be able to render pagination: - -
    - <% for post in @posts -%> -
  1. Render `post` in some nice way.
  2. - <% end -%> -
- -

Now let's render us some pagination!

- <%= will_paginate @posts %> - -More detailed documentation: - -* WillPaginate::Finder::ClassMethods for pagination on your models; -* WillPaginate::ViewHelpers for your views. - - -== Authors and credits - -Authors:: Mislav Marohnić, PJ Hyett -Original announcement:: http://errtheblog.com/post/929 -Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php - -All these people helped making will_paginate what it is now with their code -contributions or just simply awesome ideas: - -Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence -Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs -van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel, -Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein, -Denis Barushev, Ben Pickles. - - -== Usable pagination in the UI - -There are some CSS styles to get you started in the "examples/" directory. They -are {showcased online here}[http://mislav.caboo.se/static/will_paginate/]. - -More reading about pagination as design pattern: - -* {Pagination 101}[http://kurafire.net/log/archive/2007/06/22/pagination-101] -* {Pagination gallery}[http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/] -* {Pagination on Yahoo Design Pattern Library}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination] - -Want to discuss, request features, ask questions? Join the -{Google group}[http://groups.google.com/group/will_paginate]. - diff --git a/vendor/plugins/will_paginate/Rakefile b/vendor/plugins/will_paginate/Rakefile deleted file mode 100644 index 253efd0..0000000 --- a/vendor/plugins/will_paginate/Rakefile +++ /dev/null @@ -1,62 +0,0 @@ -require 'rubygems' -begin - hanna_dir = '/Users/mislav/Projects/Hanna/lib' - $:.unshift hanna_dir if File.exists? hanna_dir - require 'hanna/rdoctask' -rescue LoadError - require 'rake' - require 'rake/rdoctask' -end -load 'test/tasks.rake' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Generate RDoc documentation for the will_paginate plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc'). - include('lib/**/*.rb'). - exclude('lib/will_paginate/named_scope*'). - exclude('lib/will_paginate/array.rb'). - exclude('lib/will_paginate/version.rb') - - rdoc.main = "README.rdoc" # page to start on - rdoc.title = "will_paginate documentation" - - rdoc.rdoc_dir = 'doc' # rdoc output folder - rdoc.options << '--inline-source' << '--charset=UTF-8' - rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/' -end - -desc %{Update ".manifest" with the latest list of project filenames. Respect\ -.gitignore by excluding everything that git ignores. Update `files` and\ -`test_files` arrays in "*.gemspec" file if it's present.} -task :manifest do - list = Dir['**/*'].sort - spec_file = Dir['*.gemspec'].first - list -= [spec_file] if spec_file - - File.read('.gitignore').each_line do |glob| - glob = glob.chomp.sub(/^\//, '') - list -= Dir[glob] - list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob) - puts "excluding #{glob}" - end - - if spec_file - spec = File.read spec_file - spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do - assignment = $1 - bunch = $2 ? list.grep(/^test\//) : list - '%s%%w(%s)' % [assignment, bunch.join(' ')] - end - - File.open(spec_file, 'w') {|f| f << spec } - end - File.open('.manifest', 'w') {|f| f << list.join("\n") } -end - -task :examples do - %x(haml examples/index.haml examples/index.html) - %x(sass examples/pagination.sass examples/pagination.css) -end diff --git a/vendor/plugins/will_paginate/examples/apple-circle.gif b/vendor/plugins/will_paginate/examples/apple-circle.gif deleted file mode 100644 index df8cbf7..0000000 Binary files a/vendor/plugins/will_paginate/examples/apple-circle.gif and /dev/null differ diff --git a/vendor/plugins/will_paginate/examples/index.haml b/vendor/plugins/will_paginate/examples/index.haml deleted file mode 100644 index fb41ac8..0000000 --- a/vendor/plugins/will_paginate/examples/index.haml +++ /dev/null @@ -1,69 +0,0 @@ -!!! -%html -%head - %title Samples of pagination styling for will_paginate - %link{ :rel => 'stylesheet', :type => 'text/css', :href => 'pagination.css' } - %style{ :type => 'text/css' } - :sass - html - :margin 0 - :padding 0 - :background #999 - :font normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif - body - :margin 2em - :padding 2em - :border 2px solid gray - :background white - :color #222 - h1 - :font-size 2em - :font-weight normal - :margin 0 0 1em 0 - h2 - :font-size 1.4em - :margin 1em 0 .5em 0 - pre - :font-size 13px - :font-family Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace - -- pagination = '« Previous 1 3 4 5 6 7 8 9 29 30 ' -- pagination_no_page_links = '« Previous ' - -%body - %h1 Samples of pagination styling for will_paginate - %p - Find these styles in "examples/pagination.css" of will_paginate library. - There is a Sass version of it for all you sassy people. - %p - Read about good rules for pagination: - %a{ :href => 'http://kurafire.net/log/archive/2007/06/22/pagination-101' } Pagination 101 - %p - %em Warning: - page links below don't lead anywhere (so don't click on them). - - %h2 Unstyled pagination (ewww!) - %div= pagination - - %h2 Digg.com - .digg_pagination= pagination - - %h2 Digg-style, no page links - .digg_pagination= pagination_no_page_links - %p Code that renders this: - %pre= '%s' % %[<%= will_paginate @posts, :page_links => false %>].gsub('<', '<').gsub('>', '>') - - %h2 Digg-style, extra content - .digg_pagination - .page_info Displaying entries 1 - 6 of 180 in total - = pagination - %p Code that renders this: - %pre= '%s' % %[
\n
\n <%= page_entries_info @posts %>\n
\n <%= will_paginate @posts, :container => false %>\n
].gsub('<', '<').gsub('>', '>') - - %h2 Apple.com store - .apple_pagination= pagination - - %h2 Flickr.com - .flickr_pagination - = pagination - .page_info (118 photos) diff --git a/vendor/plugins/will_paginate/examples/index.html b/vendor/plugins/will_paginate/examples/index.html deleted file mode 100644 index 858f7c6..0000000 --- a/vendor/plugins/will_paginate/examples/index.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - - Samples of pagination styling for will_paginate - - - - -

Samples of pagination styling for will_paginate

-

- Find these styles in "examples/pagination.css" of will_paginate library. - There is a Sass version of it for all you sassy people. -

-

- Read about good rules for pagination: - Pagination 101 -

-

- Warning: - page links below don't lead anywhere (so don't click on them). -

-

- Unstyled pagination (ewww!) -

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Digg.com

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Digg-style, no page links

-
- « Previous -
-

Code that renders this:

-
-    <%= will_paginate @posts, :page_links => false %>
-  
-

Digg-style, extra content

-
-
- Displaying entries 1 - 6 of 180 in total -
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Code that renders this:

-
-    <div class="digg_pagination">
-      <div clas="page_info">
-        <%= page_entries_info @posts %>
-      </div>
-      <%= will_paginate @posts, :container => false %>
-    </div>
-  
-

Apple.com store

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
-

Flickr.com

-
- « Previous 1 3 4 5 6 7 8 9 29 30 -
(118 photos)
-
- diff --git a/vendor/plugins/will_paginate/examples/pagination.css b/vendor/plugins/will_paginate/examples/pagination.css deleted file mode 100644 index b55e977..0000000 --- a/vendor/plugins/will_paginate/examples/pagination.css +++ /dev/null @@ -1,90 +0,0 @@ -.digg_pagination { - background: white; - /* self-clearing method: */ } - .digg_pagination a, .digg_pagination span { - padding: .2em .5em; - display: block; - float: left; - margin-right: 1px; } - .digg_pagination span.disabled { - color: #999; - border: 1px solid #DDD; } - .digg_pagination span.current { - font-weight: bold; - background: #2E6AB1; - color: white; - border: 1px solid #2E6AB1; } - .digg_pagination a { - text-decoration: none; - color: #105CB6; - border: 1px solid #9AAFE5; } - .digg_pagination a:hover, .digg_pagination a:focus { - color: #003; - border-color: #003; } - .digg_pagination .page_info { - background: #2E6AB1; - color: white; - padding: .4em .6em; - width: 22em; - margin-bottom: .3em; - text-align: center; } - .digg_pagination .page_info b { - color: #003; - background: #6aa6ed; - padding: .1em .25em; } - .digg_pagination:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; } - * html .digg_pagination { - height: 1%; } - *:first-child+html .digg_pagination { - overflow: hidden; } - -.apple_pagination { - background: #F1F1F1; - border: 1px solid #E5E5E5; - text-align: center; - padding: 1em; } - .apple_pagination a, .apple_pagination span { - padding: .2em .3em; } - .apple_pagination span.disabled { - color: #AAA; } - .apple_pagination span.current { - font-weight: bold; - background: transparent url(apple-circle.gif) no-repeat 50% 50%; } - .apple_pagination a { - text-decoration: none; - color: black; } - .apple_pagination a:hover, .apple_pagination a:focus { - text-decoration: underline; } - -.flickr_pagination { - text-align: center; - padding: .3em; } - .flickr_pagination a, .flickr_pagination span { - padding: .2em .5em; } - .flickr_pagination span.disabled { - color: #AAA; } - .flickr_pagination span.current { - font-weight: bold; - color: #FF0084; } - .flickr_pagination a { - border: 1px solid #DDDDDD; - color: #0063DC; - text-decoration: none; } - .flickr_pagination a:hover, .flickr_pagination a:focus { - border-color: #003366; - background: #0063DC; - color: white; } - .flickr_pagination .page_info { - color: #aaa; - padding-top: .8em; } - .flickr_pagination .prev_page, .flickr_pagination .next_page { - border-width: 2px; } - .flickr_pagination .prev_page { - margin-right: 1em; } - .flickr_pagination .next_page { - margin-left: 1em; } diff --git a/vendor/plugins/will_paginate/examples/pagination.sass b/vendor/plugins/will_paginate/examples/pagination.sass deleted file mode 100644 index 737a97b..0000000 --- a/vendor/plugins/will_paginate/examples/pagination.sass +++ /dev/null @@ -1,91 +0,0 @@ -.digg_pagination - :background white - a, span - :padding .2em .5em - :display block - :float left - :margin-right 1px - span.disabled - :color #999 - :border 1px solid #DDD - span.current - :font-weight bold - :background #2E6AB1 - :color white - :border 1px solid #2E6AB1 - a - :text-decoration none - :color #105CB6 - :border 1px solid #9AAFE5 - &:hover, &:focus - :color #003 - :border-color #003 - .page_info - :background #2E6AB1 - :color white - :padding .4em .6em - :width 22em - :margin-bottom .3em - :text-align center - b - :color #003 - :background = #2E6AB1 + 60 - :padding .1em .25em - - /* self-clearing method: - &:after - :content "." - :display block - :height 0 - :clear both - :visibility hidden - * html & - :height 1% - *:first-child+html & - :overflow hidden - -.apple_pagination - :background #F1F1F1 - :border 1px solid #E5E5E5 - :text-align center - :padding 1em - a, span - :padding .2em .3em - span.disabled - :color #AAA - span.current - :font-weight bold - :background transparent url(apple-circle.gif) no-repeat 50% 50% - a - :text-decoration none - :color black - &:hover, &:focus - :text-decoration underline - -.flickr_pagination - :text-align center - :padding .3em - a, span - :padding .2em .5em - span.disabled - :color #AAA - span.current - :font-weight bold - :color #FF0084 - a - :border 1px solid #DDDDDD - :color #0063DC - :text-decoration none - &:hover, &:focus - :border-color #003366 - :background #0063DC - :color white - .page_info - :color #aaa - :padding-top .8em - .prev_page, .next_page - :border-width 2px - .prev_page - :margin-right 1em - .next_page - :margin-left 1em diff --git a/vendor/plugins/will_paginate/init.rb b/vendor/plugins/will_paginate/init.rb deleted file mode 100644 index 838d30e..0000000 --- a/vendor/plugins/will_paginate/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'will_paginate' diff --git a/vendor/plugins/will_paginate/lib/will_paginate.rb b/vendor/plugins/will_paginate/lib/will_paginate.rb deleted file mode 100644 index e072412..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'active_support' - -# = You *will* paginate! -# -# First read about WillPaginate::Finder::ClassMethods, then see -# WillPaginate::ViewHelpers. The magical array you're handling in-between is -# WillPaginate::Collection. -# -# Happy paginating! -module WillPaginate - class << self - # shortcut for enable_actionpack and enable_activerecord combined - def enable - enable_actionpack - enable_activerecord - end - - # hooks WillPaginate::ViewHelpers into ActionView::Base - def enable_actionpack - return if ActionView::Base.instance_methods.include? 'will_paginate' - require 'will_paginate/view_helpers' - ActionView::Base.send :include, ViewHelpers - - if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses - ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found - end - end - - # hooks WillPaginate::Finder into ActiveRecord::Base and classes that deal - # with associations - def enable_activerecord - return if ActiveRecord::Base.respond_to? :paginate - require 'will_paginate/finder' - ActiveRecord::Base.send :include, Finder - - # support pagination on associations - a = ActiveRecord::Associations - returning([ a::AssociationCollection ]) { |classes| - # detect http://dev.rubyonrails.org/changeset/9230 - unless a::HasManyThroughAssociation.superclass == a::HasManyAssociation - classes << a::HasManyThroughAssociation - end - }.each do |klass| - klass.send :include, Finder::ClassMethods - klass.class_eval { alias_method_chain :method_missing, :paginate } - end - end - - # Enable named_scope, a feature of Rails 2.1, even if you have older Rails - # (tested on Rails 2.0.2 and 1.2.6). - # - # You can pass +false+ for +patch+ parameter to skip monkeypatching - # *associations*. Use this if you feel that named_scope broke - # has_many, has_many :through or has_and_belongs_to_many associations in - # your app. By passing +false+, you can still use named_scope in - # your models, but not through associations. - def enable_named_scope(patch = true) - return if defined? ActiveRecord::NamedScope - require 'will_paginate/named_scope' - require 'will_paginate/named_scope_patch' if patch - - ActiveRecord::Base.send :include, WillPaginate::NamedScope - end - end - - module Deprecation # :nodoc: - extend ActiveSupport::Deprecation - - def self.warn(message, callstack = caller) - message = 'WillPaginate: ' + message.strip.gsub(/\s+/, ' ') - ActiveSupport::Deprecation.warn(message, callstack) - end - end -end - -if defined?(Rails) and defined?(ActiveRecord) and defined?(ActionController) - WillPaginate.enable -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/array.rb b/vendor/plugins/will_paginate/lib/will_paginate/array.rb deleted file mode 100644 index d061d2b..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/array.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'will_paginate/collection' - -# http://www.desimcadam.com/archives/8 -Array.class_eval do - def paginate(options = {}) - raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options - - WillPaginate::Collection.create( - options[:page] || 1, - options[:per_page] || 30, - options[:total_entries] || self.length - ) { |pager| - pager.replace self[pager.offset, pager.per_page].to_a - } - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/collection.rb b/vendor/plugins/will_paginate/lib/will_paginate/collection.rb deleted file mode 100644 index e253570..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +++ /dev/null @@ -1,146 +0,0 @@ -module WillPaginate - # = Invalid page number error - # This is an ArgumentError raised in case a page was requested that is either - # zero or negative number. You should decide how do deal with such errors in - # the controller. - # - # If you're using Rails 2, then this error will automatically get handled like - # 404 Not Found. The hook is in "will_paginate.rb": - # - # ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found - # - # If you don't like this, use your preffered method of rescuing exceptions in - # public from your controllers to handle this differently. The +rescue_from+ - # method is a nice addition to Rails 2. - # - # This error is *not* raised when a page further than the last page is - # requested. Use WillPaginate::Collection#out_of_bounds? method to - # check for those cases and manually deal with them as you see fit. - class InvalidPage < ArgumentError - def initialize(page, page_num) - super "#{page.inspect} given as value, which translates to '#{page_num}' as page number" - end - end - - # = The key to pagination - # Arrays returned from paginating finds are, in fact, instances of this little - # class. You may think of WillPaginate::Collection as an ordinary array with - # some extra properties. Those properties are used by view helpers to generate - # correct page links. - # - # WillPaginate::Collection also assists in rolling out your own pagination - # solutions: see +create+. - # - # If you are writing a library that provides a collection which you would like - # to conform to this API, you don't have to copy these methods over; simply - # make your plugin/gem dependant on the "mislav-will_paginate" gem: - # - # gem 'mislav-will_paginate' - # require 'will_paginate/collection' - # - # # WillPaginate::Collection is now available for use - class Collection < Array - attr_reader :current_page, :per_page, :total_entries, :total_pages - - # Arguments to the constructor are the current page number, per-page limit - # and the total number of entries. The last argument is optional because it - # is best to do lazy counting; in other words, count *conditionally* after - # populating the collection using the +replace+ method. - def initialize(page, per_page, total = nil) - @current_page = page.to_i - raise InvalidPage.new(page, @current_page) if @current_page < 1 - @per_page = per_page.to_i - raise ArgumentError, "`per_page` setting cannot be less than 1 (#{@per_page} given)" if @per_page < 1 - - self.total_entries = total if total - end - - # Just like +new+, but yields the object after instantiation and returns it - # afterwards. This is very useful for manual pagination: - # - # @entries = WillPaginate::Collection.create(1, 10) do |pager| - # result = Post.find(:all, :limit => pager.per_page, :offset => pager.offset) - # # inject the result array into the paginated collection: - # pager.replace(result) - # - # unless pager.total_entries - # # the pager didn't manage to guess the total count, do it manually - # pager.total_entries = Post.count - # end - # end - # - # The possibilities with this are endless. For another example, here is how - # WillPaginate used to define pagination for Array instances: - # - # Array.class_eval do - # def paginate(page = 1, per_page = 15) - # WillPaginate::Collection.create(page, per_page, size) do |pager| - # pager.replace self[pager.offset, pager.per_page].to_a - # end - # end - # end - # - # The Array#paginate API has since then changed, but this still serves as a - # fine example of WillPaginate::Collection usage. - def self.create(page, per_page, total = nil) - pager = new(page, per_page, total) - yield pager - pager - end - - # Helper method that is true when someone tries to fetch a page with a - # larger number than the last page. Can be used in combination with flashes - # and redirecting. - def out_of_bounds? - current_page > total_pages - end - - # Current offset of the paginated collection. If we're on the first page, - # it is always 0. If we're on the 2nd page and there are 30 entries per page, - # the offset is 30. This property is useful if you want to render ordinals - # side by side with records in the view: simply start with offset + 1. - def offset - (current_page - 1) * per_page - end - - # current_page - 1 or nil if there is no previous page - def previous_page - current_page > 1 ? (current_page - 1) : nil - end - - # current_page + 1 or nil if there is no next page - def next_page - current_page < total_pages ? (current_page + 1) : nil - end - - # sets the total_entries property and calculates total_pages - def total_entries=(number) - @total_entries = number.to_i - @total_pages = (@total_entries / per_page.to_f).ceil - end - - # This is a magic wrapper for the original Array#replace method. It serves - # for populating the paginated collection after initialization. - # - # Why magic? Because it tries to guess the total number of entries judging - # by the size of given array. If it is shorter than +per_page+ limit, then we - # know we're on the last page. This trick is very useful for avoiding - # unnecessary hits to the database to do the counting after we fetched the - # data for the current page. - # - # However, after using +replace+ you should always test the value of - # +total_entries+ and set it to a proper value if it's +nil+. See the example - # in +create+. - def replace(array) - result = super - - # The collection is shorter then page limit? Rejoice, because - # then we know that we are on the last page! - if total_entries.nil? and length < per_page and (current_page == 1 or length > 0) - self.total_entries = offset + length - end - - result - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb b/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb deleted file mode 100644 index 32f10f5..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'set' -require 'will_paginate/array' - -unless Hash.instance_methods.include? 'except' - Hash.class_eval do - # Returns a new hash without the given keys. - def except(*keys) - rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| rejected.include?(key) } - end - - # Replaces the hash without only the given keys. - def except!(*keys) - replace(except(*keys)) - end - end -end - -unless Hash.instance_methods.include? 'slice' - Hash.class_eval do - # Returns a new hash with only the given keys. - def slice(*keys) - allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| !allowed.include?(key) } - end - - # Replaces the hash with only the given keys. - def slice!(*keys) - replace(slice(*keys)) - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/finder.rb b/vendor/plugins/will_paginate/lib/will_paginate/finder.rb deleted file mode 100644 index d0e5668..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +++ /dev/null @@ -1,264 +0,0 @@ -require 'will_paginate/core_ext' - -module WillPaginate - # A mixin for ActiveRecord::Base. Provides +per_page+ class method - # and hooks things up to provide paginating finders. - # - # Find out more in WillPaginate::Finder::ClassMethods - # - module Finder - def self.included(base) - base.extend ClassMethods - class << base - alias_method_chain :method_missing, :paginate - # alias_method_chain :find_every, :paginate - define_method(:per_page) { 30 } unless respond_to?(:per_page) - end - end - - # = Paginating finders for ActiveRecord models - # - # WillPaginate adds +paginate+, +per_page+ and other methods to - # ActiveRecord::Base class methods and associations. It also hooks into - # +method_missing+ to intercept pagination calls to dynamic finders such as - # +paginate_by_user_id+ and translate them to ordinary finders - # (+find_all_by_user_id+ in this case). - # - # In short, paginating finders are equivalent to ActiveRecord finders; the - # only difference is that we start with "paginate" instead of "find" and - # that :page is required parameter: - # - # @posts = Post.paginate :all, :page => params[:page], :order => 'created_at DESC' - # - # In paginating finders, "all" is implicit. There is no sense in paginating - # a single record, right? So, you can drop the :all argument: - # - # Post.paginate(...) => Post.find :all - # Post.paginate_all_by_something => Post.find_all_by_something - # Post.paginate_by_something => Post.find_all_by_something - # - # == The importance of the :order parameter - # - # In ActiveRecord finders, :order parameter specifies columns for - # the ORDER BY clause in SQL. It is important to have it, since - # pagination only makes sense with ordered sets. Without the ORDER - # BY clause, databases aren't required to do consistent ordering when - # performing SELECT queries; this is especially true for - # PostgreSQL. - # - # Therefore, make sure you are doing ordering on a column that makes the - # most sense in the current context. Make that obvious to the user, also. - # For perfomance reasons you will also want to add an index to that column. - module ClassMethods - # This is the main paginating finder. - # - # == Special parameters for paginating finders - # * :page -- REQUIRED, but defaults to 1 if false or nil - # * :per_page -- defaults to CurrentModel.per_page (which is 30 if not overridden) - # * :total_entries -- use only if you manually count total entries - # * :count -- additional options that are passed on to +count+ - # * :finder -- name of the ActiveRecord finder used (default: "find") - # - # All other options (+conditions+, +order+, ...) are forwarded to +find+ - # and +count+ calls. - def paginate(*args) - options = args.pop - page, per_page, total_entries = wp_parse_options(options) - finder = (options[:finder] || 'find').to_s - - if finder == 'find' - # an array of IDs may have been given: - total_entries ||= (Array === args.first and args.first.size) - # :all is implicit - args.unshift(:all) if args.empty? - end - - WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - count_options = options.except :page, :per_page, :total_entries, :finder - find_options = count_options.except(:count).update(:offset => pager.offset, :limit => pager.per_page) - - args << find_options - # @options_from_last_find = nil - pager.replace(send(finder, *args) { |*a| yield(*a) if block_given? }) - - # magic counting for user convenience: - pager.total_entries = wp_count(count_options, args, finder) unless pager.total_entries - end - end - - # Iterates through all records by loading one page at a time. This is useful - # for migrations or any other use case where you don't want to load all the - # records in memory at once. - # - # It uses +paginate+ internally; therefore it accepts all of its options. - # You can specify a starting page with :page (default is 1). Default - # :order is "id", override if necessary. - # - # See {Faking Cursors in ActiveRecord}[http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord] - # where Jamis Buck describes this and a more efficient way for MySQL. - def paginated_each(options = {}) - options = { :order => 'id', :page => 1 }.merge options - options[:page] = options[:page].to_i - options[:total_entries] = 0 # skip the individual count queries - total = 0 - - begin - collection = paginate(options) - with_exclusive_scope(:find => {}) do - # using exclusive scope so that the block is yielded in scope-free context - total += collection.each { |item| yield item }.size - end - options[:page] += 1 - end until collection.size < collection.per_page - - total - end - - # Wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string - # based on the params otherwise used by paginating finds: +page+ and - # +per_page+. - # - # Example: - # - # @developers = Developer.paginate_by_sql ['select * from developers where salary > ?', 80000], - # :page => params[:page], :per_page => 3 - # - # A query for counting rows will automatically be generated if you don't - # supply :total_entries. If you experience problems with this - # generated SQL, you might want to perform the count manually in your - # application. - # - def paginate_by_sql(sql, options) - WillPaginate::Collection.create(*wp_parse_options(options)) do |pager| - query = sanitize_sql(sql.dup) - original_query = query.dup - # add limit, offset - add_limit! query, :offset => pager.offset, :limit => pager.per_page - # perfom the find - pager.replace find_by_sql(query) - - unless pager.total_entries - count_query = original_query.sub /\bORDER\s+BY\s+[\w`,\s]+$/mi, '' - count_query = "SELECT COUNT(*) FROM (#{count_query})" - - unless ['oracle', 'oci'].include?(self.connection.adapter_name.downcase) - count_query << ' AS count_table' - end - # perform the count query - pager.total_entries = count_by_sql(count_query) - end - end - end - - def respond_to?(method, include_priv = false) #:nodoc: - case method.to_sym - when :paginate, :paginate_by_sql - true - else - super(method.to_s.sub(/^paginate/, 'find'), include_priv) - end - end - - protected - - def method_missing_with_paginate(method, *args) #:nodoc: - # did somebody tried to paginate? if not, let them be - unless method.to_s.index('paginate') == 0 - if block_given? - return method_missing_without_paginate(method, *args) { |*a| yield(*a) } - else - return method_missing_without_paginate(method, *args) - end - end - - # paginate finders are really just find_* with limit and offset - finder = method.to_s.sub('paginate', 'find') - finder.sub!('find', 'find_all') if finder.index('find_by_') == 0 - - options = args.pop - raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys - options = options.dup - options[:finder] = finder - args << options - - paginate(*args) { |*a| yield(*a) if block_given? } - end - - # Does the not-so-trivial job of finding out the total number of entries - # in the database. It relies on the ActiveRecord +count+ method. - def wp_count(options, args, finder) - excludees = [:count, :order, :limit, :offset, :readonly] - excludees << :from unless ActiveRecord::Calculations::CALCULATIONS_OPTIONS.include?(:from) - - # we may be in a model or an association proxy - klass = (@owner and @reflection) ? @reflection.klass : self - - # Use :select from scope if it isn't already present. - options[:select] = scope(:find, :select) unless options[:select] - - if options[:select] and options[:select] =~ /^\s*DISTINCT\b/i - # Remove quoting and check for table_name.*-like statement. - if options[:select].gsub('`', '') =~ /\w+\.\*/ - options[:select] = "DISTINCT #{klass.table_name}.#{klass.primary_key}" - end - else - excludees << :select # only exclude the select param if it doesn't begin with DISTINCT - end - - # count expects (almost) the same options as find - count_options = options.except *excludees - - # merge the hash found in :count - # this allows you to specify :select, :order, or anything else just for the count query - count_options.update options[:count] if options[:count] - - # forget about includes if they are irrelevant (Rails 2.1) - if count_options[:include] and - klass.private_methods.include?('references_eager_loaded_tables?') and - !klass.send(:references_eager_loaded_tables?, count_options) - count_options.delete :include - end - - # we may have to scope ... - counter = Proc.new { count(count_options) } - - count = if finder.index('find_') == 0 and klass.respond_to?(scoper = finder.sub('find', 'with')) - # scope_out adds a 'with_finder' method which acts like with_scope, if it's present - # then execute the count with the scoping provided by the with_finder - send(scoper, &counter) - elsif finder =~ /^find_(all_by|by)_([_a-zA-Z]\w*)$/ - # extract conditions from calls like "paginate_by_foo_and_bar" - attribute_names = $2.split('_and_') - conditions = construct_attributes_from_arguments(attribute_names, args) - with_scope(:find => { :conditions => conditions }, &counter) - else - counter.call - end - - count.respond_to?(:length) ? count.length : count - end - - def wp_parse_options(options) #:nodoc: - raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys - options = options.symbolize_keys - raise ArgumentError, ':page parameter required' unless options.key? :page - - if options[:count] and options[:total_entries] - raise ArgumentError, ':count and :total_entries are mutually exclusive' - end - - page = options[:page] || 1 - per_page = options[:per_page] || self.per_page - total = options[:total_entries] - [page, per_page, total] - end - - private - - # def find_every_with_paginate(options) - # @options_from_last_find = options - # find_every_without_paginate(options) - # end - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb b/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb deleted file mode 100644 index 5a743d7..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb +++ /dev/null @@ -1,170 +0,0 @@ -module WillPaginate - # This is a feature backported from Rails 2.1 because of its usefullness not only with will_paginate, - # but in other aspects when managing complex conditions that you want to be reusable. - module NamedScope - # All subclasses of ActiveRecord::Base have two named_scopes: - # * all, which is similar to a find(:all) query, and - # * scoped, which allows for the creation of anonymous scopes, on the fly: Shirt.scoped(:conditions => {:color => 'red'}).scoped(:include => :washing_instructions) - # - # These anonymous scopes tend to be useful when procedurally generating complex queries, where passing - # intermediate values (scopes) around as first-class objects is convenient. - def self.included(base) - base.class_eval do - extend ClassMethods - named_scope :scoped, lambda { |scope| scope } - end - end - - module ClassMethods - def scopes - read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {}) - end - - # Adds a class method for retrieving and querying objects. A scope represents a narrowing of a database query, - # such as :conditions => {:color => :red}, :select => 'shirts.*', :include => :washing_instructions. - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} - # named_scope :dry_clean_only, :joins => :washing_instructions, :conditions => ['washing_instructions.dry_clean_only = ?', true] - # end - # - # The above calls to named_scope define class methods Shirt.red and Shirt.dry_clean_only. Shirt.red, - # in effect, represents the query Shirt.find(:all, :conditions => {:color => 'red'}). - # - # Unlike Shirt.find(...), however, the object returned by Shirt.red is not an Array; it resembles the association object - # constructed by a has_many declaration. For instance, you can invoke Shirt.red.find(:first), Shirt.red.count, - # Shirt.red.find(:all, :conditions => {:size => 'small'}). Also, just - # as with the association objects, name scopes acts like an Array, implementing Enumerable; Shirt.red.each(&block), - # Shirt.red.first, and Shirt.red.inject(memo, &block) all behave as if Shirt.red really were an Array. - # - # These named scopes are composable. For instance, Shirt.red.dry_clean_only will produce all shirts that are both red and dry clean only. - # Nested finds and calculations also work with these compositions: Shirt.red.dry_clean_only.count returns the number of garments - # for which these criteria obtain. Similarly with Shirt.red.dry_clean_only.average(:thread_count). - # - # All scopes are available as class methods on the ActiveRecord::Base descendent upon which the scopes were defined. But they are also available to - # has_many associations. If, - # - # class Person < ActiveRecord::Base - # has_many :shirts - # end - # - # then elton.shirts.red.dry_clean_only will return all of Elton's red, dry clean - # only shirts. - # - # Named scopes can also be procedural. - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # In this example, Shirt.colored('puce') finds all puce shirts. - # - # Named scopes can also have extensions, just as with has_many declarations: - # - # class Shirt < ActiveRecord::Base - # named_scope :red, :conditions => {:color => 'red'} do - # def dom_id - # 'red_shirts' - # end - # end - # end - # - # - # For testing complex named scopes, you can examine the scoping options using the - # proxy_options method on the proxy itself. - # - # class Shirt < ActiveRecord::Base - # named_scope :colored, lambda { |color| - # { :conditions => { :color => color } } - # } - # end - # - # expected_options = { :conditions => { :colored => 'red' } } - # assert_equal expected_options, Shirt.colored('red').proxy_options - def named_scope(name, options = {}) - name = name.to_sym - scopes[name] = lambda do |parent_scope, *args| - Scope.new(parent_scope, case options - when Hash - options - when Proc - options.call(*args) - end) { |*a| yield(*a) if block_given? } - end - (class << self; self end).instance_eval do - define_method name do |*args| - scopes[name].call(self, *args) - end - end - end - end - - class Scope - attr_reader :proxy_scope, :proxy_options - - [].methods.each do |m| - unless m =~ /(^__|^nil\?|^send|^object_id$|class|extend|^find$|count|sum|average|maximum|minimum|paginate|first|last|empty\?|respond_to\?)/ - delegate m, :to => :proxy_found - end - end - - delegate :scopes, :with_scope, :to => :proxy_scope - - def initialize(proxy_scope, options) - [options[:extend]].flatten.each { |extension| extend extension } if options[:extend] - extend Module.new { |*args| yield(*args) } if block_given? - @proxy_scope, @proxy_options = proxy_scope, options.except(:extend) - end - - def reload - load_found; self - end - - def first(*args) - if args.first.kind_of?(Integer) || (@found && !args.first.kind_of?(Hash)) - proxy_found.first(*args) - else - find(:first, *args) - end - end - - def last(*args) - if args.first.kind_of?(Integer) || (@found && !args.first.kind_of?(Hash)) - proxy_found.last(*args) - else - find(:last, *args) - end - end - - def empty? - @found ? @found.empty? : count.zero? - end - - def respond_to?(method, include_private = false) - super || @proxy_scope.respond_to?(method, include_private) - end - - protected - def proxy_found - @found || load_found - end - - private - def method_missing(method, *args) - if scopes.include?(method) - scopes[method].call(self, *args) - else - with_scope :find => proxy_options do - proxy_scope.send(method, *args) { |*a| yield(*a) if block_given? } - end - end - end - - def load_found - @found = find(:all) - end - end - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb b/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb deleted file mode 100644 index 7daff59..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb +++ /dev/null @@ -1,37 +0,0 @@ -ActiveRecord::Associations::AssociationProxy.class_eval do - protected - def with_scope(*args) - @reflection.klass.send(:with_scope, *args) { |*a| yield(*a) if block_given? } - end -end - -[ ActiveRecord::Associations::AssociationCollection, - ActiveRecord::Associations::HasManyThroughAssociation ].each do |klass| - klass.class_eval do - protected - alias :method_missing_without_scopes :method_missing_without_paginate - def method_missing_without_paginate(method, *args) - if @reflection.klass.scopes.include?(method) - @reflection.klass.scopes[method].call(self, *args) { |*a| yield(*a) if block_given? } - else - method_missing_without_scopes(method, *args) { |*a| yield(*a) if block_given? } - end - end - end -end - -# Rails 1.2.6 -ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do - protected - def method_missing(method, *args) - if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) - super - elsif @reflection.klass.scopes.include?(method) - @reflection.klass.scopes[method].call(self, *args) - else - @reflection.klass.with_scope(:find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false }) do - @reflection.klass.send(method, *args) { |*a| yield(*a) if block_given? } - end - end - end -end if ActiveRecord::Base.respond_to? :find_first diff --git a/vendor/plugins/will_paginate/lib/will_paginate/version.rb b/vendor/plugins/will_paginate/lib/will_paginate/version.rb deleted file mode 100644 index 99f3238..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module WillPaginate - module VERSION - MAJOR = 2 - MINOR = 3 - TINY = 5 - - STRING = [MAJOR, MINOR, TINY].join('.') - end -end diff --git a/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb b/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb deleted file mode 100644 index 5f7ae42..0000000 --- a/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +++ /dev/null @@ -1,389 +0,0 @@ -require 'will_paginate/core_ext' - -module WillPaginate - # = Will Paginate view helpers - # - # The main view helper, #will_paginate, renders - # pagination links for the given collection. The helper itself is lightweight - # and serves only as a wrapper around LinkRenderer instantiation; the - # renderer then does all the hard work of generating the HTML. - # - # == Global options for helpers - # - # Options for pagination helpers are optional and get their default values from the - # WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to - # override default options on the global level: - # - # WillPaginate::ViewHelpers.pagination_options[:previous_label] = 'Previous page' - # - # By putting this into "config/initializers/will_paginate.rb" (or simply environment.rb in - # older versions of Rails) you can easily translate link texts to previous - # and next pages, as well as override some other defaults to your liking. - module ViewHelpers - # default options that can be overridden on the global level - @@pagination_options = { - :class => 'pagination', - :previous_label => '« Previous', - :next_label => 'Next »', - :inner_window => 4, # links around the current page - :outer_window => 1, # links around beginning and end - :separator => ' ', # single space is friendly to spiders and non-graphic browsers - :param_name => :page, - :params => nil, - :renderer => 'WillPaginate::LinkRenderer', - :page_links => true, - :container => true - } - mattr_reader :pagination_options - - # Renders Digg/Flickr-style pagination for a WillPaginate::Collection - # object. Nil is returned if there is only one page in total; no point in - # rendering the pagination in that case... - # - # ==== Options - # Display options: - # * :previous_label -- default: "« Previous" (this parameter is called :prev_label in versions 2.3.2 and older!) - # * :next_label -- default: "Next »" - # * :page_links -- when false, only previous/next links are rendered (default: true) - # * :inner_window -- how many links are shown around the current page (default: 4) - # * :outer_window -- how many links are around the first and the last page (default: 1) - # * :separator -- string separator for page HTML elements (default: single space) - # - # HTML options: - # * :class -- CSS class name for the generated DIV (default: "pagination") - # * :container -- toggles rendering of the DIV container for pagination links, set to - # false only when you are rendering your own pagination markup (default: true) - # * :id -- HTML ID for the container (default: nil). Pass +true+ to have the ID - # automatically generated from the class name of objects in collection: for example, paginating - # ArticleComment models would yield an ID of "article_comments_pagination". - # - # Advanced options: - # * :param_name -- parameter name for page number in URLs (default: :page) - # * :params -- additional parameters when generating pagination links - # (eg. :controller => "foo", :action => nil) - # * :renderer -- class name, class or instance of a link renderer (default: - # WillPaginate::LinkRenderer) - # - # All options not recognized by will_paginate will become HTML attributes on the container - # element for pagination links (the DIV). For example: - # - # <%= will_paginate @posts, :style => 'font-size: small' %> - # - # ... will result in: - # - # - # - # ==== Using the helper without arguments - # If the helper is called without passing in the collection object, it will - # try to read from the instance variable inferred by the controller name. - # For example, calling +will_paginate+ while the current controller is - # PostsController will result in trying to read from the @posts - # variable. Example: - # - # <%= will_paginate :id => true %> - # - # ... will result in @post collection getting paginated: - # - # - # - def will_paginate(collection = nil, options = {}) - options, collection = collection, nil if collection.is_a? Hash - unless collection or !controller - collection_name = "@#{controller.controller_name}" - collection = instance_variable_get(collection_name) - raise ArgumentError, "The #{collection_name} variable appears to be empty. Did you " + - "forget to pass the collection object for will_paginate?" unless collection - end - # early exit if there is nothing to render - return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1 - - options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options - if options[:prev_label] - WillPaginate::Deprecation::warn(":prev_label view parameter is now :previous_label; the old name has been deprecated", caller) - options[:previous_label] = options.delete(:prev_label) - end - - # get the renderer instance - renderer = case options[:renderer] - when String - options[:renderer].to_s.constantize.new - when Class - options[:renderer].new - else - options[:renderer] - end - # render HTML for pagination - renderer.prepare collection, options, self - renderer.to_html - end - - # Wrapper for rendering pagination links at both top and bottom of a block - # of content. - # - # <% paginated_section @posts do %> - #
    - # <% for post in @posts %> - #
  1. ...
  2. - # <% end %> - #
- # <% end %> - # - # will result in: - # - # - #
    - # ... - #
- # - # - # Arguments are passed to a will_paginate call, so the same options - # apply. Don't use the :id option; otherwise you'll finish with two - # blocks of pagination links sharing the same ID (which is invalid HTML). - def paginated_section(*args, &block) - pagination = will_paginate(*args).to_s - - unless ActionView::Base.respond_to? :erb_variable - concat pagination - yield - concat pagination - else - content = pagination + capture(&block) + pagination - concat(content, block.binding) - end - end - - # Renders a helpful message with numbers of displayed vs. total entries. - # You can use this as a blueprint for your own, similar helpers. - # - # <%= page_entries_info @posts %> - # #-> Displaying posts 6 - 10 of 26 in total - # - # By default, the message will use the humanized class name of objects - # in collection: for instance, "project types" for ProjectType models. - # Override this with the :entry_name parameter: - # - # <%= page_entries_info @posts, :entry_name => 'item' %> - # #-> Displaying items 6 - 10 of 26 in total - def page_entries_info(collection, options = {}) - entry_name = options[:entry_name] || - (collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' ')) - - if collection.total_pages < 2 - case collection.size - when 0; "No #{entry_name.pluralize} found" - when 1; "Displaying 1 #{entry_name}" - else; "Displaying all #{collection.size} #{entry_name.pluralize}" - end - else - %{Displaying #{entry_name.pluralize} %d - %d of %d in total} % [ - collection.offset + 1, - collection.offset + collection.length, - collection.total_entries - ] - end - end - - def self.total_pages_for_collection(collection) #:nodoc: - if collection.respond_to?('page_count') and !collection.respond_to?('total_pages') - WillPaginate::Deprecation.warn %{ - You are using a paginated collection of class #{collection.class.name} - which conforms to the old API of WillPaginate::Collection by using - `page_count`, while the current method name is `total_pages`. Please - upgrade yours or 3rd-party code that provides the paginated collection}, caller - class << collection - def total_pages; page_count; end - end - end - collection.total_pages - end - end - - # This class does the heavy lifting of actually building the pagination - # links. It is used by the will_paginate helper internally. - class LinkRenderer - - # The gap in page links is represented by: - # - # - attr_accessor :gap_marker - - def initialize - @gap_marker = '' - end - - # * +collection+ is a WillPaginate::Collection instance or any other object - # that conforms to that API - # * +options+ are forwarded from +will_paginate+ view helper - # * +template+ is the reference to the template being rendered - def prepare(collection, options, template) - @collection = collection - @options = options - @template = template - - # reset values in case we're re-using this instance - @total_pages = @param_name = @url_string = nil - end - - # Process it! This method returns the complete HTML string which contains - # pagination links. Feel free to subclass LinkRenderer and change this - # method as you see fit. - def to_html - links = @options[:page_links] ? windowed_links : [] - # previous/next buttons - links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label]) - links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label]) - - html = links.join(@options[:separator]) - @options[:container] ? @template.content_tag(:div, html, html_attributes) : html - end - - # Returns the subset of +options+ this instance was initialized with that - # represent HTML attributes for the container element of pagination links. - def html_attributes - return @html_attributes if @html_attributes - @html_attributes = @options.except *(WillPaginate::ViewHelpers.pagination_options.keys - [:class]) - # pagination of Post models will have the ID of "posts_pagination" - if @options[:container] and @options[:id] === true - @html_attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination' - end - @html_attributes - end - - protected - - # Collects link items for visible page numbers. - def windowed_links - prev = nil - - visible_page_numbers.inject [] do |links, n| - # detect gaps: - links << gap_marker if prev and n > prev + 1 - links << page_link_or_span(n, 'current') - prev = n - links - end - end - - # Calculates visible page numbers using the :inner_window and - # :outer_window options. - def visible_page_numbers - inner_window, outer_window = @options[:inner_window].to_i, @options[:outer_window].to_i - window_from = current_page - inner_window - window_to = current_page + inner_window - - # adjust lower or upper limit if other is out of bounds - if window_to > total_pages - window_from -= window_to - total_pages - window_to = total_pages - end - if window_from < 1 - window_to += 1 - window_from - window_from = 1 - window_to = total_pages if window_to > total_pages - end - - visible = (1..total_pages).to_a - left_gap = (2 + outer_window)...window_from - right_gap = (window_to + 1)...(total_pages - outer_window) - visible -= left_gap.to_a if left_gap.last - left_gap.first > 1 - visible -= right_gap.to_a if right_gap.last - right_gap.first > 1 - - visible - end - - def page_link_or_span(page, span_class, text = nil) - text ||= page.to_s - - if page and page != current_page - classnames = span_class && span_class.index(' ') && span_class.split(' ', 2).last - page_link page, text, :rel => rel_value(page), :class => classnames - else - page_span page, text, :class => span_class - end - end - - def page_link(page, text, attributes = {}) - @template.link_to text, url_for(page), attributes - end - - def page_span(page, text, attributes = {}) - @template.content_tag :span, text, attributes - end - - # Returns URL params for +page_link_or_span+, taking the current GET params - # and :params option into account. - def url_for(page) - page_one = page == 1 - unless @url_string and !page_one - @url_params = {} - # page links should preserve GET parameters - stringified_merge @url_params, @template.params if @template.request.get? - stringified_merge @url_params, @options[:params] if @options[:params] - - if complex = param_name.index(/[^\w-]/) - page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest). - parse_query_parameters("#{param_name}=#{page}") - - stringified_merge @url_params, page_param - else - @url_params[param_name] = page_one ? 1 : 2 - end - - url = @template.url_for(@url_params) - return url if page_one - - if complex - @url_string = url.sub(%r!((?:\?|&)#{CGI.escape param_name}=)#{page}!, '\1@') - return url - else - @url_string = url - @url_params[param_name] = 3 - @template.url_for(@url_params).split(//).each_with_index do |char, i| - if char == '3' and url[i, 1] == '2' - @url_string[i] = '@' - break - end - end - end - end - # finally! - @url_string.sub '@', page.to_s - end - - private - - def rel_value(page) - case page - when @collection.previous_page; 'prev' + (page == 1 ? ' start' : '') - when @collection.next_page; 'next' - when 1; 'start' - end - end - - def current_page - @collection.current_page - end - - def total_pages - @total_pages ||= WillPaginate::ViewHelpers.total_pages_for_collection(@collection) - end - - def param_name - @param_name ||= @options[:param_name].to_s - end - - # Recursively merge into target hash by using stringified keys from the other one - def stringified_merge(target, other) - other.each do |key, value| - key = key.to_s # this line is what it's all about! - existing = target[key] - - if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?) - stringified_merge(existing || (target[key] = {}), value) - else - target[key] = value - end - end - end - end -end diff --git a/vendor/plugins/will_paginate/test/boot.rb b/vendor/plugins/will_paginate/test/boot.rb deleted file mode 100644 index 622fc93..0000000 --- a/vendor/plugins/will_paginate/test/boot.rb +++ /dev/null @@ -1,21 +0,0 @@ -plugin_root = File.join(File.dirname(__FILE__), '..') -version = ENV['RAILS_VERSION'] -version = nil if version and version == "" - -# first look for a symlink to a copy of the framework -if !version and framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p } - puts "found framework root: #{framework_root}" - # this allows for a plugin to be tested outside of an app and without Rails gems - $:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib" -else - # simply use installed gems if available - puts "using Rails#{version ? ' ' + version : nil} gems" - require 'rubygems' - - if version - gem 'rails', version - else - gem 'actionpack' - gem 'activerecord' - end -end diff --git a/vendor/plugins/will_paginate/test/collection_test.rb b/vendor/plugins/will_paginate/test/collection_test.rb deleted file mode 100644 index a9336bb..0000000 --- a/vendor/plugins/will_paginate/test/collection_test.rb +++ /dev/null @@ -1,143 +0,0 @@ -require 'helper' -require 'will_paginate/array' - -class ArrayPaginationTest < Test::Unit::TestCase - - def setup ; end - - def test_simple - collection = ('a'..'e').to_a - - [{ :page => 1, :per_page => 3, :expected => %w( a b c ) }, - { :page => 2, :per_page => 3, :expected => %w( d e ) }, - { :page => 1, :per_page => 5, :expected => %w( a b c d e ) }, - { :page => 3, :per_page => 5, :expected => [] }, - ]. - each do |conditions| - expected = conditions.delete :expected - assert_equal expected, collection.paginate(conditions) - end - end - - def test_defaults - result = (1..50).to_a.paginate - assert_equal 1, result.current_page - assert_equal 30, result.size - end - - def test_deprecated_api - assert_raise(ArgumentError) { [].paginate(2) } - assert_raise(ArgumentError) { [].paginate(2, 10) } - end - - def test_total_entries_has_precedence - result = %w(a b c).paginate :total_entries => 5 - assert_equal 5, result.total_entries - end - - def test_argument_error_with_params_and_another_argument - assert_raise ArgumentError do - [].paginate({}, 5) - end - end - - def test_paginated_collection - entries = %w(a b c) - collection = create(2, 3, 10) do |pager| - assert_equal entries, pager.replace(entries) - end - - assert_equal entries, collection - assert_respond_to_all collection, %w(total_pages each offset size current_page per_page total_entries) - assert_kind_of Array, collection - assert_instance_of Array, collection.entries - assert_equal 3, collection.offset - assert_equal 4, collection.total_pages - assert !collection.out_of_bounds? - end - - def test_previous_next_pages - collection = create(1, 1, 3) - assert_nil collection.previous_page - assert_equal 2, collection.next_page - - collection = create(2, 1, 3) - assert_equal 1, collection.previous_page - assert_equal 3, collection.next_page - - collection = create(3, 1, 3) - assert_equal 2, collection.previous_page - assert_nil collection.next_page - end - - def test_out_of_bounds - entries = create(2, 3, 2){} - assert entries.out_of_bounds? - - entries = create(1, 3, 2){} - assert !entries.out_of_bounds? - end - - def test_guessing_total_count - entries = create do |pager| - # collection is shorter than limit - pager.replace array - end - assert_equal 8, entries.total_entries - - entries = create(2, 5, 10) do |pager| - # collection is shorter than limit, but we have an explicit count - pager.replace array - end - assert_equal 10, entries.total_entries - - entries = create do |pager| - # collection is the same as limit; we can't guess - pager.replace array(5) - end - assert_equal nil, entries.total_entries - - entries = create do |pager| - # collection is empty; we can't guess - pager.replace array(0) - end - assert_equal nil, entries.total_entries - - entries = create(1) do |pager| - # collection is empty and we're on page 1, - # so the whole thing must be empty, too - pager.replace array(0) - end - assert_equal 0, entries.total_entries - end - - def test_invalid_page - bad_inputs = [0, -1, nil, '', 'Schnitzel'] - - bad_inputs.each do |bad| - assert_raise(WillPaginate::InvalidPage) { create bad } - end - end - - def test_invalid_per_page_setting - assert_raise(ArgumentError) { create(1, -1) } - end - - def test_page_count_was_removed - assert_raise(NoMethodError) { create.page_count } - # It's `total_pages` now. - end - - private - def create(page = 2, limit = 5, total = nil, &block) - if block_given? - WillPaginate::Collection.create(page, limit, total, &block) - else - WillPaginate::Collection.new(page, limit, total) - end - end - - def array(size = 3) - Array.new(size) - end -end diff --git a/vendor/plugins/will_paginate/test/console b/vendor/plugins/will_paginate/test/console deleted file mode 100755 index 3f282f1..0000000 --- a/vendor/plugins/will_paginate/test/console +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' -libs = [] - -libs << 'irb/completion' -libs << File.join('lib', 'load_fixtures') - -exec "#{irb} -Ilib:test#{libs.map{ |l| " -r #{l}" }.join} --simple-prompt" diff --git a/vendor/plugins/will_paginate/test/finder_test.rb b/vendor/plugins/will_paginate/test/finder_test.rb deleted file mode 100644 index 38ef565..0000000 --- a/vendor/plugins/will_paginate/test/finder_test.rb +++ /dev/null @@ -1,476 +0,0 @@ -require 'helper' -require 'lib/activerecord_test_case' - -require 'will_paginate' -WillPaginate.enable_activerecord -WillPaginate.enable_named_scope - -class FinderTest < ActiveRecordTestCase - fixtures :topics, :replies, :users, :projects, :developers_projects - - def test_new_methods_presence - assert_respond_to_all Topic, %w(per_page paginate paginate_by_sql) - end - - def test_simple_paginate - assert_queries(1) do - entries = Topic.paginate :page => nil - assert_equal 1, entries.current_page - assert_equal 1, entries.total_pages - assert_equal 4, entries.size - end - - assert_queries(2) do - entries = Topic.paginate :page => 2 - assert_equal 1, entries.total_pages - assert entries.empty? - end - end - - def test_parameter_api - # :page parameter in options is required! - assert_raise(ArgumentError){ Topic.paginate } - assert_raise(ArgumentError){ Topic.paginate({}) } - - # explicit :all should not break anything - assert_equal Topic.paginate(:page => nil), Topic.paginate(:all, :page => 1) - - # :count could be nil and we should still not cry - assert_nothing_raised { Topic.paginate :page => 1, :count => nil } - end - - def test_paginate_with_per_page - entries = Topic.paginate :page => 1, :per_page => 1 - assert_equal 1, entries.size - assert_equal 4, entries.total_pages - - # Developer class has explicit per_page at 10 - entries = Developer.paginate :page => 1 - assert_equal 10, entries.size - assert_equal 2, entries.total_pages - - entries = Developer.paginate :page => 1, :per_page => 5 - assert_equal 11, entries.total_entries - assert_equal 5, entries.size - assert_equal 3, entries.total_pages - end - - def test_paginate_with_order - entries = Topic.paginate :page => 1, :order => 'created_at desc' - expected = [topics(:futurama), topics(:harvey_birdman), topics(:rails), topics(:ar)].reverse - assert_equal expected, entries.to_a - assert_equal 1, entries.total_pages - end - - def test_paginate_with_conditions - entries = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago] - expected = [topics(:rails), topics(:ar)] - assert_equal expected, entries.to_a - assert_equal 1, entries.total_pages - end - - def test_paginate_with_include_and_conditions - entries = Topic.paginate \ - :page => 1, - :include => :replies, - :conditions => "replies.content LIKE 'Bird%' ", - :per_page => 10 - - expected = Topic.find :all, - :include => 'replies', - :conditions => "replies.content LIKE 'Bird%' ", - :limit => 10 - - assert_equal expected, entries.to_a - assert_equal 1, entries.total_entries - end - - def test_paginate_with_include_and_order - entries = nil - assert_queries(2) do - entries = Topic.paginate \ - :page => 1, - :include => :replies, - :order => 'replies.created_at asc, topics.created_at asc', - :per_page => 10 - end - - expected = Topic.find :all, - :include => 'replies', - :order => 'replies.created_at asc, topics.created_at asc', - :limit => 10 - - assert_equal expected, entries.to_a - assert_equal 4, entries.total_entries - end - - def test_paginate_associations_with_include - entries, project = nil, projects(:active_record) - - assert_nothing_raised "THIS IS A BUG in Rails 1.2.3 that was fixed in [7326]. " + - "Please upgrade to a newer version of Rails." do - entries = project.topics.paginate \ - :page => 1, - :include => :replies, - :conditions => "replies.content LIKE 'Nice%' ", - :per_page => 10 - end - - expected = Topic.find :all, - :include => 'replies', - :conditions => "project_id = #{project.id} AND replies.content LIKE 'Nice%' ", - :limit => 10 - - assert_equal expected, entries.to_a - end - - def test_paginate_associations - dhh = users :david - expected_name_ordered = [projects(:action_controller), projects(:active_record)] - expected_id_ordered = [projects(:active_record), projects(:action_controller)] - - assert_queries(2) do - # with association-specified order - entries = dhh.projects.paginate(:page => 1) - assert_equal expected_name_ordered, entries - assert_equal 2, entries.total_entries - end - - # with explicit order - entries = dhh.projects.paginate(:page => 1, :order => 'projects.id') - assert_equal expected_id_ordered, entries - assert_equal 2, entries.total_entries - - assert_nothing_raised { dhh.projects.find(:all, :order => 'projects.id', :limit => 4) } - entries = dhh.projects.paginate(:page => 1, :order => 'projects.id', :per_page => 4) - assert_equal expected_id_ordered, entries - - # has_many with implicit order - topic = Topic.find(1) - expected = [replies(:spam), replies(:witty_retort)] - assert_equal expected.map(&:id).sort, topic.replies.paginate(:page => 1).map(&:id).sort - assert_equal expected.reverse, topic.replies.paginate(:page => 1, :order => 'replies.id ASC') - end - - def test_paginate_association_extension - project = Project.find(:first) - - assert_queries(2) do - entries = project.replies.paginate_recent :page => 1 - assert_equal [replies(:brave)], entries - end - end - - def test_paginate_with_joins - entries = nil - - assert_queries(1) do - entries = Developer.paginate :page => 1, - :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id', - :conditions => 'project_id = 1' - assert_equal 2, entries.size - developer_names = entries.map &:name - assert developer_names.include?('David') - assert developer_names.include?('Jamis') - end - - assert_queries(1) do - expected = entries.to_a - entries = Developer.paginate :page => 1, - :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id', - :conditions => 'project_id = 1', :count => { :select => "users.id" } - assert_equal expected, entries.to_a - assert_equal 2, entries.total_entries - end - end - - def test_paginate_with_group - entries = nil - assert_queries(1) do - entries = Developer.paginate :page => 1, :per_page => 10, - :group => 'salary', :select => 'salary', :order => 'salary' - end - - expected = [ users(:david), users(:jamis), users(:dev_10), users(:poor_jamis) ].map(&:salary).sort - assert_equal expected, entries.map(&:salary) - end - - def test_paginate_with_dynamic_finder - expected = [replies(:witty_retort), replies(:spam)] - assert_equal expected, Reply.paginate_by_topic_id(1, :page => 1) - - entries = Developer.paginate :conditions => { :salary => 100000 }, :page => 1, :per_page => 5 - assert_equal 8, entries.total_entries - assert_equal entries, Developer.paginate_by_salary(100000, :page => 1, :per_page => 5) - - # dynamic finder + conditions - entries = Developer.paginate_by_salary(100000, :page => 1, - :conditions => ['id > ?', 6]) - assert_equal 4, entries.total_entries - assert_equal (7..10).to_a, entries.map(&:id) - - assert_raises NoMethodError do - Developer.paginate_by_inexistent_attribute 100000, :page => 1 - end - end - - def test_scoped_paginate - entries = Developer.with_poor_ones { Developer.paginate :page => 1 } - - assert_equal 2, entries.size - assert_equal 2, entries.total_entries - end - - ## named_scope ## - - def test_paginate_in_named_scope - entries = Developer.poor.paginate :page => 1, :per_page => 1 - - assert_equal 1, entries.size - assert_equal 2, entries.total_entries - end - - def test_paginate_in_named_scope_on_habtm_association - project = projects(:active_record) - assert_queries(2) do - entries = project.developers.poor.paginate :page => 1, :per_page => 1 - - assert_equal 1, entries.size, 'one developer should be found' - assert_equal 1, entries.total_entries, 'only one developer should be found' - end - end - - def test_paginate_in_named_scope_on_hmt_association - project = projects(:active_record) - expected = [replies(:brave)] - - assert_queries(2) do - entries = project.replies.recent.paginate :page => 1, :per_page => 1 - assert_equal expected, entries - assert_equal 1, entries.total_entries, 'only one reply should be found' - end - end - - def test_paginate_in_named_scope_on_has_many_association - project = projects(:active_record) - expected = [topics(:ar)] - - assert_queries(2) do - entries = project.topics.mentions_activerecord.paginate :page => 1, :per_page => 1 - assert_equal expected, entries - assert_equal 1, entries.total_entries, 'only one topic should be found' - end - end - - def test_named_scope_with_include - project = projects(:active_record) - entries = project.topics.with_replies_starting_with('AR ').paginate(:page => 1, :per_page => 1) - assert_equal 1, entries.size - end - - ## misc ## - - def test_count_and_total_entries_options_are_mutually_exclusive - e = assert_raise ArgumentError do - Developer.paginate :page => 1, :count => {}, :total_entries => 1 - end - assert_match /exclusive/, e.to_s - end - - def test_readonly - assert_nothing_raised { Developer.paginate :readonly => true, :page => 1 } - end - - # this functionality is temporarily removed - def xtest_pagination_defines_method - pager = "paginate_by_created_at" - assert !User.methods.include?(pager), "User methods should not include `#{pager}` method" - # paginate! - assert 0, User.send(pager, nil, :page => 1).total_entries - # the paging finder should now be defined - assert User.methods.include?(pager), "`#{pager}` method should be defined on User" - end - - # Is this Rails 2.0? Find out by testing find_all which was removed in [6998] - unless ActiveRecord::Base.respond_to? :find_all - def test_paginate_array_of_ids - # AR finders also accept arrays of IDs - # (this was broken in Rails before [6912]) - assert_queries(1) do - entries = Developer.paginate((1..8).to_a, :per_page => 3, :page => 2, :order => 'id') - assert_equal (4..6).to_a, entries.map(&:id) - assert_equal 8, entries.total_entries - end - end - end - - uses_mocha 'internals' do - def test_implicit_all_with_dynamic_finders - Topic.expects(:find_all_by_foo).returns([]) - Topic.expects(:count).returns(0) - Topic.paginate_by_foo :page => 2 - end - - def test_guessing_the_total_count - Topic.expects(:find).returns(Array.new(2)) - Topic.expects(:count).never - - entries = Topic.paginate :page => 2, :per_page => 4 - assert_equal 6, entries.total_entries - end - - def test_guessing_that_there_are_no_records - Topic.expects(:find).returns([]) - Topic.expects(:count).never - - entries = Topic.paginate :page => 1, :per_page => 4 - assert_equal 0, entries.total_entries - end - - def test_extra_parameters_stay_untouched - Topic.expects(:find).with(:all, {:foo => 'bar', :limit => 4, :offset => 0 }).returns(Array.new(5)) - Topic.expects(:count).with({:foo => 'bar'}).returns(1) - - Topic.paginate :foo => 'bar', :page => 1, :per_page => 4 - end - - def test_count_skips_select - Developer.stubs(:find).returns([]) - Developer.expects(:count).with({}).returns(0) - Developer.paginate :select => 'salary', :page => 2 - end - - def test_count_select_when_distinct - Developer.stubs(:find).returns([]) - Developer.expects(:count).with(:select => 'DISTINCT salary').returns(0) - Developer.paginate :select => 'DISTINCT salary', :page => 2 - end - - def test_count_with_scoped_select_when_distinct - Developer.stubs(:find).returns([]) - Developer.expects(:count).with(:select => 'DISTINCT users.id').returns(0) - Developer.distinct.paginate :page => 2 - end - - def test_should_use_scoped_finders_if_present - # scope-out compatibility - Topic.expects(:find_best).returns(Array.new(5)) - Topic.expects(:with_best).returns(1) - - Topic.paginate_best :page => 1, :per_page => 4 - end - - def test_paginate_by_sql - assert_respond_to Developer, :paginate_by_sql - Developer.expects(:find_by_sql).with(regexp_matches(/sql LIMIT 3(,| OFFSET) 3/)).returns([]) - Developer.expects(:count_by_sql).with('SELECT COUNT(*) FROM (sql) AS count_table').returns(0) - - entries = Developer.paginate_by_sql 'sql', :page => 2, :per_page => 3 - end - - def test_paginate_by_sql_respects_total_entries_setting - Developer.expects(:find_by_sql).returns([]) - Developer.expects(:count_by_sql).never - - entries = Developer.paginate_by_sql 'sql', :page => 1, :total_entries => 999 - assert_equal 999, entries.total_entries - end - - def test_paginate_by_sql_strips_order_by_when_counting - Developer.expects(:find_by_sql).returns([]) - Developer.expects(:count_by_sql).with("SELECT COUNT(*) FROM (sql\n ) AS count_table").returns(0) - - Developer.paginate_by_sql "sql\n ORDER\nby foo, bar, `baz` ASC", :page => 2 - end - - # TODO: counts are still wrong - def test_ability_to_use_with_custom_finders - # acts_as_taggable defines find_tagged_with(tag, options) - Topic.expects(:find_tagged_with).with('will_paginate', :offset => 5, :limit => 5).returns([]) - Topic.expects(:count).with({}).returns(0) - - Topic.paginate_tagged_with 'will_paginate', :page => 2, :per_page => 5 - end - - def test_array_argument_doesnt_eliminate_count - ids = (1..8).to_a - Developer.expects(:find_all_by_id).returns([]) - Developer.expects(:count).returns(0) - - Developer.paginate_by_id(ids, :per_page => 3, :page => 2, :order => 'id') - end - - def test_paginating_finder_doesnt_mangle_options - Developer.expects(:find).returns([]) - options = { :page => 1, :per_page => 2, :foo => 'bar' } - options_before = options.dup - - Developer.paginate(options) - assert_equal options_before, options - end - - def test_paginate_by_sql_doesnt_change_original_query - query = 'SQL QUERY' - original_query = query.dup - Developer.expects(:find_by_sql).returns([]) - - Developer.paginate_by_sql query, :page => 1 - assert_equal original_query, query - end - - def test_paginated_each - collection = stub('collection', :size => 5, :empty? => false, :per_page => 5) - collection.expects(:each).times(2).returns(collection) - last_collection = stub('collection', :size => 4, :empty? => false, :per_page => 5) - last_collection.expects(:each).returns(last_collection) - - params = { :order => 'id', :total_entries => 0 } - - Developer.expects(:paginate).with(params.merge(:page => 2)).returns(collection) - Developer.expects(:paginate).with(params.merge(:page => 3)).returns(collection) - Developer.expects(:paginate).with(params.merge(:page => 4)).returns(last_collection) - - assert_equal 14, Developer.paginated_each(:page => '2') { } - end - - def test_paginated_each_with_named_scope - assert_equal 2, Developer.poor.paginated_each(:per_page => 1) { - assert_equal 11, Developer.count - } - end - - # detect ActiveRecord 2.1 - if ActiveRecord::Base.private_methods.include?('references_eager_loaded_tables?') - def test_removes_irrelevant_includes_in_count - Developer.expects(:find).returns([1]) - Developer.expects(:count).with({}).returns(0) - - Developer.paginate :page => 1, :per_page => 1, :include => :projects - end - - def test_doesnt_remove_referenced_includes_in_count - Developer.expects(:find).returns([1]) - Developer.expects(:count).with({ :include => :projects, :conditions => 'projects.id > 2' }).returns(0) - - Developer.paginate :page => 1, :per_page => 1, - :include => :projects, :conditions => 'projects.id > 2' - end - end - - def test_paginate_from - result = Developer.paginate(:from => 'users', :page => 1, :per_page => 1) - assert_equal 1, result.size - end - - def test_hmt_with_include - # ticket #220 - reply = projects(:active_record).replies.find(:first, :order => 'replies.id') - assert_equal replies(:decisive), reply - - # ticket #223 - Project.find(1, :include => :replies) - - # I cannot reproduce any of the failures from those reports :( - end - end -end diff --git a/vendor/plugins/will_paginate/test/fixtures/admin.rb b/vendor/plugins/will_paginate/test/fixtures/admin.rb deleted file mode 100644 index 1d5e7f3..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/admin.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Admin < User - has_many :companies, :finder_sql => 'SELECT * FROM companies' -end diff --git a/vendor/plugins/will_paginate/test/fixtures/developer.rb b/vendor/plugins/will_paginate/test/fixtures/developer.rb deleted file mode 100644 index 0224f4b..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/developer.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Developer < User - has_and_belongs_to_many :projects, :include => :topics, :order => 'projects.name' - - def self.with_poor_ones(&block) - with_scope :find => { :conditions => ['salary <= ?', 80000], :order => 'salary' } do - yield - end - end - - named_scope :distinct, :select => 'DISTINCT `users`.*' - named_scope :poor, :conditions => ['salary <= ?', 80000], :order => 'salary' - - def self.per_page() 10 end -end diff --git a/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml b/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml deleted file mode 100644 index cee359c..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,13 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 \ No newline at end of file diff --git a/vendor/plugins/will_paginate/test/fixtures/project.rb b/vendor/plugins/will_paginate/test/fixtures/project.rb deleted file mode 100644 index 0f85ef5..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/project.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true - - has_many :topics - # :finder_sql => 'SELECT * FROM topics WHERE (topics.project_id = #{id})', - # :counter_sql => 'SELECT COUNT(*) FROM topics WHERE (topics.project_id = #{id})' - - has_many :replies, :through => :topics do - def find_recent(params = {}) - with_scope :find => { :conditions => ['replies.created_at > ?', 15.minutes.ago] } do - find :all, params - end - end - end -end diff --git a/vendor/plugins/will_paginate/test/fixtures/projects.yml b/vendor/plugins/will_paginate/test/fixtures/projects.yml deleted file mode 100644 index 74f3c32..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/projects.yml +++ /dev/null @@ -1,6 +0,0 @@ -active_record: - id: 1 - name: Active Record -action_controller: - id: 2 - name: Active Controller diff --git a/vendor/plugins/will_paginate/test/fixtures/replies.yml b/vendor/plugins/will_paginate/test/fixtures/replies.yml deleted file mode 100644 index 9a83c00..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/replies.yml +++ /dev/null @@ -1,29 +0,0 @@ -witty_retort: - id: 1 - topic_id: 1 - content: Birdman is better! - created_at: <%= 6.hours.ago.to_s(:db) %> - -another: - id: 2 - topic_id: 2 - content: Nuh uh! - created_at: <%= 1.hour.ago.to_s(:db) %> - -spam: - id: 3 - topic_id: 1 - content: Nice site! - created_at: <%= 1.hour.ago.to_s(:db) %> - -decisive: - id: 4 - topic_id: 4 - content: "I'm getting to the bottom of this" - created_at: <%= 30.minutes.ago.to_s(:db) %> - -brave: - id: 5 - topic_id: 4 - content: "AR doesn't scare me a bit" - created_at: <%= 10.minutes.ago.to_s(:db) %> diff --git a/vendor/plugins/will_paginate/test/fixtures/reply.rb b/vendor/plugins/will_paginate/test/fixtures/reply.rb deleted file mode 100644 index ecaf3c1..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/reply.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Reply < ActiveRecord::Base - belongs_to :topic, :include => [:replies] - - named_scope :recent, :conditions => ['replies.created_at > ?', 15.minutes.ago] - - validates_presence_of :content -end diff --git a/vendor/plugins/will_paginate/test/fixtures/topic.rb b/vendor/plugins/will_paginate/test/fixtures/topic.rb deleted file mode 100644 index 2c2ce72..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/topic.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC' - belongs_to :project - - named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%'] - - named_scope :with_replies_starting_with, lambda { |text| - { :conditions => "replies.content LIKE '#{text}%' ", :include => :replies } - } -end diff --git a/vendor/plugins/will_paginate/test/fixtures/topics.yml b/vendor/plugins/will_paginate/test/fixtures/topics.yml deleted file mode 100644 index 0a26904..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/topics.yml +++ /dev/null @@ -1,30 +0,0 @@ -futurama: - id: 1 - title: Isnt futurama awesome? - subtitle: It really is, isnt it. - content: I like futurama - created_at: <%= 1.day.ago.to_s(:db) %> - updated_at: - -harvey_birdman: - id: 2 - title: Harvey Birdman is the king of all men - subtitle: yup - content: He really is - created_at: <%= 2.hours.ago.to_s(:db) %> - updated_at: - -rails: - id: 3 - project_id: 1 - title: Rails is nice - subtitle: It makes me happy - content: except when I have to hack internals to fix pagination. even then really. - created_at: <%= 20.minutes.ago.to_s(:db) %> - -ar: - id: 4 - project_id: 1 - title: ActiveRecord sometimes freaks me out - content: "I mean, what's the deal with eager loading?" - created_at: <%= 15.minutes.ago.to_s(:db) %> diff --git a/vendor/plugins/will_paginate/test/fixtures/user.rb b/vendor/plugins/will_paginate/test/fixtures/user.rb deleted file mode 100644 index 4a57cf0..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/user.rb +++ /dev/null @@ -1,2 +0,0 @@ -class User < ActiveRecord::Base -end diff --git a/vendor/plugins/will_paginate/test/fixtures/users.yml b/vendor/plugins/will_paginate/test/fixtures/users.yml deleted file mode 100644 index ed2c03a..0000000 --- a/vendor/plugins/will_paginate/test/fixtures/users.yml +++ /dev/null @@ -1,35 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - type: Developer - -jamis: - id: 2 - name: Jamis - salary: 150000 - type: Developer - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 - type: Developer -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 - type: Developer - -admin: - id: 12 - name: admin - type: Admin - -goofy: - id: 13 - name: Goofy - type: Admin diff --git a/vendor/plugins/will_paginate/test/helper.rb b/vendor/plugins/will_paginate/test/helper.rb deleted file mode 100644 index ad52b1b..0000000 --- a/vendor/plugins/will_paginate/test/helper.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'test/unit' -require 'rubygems' - -# gem install redgreen for colored test output -begin require 'redgreen'; rescue LoadError; end - -require 'boot' unless defined?(ActiveRecord) - -class Test::Unit::TestCase - protected - def assert_respond_to_all object, methods - methods.each do |method| - [method.to_s, method.to_sym].each { |m| assert_respond_to object, m } - end - end - - def collect_deprecations - old_behavior = WillPaginate::Deprecation.behavior - deprecations = [] - WillPaginate::Deprecation.behavior = Proc.new do |message, callstack| - deprecations << message - end - result = yield - [result, deprecations] - ensure - WillPaginate::Deprecation.behavior = old_behavior - end -end - -# Wrap tests that use Mocha and skip if unavailable. -def uses_mocha(test_name) - require 'mocha' unless Object.const_defined?(:Mocha) -rescue LoadError => load_error - $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again." -else - yield -end diff --git a/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb b/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb deleted file mode 100644 index 8f66ebe..0000000 --- a/vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'lib/activerecord_test_connector' - -class ActiveRecordTestCase < Test::Unit::TestCase - # Set our fixture path - if ActiveRecordTestConnector.able_to_connect - self.fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures') - self.use_transactional_fixtures = true - end - - def self.fixtures(*args) - super if ActiveRecordTestConnector.connected - end - - def run(*args) - super if ActiveRecordTestConnector.connected - end - - # Default so Test::Unit::TestCase doesn't complain - def test_truth - end - - protected - - def assert_queries(num = 1) - $query_count = 0 - yield - ensure - assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed." - end - - def assert_no_queries(&block) - assert_queries(0, &block) - end -end - -ActiveRecordTestConnector.setup diff --git a/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb b/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb deleted file mode 100644 index 1130cf5..0000000 --- a/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'active_record' -require 'active_record/version' -require 'active_record/fixtures' - -class ActiveRecordTestConnector - cattr_accessor :able_to_connect - cattr_accessor :connected - - FIXTURES_PATH = File.join(File.dirname(__FILE__), '..', 'fixtures') - - # Set our defaults - self.connected = false - self.able_to_connect = true - - def self.setup - unless self.connected || !self.able_to_connect - setup_connection - load_schema - add_load_path FIXTURES_PATH - self.connected = true - end - rescue Exception => e # errors from ActiveRecord setup - $stderr.puts "\nSkipping ActiveRecord tests: #{e}\n\n" - self.able_to_connect = false - end - - private - - def self.add_load_path(path) - dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies - dep.load_paths.unshift path - end - - def self.setup_connection - db = ENV['DB'].blank?? 'sqlite3' : ENV['DB'] - - configurations = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'database.yml')) - raise "no configuration for '#{db}'" unless configurations.key? db - configuration = configurations[db] - - ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb' - puts "using #{configuration['adapter']} adapter" unless ENV['DB'].blank? - - gem 'sqlite3-ruby' if 'sqlite3' == db - - ActiveRecord::Base.establish_connection(configuration) - ActiveRecord::Base.configurations = { db => configuration } - prepare ActiveRecord::Base.connection - - unless Object.const_defined?(:QUOTED_TYPE) - Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type') - end - end - - def self.load_schema - ActiveRecord::Base.silence do - ActiveRecord::Migration.verbose = false - load File.join(FIXTURES_PATH, 'schema.rb') - end - end - - def self.prepare(conn) - class << conn - IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS /] - - def execute_with_counting(sql, name = nil, &block) - $query_count ||= 0 - $query_count += 1 unless IGNORED_SQL.any? { |r| sql =~ r } - execute_without_counting(sql, name, &block) - end - - alias_method_chain :execute, :counting - end - end -end diff --git a/vendor/plugins/will_paginate/test/lib/load_fixtures.rb b/vendor/plugins/will_paginate/test/lib/load_fixtures.rb deleted file mode 100644 index 10d6f42..0000000 --- a/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'boot' -require 'lib/activerecord_test_connector' - -# setup the connection -ActiveRecordTestConnector.setup - -# load all fixtures -Fixtures.create_fixtures(ActiveRecordTestConnector::FIXTURES_PATH, ActiveRecord::Base.connection.tables) - -require 'will_paginate' -WillPaginate.enable_activerecord diff --git a/vendor/plugins/will_paginate/test/lib/view_test_process.rb b/vendor/plugins/will_paginate/test/lib/view_test_process.rb deleted file mode 100644 index 508411e..0000000 --- a/vendor/plugins/will_paginate/test/lib/view_test_process.rb +++ /dev/null @@ -1,171 +0,0 @@ -require 'action_controller' -require 'action_controller/test_process' - -require 'will_paginate' -WillPaginate.enable_actionpack - -ActionController::Routing::Routes.draw do |map| - map.connect 'dummy/page/:page', :controller => 'dummy' - map.connect 'dummy/dots/page.:page', :controller => 'dummy', :action => 'dots' - map.connect 'ibocorp/:page', :controller => 'ibocorp', - :requirements => { :page => /\d+/ }, - :defaults => { :page => 1 } - - map.connect ':controller/:action/:id' -end - -ActionController::Base.perform_caching = false - -class WillPaginate::ViewTestCase < Test::Unit::TestCase - def setup - super - @controller = DummyController.new - @request = @controller.request - @html_result = nil - @template = '<%= will_paginate collection, options %>' - - @view = ActionView::Base.new - @view.assigns['controller'] = @controller - @view.assigns['_request'] = @request - @view.assigns['_params'] = @request.params - end - - def test_no_complain; end - - protected - - def paginate(collection = {}, options = {}, &block) - if collection.instance_of? Hash - page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection) - collection = [1].paginate(page_options) - end - - locals = { :collection => collection, :options => options } - - unless @view.respond_to? :render_template - # Rails 2.2 - @html_result = ActionView::InlineTemplate.new(@template).render(@view, locals) - else - if defined? ActionView::InlineTemplate - # Rails 2.1 - args = [ ActionView::InlineTemplate.new(@view, @template, locals) ] - else - # older Rails versions - args = [nil, @template, nil, locals] - end - - @html_result = @view.render_template(*args) - end - - @html_document = HTML::Document.new(@html_result, true, false) - - if block_given? - classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class] - assert_select("div.#{classname}", 1, 'no main DIV', &block) - end - end - - def response_from_page_or_rjs - @html_document.root - end - - def validate_page_numbers expected, links, param_name = :page - param_pattern = /\W#{CGI.escape(param_name.to_s)}=([^&]*)/ - - assert_equal(expected, links.map { |e| - e['href'] =~ param_pattern - $1 ? $1.to_i : $1 - }) - end - - def assert_links_match pattern, links = nil, numbers = nil - links ||= assert_select 'div.pagination a[href]' do |elements| - elements - end - - pages = [] if numbers - - links.each do |el| - assert_match pattern, el['href'] - if numbers - el['href'] =~ pattern - pages << ($1.nil?? nil : $1.to_i) - end - end - - assert_equal numbers, pages, "page numbers don't match" if numbers - end - - def assert_no_links_match pattern - assert_select 'div.pagination a[href]' do |elements| - elements.each do |el| - assert_no_match pattern, el['href'] - end - end - end -end - -class DummyRequest - attr_accessor :symbolized_path_parameters - - def initialize - @get = true - @params = {} - @symbolized_path_parameters = { :controller => 'foo', :action => 'bar' } - end - - def get? - @get - end - - def post - @get = false - end - - def relative_url_root - '' - end - - def params(more = nil) - @params.update(more) if more - @params - end -end - -class DummyController - attr_reader :request - attr_accessor :controller_name - - def initialize - @request = DummyRequest.new - @url = ActionController::UrlRewriter.new(@request, @request.params) - end - - def params - @request.params - end - - def url_for(params) - @url.rewrite(params) - end -end - -module HTML - Node.class_eval do - def inner_text - children.map(&:inner_text).join('') - end - end - - Text.class_eval do - def inner_text - self.to_s - end - end - - Tag.class_eval do - def inner_text - childless?? '' : super - end - end -end diff --git a/vendor/plugins/will_paginate/test/tasks.rake b/vendor/plugins/will_paginate/test/tasks.rake deleted file mode 100644 index 59f2f94..0000000 --- a/vendor/plugins/will_paginate/test/tasks.rake +++ /dev/null @@ -1,59 +0,0 @@ -require 'rake/testtask' - -desc 'Test the will_paginate plugin.' -Rake::TestTask.new(:test) do |t| - t.pattern = 'test/**/*_test.rb' - t.verbose = true - t.libs << 'test' -end - -# I want to specify environment variables at call time -class EnvTestTask < Rake::TestTask - attr_accessor :env - - def ruby(*args) - env.each { |key, value| ENV[key] = value } if env - super - env.keys.each { |key| ENV.delete key } if env - end -end - -for configuration in %w( sqlite3 mysql postgres ) - EnvTestTask.new("test_#{configuration}") do |t| - t.pattern = 'test/finder_test.rb' - t.verbose = true - t.env = { 'DB' => configuration } - t.libs << 'test' - end -end - -task :test_databases => %w(test_mysql test_sqlite3 test_postgres) - -desc %{Test everything on SQLite3, MySQL and PostgreSQL} -task :test_full => %w(test test_mysql test_postgres) - -desc %{Test everything with Rails 2.1.x, 2.0.x & 1.2.x gems} -task :test_all do - all = Rake::Task['test_full'] - versions = %w(2.1.0 2.0.4 1.2.6) - versions.each do |version| - ENV['RAILS_VERSION'] = "~> #{version}" - all.invoke - reset_invoked unless version == versions.last - end -end - -def reset_invoked - %w( test_full test test_mysql test_postgres ).each do |name| - Rake::Task[name].instance_variable_set '@already_invoked', false - end -end - -task :rcov do - excludes = %w( lib/will_paginate/named_scope* - lib/will_paginate/core_ext.rb - lib/will_paginate.rb - rails* ) - - system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}] -end diff --git a/vendor/plugins/will_paginate/test/view_test.rb b/vendor/plugins/will_paginate/test/view_test.rb deleted file mode 100644 index 3ada457..0000000 --- a/vendor/plugins/will_paginate/test/view_test.rb +++ /dev/null @@ -1,365 +0,0 @@ -require 'helper' -require 'lib/view_test_process' - -class AdditionalLinkAttributesRenderer < WillPaginate::LinkRenderer - def initialize(link_attributes = nil) - super() - @additional_link_attributes = link_attributes || { :default => 'true' } - end - - def page_link(page, text, attributes = {}) - @template.link_to text, url_for(page), attributes.merge(@additional_link_attributes) - end -end - -class ViewTest < WillPaginate::ViewTestCase - - ## basic pagination ## - - def test_will_paginate - paginate do |pagination| - assert_select 'a[href]', 3 do |elements| - validate_page_numbers [2,3,2], elements - assert_select elements.last, ':last-child', "Next »" - end - assert_select 'span', 2 - assert_select 'span.disabled:first-child', '« Previous' - assert_select 'span.current', '1' - assert_equal '« Previous 1 2 3 Next »', pagination.first.inner_text - end - end - - def test_no_pagination_when_page_count_is_one - paginate :per_page => 30 - assert_equal '', @html_result - end - - def test_will_paginate_with_options - paginate({ :page => 2 }, - :class => 'will_paginate', :previous_label => 'Prev', :next_label => 'Next') do - assert_select 'a[href]', 4 do |elements| - validate_page_numbers [1,1,3,3], elements - # test rel attribute values: - assert_select elements[1], 'a', '1' do |link| - assert_equal 'prev start', link.first['rel'] - end - assert_select elements.first, 'a', "Prev" do |link| - assert_equal 'prev start', link.first['rel'] - end - assert_select elements.last, 'a', "Next" do |link| - assert_equal 'next', link.first['rel'] - end - end - assert_select 'span.current', '2' - end - end - - def test_will_paginate_using_renderer_class - paginate({}, :renderer => AdditionalLinkAttributesRenderer) do - assert_select 'a[default=true]', 3 - end - end - - def test_will_paginate_using_renderer_instance - renderer = WillPaginate::LinkRenderer.new - renderer.gap_marker = '~~' - - paginate({ :per_page => 2 }, :inner_window => 0, :outer_window => 0, :renderer => renderer) do - assert_select 'span.my-gap', '~~' - end - - renderer = AdditionalLinkAttributesRenderer.new(:title => 'rendered') - paginate({}, :renderer => renderer) do - assert_select 'a[title=rendered]', 3 - end - end - - def test_prev_next_links_have_classnames - paginate do |pagination| - assert_select 'span.disabled.prev_page:first-child' - assert_select 'a.next_page[href]:last-child' - end - end - - def test_prev_label_deprecated - assert_deprecated ':previous_label' do - paginate({ :page => 2 }, :prev_label => 'Deprecated') do - assert_select 'a[href]:first-child', 'Deprecated' - end - end - end - - def test_full_output - paginate - expected = <<-HTML - - HTML - expected.strip!.gsub!(/\s{2,}/, ' ') - - assert_dom_equal expected, @html_result - end - - def test_escaping_of_urls - paginate({:page => 1, :per_page => 1, :total_entries => 2}, - :page_links => false, :params => { :tag => '
' }) - - assert_select 'a[href]', 1 do |links| - query = links.first['href'].split('?', 2)[1] - assert_equal %w(page=2 tag=%3Cbr%3E), query.split('&').sort - end - end - - ## advanced options for pagination ## - - def test_will_paginate_without_container - paginate({}, :container => false) - assert_select 'div.pagination', 0, 'main DIV present when it shouldn\'t' - assert_select 'a[href]', 3 - end - - def test_will_paginate_without_page_links - paginate({ :page => 2 }, :page_links => false) do - assert_select 'a[href]', 2 do |elements| - validate_page_numbers [1,3], elements - end - end - end - - def test_will_paginate_windows - paginate({ :page => 6, :per_page => 1 }, :inner_window => 1) do |pagination| - assert_select 'a[href]', 8 do |elements| - validate_page_numbers [5,1,2,5,7,10,11,7], elements - assert_select elements.first, 'a', '« Previous' - assert_select elements.last, 'a', 'Next »' - end - assert_select 'span.current', '6' - assert_equal '« Previous 1 2 … 5 6 7 … 10 11 Next »', pagination.first.inner_text - end - end - - def test_will_paginate_eliminates_small_gaps - paginate({ :page => 6, :per_page => 1 }, :inner_window => 2) do - assert_select 'a[href]', 12 do |elements| - validate_page_numbers [5,1,2,3,4,5,7,8,9,10,11,7], elements - end - end - end - - def test_container_id - paginate do |div| - assert_nil div.first['id'] - end - - # magic ID - paginate({}, :id => true) do |div| - assert_equal 'fixnums_pagination', div.first['id'] - end - - # explicit ID - paginate({}, :id => 'custom_id') do |div| - assert_equal 'custom_id', div.first['id'] - end - end - - ## other helpers ## - - def test_paginated_section - @template = <<-ERB - <% paginated_section collection, options do %> - <%= content_tag :div, '', :id => "developers" %> - <% end %> - ERB - - paginate - assert_select 'div.pagination', 2 - assert_select 'div.pagination + div#developers', 1 - end - - def test_page_entries_info - @template = '<%= page_entries_info collection %>' - array = ('a'..'z').to_a - - paginate array.paginate(:page => 2, :per_page => 5) - assert_equal %{Displaying strings 6 - 10 of 26 in total}, - @html_result - - paginate array.paginate(:page => 7, :per_page => 4) - assert_equal %{Displaying strings 25 - 26 of 26 in total}, - @html_result - end - - uses_mocha 'class name' do - def test_page_entries_info_with_longer_class_name - @template = '<%= page_entries_info collection %>' - collection = ('a'..'z').to_a.paginate - collection.first.stubs(:class).returns(mock('class', :name => 'ProjectType')) - - paginate collection - assert @html_result.index('project types'), "expected <#{@html_result.inspect}> to mention 'project types'" - end - end - - def test_page_entries_info_with_single_page_collection - @template = '<%= page_entries_info collection %>' - - paginate(('a'..'d').to_a.paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying all 4 strings}, @html_result - - paginate(['a'].paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying 1 string}, @html_result - - paginate([].paginate(:page => 1, :per_page => 5)) - assert_equal %{No entries found}, @html_result - end - - def test_page_entries_info_with_custom_entry_name - @template = '<%= page_entries_info collection, :entry_name => "author" %>' - - entries = (1..20).to_a - - paginate(entries.paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying authors 1 - 5 of 20 in total}, @html_result - - paginate(entries.paginate(:page => 1, :per_page => 20)) - assert_equal %{Displaying all 20 authors}, @html_result - - paginate(['a'].paginate(:page => 1, :per_page => 5)) - assert_equal %{Displaying 1 author}, @html_result - - paginate([].paginate(:page => 1, :per_page => 5)) - assert_equal %{No authors found}, @html_result - end - - ## parameter handling in page links ## - - def test_will_paginate_preserves_parameters_on_get - @request.params :foo => { :bar => 'baz' } - paginate - assert_links_match /foo%5Bbar%5D=baz/ - end - - def test_will_paginate_doesnt_preserve_parameters_on_post - @request.post - @request.params :foo => 'bar' - paginate - assert_no_links_match /foo=bar/ - end - - def test_adding_additional_parameters - paginate({}, :params => { :foo => 'bar' }) - assert_links_match /foo=bar/ - end - - def test_adding_anchor_parameter - paginate({}, :params => { :anchor => 'anchor' }) - assert_links_match /#anchor$/ - end - - def test_removing_arbitrary_parameters - @request.params :foo => 'bar' - paginate({}, :params => { :foo => nil }) - assert_no_links_match /foo=bar/ - end - - def test_adding_additional_route_parameters - paginate({}, :params => { :controller => 'baz', :action => 'list' }) - assert_links_match %r{\Wbaz/list\W} - end - - def test_will_paginate_with_custom_page_param - paginate({ :page => 2 }, :param_name => :developers_page) do - assert_select 'a[href]', 4 do |elements| - validate_page_numbers [1,1,3,3], elements, :developers_page - end - end - end - - def test_complex_custom_page_param - @request.params :developers => { :page => 2 } - - paginate({ :page => 2 }, :param_name => 'developers[page]') do - assert_select 'a[href]', 4 do |links| - assert_links_match /\?developers%5Bpage%5D=\d+$/, links - validate_page_numbers [1,1,3,3], links, 'developers[page]' - end - end - end - - def test_custom_routing_page_param - @request.symbolized_path_parameters.update :controller => 'dummy', :action => nil - paginate :per_page => 2 do - assert_select 'a[href]', 6 do |links| - assert_links_match %r{/page/(\d+)$}, links, [2, 3, 4, 5, 6, 2] - end - end - end - - def test_custom_routing_page_param_with_dot_separator - @request.symbolized_path_parameters.update :controller => 'dummy', :action => 'dots' - paginate :per_page => 2 do - assert_select 'a[href]', 6 do |links| - assert_links_match %r{/page\.(\d+)$}, links, [2, 3, 4, 5, 6, 2] - end - end - end - - def test_custom_routing_with_first_page_hidden - @request.symbolized_path_parameters.update :controller => 'ibocorp', :action => nil - paginate :page => 2, :per_page => 2 do - assert_select 'a[href]', 7 do |links| - assert_links_match %r{/ibocorp(?:/(\d+))?$}, links, [nil, nil, 3, 4, 5, 6, 3] - end - end - end - - ## internal hardcore stuff ## - - class LegacyCollection < WillPaginate::Collection - alias :page_count :total_pages - undef :total_pages - end - - def test_deprecation_notices_with_page_count - collection = LegacyCollection.new(1, 1, 2) - - assert_deprecated collection.class.name do - paginate collection - end - end - - uses_mocha 'view internals' do - def test_collection_name_can_be_guessed - collection = mock - collection.expects(:total_pages).returns(1) - - @template = '<%= will_paginate options %>' - @controller.controller_name = 'developers' - @view.assigns['developers'] = collection - - paginate(nil) - end - end - - def test_inferred_collection_name_raises_error_when_nil - @template = '<%= will_paginate options %>' - @controller.controller_name = 'developers' - - e = assert_raise ArgumentError do - paginate(nil) - end - assert e.message.include?('@developers') - end - - if ActionController::Base.respond_to? :rescue_responses - # only on Rails 2 - def test_rescue_response_hook_presence - assert_equal :not_found, - ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] - end - end - -end diff --git a/vendor/plugins/will_paginate/will_paginate.gemspec b/vendor/plugins/will_paginate/will_paginate.gemspec deleted file mode 100644 index 1072c3a..0000000 --- a/vendor/plugins/will_paginate/will_paginate.gemspec +++ /dev/null @@ -1,20 +0,0 @@ -Gem::Specification.new do |s| - s.name = 'will_paginate' - s.version = '2.3.7' - s.date = '2009-02-10' - - s.summary = "Most awesome pagination solution for Rails" - s.description = "The will_paginate library provides a simple, yet powerful and extensible API for ActiveRecord pagination and rendering of pagination links in ActionView templates." - - s.authors = ['Mislav Marohnić', 'PJ Hyett'] - s.email = 'mislav.marohnic@gmail.com' - s.homepage = 'http://github.com/mislav/will_paginate/wikis' - - s.has_rdoc = true - s.rdoc_options = ['--main', 'README.rdoc'] - s.rdoc_options << '--inline-source' << '--charset=UTF-8' - s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG.rdoc'] - - s.files = %w(CHANGELOG.rdoc LICENSE README.rdoc Rakefile examples examples/apple-circle.gif examples/index.haml examples/index.html examples/pagination.css examples/pagination.sass init.rb lib lib/will_paginate lib/will_paginate.rb lib/will_paginate/array.rb lib/will_paginate/collection.rb lib/will_paginate/core_ext.rb lib/will_paginate/finder.rb lib/will_paginate/named_scope.rb lib/will_paginate/named_scope_patch.rb lib/will_paginate/version.rb lib/will_paginate/view_helpers.rb test test/boot.rb test/collection_test.rb test/console test/database.yml test/finder_test.rb test/fixtures test/fixtures/admin.rb test/fixtures/developer.rb test/fixtures/developers_projects.yml test/fixtures/project.rb test/fixtures/projects.yml test/fixtures/replies.yml test/fixtures/reply.rb test/fixtures/schema.rb test/fixtures/topic.rb test/fixtures/topics.yml test/fixtures/user.rb test/fixtures/users.yml test/helper.rb test/lib test/lib/activerecord_test_case.rb test/lib/activerecord_test_connector.rb test/lib/load_fixtures.rb test/lib/view_test_process.rb test/tasks.rake test/view_test.rb) - s.test_files = %w(test/boot.rb test/collection_test.rb test/console test/database.yml test/finder_test.rb test/fixtures test/fixtures/admin.rb test/fixtures/developer.rb test/fixtures/developers_projects.yml test/fixtures/project.rb test/fixtures/projects.yml test/fixtures/replies.yml test/fixtures/reply.rb test/fixtures/schema.rb test/fixtures/topic.rb test/fixtures/topics.yml test/fixtures/user.rb test/fixtures/users.yml test/helper.rb test/lib test/lib/activerecord_test_case.rb test/lib/activerecord_test_connector.rb test/lib/load_fixtures.rb test/lib/view_test_process.rb test/tasks.rake test/view_test.rb) -end -- cgit v1.3