railscart 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/License.txt +26 -0
- data/Manifest.txt +462 -0
- data/README.txt +1 -0
- data/Rakefile +4 -0
- data/bin/railscart +114 -0
- data/config/hoe.rb +78 -0
- data/config/requirements.rb +19 -0
- data/lib/railscart.rb +5 -0
- data/lib/railscart/version.rb +9 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/starter-app/README +182 -0
- data/starter-app/Rakefile +10 -0
- data/starter-app/app/controllers/application.rb +14 -0
- data/starter-app/app/helpers/application_helper.rb +3 -0
- data/starter-app/app/models/role.rb +3 -0
- data/starter-app/app/models/tag.rb +37 -0
- data/starter-app/app/models/tagging.rb +16 -0
- data/starter-app/app/models/user.rb +101 -0
- data/starter-app/app/views/layouts/application.rhtml +20 -0
- data/starter-app/config/boot.rb +45 -0
- data/starter-app/config/database.yml +23 -0
- data/starter-app/config/environment.rb +119 -0
- data/starter-app/config/environments/development.rb +21 -0
- data/starter-app/config/environments/production.rb +21 -0
- data/starter-app/config/environments/test.rb +19 -0
- data/starter-app/config/routes.rb +28 -0
- data/starter-app/db/migrate/001_add_sessions.rb +16 -0
- data/starter-app/db/migrate/002_create_tags_and_taggings.rb +28 -0
- data/starter-app/db/migrate/003_railscart_to_version_19.rb +9 -0
- data/starter-app/db/migrate/004_railscart_to_version_20.rb +9 -0
- data/starter-app/db/migrate/005_create_users.rb +17 -0
- data/starter-app/db/migrate/006_create_roles.rb +20 -0
- data/starter-app/db/sample/addresses.yml +29 -0
- data/starter-app/db/sample/categories.yml +35 -0
- data/starter-app/db/sample/countries.yml +4 -0
- data/starter-app/db/sample/line_items.yml +32 -0
- data/starter-app/db/sample/option_groups.yml +16 -0
- data/starter-app/db/sample/option_values.yml +13 -0
- data/starter-app/db/sample/options.yml +3 -0
- data/starter-app/db/sample/orders.yml +17 -0
- data/starter-app/db/sample/products.yml +70 -0
- data/starter-app/db/sample/roles.yml +3 -0
- data/starter-app/db/sample/skus.yml +35 -0
- data/starter-app/db/sample/states.yml +204 -0
- data/starter-app/db/sample/taggings.yml +16 -0
- data/starter-app/db/sample/tags.yml +6 -0
- data/starter-app/db/sample/txns.yml +13 -0
- data/starter-app/db/sample/users.yml +10 -0
- data/starter-app/db/sample/variations.yml +20 -0
- data/starter-app/doc/README_FOR_APP +2 -0
- data/starter-app/lib/authenticated_system.rb +116 -0
- data/starter-app/lib/authenticated_test_helper.rb +10 -0
- data/starter-app/lib/custom_fixtures.rb +7 -0
- data/starter-app/lib/hijacker.rb +78 -0
- data/starter-app/lib/role_requirement_system.rb +142 -0
- data/starter-app/lib/role_requirement_test_helper.rb +86 -0
- data/starter-app/lib/tagging_extensions.rb +104 -0
- data/starter-app/lib/tasks/rc_sample_data.rake +31 -0
- data/starter-app/lib/tasks/sample/images/ror_bag.jpg +0 -0
- data/starter-app/lib/tasks/sample/images/ror_baseball_jersey.jpg +0 -0
- data/starter-app/lib/tasks/sample/images/ror_jr_spaghetti.jpg +0 -0
- data/starter-app/lib/tasks/sample/images/ror_mug.jpg +0 -0
- data/starter-app/lib/tasks/sample/images/ror_ringer_tshirt.jpg +0 -0
- data/starter-app/lib/tasks/sample/images/ror_stein.jpg +0 -0
- data/starter-app/lib/tasks/sample/images/ror_tote.jpg +0 -0
- data/starter-app/public/.htaccess +40 -0
- data/starter-app/public/404.html +30 -0
- data/starter-app/public/500.html +30 -0
- data/starter-app/public/dispatch.cgi +10 -0
- data/starter-app/public/dispatch.fcgi +24 -0
- data/starter-app/public/dispatch.rb +10 -0
- data/starter-app/public/favicon.ico +0 -0
- data/starter-app/public/images/rails.png +0 -0
- data/starter-app/public/index.html +277 -0
- data/starter-app/public/javascripts/application.js +2 -0
- data/starter-app/public/javascripts/controls.js +833 -0
- data/starter-app/public/javascripts/dragdrop.js +942 -0
- data/starter-app/public/javascripts/effects.js +1088 -0
- data/starter-app/public/javascripts/prototype.js +4184 -0
- data/starter-app/public/robots.txt +1 -0
- data/starter-app/public/stylesheets/application.css +186 -0
- data/starter-app/public/stylesheets/cart/_controller.css +4 -0
- data/starter-app/public/stylesheets/checkout/_controller.css +13 -0
- data/starter-app/script/about +3 -0
- data/starter-app/script/breakpointer +3 -0
- data/starter-app/script/console +3 -0
- data/starter-app/script/destroy +3 -0
- data/starter-app/script/generate +3 -0
- data/starter-app/script/performance/benchmarker +3 -0
- data/starter-app/script/performance/profiler +3 -0
- data/starter-app/script/plugin +3 -0
- data/starter-app/script/process/inspector +3 -0
- data/starter-app/script/process/reaper +3 -0
- data/starter-app/script/process/spawner +3 -0
- data/starter-app/script/runner +3 -0
- data/starter-app/script/server +3 -0
- data/starter-app/test/fixtures/users.yml +7 -0
- data/starter-app/test/test_helper.rb +28 -0
- data/starter-app/test/unit/user_test.rb +8 -0
- data/starter-app/vendor/plugins/acts_as_list/README +23 -0
- data/starter-app/vendor/plugins/acts_as_list/init.rb +3 -0
- data/starter-app/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/starter-app/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
- data/starter-app/vendor/plugins/acts_as_tree/README +26 -0
- data/starter-app/vendor/plugins/acts_as_tree/Rakefile +22 -0
- data/starter-app/vendor/plugins/acts_as_tree/init.rb +1 -0
- data/starter-app/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/database.yml +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/starter-app/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
- data/starter-app/vendor/plugins/calendar_date_select/CHANGELOG +170 -0
- data/starter-app/vendor/plugins/calendar_date_select/MIT-LICENSE +20 -0
- data/starter-app/vendor/plugins/calendar_date_select/README +10 -0
- data/starter-app/vendor/plugins/calendar_date_select/init.rb +15 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/functional/.tmp_cds_test.html +306 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/functional/cds_test.html +324 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/prototype.js +4184 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/test.css +40 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/unit/cds_helper_methods.html +46 -0
- data/starter-app/vendor/plugins/calendar_date_select/js_test/unittest.js +564 -0
- data/starter-app/vendor/plugins/calendar_date_select/lib/calendar_date_select.rb +192 -0
- data/starter-app/vendor/plugins/calendar_date_select/lib/includes_helper.rb +22 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/images/calendar_date_select/calendar.gif +0 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/calendar_date_select.js +439 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_american.js +34 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_finnish.js +24 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_hyphen_ampm.js +36 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_italian.js +24 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/locale/fi.js +10 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/blue.css +130 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/default.css +135 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/plain.css +128 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/red.css +135 -0
- data/starter-app/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/silver.css +133 -0
- data/starter-app/vendor/plugins/calendar_date_select/test/functional/calendar_date_select_test.rb +95 -0
- data/starter-app/vendor/plugins/calendar_date_select/test/functional/helper_methods_test.rb +15 -0
- data/starter-app/vendor/plugins/calendar_date_select/test/test_helper.rb +26 -0
- data/starter-app/vendor/plugins/engines/CHANGELOG +258 -0
- data/starter-app/vendor/plugins/engines/MIT-LICENSE +21 -0
- data/starter-app/vendor/plugins/engines/README +63 -0
- data/starter-app/vendor/plugins/engines/Rakefile +32 -0
- data/starter-app/vendor/plugins/engines/about.yml +7 -0
- data/starter-app/vendor/plugins/engines/boot.rb +18 -0
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/USAGE +45 -0
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +79 -0
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +13 -0
- data/starter-app/vendor/plugins/engines/init.rb +2 -0
- data/starter-app/vendor/plugins/engines/lib/engines.rb +169 -0
- data/starter-app/vendor/plugins/engines/lib/engines/assets.rb +38 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin.rb +125 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb +30 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/loader.rb +18 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/locator.rb +11 -0
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/migrator.rb +60 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb +85 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +24 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb +119 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +145 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +161 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +11 -0
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +84 -0
- data/starter-app/vendor/plugins/engines/lib/engines/testing.rb +87 -0
- data/starter-app/vendor/plugins/engines/tasks/engines.rake +148 -0
- data/starter-app/vendor/plugins/in_place_editing/README +14 -0
- data/starter-app/vendor/plugins/in_place_editing/Rakefile +22 -0
- data/starter-app/vendor/plugins/in_place_editing/init.rb +2 -0
- data/starter-app/vendor/plugins/in_place_editing/lib/in_place_editing.rb +25 -0
- data/starter-app/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb +71 -0
- data/starter-app/vendor/plugins/in_place_editing/test/in_place_editing_test.rb +69 -0
- data/starter-app/vendor/plugins/paginating_find/CHANGELOG +117 -0
- data/starter-app/vendor/plugins/paginating_find/README +89 -0
- data/starter-app/vendor/plugins/paginating_find/init.rb +2 -0
- data/starter-app/vendor/plugins/paginating_find/lib/paginating_find.rb +135 -0
- data/starter-app/vendor/plugins/paginating_find/lib/paging_enumerator.rb +158 -0
- data/starter-app/vendor/plugins/paginating_find/lib/paging_helper.rb +47 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/Rakefile +10 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/app/controllers/application.rb +2 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/boot.rb +44 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/database.yml +6 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/environment.rb +53 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/environments/test.rb +19 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/config/routes.rb +22 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/db/schema.rb +16 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/script/breakpointer +3 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/script/console +3 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/articles.yml +19 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/authors.yml +7 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/edits.yml +11 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/fixtures/models.rb +18 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/test_helper.rb +33 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/abstract_test.rb +7 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/group_test.rb +40 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb +194 -0
- data/starter-app/vendor/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb +143 -0
- data/starter-app/vendor/plugins/railscart/.rakeTasks +7 -0
- data/starter-app/vendor/plugins/railscart/CHANGELOG +1 -0
- data/starter-app/vendor/plugins/railscart/LICENSE +26 -0
- data/starter-app/vendor/plugins/railscart/README +2 -0
- data/starter-app/vendor/plugins/railscart/Rakefile +10 -0
- data/starter-app/vendor/plugins/railscart/VERSION +1 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/account_controller.rb +48 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/base_controller.rb +7 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/categories_controller.rb +107 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/option_groups_controller.rb +36 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/option_values_controller.rb +42 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/options_controller.rb +52 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/orders_controller.rb +194 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/overview_controller.rb +14 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/products_controller.rb +147 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/reports_controller.rb +53 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/users_controller.rb +45 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/admin/variations_controller.rb +73 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/cart_controller.rb +45 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/checkout_controller.rb +179 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/rails_cart/base_controller.rb +41 -0
- data/starter-app/vendor/plugins/railscart/app/controllers/store_controller.rb +20 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/account_helper.rb +2 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/base_helper.rb +15 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/categories_helper.rb +3 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/option_groups_helper.rb +2 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/option_values_helper.rb +2 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/orders_helper.rb +11 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/overview_helper.rb +12 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/users_helper.rb +2 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/admin/variations_helper.rb +2 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/cart_helper.rb +6 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/checkout_helper.rb +17 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/rails_cart/base_helper.rb +67 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/search_helper.rb +10 -0
- data/starter-app/vendor/plugins/railscart/app/helpers/store_helper.rb +3 -0
- data/starter-app/vendor/plugins/railscart/app/models/address.rb +17 -0
- data/starter-app/vendor/plugins/railscart/app/models/cart.rb +37 -0
- data/starter-app/vendor/plugins/railscart/app/models/cart_item.rb +28 -0
- data/starter-app/vendor/plugins/railscart/app/models/category.rb +66 -0
- data/starter-app/vendor/plugins/railscart/app/models/country.rb +3 -0
- data/starter-app/vendor/plugins/railscart/app/models/line_item.rb +24 -0
- data/starter-app/vendor/plugins/railscart/app/models/option.rb +4 -0
- data/starter-app/vendor/plugins/railscart/app/models/option_group.rb +6 -0
- data/starter-app/vendor/plugins/railscart/app/models/option_value.rb +4 -0
- data/starter-app/vendor/plugins/railscart/app/models/order.rb +86 -0
- data/starter-app/vendor/plugins/railscart/app/models/order_mailer.rb +20 -0
- data/starter-app/vendor/plugins/railscart/app/models/payment.rb +49 -0
- data/starter-app/vendor/plugins/railscart/app/models/product.rb +76 -0
- data/starter-app/vendor/plugins/railscart/app/models/search_criteria.rb +27 -0
- data/starter-app/vendor/plugins/railscart/app/models/sku.rb +7 -0
- data/starter-app/vendor/plugins/railscart/app/models/state.rb +3 -0
- data/starter-app/vendor/plugins/railscart/app/models/tax_treatment.rb +2 -0
- data/starter-app/vendor/plugins/railscart/app/models/txn.rb +7 -0
- data/starter-app/vendor/plugins/railscart/app/models/variation.rb +5 -0
- data/starter-app/vendor/plugins/railscart/app/views/account/index.rhtml +3 -0
- data/starter-app/vendor/plugins/railscart/app/views/account/login.rhtml +12 -0
- data/starter-app/vendor/plugins/railscart/app/views/account/signup.rhtml +16 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/categories/_form.rhtml +27 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/categories/edit.rhtml +9 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/categories/list.rhtml +47 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/categories/new.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/option_groups/_form.rhtml +19 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/option_groups/new.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/option_values/_form.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/option_values/edit.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/option_values/list.rhtml +22 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/option_values/new.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/options/_form.rhtml +7 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/options/edit.rhtml +26 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/options/list.rhtml +23 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/options/new.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/orders/_address.rhtml +37 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/orders/index.rhtml +99 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/orders/show.rhtml +43 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/overview/index.rhtml +0 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/_form.rhtml +55 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/_menu.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/_new_variation.rhtml +0 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/edit.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/index.rhtml +66 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/new.rhtml +13 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/products/show.rhtml +26 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/reports/index.rhtml +29 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/reports/sales_total.rhtml +28 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/users/_form.rhtml +29 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/users/_menu.rhtml +5 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/users/edit.rhtml +8 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/users/index.rhtml +26 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/users/new.rhtml +6 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/users/show.rhtml +9 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/variations/_form.rhtml +33 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/variations/_option_values.rhtml +5 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/variations/list.rhtml +23 -0
- data/starter-app/vendor/plugins/railscart/app/views/admin/variations/new.rhtml +14 -0
- data/starter-app/vendor/plugins/railscart/app/views/cart/index.rhtml +49 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/_address.rhtml +51 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/_address_ro.rhtml +18 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/_cart_item.rhtml +5 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/_extra.rhtml +1 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/addresses.rhtml +49 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/cvv.rhtml +15 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/empty_cart.rhtml +4 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/final_confirmation.rhtml +92 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/incomplete.rhtml +7 -0
- data/starter-app/vendor/plugins/railscart/app/views/checkout/thank_you.rhtml +11 -0
- data/starter-app/vendor/plugins/railscart/app/views/layouts/admin.rhtml +69 -0
- data/starter-app/vendor/plugins/railscart/app/views/layouts/products.rhtml +20 -0
- data/starter-app/vendor/plugins/railscart/app/views/layouts/simple.rhtml +37 -0
- data/starter-app/vendor/plugins/railscart/app/views/order_mailer/cancel.rhtml +15 -0
- data/starter-app/vendor/plugins/railscart/app/views/order_mailer/confirm.rhtml +18 -0
- data/starter-app/vendor/plugins/railscart/app/views/shared/_order_details.rhtml +35 -0
- data/starter-app/vendor/plugins/railscart/app/views/shared/_paginate.rhtml +34 -0
- data/starter-app/vendor/plugins/railscart/app/views/shared/_report_criteria.rhtml +32 -0
- data/starter-app/vendor/plugins/railscart/app/views/shared/_tax_treatments.rhtml +12 -0
- data/starter-app/vendor/plugins/railscart/app/views/shared/_variations.rhtml +60 -0
- data/starter-app/vendor/plugins/railscart/app/views/store/_menu.rhtml +7 -0
- data/starter-app/vendor/plugins/railscart/app/views/store/_products.rhtml +10 -0
- data/starter-app/vendor/plugins/railscart/app/views/store/list.rhtml +16 -0
- data/starter-app/vendor/plugins/railscart/app/views/store/show.rhtml +71 -0
- data/starter-app/vendor/plugins/railscart/assets/.htaccess +40 -0
- data/starter-app/vendor/plugins/railscart/assets/404.html +30 -0
- data/starter-app/vendor/plugins/railscart/assets/500.html +30 -0
- data/starter-app/vendor/plugins/railscart/assets/dispatch.cgi +10 -0
- data/starter-app/vendor/plugins/railscart/assets/dispatch.fcgi +24 -0
- data/starter-app/vendor/plugins/railscart/assets/dispatch.rb +10 -0
- data/starter-app/vendor/plugins/railscart/assets/favicon.ico +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/amex_cid.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/creditcard.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/discover_cid.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/master_cid.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_bag.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_baseball_jersey.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_jr_spaghetti.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_mug.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_ringer_tshirt.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_stein.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/products/ror_tote.jpg +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/rails.png +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/railscart/progress.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/railscart/railscart_logo142x65.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/railscart/railscart_logo245x112.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/railscart/spinner.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/spinner.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/images/visa_cid.gif +0 -0
- data/starter-app/vendor/plugins/railscart/assets/javascripts/application.js +2 -0
- data/starter-app/vendor/plugins/railscart/assets/javascripts/controls.js +833 -0
- data/starter-app/vendor/plugins/railscart/assets/javascripts/dragdrop.js +942 -0
- data/starter-app/vendor/plugins/railscart/assets/javascripts/effects.js +1088 -0
- data/starter-app/vendor/plugins/railscart/assets/javascripts/lowpro.js +307 -0
- data/starter-app/vendor/plugins/railscart/assets/javascripts/prototype.js +2515 -0
- data/starter-app/vendor/plugins/railscart/assets/robots.txt +1 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/cart/_controller.css +71 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/checkout/_controller.css +31 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/fullscreen.css +63 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/orders/_controller.css +3 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/products/_controller.css +13 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/railscart-admin.css +295 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/railscart.css +66 -0
- data/starter-app/vendor/plugins/railscart/assets/stylesheets/store/_controller.css +23 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/001_create_addresses.rb +22 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/002_create_cart_items.rb +14 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/003_create_carts.rb +12 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/004_create_categories.rb +15 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/005_create_categories_products.rb +12 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/006_create_line_items.rb +17 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/007_create_option_groups.rb +12 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/008_create_option_values.rb +11 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/009_create_options.rb +11 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/010_create_orders.rb +24 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/011_create_products.rb +22 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/012_ignore_users.rb +9 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/013_create_txns.rb +21 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/014_ignore_roles.rb +9 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/015_create_variations.rb +14 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/016_create_tax_treatments.rb +23 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/017_create_skus.rb +13 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/018_create_countries.rb +11 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/019_create_states.rb +13 -0
- data/starter-app/vendor/plugins/railscart/db/migrate/020_modify_users.rb +9 -0
- data/starter-app/vendor/plugins/railscart/init.rb +16 -0
- data/starter-app/vendor/plugins/railscart/install.rb +3 -0
- data/starter-app/vendor/plugins/railscart/lib/constants/enumerable_constants.rb +207 -0
- data/starter-app/vendor/plugins/railscart/lib/format.rb +12 -0
- data/starter-app/vendor/plugins/railscart/lib/gateway/bogus_gateway.rb +63 -0
- data/starter-app/vendor/plugins/railscart/lib/shipping/flat_rate.rb +10 -0
- data/starter-app/vendor/plugins/railscart/lib/tasks/rc_bootstrap.rake +24 -0
- data/starter-app/vendor/plugins/railscart/lib/tax/sales_tax.rb +26 -0
- data/starter-app/vendor/plugins/railscart/routes.rb +3 -0
- data/starter-app/vendor/plugins/railscart/script/about +3 -0
- data/starter-app/vendor/plugins/railscart/script/breakpointer +3 -0
- data/starter-app/vendor/plugins/railscart/script/console +3 -0
- data/starter-app/vendor/plugins/railscart/script/destroy +3 -0
- data/starter-app/vendor/plugins/railscart/script/generate +3 -0
- data/starter-app/vendor/plugins/railscart/script/performance/benchmarker +3 -0
- data/starter-app/vendor/plugins/railscart/script/performance/profiler +3 -0
- data/starter-app/vendor/plugins/railscart/script/plugin +3 -0
- data/starter-app/vendor/plugins/railscart/script/process/inspector +3 -0
- data/starter-app/vendor/plugins/railscart/script/process/reaper +3 -0
- data/starter-app/vendor/plugins/railscart/script/process/spawner +3 -0
- data/starter-app/vendor/plugins/railscart/script/runner +3 -0
- data/starter-app/vendor/plugins/railscart/script/server +3 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/addresses.yml +29 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/categories.yml +40 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/line_items.yml +32 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/orders.yml +17 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/products.yml +63 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/products_tags.yml +10 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/roles.yml +6 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/roles_users.yml +3 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/skus.yml +5 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/tags.yml +7 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/tax_treatments.yml +7 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/txns.yml +13 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/users.yml +40 -0
- data/starter-app/vendor/plugins/railscart/test/fixtures/variations.yml +16 -0
- data/starter-app/vendor/plugins/railscart/test/functional/account_controller_test.rb +129 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/base_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/option_groups_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/option_values_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/orders_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/overview_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/products_controller_test.rb +125 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/users_controller_test.rb +58 -0
- data/starter-app/vendor/plugins/railscart/test/functional/admin/variations_controller_test.rb +18 -0
- data/starter-app/vendor/plugins/railscart/test/functional/application_controller_test.rb +30 -0
- data/starter-app/vendor/plugins/railscart/test/functional/cart_controller_test.rb +76 -0
- data/starter-app/vendor/plugins/railscart/test/functional/checkout_controller_test.rb +20 -0
- data/starter-app/vendor/plugins/railscart/test/integration/authentication_test.rb +53 -0
- data/starter-app/vendor/plugins/railscart/test/integration/product_admin_test.rb +135 -0
- data/starter-app/vendor/plugins/railscart/test/integration/user_stories_test.rb +59 -0
- data/starter-app/vendor/plugins/railscart/test/integration/variations_test.rb +24 -0
- data/starter-app/vendor/plugins/railscart/test/test_helper.rb +45 -0
- data/starter-app/vendor/plugins/railscart/test/unit/address_test.rb +10 -0
- data/starter-app/vendor/plugins/railscart/test/unit/cart_item_test.rb +55 -0
- data/starter-app/vendor/plugins/railscart/test/unit/cart_test.rb +35 -0
- data/starter-app/vendor/plugins/railscart/test/unit/category_test.rb +52 -0
- data/starter-app/vendor/plugins/railscart/test/unit/line_item_test.rb +61 -0
- data/starter-app/vendor/plugins/railscart/test/unit/option_group_test.rb +12 -0
- data/starter-app/vendor/plugins/railscart/test/unit/order_test.rb +49 -0
- data/starter-app/vendor/plugins/railscart/test/unit/product_test.rb +107 -0
- data/starter-app/vendor/plugins/railscart/test/unit/role_test.rb +10 -0
- data/starter-app/vendor/plugins/railscart/test/unit/sales_tax_test.rb +46 -0
- data/starter-app/vendor/plugins/railscart/test/unit/sku_test.rb +10 -0
- data/starter-app/vendor/plugins/railscart/test/unit/tag_test.rb +9 -0
- data/starter-app/vendor/plugins/railscart/test/unit/tax_treatment_test.rb +10 -0
- data/starter-app/vendor/plugins/railscart/test/unit/txn_test.rb +10 -0
- data/starter-app/vendor/plugins/railscart/test/unit/variation_test.rb +9 -0
- data/starter-app/vendor/plugins/railscart/uninstall.rb +1 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_railscart.rb +11 -0
- data/website/index.html +93 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +557 -0
@@ -0,0 +1,332 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'activerecord', '>= 1.15.4.7794'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
require "#{File.dirname(__FILE__)}/../init"
|
8
|
+
|
9
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
|
10
|
+
|
11
|
+
def setup_db
|
12
|
+
ActiveRecord::Schema.define(:version => 1) do
|
13
|
+
create_table :mixins do |t|
|
14
|
+
t.column :pos, :integer
|
15
|
+
t.column :parent_id, :integer
|
16
|
+
t.column :created_at, :datetime
|
17
|
+
t.column :updated_at, :datetime
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown_db
|
23
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
24
|
+
ActiveRecord::Base.connection.drop_table(table)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Mixin < ActiveRecord::Base
|
29
|
+
end
|
30
|
+
|
31
|
+
class ListMixin < Mixin
|
32
|
+
acts_as_list :column => "pos", :scope => :parent
|
33
|
+
|
34
|
+
def self.table_name() "mixins" end
|
35
|
+
end
|
36
|
+
|
37
|
+
class ListMixinSub1 < ListMixin
|
38
|
+
end
|
39
|
+
|
40
|
+
class ListMixinSub2 < ListMixin
|
41
|
+
end
|
42
|
+
|
43
|
+
class ListWithStringScopeMixin < ActiveRecord::Base
|
44
|
+
acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}'
|
45
|
+
|
46
|
+
def self.table_name() "mixins" end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
class ListTest < Test::Unit::TestCase
|
51
|
+
|
52
|
+
def setup
|
53
|
+
setup_db
|
54
|
+
(1..4).each { |counter| ListMixin.create! :pos => counter, :parent_id => 5 }
|
55
|
+
end
|
56
|
+
|
57
|
+
def teardown
|
58
|
+
teardown_db
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_reordering
|
62
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
63
|
+
|
64
|
+
ListMixin.find(2).move_lower
|
65
|
+
assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
66
|
+
|
67
|
+
ListMixin.find(2).move_higher
|
68
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
69
|
+
|
70
|
+
ListMixin.find(1).move_to_bottom
|
71
|
+
assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
72
|
+
|
73
|
+
ListMixin.find(1).move_to_top
|
74
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
75
|
+
|
76
|
+
ListMixin.find(2).move_to_bottom
|
77
|
+
assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
78
|
+
|
79
|
+
ListMixin.find(4).move_to_top
|
80
|
+
assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_move_to_bottom_with_next_to_last_item
|
84
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
85
|
+
ListMixin.find(3).move_to_bottom
|
86
|
+
assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_next_prev
|
90
|
+
assert_equal ListMixin.find(2), ListMixin.find(1).lower_item
|
91
|
+
assert_nil ListMixin.find(1).higher_item
|
92
|
+
assert_equal ListMixin.find(3), ListMixin.find(4).higher_item
|
93
|
+
assert_nil ListMixin.find(4).lower_item
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_injection
|
97
|
+
item = ListMixin.new(:parent_id => 1)
|
98
|
+
assert_equal "parent_id = 1", item.scope_condition
|
99
|
+
assert_equal "pos", item.position_column
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_insert
|
103
|
+
new = ListMixin.create(:parent_id => 20)
|
104
|
+
assert_equal 1, new.pos
|
105
|
+
assert new.first?
|
106
|
+
assert new.last?
|
107
|
+
|
108
|
+
new = ListMixin.create(:parent_id => 20)
|
109
|
+
assert_equal 2, new.pos
|
110
|
+
assert !new.first?
|
111
|
+
assert new.last?
|
112
|
+
|
113
|
+
new = ListMixin.create(:parent_id => 20)
|
114
|
+
assert_equal 3, new.pos
|
115
|
+
assert !new.first?
|
116
|
+
assert new.last?
|
117
|
+
|
118
|
+
new = ListMixin.create(:parent_id => 0)
|
119
|
+
assert_equal 1, new.pos
|
120
|
+
assert new.first?
|
121
|
+
assert new.last?
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_insert_at
|
125
|
+
new = ListMixin.create(:parent_id => 20)
|
126
|
+
assert_equal 1, new.pos
|
127
|
+
|
128
|
+
new = ListMixin.create(:parent_id => 20)
|
129
|
+
assert_equal 2, new.pos
|
130
|
+
|
131
|
+
new = ListMixin.create(:parent_id => 20)
|
132
|
+
assert_equal 3, new.pos
|
133
|
+
|
134
|
+
new4 = ListMixin.create(:parent_id => 20)
|
135
|
+
assert_equal 4, new4.pos
|
136
|
+
|
137
|
+
new4.insert_at(3)
|
138
|
+
assert_equal 3, new4.pos
|
139
|
+
|
140
|
+
new.reload
|
141
|
+
assert_equal 4, new.pos
|
142
|
+
|
143
|
+
new.insert_at(2)
|
144
|
+
assert_equal 2, new.pos
|
145
|
+
|
146
|
+
new4.reload
|
147
|
+
assert_equal 4, new4.pos
|
148
|
+
|
149
|
+
new5 = ListMixin.create(:parent_id => 20)
|
150
|
+
assert_equal 5, new5.pos
|
151
|
+
|
152
|
+
new5.insert_at(1)
|
153
|
+
assert_equal 1, new5.pos
|
154
|
+
|
155
|
+
new4.reload
|
156
|
+
assert_equal 5, new4.pos
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_delete_middle
|
160
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
161
|
+
|
162
|
+
ListMixin.find(2).destroy
|
163
|
+
|
164
|
+
assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
165
|
+
|
166
|
+
assert_equal 1, ListMixin.find(1).pos
|
167
|
+
assert_equal 2, ListMixin.find(3).pos
|
168
|
+
assert_equal 3, ListMixin.find(4).pos
|
169
|
+
|
170
|
+
ListMixin.find(1).destroy
|
171
|
+
|
172
|
+
assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
173
|
+
|
174
|
+
assert_equal 1, ListMixin.find(3).pos
|
175
|
+
assert_equal 2, ListMixin.find(4).pos
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_with_string_based_scope
|
179
|
+
new = ListWithStringScopeMixin.create(:parent_id => 500)
|
180
|
+
assert_equal 1, new.pos
|
181
|
+
assert new.first?
|
182
|
+
assert new.last?
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_nil_scope
|
186
|
+
new1, new2, new3 = ListMixin.create, ListMixin.create, ListMixin.create
|
187
|
+
new2.move_higher
|
188
|
+
assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
def test_remove_from_list_should_then_fail_in_list?
|
193
|
+
assert_equal true, ListMixin.find(1).in_list?
|
194
|
+
ListMixin.find(1).remove_from_list
|
195
|
+
assert_equal false, ListMixin.find(1).in_list?
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_remove_from_list_should_set_position_to_nil
|
199
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
200
|
+
|
201
|
+
ListMixin.find(2).remove_from_list
|
202
|
+
|
203
|
+
assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
204
|
+
|
205
|
+
assert_equal 1, ListMixin.find(1).pos
|
206
|
+
assert_equal nil, ListMixin.find(2).pos
|
207
|
+
assert_equal 2, ListMixin.find(3).pos
|
208
|
+
assert_equal 3, ListMixin.find(4).pos
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_remove_before_destroy_does_not_shift_lower_items_twice
|
212
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
213
|
+
|
214
|
+
ListMixin.find(2).remove_from_list
|
215
|
+
ListMixin.find(2).destroy
|
216
|
+
|
217
|
+
assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
|
218
|
+
|
219
|
+
assert_equal 1, ListMixin.find(1).pos
|
220
|
+
assert_equal 2, ListMixin.find(3).pos
|
221
|
+
assert_equal 3, ListMixin.find(4).pos
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
class ListSubTest < Test::Unit::TestCase
|
227
|
+
|
228
|
+
def setup
|
229
|
+
setup_db
|
230
|
+
(1..4).each { |i| ((i % 2 == 1) ? ListMixinSub1 : ListMixinSub2).create! :pos => i, :parent_id => 5000 }
|
231
|
+
end
|
232
|
+
|
233
|
+
def teardown
|
234
|
+
teardown_db
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_reordering
|
238
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
239
|
+
|
240
|
+
ListMixin.find(2).move_lower
|
241
|
+
assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
242
|
+
|
243
|
+
ListMixin.find(2).move_higher
|
244
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
245
|
+
|
246
|
+
ListMixin.find(1).move_to_bottom
|
247
|
+
assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
248
|
+
|
249
|
+
ListMixin.find(1).move_to_top
|
250
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
251
|
+
|
252
|
+
ListMixin.find(2).move_to_bottom
|
253
|
+
assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
254
|
+
|
255
|
+
ListMixin.find(4).move_to_top
|
256
|
+
assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_move_to_bottom_with_next_to_last_item
|
260
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
261
|
+
ListMixin.find(3).move_to_bottom
|
262
|
+
assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_next_prev
|
266
|
+
assert_equal ListMixin.find(2), ListMixin.find(1).lower_item
|
267
|
+
assert_nil ListMixin.find(1).higher_item
|
268
|
+
assert_equal ListMixin.find(3), ListMixin.find(4).higher_item
|
269
|
+
assert_nil ListMixin.find(4).lower_item
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_injection
|
273
|
+
item = ListMixin.new("parent_id"=>1)
|
274
|
+
assert_equal "parent_id = 1", item.scope_condition
|
275
|
+
assert_equal "pos", item.position_column
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_insert_at
|
279
|
+
new = ListMixin.create("parent_id" => 20)
|
280
|
+
assert_equal 1, new.pos
|
281
|
+
|
282
|
+
new = ListMixinSub1.create("parent_id" => 20)
|
283
|
+
assert_equal 2, new.pos
|
284
|
+
|
285
|
+
new = ListMixinSub2.create("parent_id" => 20)
|
286
|
+
assert_equal 3, new.pos
|
287
|
+
|
288
|
+
new4 = ListMixin.create("parent_id" => 20)
|
289
|
+
assert_equal 4, new4.pos
|
290
|
+
|
291
|
+
new4.insert_at(3)
|
292
|
+
assert_equal 3, new4.pos
|
293
|
+
|
294
|
+
new.reload
|
295
|
+
assert_equal 4, new.pos
|
296
|
+
|
297
|
+
new.insert_at(2)
|
298
|
+
assert_equal 2, new.pos
|
299
|
+
|
300
|
+
new4.reload
|
301
|
+
assert_equal 4, new4.pos
|
302
|
+
|
303
|
+
new5 = ListMixinSub1.create("parent_id" => 20)
|
304
|
+
assert_equal 5, new5.pos
|
305
|
+
|
306
|
+
new5.insert_at(1)
|
307
|
+
assert_equal 1, new5.pos
|
308
|
+
|
309
|
+
new4.reload
|
310
|
+
assert_equal 5, new4.pos
|
311
|
+
end
|
312
|
+
|
313
|
+
def test_delete_middle
|
314
|
+
assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
315
|
+
|
316
|
+
ListMixin.find(2).destroy
|
317
|
+
|
318
|
+
assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
319
|
+
|
320
|
+
assert_equal 1, ListMixin.find(1).pos
|
321
|
+
assert_equal 2, ListMixin.find(3).pos
|
322
|
+
assert_equal 3, ListMixin.find(4).pos
|
323
|
+
|
324
|
+
ListMixin.find(1).destroy
|
325
|
+
|
326
|
+
assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
|
327
|
+
|
328
|
+
assert_equal 1, ListMixin.find(3).pos
|
329
|
+
assert_equal 2, ListMixin.find(4).pos
|
330
|
+
end
|
331
|
+
|
332
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
acts_as_tree
|
2
|
+
============
|
3
|
+
|
4
|
+
Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
|
5
|
+
association. This requires that you have a foreign key column, which by default is called +parent_id+.
|
6
|
+
|
7
|
+
class Category < ActiveRecord::Base
|
8
|
+
acts_as_tree :order => "name"
|
9
|
+
end
|
10
|
+
|
11
|
+
Example:
|
12
|
+
root
|
13
|
+
\_ child1
|
14
|
+
\_ subchild1
|
15
|
+
\_ subchild2
|
16
|
+
|
17
|
+
root = Category.create("name" => "root")
|
18
|
+
child1 = root.children.create("name" => "child1")
|
19
|
+
subchild1 = child1.children.create("name" => "subchild1")
|
20
|
+
|
21
|
+
root.parent # => nil
|
22
|
+
child1.parent # => root
|
23
|
+
root.children # => [child1]
|
24
|
+
root.children.first.children.first # => subchild1
|
25
|
+
|
26
|
+
Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test acts_as_tree plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for acts_as_tree plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'acts_as_tree'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Acts
|
3
|
+
module Tree
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
|
9
|
+
# association. This requires that you have a foreign key column, which by default is called +parent_id+.
|
10
|
+
#
|
11
|
+
# class Category < ActiveRecord::Base
|
12
|
+
# acts_as_tree :order => "name"
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# Example:
|
16
|
+
# root
|
17
|
+
# \_ child1
|
18
|
+
# \_ subchild1
|
19
|
+
# \_ subchild2
|
20
|
+
#
|
21
|
+
# root = Category.create("name" => "root")
|
22
|
+
# child1 = root.children.create("name" => "child1")
|
23
|
+
# subchild1 = child1.children.create("name" => "subchild1")
|
24
|
+
#
|
25
|
+
# root.parent # => nil
|
26
|
+
# child1.parent # => root
|
27
|
+
# root.children # => [child1]
|
28
|
+
# root.children.first.children.first # => subchild1
|
29
|
+
#
|
30
|
+
# In addition to the parent and children associations, the following instance methods are added to the class
|
31
|
+
# after calling <tt>acts_as_tree</tt>:
|
32
|
+
# * <tt>siblings</tt> - Returns all the children of the parent, excluding the current node (<tt>[subchild2]</tt> when called on <tt>subchild1</tt>)
|
33
|
+
# * <tt>self_and_siblings</tt> - Returns all the children of the parent, including the current node (<tt>[subchild1, subchild2]</tt> when called on <tt>subchild1</tt>)
|
34
|
+
# * <tt>ancestors</tt> - Returns all the ancestors of the current node (<tt>[child1, root]</tt> when called on <tt>subchild2</tt>)
|
35
|
+
# * <tt>root</tt> - Returns the root of the current node (<tt>root</tt> when called on <tt>subchild2</tt>)
|
36
|
+
module ClassMethods
|
37
|
+
# Configuration options are:
|
38
|
+
#
|
39
|
+
# * <tt>foreign_key</tt> - specifies the column name to use for tracking of the tree (default: +parent_id+)
|
40
|
+
# * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet.
|
41
|
+
# * <tt>counter_cache</tt> - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
|
42
|
+
def acts_as_tree(options = {})
|
43
|
+
configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
|
44
|
+
configuration.update(options) if options.is_a?(Hash)
|
45
|
+
|
46
|
+
belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
|
47
|
+
has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => :destroy
|
48
|
+
|
49
|
+
class_eval <<-EOV
|
50
|
+
include ActiveRecord::Acts::Tree::InstanceMethods
|
51
|
+
|
52
|
+
def self.roots
|
53
|
+
find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.root
|
57
|
+
find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
|
58
|
+
end
|
59
|
+
EOV
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
module InstanceMethods
|
64
|
+
# Returns list of ancestors, starting from parent until root.
|
65
|
+
#
|
66
|
+
# subchild1.ancestors # => [child1, root]
|
67
|
+
def ancestors
|
68
|
+
node, nodes = self, []
|
69
|
+
nodes << node = node.parent while node.parent
|
70
|
+
nodes
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns the root node of the tree.
|
74
|
+
def root
|
75
|
+
node = self
|
76
|
+
node = node.parent while node.parent
|
77
|
+
node
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns all siblings of the current node.
|
81
|
+
#
|
82
|
+
# subchild1.siblings # => [subchild2]
|
83
|
+
def siblings
|
84
|
+
self_and_siblings - [self]
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns all siblings and a reference to the current node.
|
88
|
+
#
|
89
|
+
# subchild1.self_and_siblings # => [subchild1, subchild2]
|
90
|
+
def self_and_siblings
|
91
|
+
parent ? parent.children : self.class.roots
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|