elucid-rails_admin 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +54 -0
- data/LICENSE.md +20 -0
- data/README.md +1334 -0
- data/Rakefile +14 -0
- data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/rails_admin/bullet_black.png +0 -0
- data/app/assets/images/rails_admin/bullet_white.png +0 -0
- data/app/assets/images/rails_admin/calendar.png +0 -0
- data/app/assets/images/rails_admin/clock.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/app/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/app/assets/images/rails_admin/logo.png +0 -0
- data/app/assets/images/rails_admin/magnifier.png +0 -0
- data/app/assets/images/rails_admin/multiselect/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-light.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
- data/app/assets/javascripts/rails_admin/custom/ui.js +1 -0
- data/app/assets/javascripts/rails_admin/jquery-ui-1.8.16.custom.js +5019 -0
- data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -0
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1219 -0
- data/app/assets/javascripts/rails_admin/ra.datetimepicker.js +67 -0
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +119 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +280 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +181 -0
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +147 -0
- data/app/assets/javascripts/rails_admin/rails_admin.js.erb +17 -0
- data/app/assets/javascripts/rails_admin/themes/default/ui.js +1 -0
- data/app/assets/javascripts/rails_admin/ui.js.coffee +30 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.css.scss +733 -0
- data/app/assets/stylesheets/rails_admin/base/README +2 -0
- data/app/assets/stylesheets/rails_admin/base/mixins.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/base/theming.css.scss +102 -0
- data/app/assets/stylesheets/rails_admin/base/variables.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/custom/README +3 -0
- data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +9 -0
- data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +11 -0
- data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +11 -0
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +51 -0
- data/app/assets/stylesheets/rails_admin/jquery.colorpicker.css.scss +180 -0
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +53 -0
- data/app/assets/stylesheets/rails_admin/ra.calendar-additions.css.scss +25 -0
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.css.scss +85 -0
- data/app/assets/stylesheets/rails_admin/rails_admin.css +4 -0
- data/app/assets/stylesheets/rails_admin/themes/README +11 -0
- data/app/assets/stylesheets/rails_admin/themes/default/mixins.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +1 -0
- data/app/controllers/rails_admin/application_controller.rb +62 -0
- data/app/controllers/rails_admin/history_controller.rb +26 -0
- data/app/controllers/rails_admin/main_controller.rb +371 -0
- data/app/helpers/rails_admin/application_helper.rb +65 -0
- data/app/helpers/rails_admin/form_builder.rb +52 -0
- data/app/helpers/rails_admin/main_helper.rb +100 -0
- data/app/models/rails_admin/history.rb +64 -0
- data/app/views/kaminari/twitter-bootstrap/_gap.html.haml +2 -0
- data/app/views/kaminari/twitter-bootstrap/_next_page.html.haml +4 -0
- data/app/views/kaminari/twitter-bootstrap/_page.html.haml +4 -0
- data/app/views/kaminari/twitter-bootstrap/_paginator.html.haml +10 -0
- data/app/views/kaminari/twitter-bootstrap/_prev_page.html.haml +4 -0
- data/app/views/layouts/rails_admin/_navigation.html.haml +19 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +9 -0
- data/app/views/layouts/rails_admin/application.html.haml +41 -0
- data/app/views/rails_admin/history/_dashboard.html.haml +10 -0
- data/app/views/rails_admin/history/show.html.haml +42 -0
- data/app/views/rails_admin/main/_delete_notice.html.haml +19 -0
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +26 -0
- data/app/views/rails_admin/main/_form_datetime.html.haml +7 -0
- data/app/views/rails_admin/main/_form_enumeration.html.haml +5 -0
- data/app/views/rails_admin/main/_form_field.html.haml +1 -0
- data/app/views/rails_admin/main/_form_file_upload.html.haml +19 -0
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +57 -0
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +47 -0
- data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +36 -0
- data/app/views/rails_admin/main/_form_text.html.haml +13 -0
- data/app/views/rails_admin/main/_models_links.html.haml +31 -0
- data/app/views/rails_admin/main/_object_links.html.haml +23 -0
- data/app/views/rails_admin/main/_submit_buttons.html.haml +12 -0
- data/app/views/rails_admin/main/bulk_delete.html.haml +6 -0
- data/app/views/rails_admin/main/dashboard.html.haml +31 -0
- data/app/views/rails_admin/main/delete.html.haml +13 -0
- data/app/views/rails_admin/main/edit.html.haml +2 -0
- data/app/views/rails_admin/main/export.html.haml +70 -0
- data/app/views/rails_admin/main/index.html.haml +98 -0
- data/app/views/rails_admin/main/new.html.haml +2 -0
- data/app/views/rails_admin/main/show.html.haml +14 -0
- data/config/initializers/active_record_extensions.rb +19 -0
- data/config/initializers/devise_patch.rb +9 -0
- data/config/initializers/haml.rb +3 -0
- data/config/locales/devise.bg.yml +42 -0
- data/config/locales/devise.de.yml +39 -0
- data/config/locales/devise.en.yml +39 -0
- data/config/locales/devise.es.yml +39 -0
- data/config/locales/devise.fi.yml +39 -0
- data/config/locales/devise.fr.yml +78 -0
- data/config/locales/devise.hr.yml +49 -0
- data/config/locales/devise.it.yml +39 -0
- data/config/locales/devise.lt.yml +39 -0
- data/config/locales/devise.mn.yml +39 -0
- data/config/locales/devise.nb.yml +43 -0
- data/config/locales/devise.pt-BR.yml +39 -0
- data/config/locales/devise.pt-PT.yml +39 -0
- data/config/locales/devise.ro.yml +46 -0
- data/config/locales/devise.ru.yml +39 -0
- data/config/locales/devise.sv.yml +39 -0
- data/config/locales/devise.tr.yml +39 -0
- data/config/locales/devise.uk.yml +39 -0
- data/config/locales/devise.zh-CN.yml +39 -0
- data/config/locales/devise.zh_cn.yml +39 -0
- data/config/locales/rails_admin.bg.yml +104 -0
- data/config/locales/rails_admin.da.yml +99 -0
- data/config/locales/rails_admin.de.yml +110 -0
- data/config/locales/rails_admin.en.yml +114 -0
- data/config/locales/rails_admin.es.yml +112 -0
- data/config/locales/rails_admin.fi.yml +107 -0
- data/config/locales/rails_admin.fr.yml +110 -0
- data/config/locales/rails_admin.hr.yml +81 -0
- data/config/locales/rails_admin.it.yml +109 -0
- data/config/locales/rails_admin.ja.yml +110 -0
- data/config/locales/rails_admin.lt.yml +102 -0
- data/config/locales/rails_admin.lv.yml +100 -0
- data/config/locales/rails_admin.mn.yml +103 -0
- data/config/locales/rails_admin.nb.yml +110 -0
- data/config/locales/rails_admin.nl.yml +135 -0
- data/config/locales/rails_admin.pl.yml +111 -0
- data/config/locales/rails_admin.pt-BR.yml +109 -0
- data/config/locales/rails_admin.pt-PT.yml +109 -0
- data/config/locales/rails_admin.ro.yml +113 -0
- data/config/locales/rails_admin.ru.yml +109 -0
- data/config/locales/rails_admin.sv.yml +103 -0
- data/config/locales/rails_admin.tr.yml +103 -0
- data/config/locales/rails_admin.uk.yml +100 -0
- data/config/locales/rails_admin.zh-CN.yml +114 -0
- data/config/locales/rails_admin.zh_cn.yml +107 -0
- data/config/routes.rb +28 -0
- data/lib/generators/rails_admin/install_generator.rb +83 -0
- data/lib/generators/rails_admin/templates/drop.rb +18 -0
- data/lib/generators/rails_admin/templates/initializer.erb +150 -0
- data/lib/generators/rails_admin/templates/migration.rb +18 -0
- data/lib/generators/rails_admin/uninstall_generator.rb +22 -0
- data/lib/generators/rails_admin/utils.rb +30 -0
- data/lib/rails_admin.rb +57 -0
- data/lib/rails_admin/abstract_model.rb +73 -0
- data/lib/rails_admin/abstract_object.rb +28 -0
- data/lib/rails_admin/adapters/active_record.rb +359 -0
- data/lib/rails_admin/config.rb +287 -0
- data/lib/rails_admin/config/base.rb +111 -0
- data/lib/rails_admin/config/fields.rb +99 -0
- data/lib/rails_admin/config/fields/association.rb +101 -0
- data/lib/rails_admin/config/fields/base.rb +273 -0
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +16 -0
- data/lib/rails_admin/config/fields/factories/devise.rb +31 -0
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +20 -0
- data/lib/rails_admin/config/fields/factories/enum.rb +11 -0
- data/lib/rails_admin/config/fields/factories/paperclip.rb +26 -0
- data/lib/rails_admin/config/fields/factories/password.rb +17 -0
- data/lib/rails_admin/config/fields/group.rb +63 -0
- data/lib/rails_admin/config/fields/groupable.rb +25 -0
- data/lib/rails_admin/config/fields/types.rb +26 -0
- data/lib/rails_admin/config/fields/types/all.rb +22 -0
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +51 -0
- data/lib/rails_admin/config/fields/types/boolean.rb +29 -0
- data/lib/rails_admin/config/fields/types/carrierwave.rb +32 -0
- data/lib/rails_admin/config/fields/types/color.rb +37 -0
- data/lib/rails_admin/config/fields/types/date.rb +24 -0
- data/lib/rails_admin/config/fields/types/datetime.rb +160 -0
- data/lib/rails_admin/config/fields/types/decimal.rb +14 -0
- data/lib/rails_admin/config/fields/types/dragonfly.rb +51 -0
- data/lib/rails_admin/config/fields/types/enum.rb +35 -0
- data/lib/rails_admin/config/fields/types/file_upload.rb +54 -0
- data/lib/rails_admin/config/fields/types/float.rb +14 -0
- data/lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb +14 -0
- data/lib/rails_admin/config/fields/types/has_many_association.rb +42 -0
- data/lib/rails_admin/config/fields/types/has_one_association.rb +31 -0
- data/lib/rails_admin/config/fields/types/integer.rb +24 -0
- data/lib/rails_admin/config/fields/types/paperclip.rb +38 -0
- data/lib/rails_admin/config/fields/types/password.rb +41 -0
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +78 -0
- data/lib/rails_admin/config/fields/types/string.rb +34 -0
- data/lib/rails_admin/config/fields/types/text.rb +39 -0
- data/lib/rails_admin/config/fields/types/time.rb +31 -0
- data/lib/rails_admin/config/fields/types/timestamp.rb +18 -0
- data/lib/rails_admin/config/has_fields.rb +112 -0
- data/lib/rails_admin/config/has_groups.rb +39 -0
- data/lib/rails_admin/config/hideable.rb +28 -0
- data/lib/rails_admin/config/model.rb +89 -0
- data/lib/rails_admin/config/proxy.rb +40 -0
- data/lib/rails_admin/config/sections.rb +51 -0
- data/lib/rails_admin/config/sections/create.rb +11 -0
- data/lib/rails_admin/config/sections/export.rb +18 -0
- data/lib/rails_admin/config/sections/list.rb +55 -0
- data/lib/rails_admin/config/sections/navigation.rb +21 -0
- data/lib/rails_admin/config/sections/show.rb +50 -0
- data/lib/rails_admin/config/sections/update.rb +11 -0
- data/lib/rails_admin/engine.rb +15 -0
- data/lib/rails_admin/extension.rb +23 -0
- data/lib/rails_admin/extensions/cancan.rb +5 -0
- data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +71 -0
- data/lib/rails_admin/generic_support.rb +15 -0
- data/lib/rails_admin/i18n_support.rb +43 -0
- data/lib/rails_admin/support/core_extensions.rb +44 -0
- data/lib/rails_admin/support/csv_converter.rb +109 -0
- data/lib/rails_admin/version.rb +6 -0
- data/lib/tasks/prepare_ci_env.rake +27 -0
- data/lib/tasks/rails_admin.rake +18 -0
- data/spec/ci.sh +2 -0
- data/spec/controllers/application_controller_spec.rb +30 -0
- data/spec/controllers/main_controller_spec.rb +86 -0
- data/spec/database_helpers.rb +15 -0
- data/spec/dummy_app/Gemfile +52 -0
- data/spec/dummy_app/README +256 -0
- data/spec/dummy_app/Rakefile +7 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/locales/models.en.yml +8 -0
- data/spec/dummy_app/app/models/abstract.rb +5 -0
- data/spec/dummy_app/app/models/ball.rb +8 -0
- data/spec/dummy_app/app/models/cms.rb +5 -0
- data/spec/dummy_app/app/models/cms/basic_page.rb +7 -0
- data/spec/dummy_app/app/models/cms/unscoped_page.rb +3 -0
- data/spec/dummy_app/app/models/comment.rb +3 -0
- data/spec/dummy_app/app/models/division.rb +8 -0
- data/spec/dummy_app/app/models/draft.rb +11 -0
- data/spec/dummy_app/app/models/fan.rb +5 -0
- data/spec/dummy_app/app/models/field_test.rb +13 -0
- data/spec/dummy_app/app/models/league.rb +10 -0
- data/spec/dummy_app/app/models/player.rb +15 -0
- data/spec/dummy_app/app/models/rel_test.rb +6 -0
- data/spec/dummy_app/app/models/team.rb +25 -0
- data/spec/dummy_app/app/models/user.rb +21 -0
- data/spec/dummy_app/app/uploaders/carrierwave_uploader.rb +53 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +13 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/config/application.rb +47 -0
- data/spec/dummy_app/config/boot.rb +6 -0
- data/spec/dummy_app/config/database.yml +22 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +27 -0
- data/spec/dummy_app/config/environments/production.rb +51 -0
- data/spec/dummy_app/config/environments/test.rb +39 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/devise.rb +142 -0
- data/spec/dummy_app/config/initializers/inflections.rb +10 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_app/config/initializers/quiet_assets.rb +10 -0
- data/spec/dummy_app/config/initializers/rails_admin.rb +10 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +7 -0
- data/spec/dummy_app/config/initializers/session_store.rb +8 -0
- data/spec/dummy_app/config/routes.rb +8 -0
- data/spec/dummy_app/db/migrate/00000000000001_create_divisions_migration.rb +13 -0
- data/spec/dummy_app/db/migrate/00000000000002_create_drafts_migration.rb +19 -0
- data/spec/dummy_app/db/migrate/00000000000003_create_leagues_migration.rb +12 -0
- data/spec/dummy_app/db/migrate/00000000000004_create_players_migration.rb +20 -0
- data/spec/dummy_app/db/migrate/00000000000005_create_teams_migration.rb +22 -0
- data/spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb +19 -0
- data/spec/dummy_app/db/migrate/00000000000007_create_histories_table.rb +16 -0
- data/spec/dummy_app/db/migrate/00000000000008_create_fans_migration.rb +12 -0
- data/spec/dummy_app/db/migrate/00000000000009_create_fans_teams_migration.rb +11 -0
- data/spec/dummy_app/db/migrate/00000000000010_add_revenue_to_team_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000011_add_suspended_to_player_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000012_add_avatar_columns_to_user.rb +16 -0
- data/spec/dummy_app/db/migrate/00000000000013_add_roles_to_user.rb +9 -0
- data/spec/dummy_app/db/migrate/00000000000014_add_color_to_team_migration.rb +9 -0
- data/spec/dummy_app/db/migrate/20101223222233_create_rel_tests.rb +15 -0
- data/spec/dummy_app/db/migrate/20110103205808_create_comments.rb +15 -0
- data/spec/dummy_app/db/migrate/20110123042530_rename_histories_to_rails_admin_histories.rb +9 -0
- data/spec/dummy_app/db/migrate/20110224184303_create_field_tests.rb +22 -0
- data/spec/dummy_app/db/migrate/20110328193014_create_cms_basic_pages.rb +14 -0
- data/spec/dummy_app/db/migrate/20110329183136_remove_league_id_from_teams.rb +9 -0
- data/spec/dummy_app/db/migrate/20110607152842_add_format_to_field_test.rb +9 -0
- data/spec/dummy_app/db/migrate/20110714095433_create_balls.rb +12 -0
- data/spec/dummy_app/db/migrate/20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb +6 -0
- data/spec/dummy_app/db/migrate/20110901131551_change_division_primary_key.rb +19 -0
- data/spec/dummy_app/db/migrate/20110901142530_rename_league_id_foreign_key_on_divisions.rb +5 -0
- data/spec/dummy_app/db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb +21 -0
- data/spec/dummy_app/db/migrate/20110901154834_change_length_for_rails_admin_histories.rb +9 -0
- data/spec/dummy_app/db/migrate/20111103174459_create_unscoped_pages.rb +9 -0
- data/spec/dummy_app/db/migrate/20111108143642_add_dragonfly_and_carrierwave_to_field_tests.rb +7 -0
- data/spec/dummy_app/db/seeds.rb +18 -0
- data/spec/dummy_app/doc/README_FOR_APP +2 -0
- data/spec/dummy_app/public/404.html +0 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/script/rails +6 -0
- data/spec/factories.rb +62 -0
- data/spec/generator_helpers.rb +30 -0
- data/spec/generators/install_generator_spec.rb +85 -0
- data/spec/generators/uninstall_generator_spec.rb +35 -0
- data/spec/lib/abstract_object_spec.rb +119 -0
- data/spec/lib/rails_admin_spec.rb +153 -0
- data/spec/requests/authorization/cancan_spec.rb +260 -0
- data/spec/requests/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +25 -0
- data/spec/requests/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +55 -0
- data/spec/requests/basic/create/rails_admin_basic_create_spec.rb +143 -0
- data/spec/requests/basic/create/rails_admin_namespaced_model_create_spec.rb +24 -0
- data/spec/requests/basic/delete/rails_admin_basic_delete_spec.rb +35 -0
- data/spec/requests/basic/destroy/rails_admin_basic_destroy_spec.rb +56 -0
- data/spec/requests/basic/edit/rails_admin_basic_edit_spec.rb +98 -0
- data/spec/requests/basic/export/rails_admin_basic_export_spec.rb +84 -0
- data/spec/requests/basic/list/rails_admin_basic_list_spec.rb +401 -0
- data/spec/requests/basic/new/rails_admin_basic_new_spec.rb +74 -0
- data/spec/requests/basic/new/rails_admin_namespaced_model_new_spec.rb +31 -0
- data/spec/requests/basic/show/rails_admin_basic_show_spec.rb +83 -0
- data/spec/requests/basic/update/rails_admin_basic_update_spec.rb +169 -0
- data/spec/requests/config/edit/rails_admin_config_edit_spec.rb +744 -0
- data/spec/requests/config/list/rails_admin_config_list_spec.rb +549 -0
- data/spec/requests/config/navigation/rails_admin_config_navigation_spec.rb +107 -0
- data/spec/requests/config/rails_admin_config_spec.rb +180 -0
- data/spec/requests/config/show/rails_admin_config_show_spec.rb +275 -0
- data/spec/requests/history/rails_admin_history_spec.rb +57 -0
- data/spec/requests/rails_admin_spec.rb +103 -0
- data/spec/requests/relation_spec.rb +26 -0
- data/spec/spec_helper.rb +88 -0
- metadata +717 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "RailsAdmin" do
|
|
4
|
+
describe ".associated_collection_cache_all" do
|
|
5
|
+
it "should default to true if associated collection count < 100" do
|
|
6
|
+
RailsAdmin.config(Team).edit.fields.find{|f| f.name == :players}.associated_collection_cache_all.should == true
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should default to false if associated collection count >= 100" do
|
|
10
|
+
@players = 100.times.map do
|
|
11
|
+
FactoryGirl.create :player
|
|
12
|
+
end
|
|
13
|
+
RailsAdmin.config(Team).edit.fields.find{|f| f.name == :players}.associated_collection_cache_all.should == false
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe ".add_extension" do
|
|
18
|
+
it "registers the extension with RailsAdmin" do
|
|
19
|
+
RailsAdmin.add_extension(:example, ExampleModule)
|
|
20
|
+
RailsAdmin::EXTENSIONS.select { |name| name == :example }.length.should == 1
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "given an extension with an authorization adapter" do
|
|
24
|
+
it "registers the adapter" do
|
|
25
|
+
RailsAdmin.add_extension(:example, ExampleModule, {
|
|
26
|
+
:authorization => true
|
|
27
|
+
})
|
|
28
|
+
RailsAdmin::AUTHORIZATION_ADAPTERS[:example].should == ExampleModule::AuthorizationAdapter
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "given an extension with a configuration adapter" do
|
|
33
|
+
it "registers the adapter" do
|
|
34
|
+
RailsAdmin.add_extension(:example, ExampleModule, {
|
|
35
|
+
:configuration => true
|
|
36
|
+
})
|
|
37
|
+
RailsAdmin::CONFIGURATION_ADAPTERS[:example].should == ExampleModule::ConfigurationAdapter
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe ".attr_accessible_role" do
|
|
43
|
+
it "sould be :default by default" do
|
|
44
|
+
RailsAdmin.config.attr_accessible_role.call.should == :default
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "sould be configurable with user role for example" do
|
|
48
|
+
RailsAdmin.config do |config|
|
|
49
|
+
config.attr_accessible_role do
|
|
50
|
+
:admin
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
RailsAdmin.config.attr_accessible_role.call.should == :admin
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe ".main_app_name" do
|
|
59
|
+
|
|
60
|
+
it "as a default meaningful dynamic value" do
|
|
61
|
+
RailsAdmin.config.main_app_name.call.should == ['Dummy App', 'Admin']
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "can be configured" do
|
|
65
|
+
RailsAdmin.config do |config|
|
|
66
|
+
config.main_app_name = ['static','value']
|
|
67
|
+
end
|
|
68
|
+
RailsAdmin.config.main_app_name.should == ['static','value']
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe ".authorize_with" do
|
|
73
|
+
context "given a key for a extension with authorization" do
|
|
74
|
+
before do
|
|
75
|
+
RailsAdmin.add_extension(:example, ExampleModule, {
|
|
76
|
+
:authorization => true
|
|
77
|
+
})
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "initializes the authorization adapter" do
|
|
81
|
+
ExampleModule::AuthorizationAdapter.should_receive(:new).with(RailsAdmin::Config)
|
|
82
|
+
RailsAdmin.config do |config|
|
|
83
|
+
config.authorize_with(:example)
|
|
84
|
+
end
|
|
85
|
+
RailsAdmin.config.authorize_with.call
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "passes through any additional arguments to the initializer" do
|
|
89
|
+
options = { :option => true }
|
|
90
|
+
ExampleModule::AuthorizationAdapter.should_receive(:new).with(RailsAdmin::Config, options)
|
|
91
|
+
RailsAdmin.config do |config|
|
|
92
|
+
config.authorize_with(:example, options)
|
|
93
|
+
end
|
|
94
|
+
RailsAdmin.config.authorize_with.call
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe ".configure_with" do
|
|
100
|
+
context "given a key for a extension with configuration" do
|
|
101
|
+
before do
|
|
102
|
+
RailsAdmin.add_extension(:example, ExampleModule, {
|
|
103
|
+
:configuration => true
|
|
104
|
+
})
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "initializes configuration adapter" do
|
|
108
|
+
ExampleModule::ConfigurationAdapter.should_receive(:new)
|
|
109
|
+
RailsAdmin.config do |config|
|
|
110
|
+
config.configure_with(:example)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "yields the (optionally) provided block, passing the initialized adapter" do
|
|
115
|
+
configurator = nil
|
|
116
|
+
RailsAdmin.config do |config|
|
|
117
|
+
config.configure_with(:example) do |configuration_adapter|
|
|
118
|
+
configurator = configuration_adapter
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
configurator.should be_a(ExampleModule::ConfigurationAdapter)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe ".config" do
|
|
127
|
+
context ".default_search_operator" do
|
|
128
|
+
it "sets the default_search_operator" do
|
|
129
|
+
RailsAdmin.config do |config|
|
|
130
|
+
config.default_search_operator = 'starts_with'
|
|
131
|
+
end
|
|
132
|
+
RailsAdmin::Config.default_search_operator.should == 'starts_with'
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "errors on unrecognized search operator" do
|
|
136
|
+
expect do
|
|
137
|
+
RailsAdmin.config do |config|
|
|
138
|
+
config.default_search_operator = 'random'
|
|
139
|
+
end
|
|
140
|
+
end.to raise_error(ArgumentError, "Search operator 'random' not supported")
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "defaults to 'default'" do
|
|
144
|
+
RailsAdmin::Config.default_search_operator.should == 'default'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
module ExampleModule
|
|
151
|
+
class AuthorizationAdapter ; end
|
|
152
|
+
class ConfigurationAdapter ; end
|
|
153
|
+
end
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
class Ability
|
|
4
|
+
include CanCan::Ability
|
|
5
|
+
def initialize(user)
|
|
6
|
+
can :access, :rails_admin if user.roles.include? :admin
|
|
7
|
+
unless user.roles.include? :test_exception
|
|
8
|
+
can :manage, Player if user.roles.include? :manage_player
|
|
9
|
+
can :read, Player, :retired => false if user.roles.include? :read_player
|
|
10
|
+
can :create, Player, :suspended => true if user.roles.include? :create_player
|
|
11
|
+
can :update, Player, :retired => false if user.roles.include? :update_player
|
|
12
|
+
can :destroy, Player, :retired => false if user.roles.include? :destroy_player
|
|
13
|
+
can :history, Player, :retired => false if user.roles.include? :history_player
|
|
14
|
+
else
|
|
15
|
+
can :access, :rails_admin
|
|
16
|
+
can :manage, :all
|
|
17
|
+
cannot [:update, :destroy], Player, :retired => true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "RailsAdmin CanCan Authorization" do
|
|
23
|
+
|
|
24
|
+
subject { page }
|
|
25
|
+
|
|
26
|
+
before(:each) do
|
|
27
|
+
RailsAdmin.config{|c| c.authorize_with :cancan }
|
|
28
|
+
@user = FactoryGirl.create :user
|
|
29
|
+
login_as @user
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "with no roles" do
|
|
33
|
+
before(:each) do
|
|
34
|
+
@user.update_attribute(:roles, [])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "GET /admin should raise CanCan::AccessDenied" do
|
|
38
|
+
visit dashboard_path
|
|
39
|
+
should have_content('CanCan::AccessDenied')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "GET /admin/player should raise CanCan::AccessDenied" do
|
|
43
|
+
visit index_path(:model_name => "player")
|
|
44
|
+
should have_content('CanCan::AccessDenied')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "with read player role" do
|
|
49
|
+
before(:each) do
|
|
50
|
+
@user.update_attribute(:roles, [:admin, :read_player])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "GET /admin should show Player but not League" do
|
|
54
|
+
visit dashboard_path
|
|
55
|
+
body.should have_content("Player")
|
|
56
|
+
body.should_not have_content("League")
|
|
57
|
+
body.should_not have_content("Add new")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "GET /admin/player should render successfully but not list retired players and not show new, edit, or delete actions" do
|
|
61
|
+
@players = [
|
|
62
|
+
FactoryGirl.create(:player, :retired => false),
|
|
63
|
+
FactoryGirl.create(:player, :retired => true),
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
visit index_path(:model_name => "player")
|
|
67
|
+
|
|
68
|
+
should have_content(@players[0].name)
|
|
69
|
+
should_not have_content(@players[1].name)
|
|
70
|
+
should_not have_content("Add new")
|
|
71
|
+
should have_css('.show_object_link')
|
|
72
|
+
should_not have_css('.edit_object_link')
|
|
73
|
+
should_not have_css('.delete_object_link')
|
|
74
|
+
should_not have_css('.history_object_link')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "GET /admin/team should raise CanCan::AccessDenied" do
|
|
78
|
+
visit index_path(:model_name => "team")
|
|
79
|
+
should have_content('CanCan::AccessDenied')
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "GET /admin/player/new should raise CanCan::AccessDenied" do
|
|
83
|
+
visit new_path(:model_name => "player")
|
|
84
|
+
should have_content('CanCan::AccessDenied')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe "with create and read player role" do
|
|
90
|
+
before(:each) do
|
|
91
|
+
@user.update_attribute(:roles, [:admin, :read_player, :create_player])
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "GET /admin/player/new should render and create record upon submission" do
|
|
95
|
+
visit new_path(:model_name => "player")
|
|
96
|
+
|
|
97
|
+
should_not have_content("Save and edit")
|
|
98
|
+
should_not have_content("Delete")
|
|
99
|
+
|
|
100
|
+
should have_content("Save and add another")
|
|
101
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
|
102
|
+
fill_in "player[number]", :with => "42"
|
|
103
|
+
fill_in "player[position]", :with => "Second baseman"
|
|
104
|
+
click_button "Save"
|
|
105
|
+
should_not have_content("Edit")
|
|
106
|
+
|
|
107
|
+
@player = RailsAdmin::AbstractModel.new("Player").first
|
|
108
|
+
@player.name.should eql("Jackie Robinson")
|
|
109
|
+
@player.number.should eql(42)
|
|
110
|
+
@player.position.should eql("Second baseman")
|
|
111
|
+
@player.should be_suspended # suspended is inherited behavior based on permission
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "GET /admin/player/1/edit should raise access denied" do
|
|
115
|
+
@player = FactoryGirl.create :player
|
|
116
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
|
117
|
+
should have_content('CanCan::AccessDenied')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe "with update and read player role" do
|
|
123
|
+
before(:each) do
|
|
124
|
+
@user.update_attribute(:roles, [:admin, :read_player, :update_player])
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "GET /admin/player/1/edit should render and update record upon submission" do
|
|
128
|
+
@player = FactoryGirl.create :player
|
|
129
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
|
130
|
+
|
|
131
|
+
should have_content("Save and edit")
|
|
132
|
+
should_not have_content("Save and add another")
|
|
133
|
+
should_not have_content("Add new")
|
|
134
|
+
should_not have_content("Delete")
|
|
135
|
+
should_not have_content("History")
|
|
136
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
|
137
|
+
click_button "Save"
|
|
138
|
+
@player.reload
|
|
139
|
+
@player.name.should eql("Jackie Robinson")
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "GET /admin/player/1/edit with retired player should raise access denied" do
|
|
143
|
+
@player = FactoryGirl.create :player, :retired => true
|
|
144
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
|
145
|
+
should have_content('CanCan::AccessDenied')
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "GET /admin/player/1/delete should raise access denied" do
|
|
149
|
+
@player = FactoryGirl.create :player
|
|
150
|
+
visit delete_path(:model_name => "player", :id => @player.id)
|
|
151
|
+
should have_content('CanCan::AccessDenied')
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
describe "with history role" do
|
|
157
|
+
it 'shows links to history action' do
|
|
158
|
+
|
|
159
|
+
@user.update_attribute(:roles, [:admin, :read_player, :history_player])
|
|
160
|
+
@player = FactoryGirl.create :player
|
|
161
|
+
|
|
162
|
+
visit index_path(:model_name => "player")
|
|
163
|
+
should have_css('.show_object_link')
|
|
164
|
+
should_not have_css('.edit_object_link')
|
|
165
|
+
should_not have_css('.delete_object_link')
|
|
166
|
+
should have_css('.history_object_link')
|
|
167
|
+
|
|
168
|
+
visit show_path(:model_name => 'player', :id => @player.id)
|
|
169
|
+
should have_content("Show")
|
|
170
|
+
should_not have_content("Edit")
|
|
171
|
+
should_not have_content("Delete")
|
|
172
|
+
should have_content("History")
|
|
173
|
+
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe "with all roles" do
|
|
178
|
+
it 'shows links to all actions' do
|
|
179
|
+
|
|
180
|
+
@user.update_attribute(:roles, [:admin, :manage_player])
|
|
181
|
+
@player = FactoryGirl.create :player
|
|
182
|
+
|
|
183
|
+
visit index_path(:model_name => "player")
|
|
184
|
+
should have_css('.show_object_link')
|
|
185
|
+
should have_css('.edit_object_link')
|
|
186
|
+
should have_css('.delete_object_link')
|
|
187
|
+
should have_css('.history_object_link')
|
|
188
|
+
|
|
189
|
+
visit show_path(:model_name => 'player', :id => @player.id)
|
|
190
|
+
should have_content("Show")
|
|
191
|
+
should have_content("Edit")
|
|
192
|
+
should have_content("Delete")
|
|
193
|
+
should have_content("History")
|
|
194
|
+
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
describe "with destroy and read player role" do
|
|
199
|
+
before(:each) do
|
|
200
|
+
@user.update_attribute(:roles, [:admin, :read_player, :destroy_player])
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it "GET /admin/player/1/delete should render and destroy record upon submission" do
|
|
204
|
+
@player = FactoryGirl.create :player
|
|
205
|
+
player_id = @player.id
|
|
206
|
+
visit delete_path(:model_name => "player", :id => player_id)
|
|
207
|
+
|
|
208
|
+
click_button "Yes, I'm sure"
|
|
209
|
+
Player.exists?(player_id).should be_false
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it "GET /admin/player/1/delete with retired player should raise access denied" do
|
|
213
|
+
@player = FactoryGirl.create :player, :retired => true
|
|
214
|
+
visit delete_path(:model_name => "player", :id => @player.id)
|
|
215
|
+
should have_content('CanCan::AccessDenied')
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "GET /admin/player/bulk_delete should render records which are authorized to" do
|
|
219
|
+
active_player = FactoryGirl.create :player, :retired => false
|
|
220
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
|
221
|
+
|
|
222
|
+
page.driver.post(bulk_action_path(:bulk_action => 'delete', :model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
|
223
|
+
|
|
224
|
+
should have_content(active_player.name)
|
|
225
|
+
should_not have_content(retired_player.name)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "POST /admin/player/bulk_destroy should destroy records which are authorized to" do
|
|
229
|
+
active_player = FactoryGirl.create :player, :retired => false
|
|
230
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
|
231
|
+
|
|
232
|
+
page.driver.post(bulk_destroy_path(:model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
|
233
|
+
Player.exists?(active_player.id).should be_false
|
|
234
|
+
Player.exists?(retired_player.id).should be_true
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
describe "with exception role" do
|
|
239
|
+
it "GET /admin/player/bulk_delete should render records which are authorized to" do
|
|
240
|
+
@user.update_attribute(:roles, [:admin, :test_exception])
|
|
241
|
+
active_player = FactoryGirl.create :player, :retired => false
|
|
242
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
|
243
|
+
|
|
244
|
+
page.driver.post(bulk_action_path(:bulk_action => 'delete', :model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
|
245
|
+
|
|
246
|
+
should have_content(active_player.name)
|
|
247
|
+
should_not have_content(retired_player.name)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
it "POST /admin/player/bulk_destroy should destroy records which are authorized to" do
|
|
251
|
+
@user.update_attribute(:roles, [:admin, :test_exception])
|
|
252
|
+
active_player = FactoryGirl.create :player, :retired => false
|
|
253
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
|
254
|
+
|
|
255
|
+
page.driver.post(bulk_destroy_path(:model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
|
256
|
+
Player.exists?(active_player.id).should be_false
|
|
257
|
+
Player.exists?(retired_player.id).should be_true
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "RailsAdmin Basic Bulk Action" do
|
|
4
|
+
|
|
5
|
+
subject { page }
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
@players = 2.times.map { FactoryGirl.create :player }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "bulk_delete" do
|
|
12
|
+
it 'should show names of to-be-deleted players' do
|
|
13
|
+
page.driver.post(bulk_action_path(:bulk_action => 'delete', :model_name => "player", :bulk_ids => @players.map(&:id)))
|
|
14
|
+
@players.each { |player| should have_content(player.name) }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "bulk_export" do
|
|
19
|
+
it 'should show form for export' do
|
|
20
|
+
visit index_path(:model_name => "player")
|
|
21
|
+
click_link "Export current view"
|
|
22
|
+
@players.each { |player| should have_content("Select fields to export") }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "RailsAdmin Basic Bulk Destroy" do
|
|
4
|
+
subject { page }
|
|
5
|
+
|
|
6
|
+
describe "successful bulk delete of records" do
|
|
7
|
+
before(:each) do
|
|
8
|
+
RailsAdmin::History.destroy_all
|
|
9
|
+
@players = 3.times.map { FactoryGirl.create(:player) }
|
|
10
|
+
@delete_ids = @players[0..1].map(&:id)
|
|
11
|
+
page.driver.post(bulk_action_path(:bulk_action => 'delete', :model_name => "player", :bulk_ids => @delete_ids))
|
|
12
|
+
|
|
13
|
+
click_button "Yes, I'm sure"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should not contain deleted records" do
|
|
17
|
+
RailsAdmin::AbstractModel.new("Player").count.should == 1
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "history count should be equal to number of deleted records" do
|
|
21
|
+
RailsAdmin::History.count.should == @delete_ids.count
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "history items should be for proper table" do
|
|
25
|
+
RailsAdmin::History.all.each do |history|
|
|
26
|
+
history.table.should == "Player"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "history items should be for proper items" do
|
|
31
|
+
RailsAdmin::History.all.each do |history|
|
|
32
|
+
@delete_ids.should include(history.item)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "displays a flash notice stating the number of records destroyed" do
|
|
37
|
+
# 2 Players because @delete_ids.count == 2:
|
|
38
|
+
page.should have_selector(".alert-message", :text => "2 Players successfully deleted")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "cancelled bulk_deletion" do
|
|
43
|
+
before(:each) do
|
|
44
|
+
RailsAdmin::History.destroy_all
|
|
45
|
+
@players = 3.times.map { FactoryGirl.create(:player) }
|
|
46
|
+
@delete_ids = @players[0..1].map(&:id)
|
|
47
|
+
page.driver.post(bulk_action_path(:bulk_action => 'delete', :model_name => "player", :bulk_ids => @delete_ids))
|
|
48
|
+
click_button "Cancel"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should not delete records" do
|
|
52
|
+
RailsAdmin::AbstractModel.new("Player").count.should == 3
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|