drewda_rails_admin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +53 -0
- data/LICENSE.md +20 -0
- data/README.md +160 -0
- data/Rakefile +19 -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 +12 -0
- data/app/assets/javascripts/rails_admin/jquery.colorpicker.js +484 -0
- data/app/assets/javascripts/rails_admin/jquery.pjax.js +431 -0
- data/app/assets/javascripts/rails_admin/jquery.ui.timepicker.js +1371 -0
- data/app/assets/javascripts/rails_admin/ra.datetimepicker.js +67 -0
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +129 -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.nested-form-hooks.coffee +40 -0
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +150 -0
- data/app/assets/javascripts/rails_admin/rails_admin.js.erb +25 -0
- data/app/assets/javascripts/rails_admin/themes/default/ui.js +12 -0
- data/app/assets/javascripts/rails_admin/ui.js.coffee +61 -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 +263 -0
- data/app/assets/stylesheets/rails_admin/base/variables.css.scss +1 -0
- data/app/assets/stylesheets/rails_admin/custom/mixins.css.scss +12 -0
- data/app/assets/stylesheets/rails_admin/custom/theming.css.scss +13 -0
- data/app/assets/stylesheets/rails_admin/custom/variables.css.scss +15 -0
- data/app/assets/stylesheets/rails_admin/imports.css.scss.erb +76 -0
- data/app/assets/stylesheets/rails_admin/jquery.colorpicker.css.scss +180 -0
- data/app/assets/stylesheets/rails_admin/jquery.ui.timepicker.css.scss +69 -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/default/mixins.css.scss +8 -0
- data/app/assets/stylesheets/rails_admin/themes/default/theming.css.scss +11 -0
- data/app/assets/stylesheets/rails_admin/themes/default/variables.css.scss +12 -0
- data/app/controllers/rails_admin/application_controller.rb +82 -0
- data/app/controllers/rails_admin/main_controller.rb +151 -0
- data/app/helpers/rails_admin/application_helper.rb +123 -0
- data/app/helpers/rails_admin/form_builder.rb +104 -0
- data/app/helpers/rails_admin/main_helper.rb +36 -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/_secondary_navigation.html.haml +12 -0
- data/app/views/layouts/rails_admin/application.html.haml +39 -0
- data/app/views/rails_admin/main/_dashboard_history.html.haml +10 -0
- data/app/views/rails_admin/main/_delete_notice.html.haml +18 -0
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +24 -0
- data/app/views/rails_admin/main/_form_datetime.html.haml +4 -0
- data/app/views/rails_admin/main/_form_enumeration.html.haml +4 -0
- data/app/views/rails_admin/main/_form_field.html.haml +1 -0
- data/app/views/rails_admin/main/_form_file_upload.html.haml +18 -0
- data/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +59 -0
- data/app/views/rails_admin/main/_form_filtering_select.html.haml +47 -0
- data/app/views/rails_admin/main/_form_nested_many.html.haml +41 -0
- data/app/views/rails_admin/main/_form_nested_one.html.haml +35 -0
- data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +34 -0
- data/app/views/rails_admin/main/_form_text.html.haml +9 -0
- data/app/views/rails_admin/main/_submit_buttons.html.haml +15 -0
- data/app/views/rails_admin/main/bulk_delete.html.haml +11 -0
- data/app/views/rails_admin/main/dashboard.html.haml +31 -0
- data/app/views/rails_admin/main/delete.html.haml +18 -0
- data/app/views/rails_admin/main/edit.html.haml +2 -0
- data/app/views/rails_admin/main/export.html.haml +75 -0
- data/app/views/rails_admin/main/history.html.haml +42 -0
- data/app/views/rails_admin/main/index.html.haml +140 -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 +2 -0
- data/config/initializers/mongoid_extensions.rb +4 -0
- data/config/locales/fr.yml +24 -0
- data/config/locales/rails_admin.en.yml +130 -0
- data/config/routes.rb +12 -0
- data/lib/generators/rails_admin/install_generator.rb +84 -0
- data/lib/generators/rails_admin/templates/drop.rb +18 -0
- data/lib/generators/rails_admin/templates/initializer.erb +101 -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 +34 -0
- data/lib/rails_admin/abstract_model.rb +110 -0
- data/lib/rails_admin/adapters/active_record.rb +247 -0
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +32 -0
- data/lib/rails_admin/adapters/mongoid.rb +333 -0
- data/lib/rails_admin/adapters/mongoid/abstract_object.rb +32 -0
- data/lib/rails_admin/adapters/mongoid/extension.rb +27 -0
- data/lib/rails_admin/config.rb +322 -0
- data/lib/rails_admin/config/actions.rb +121 -0
- data/lib/rails_admin/config/actions/base.rb +117 -0
- data/lib/rails_admin/config/actions/bulk_delete.rb +55 -0
- data/lib/rails_admin/config/actions/dashboard.rb +44 -0
- data/lib/rails_admin/config/actions/delete.rb +53 -0
- data/lib/rails_admin/config/actions/edit.rb +60 -0
- data/lib/rails_admin/config/actions/export.rb +40 -0
- data/lib/rails_admin/config/actions/history_index.rb +38 -0
- data/lib/rails_admin/config/actions/history_show.rb +38 -0
- data/lib/rails_admin/config/actions/index.rb +85 -0
- data/lib/rails_admin/config/actions/new.rb +64 -0
- data/lib/rails_admin/config/actions/show.rb +32 -0
- data/lib/rails_admin/config/actions/show_in_app.rb +28 -0
- data/lib/rails_admin/config/configurable.rb +92 -0
- data/lib/rails_admin/config/fields.rb +88 -0
- data/lib/rails_admin/config/fields/association.rb +108 -0
- data/lib/rails_admin/config/fields/base.rb +281 -0
- data/lib/rails_admin/config/fields/factories/belongs_to_association.rb +29 -0
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +31 -0
- data/lib/rails_admin/config/fields/factories/devise.rb +27 -0
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +27 -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/factories/serialized.rb +17 -0
- data/lib/rails_admin/config/fields/group.rb +78 -0
- data/lib/rails_admin/config/fields/types.rb +27 -0
- data/lib/rails_admin/config/fields/types/all.rb +26 -0
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +41 -0
- data/lib/rails_admin/config/fields/types/boolean.rb +31 -0
- data/lib/rails_admin/config/fields/types/bson_object_id.rb +42 -0
- data/lib/rails_admin/config/fields/types/carrierwave.rb +31 -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 +165 -0
- data/lib/rails_admin/config/fields/types/decimal.rb +14 -0
- data/lib/rails_admin/config/fields/types/dragonfly.rb +41 -0
- data/lib/rails_admin/config/fields/types/enum.rb +35 -0
- data/lib/rails_admin/config/fields/types/file_upload.rb +61 -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 +32 -0
- data/lib/rails_admin/config/fields/types/has_one_association.rb +39 -0
- data/lib/rails_admin/config/fields/types/hidden.rb +21 -0
- data/lib/rails_admin/config/fields/types/integer.rb +22 -0
- data/lib/rails_admin/config/fields/types/mongoid_type.rb +25 -0
- data/lib/rails_admin/config/fields/types/paperclip.rb +28 -0
- data/lib/rails_admin/config/fields/types/password.rb +39 -0
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +76 -0
- data/lib/rails_admin/config/fields/types/serialized.rb +22 -0
- data/lib/rails_admin/config/fields/types/string.rb +41 -0
- data/lib/rails_admin/config/fields/types/text.rb +36 -0
- data/lib/rails_admin/config/fields/types/time.rb +36 -0
- data/lib/rails_admin/config/fields/types/timestamp.rb +18 -0
- data/lib/rails_admin/config/groupable.rb +18 -0
- data/lib/rails_admin/config/has_fields.rb +135 -0
- data/lib/rails_admin/config/has_groups.rb +23 -0
- data/lib/rails_admin/config/hideable.rb +28 -0
- data/lib/rails_admin/config/model.rb +88 -0
- data/lib/rails_admin/config/proxyable.rb +12 -0
- data/lib/rails_admin/config/proxyable/proxy.rb +43 -0
- data/lib/rails_admin/config/sections.rb +38 -0
- data/lib/rails_admin/config/sections/base.rb +29 -0
- data/lib/rails_admin/config/sections/create.rb +11 -0
- data/lib/rails_admin/config/sections/edit.rb +11 -0
- data/lib/rails_admin/config/sections/export.rb +11 -0
- data/lib/rails_admin/config/sections/list.rb +27 -0
- data/lib/rails_admin/config/sections/nested.rb +10 -0
- data/lib/rails_admin/config/sections/show.rb +10 -0
- data/lib/rails_admin/config/sections/update.rb +10 -0
- data/lib/rails_admin/engine.rb +22 -0
- data/lib/rails_admin/extension.rb +29 -0
- data/lib/rails_admin/extensions/cancan.rb +5 -0
- data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +59 -0
- data/lib/rails_admin/extensions/history.rb +5 -0
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +37 -0
- data/lib/rails_admin/extensions/history/history.rb +69 -0
- data/lib/rails_admin/extensions/paper_trail.rb +5 -0
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +92 -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 +180 -0
- data/spec/database_helpers.rb +15 -0
- data/spec/dummy_app/Gemfile +58 -0
- data/spec/dummy_app/Rakefile +7 -0
- data/spec/dummy_app/app/assets/images/rails.png +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +15 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_app/app/controllers/players_controller.rb +5 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/locales/models.en.yml +16 -0
- data/spec/dummy_app/app/models/abstract.rb +5 -0
- data/spec/dummy_app/app/models/article.rb +9 -0
- data/spec/dummy_app/app/models/author.rb +6 -0
- data/spec/dummy_app/app/models/ball.rb +8 -0
- data/spec/dummy_app/app/models/category.rb +3 -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 +12 -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 +20 -0
- data/spec/dummy_app/app/models/hardball.rb +2 -0
- data/spec/dummy_app/app/models/league.rb +10 -0
- data/spec/dummy_app/app/models/mongoid_field_test.rb +22 -0
- data/spec/dummy_app/app/models/nested_field_test.rb +6 -0
- data/spec/dummy_app/app/models/player.rb +23 -0
- data/spec/dummy_app/app/models/rel_test.rb +6 -0
- data/spec/dummy_app/app/models/tag.rb +7 -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 +14 -0
- data/spec/dummy_app/app/views/players/show.html.haml +1 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/config/application.rb +62 -0
- data/spec/dummy_app/config/boot.rb +6 -0
- data/spec/dummy_app/config/database.yml +25 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +37 -0
- data/spec/dummy_app/config/environments/production.rb +67 -0
- data/spec/dummy_app/config/environments/test.rb +37 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/devise.rb +148 -0
- data/spec/dummy_app/config/initializers/inflections.rb +15 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_app/config/initializers/rails_admin.rb +11 -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/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_app/config/mongoid.yml +17 -0
- data/spec/dummy_app/config/routes.rb +10 -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 +49 -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/migrate/20111115041025_add_type_to_balls.rb +5 -0
- data/spec/dummy_app/db/migrate/20111123092549_create_nested_field_tests.rb +10 -0
- data/spec/dummy_app/db/migrate/20111130075338_add_dragonfly_asset_name_to_field_tests.rb +5 -0
- data/spec/dummy_app/db/migrate/20111215083258_create_foo_bars.rb +8 -0
- data/spec/dummy_app/db/migrate/20120117151733_add_custom_field_to_teams.rb +5 -0
- data/spec/dummy_app/db/migrate/20120118122004_add_categories.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 +26 -0
- data/spec/dummy_app/public/422.html +26 -0
- data/spec/dummy_app/public/500.html +25 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/robots.txt +5 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg +0 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg.meta +1 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg +0 -0
- data/spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg.meta +1 -0
- data/spec/dummy_app/public/system/paperclip_assets/1/original/Boston City Flow.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/1/thumb/Boston City Flow.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/3/original/Costa Rican Frog.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/3/thumb/Costa Rican Frog.jpg +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/6/original/liste-electorale.pdf +0 -0
- data/spec/dummy_app/public/system/paperclip_assets/6/thumb/liste-electorale.pdf +148 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/Boston_City_Flow.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/thumb_Boston_City_Flow.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/Costa_Rican_Frog.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/thumb_Costa_Rican_Frog.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/Pensive_Parakeet.jpg +0 -0
- data/spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/thumb_Pensive_Parakeet.jpg +0 -0
- data/spec/dummy_app/script/rails +6 -0
- data/spec/factories.rb +89 -0
- data/spec/helpers/application_helper_spec.rb +277 -0
- data/spec/integration/authorization/cancan_spec.rb +349 -0
- data/spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb +25 -0
- data/spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb +44 -0
- data/spec/integration/basic/create/rails_admin_basic_create_spec.rb +154 -0
- data/spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb +23 -0
- data/spec/integration/basic/delete/rails_admin_basic_delete_spec.rb +27 -0
- data/spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb +56 -0
- data/spec/integration/basic/edit/rails_admin_basic_edit_spec.rb +109 -0
- data/spec/integration/basic/export/rails_admin_basic_export_spec.rb +87 -0
- data/spec/integration/basic/list/rails_admin_basic_list_spec.rb +392 -0
- data/spec/integration/basic/new/rails_admin_basic_new_spec.rb +74 -0
- data/spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb +31 -0
- data/spec/integration/basic/show/rails_admin_basic_show_spec.rb +91 -0
- data/spec/integration/basic/update/rails_admin_basic_update_spec.rb +219 -0
- data/spec/integration/config/edit/rails_admin_config_edit_spec.rb +954 -0
- data/spec/integration/config/list/rails_admin_config_list_spec.rb +509 -0
- data/spec/integration/config/show/rails_admin_config_show_spec.rb +302 -0
- data/spec/integration/history/rails_admin_history_spec.rb +66 -0
- data/spec/integration/rails_admin_spec.rb +113 -0
- data/spec/integration/relation_spec.rb +26 -0
- data/spec/spec_helper.rb +86 -0
- data/spec/support/tableless.rb +27 -0
- data/spec/unit/adapters/active_record/abstract_object_spec.rb +131 -0
- data/spec/unit/adapters/active_record_spec.rb +373 -0
- data/spec/unit/adapters/mongoid/abstract_object_spec.rb +30 -0
- data/spec/unit/adapters/mongoid_spec.rb +581 -0
- data/spec/unit/config/actions_spec.rb +181 -0
- data/spec/unit/config/fields/base_spec.rb +300 -0
- data/spec/unit/config/model_spec.rb +75 -0
- data/spec/unit/config/sections_spec.rb +123 -0
- data/spec/unit/config_spec.rb +273 -0
- metadata +823 -0
@@ -0,0 +1,349 @@
|
|
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 :dashboard
|
9
|
+
can :manage, Player if user.roles.include? :manage_player
|
10
|
+
can :read, Player, :retired => false if user.roles.include? :read_player
|
11
|
+
can :create, Player, :suspended => true if user.roles.include? :create_player
|
12
|
+
can :update, Player, :retired => false if user.roles.include? :update_player
|
13
|
+
can :destroy, Player, :retired => false if user.roles.include? :destroy_player
|
14
|
+
can :history, Player, :retired => false if user.roles.include? :history_player
|
15
|
+
can :show_in_app, Player, :retired => false if user.roles.include? :show_in_app_player
|
16
|
+
else
|
17
|
+
can :dashboard
|
18
|
+
can :access, :rails_admin
|
19
|
+
can :manage, :all
|
20
|
+
can :show_in_app, :all
|
21
|
+
cannot [:update, :destroy], Player, :retired => true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class AdminAbility
|
27
|
+
include CanCan::Ability
|
28
|
+
def initialize(user)
|
29
|
+
can :access, :rails_admin if user.roles.include? :admin
|
30
|
+
can :show_in_app, :all
|
31
|
+
can :manage, :all
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "RailsAdmin CanCan Authorization" do
|
36
|
+
|
37
|
+
subject { page }
|
38
|
+
|
39
|
+
before(:each) do
|
40
|
+
RailsAdmin.config{|c| c.authorize_with(:cancan); c.audit_with(:history, User) }
|
41
|
+
@user = FactoryGirl.create :user
|
42
|
+
login_as @user
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "with no roles" do
|
46
|
+
before(:each) do
|
47
|
+
@user.update_attribute(:roles, [])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "GET /admin should raise CanCan::AccessDenied" do
|
51
|
+
visit dashboard_path
|
52
|
+
should have_content('CanCan::AccessDenied')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "GET /admin/player should raise CanCan::AccessDenied" do
|
56
|
+
visit index_path(:model_name => "player")
|
57
|
+
should have_content('CanCan::AccessDenied')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "with read player role" do
|
62
|
+
before(:each) do
|
63
|
+
@user.update_attribute(:roles, [:admin, :read_player])
|
64
|
+
end
|
65
|
+
|
66
|
+
it "GET /admin should show Player but not League" do
|
67
|
+
visit dashboard_path
|
68
|
+
body.should have_content("Player")
|
69
|
+
body.should_not have_content("League")
|
70
|
+
body.should_not have_content("Add new")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "GET /admin/player should render successfully but not list retired players and not show new, edit, or delete actions" do
|
74
|
+
@players = [
|
75
|
+
FactoryGirl.create(:player, :retired => false),
|
76
|
+
FactoryGirl.create(:player, :retired => true),
|
77
|
+
]
|
78
|
+
|
79
|
+
visit index_path(:model_name => "player")
|
80
|
+
|
81
|
+
should have_content(@players[0].name)
|
82
|
+
should_not have_content(@players[1].name)
|
83
|
+
should_not have_content("Add new")
|
84
|
+
should have_css('.show_member_link')
|
85
|
+
should_not have_css('.edit_member_link')
|
86
|
+
should_not have_css('.delete_member_link')
|
87
|
+
should_not have_css('.history_show_member_link')
|
88
|
+
should_not have_css('.show_in_app_member_link')
|
89
|
+
end
|
90
|
+
|
91
|
+
it "GET /admin/team should raise CanCan::AccessDenied" do
|
92
|
+
visit index_path(:model_name => "team")
|
93
|
+
should have_content('CanCan::AccessDenied')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "GET /admin/player/new should raise CanCan::AccessDenied" do
|
97
|
+
visit new_path(:model_name => "player")
|
98
|
+
should have_content('CanCan::AccessDenied')
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "with create and read player role" do
|
104
|
+
before(:each) do
|
105
|
+
@user.update_attribute(:roles, [:admin, :read_player, :create_player])
|
106
|
+
end
|
107
|
+
|
108
|
+
it "GET /admin/player/new should render and create record upon submission" do
|
109
|
+
visit new_path(:model_name => "player")
|
110
|
+
|
111
|
+
should_not have_content("Save and edit")
|
112
|
+
should_not have_content("Delete")
|
113
|
+
|
114
|
+
should have_content("Save and add another")
|
115
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
116
|
+
fill_in "player[number]", :with => "42"
|
117
|
+
fill_in "player[position]", :with => "Second baseman"
|
118
|
+
click_button "Save"
|
119
|
+
should_not have_content("Edit")
|
120
|
+
|
121
|
+
@player = RailsAdmin::AbstractModel.new("Player").first
|
122
|
+
@player.name.should eql("Jackie Robinson")
|
123
|
+
@player.number.should eql(42)
|
124
|
+
@player.position.should eql("Second baseman")
|
125
|
+
@player.should be_suspended # suspended is inherited behavior based on permission
|
126
|
+
end
|
127
|
+
|
128
|
+
it "GET /admin/player/1/edit should raise access denied" do
|
129
|
+
@player = FactoryGirl.create :player
|
130
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
131
|
+
should have_content('CanCan::AccessDenied')
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "with update and read player role" do
|
137
|
+
before(:each) do
|
138
|
+
@user.update_attribute(:roles, [:admin, :read_player, :update_player])
|
139
|
+
end
|
140
|
+
|
141
|
+
it "GET /admin/player/1/edit should render and update record upon submission" do
|
142
|
+
@player = FactoryGirl.create :player
|
143
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
144
|
+
should have_content("Save and edit")
|
145
|
+
should_not have_content("Save and add another")
|
146
|
+
should_not have_content("Add new")
|
147
|
+
should_not have_content("Delete")
|
148
|
+
should_not have_content("History")
|
149
|
+
should_not have_content("Show in app")
|
150
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
151
|
+
click_button "Save"
|
152
|
+
@player.reload
|
153
|
+
@player.name.should eql("Jackie Robinson")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "GET /admin/player/1/edit with retired player should raise access denied" do
|
157
|
+
@player = FactoryGirl.create :player, :retired => true
|
158
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
159
|
+
should have_content('CanCan::AccessDenied')
|
160
|
+
end
|
161
|
+
|
162
|
+
it "GET /admin/player/1/delete should raise access denied" do
|
163
|
+
@player = FactoryGirl.create :player
|
164
|
+
visit delete_path(:model_name => "player", :id => @player.id)
|
165
|
+
should have_content('CanCan::AccessDenied')
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "with history role" do
|
171
|
+
it 'shows links to history action' do
|
172
|
+
|
173
|
+
@user.update_attribute(:roles, [:admin, :read_player, :history_player])
|
174
|
+
@player = FactoryGirl.create :player
|
175
|
+
|
176
|
+
visit index_path(:model_name => "player")
|
177
|
+
should have_css('.show_member_link')
|
178
|
+
should_not have_css('.edit_member_link')
|
179
|
+
should_not have_css('.delete_member_link')
|
180
|
+
should have_css('.history_show_member_link')
|
181
|
+
|
182
|
+
visit show_path(:model_name => 'player', :id => @player.id)
|
183
|
+
should have_content("Show")
|
184
|
+
should_not have_content("Edit")
|
185
|
+
should_not have_content("Delete")
|
186
|
+
should have_content("History")
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "with show in app role" do
|
192
|
+
it 'shows links to show in app action' do
|
193
|
+
|
194
|
+
@user.update_attribute(:roles, [:admin, :read_player, :show_in_app_player])
|
195
|
+
@player = FactoryGirl.create :player
|
196
|
+
|
197
|
+
visit index_path(:model_name => "player")
|
198
|
+
should have_css('.show_member_link')
|
199
|
+
should_not have_css('.edit_member_link')
|
200
|
+
should_not have_css('.delete_member_link')
|
201
|
+
should_not have_css('.history_show_member_link')
|
202
|
+
should have_css('.show_in_app_member_link')
|
203
|
+
|
204
|
+
visit show_path(:model_name => 'player', :id => @player.id)
|
205
|
+
should have_content("Show")
|
206
|
+
should_not have_content("Edit")
|
207
|
+
should_not have_content("Delete")
|
208
|
+
should_not have_content("History")
|
209
|
+
should have_content("Show in app")
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "with all roles" do
|
215
|
+
it 'shows links to all actions' do
|
216
|
+
|
217
|
+
@user.update_attribute(:roles, [:admin, :manage_player])
|
218
|
+
@player = FactoryGirl.create :player
|
219
|
+
|
220
|
+
visit index_path(:model_name => "player")
|
221
|
+
should have_css('.show_member_link')
|
222
|
+
should have_css('.edit_member_link')
|
223
|
+
should have_css('.delete_member_link')
|
224
|
+
should have_css('.history_show_member_link')
|
225
|
+
should have_css('.show_in_app_member_link')
|
226
|
+
|
227
|
+
visit show_path(:model_name => 'player', :id => @player.id)
|
228
|
+
should have_content("Show")
|
229
|
+
should have_content("Edit")
|
230
|
+
should have_content("Delete")
|
231
|
+
should have_content("History")
|
232
|
+
should have_content("Show in app")
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "with destroy and read player role" do
|
238
|
+
before(:each) do
|
239
|
+
@user.update_attribute(:roles, [:admin, :read_player, :destroy_player])
|
240
|
+
end
|
241
|
+
|
242
|
+
it "GET /admin/player/1/delete should render and destroy record upon submission" do
|
243
|
+
@player = FactoryGirl.create :player
|
244
|
+
player_id = @player.id
|
245
|
+
visit delete_path(:model_name => "player", :id => player_id)
|
246
|
+
|
247
|
+
click_button "Yes, I'm sure"
|
248
|
+
|
249
|
+
Player.exists?(player_id).should be_false
|
250
|
+
end
|
251
|
+
|
252
|
+
it "GET /admin/player/1/delete with retired player should raise access denied" do
|
253
|
+
@player = FactoryGirl.create :player, :retired => true
|
254
|
+
visit delete_path(:model_name => "player", :id => @player.id)
|
255
|
+
should have_content('CanCan::AccessDenied')
|
256
|
+
end
|
257
|
+
|
258
|
+
it "GET /admin/player/bulk_delete should render records which are authorized to" do
|
259
|
+
active_player = FactoryGirl.create :player, :retired => false
|
260
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
261
|
+
|
262
|
+
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
263
|
+
|
264
|
+
should have_content(active_player.name)
|
265
|
+
should_not have_content(retired_player.name)
|
266
|
+
end
|
267
|
+
|
268
|
+
it "POST /admin/player/bulk_destroy should destroy records which are authorized to" do
|
269
|
+
active_player = FactoryGirl.create :player, :retired => false
|
270
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
271
|
+
|
272
|
+
page.driver.delete(bulk_delete_path(:model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
273
|
+
Player.exists?(active_player.id).should be_false
|
274
|
+
Player.exists?(retired_player.id).should be_true
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
describe "with exception role" do
|
279
|
+
it "GET /admin/player/bulk_delete should render records which are authorized to" do
|
280
|
+
@user.update_attribute(:roles, [:admin, :test_exception])
|
281
|
+
active_player = FactoryGirl.create :player, :retired => false
|
282
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
283
|
+
|
284
|
+
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
285
|
+
|
286
|
+
should have_content(active_player.name)
|
287
|
+
should_not have_content(retired_player.name)
|
288
|
+
end
|
289
|
+
|
290
|
+
it "POST /admin/player/bulk_destroy should destroy records which are authorized to" do
|
291
|
+
@user.update_attribute(:roles, [:admin, :test_exception])
|
292
|
+
active_player = FactoryGirl.create :player, :retired => false
|
293
|
+
retired_player = FactoryGirl.create :player, :retired => true
|
294
|
+
|
295
|
+
page.driver.delete(bulk_delete_path(:model_name => "player", :bulk_ids => [active_player, retired_player].map(&:id)))
|
296
|
+
Player.exists?(active_player.id).should be_false
|
297
|
+
Player.exists?(retired_player.id).should be_true
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
describe "with a custom admin ability" do
|
302
|
+
before(:each) do
|
303
|
+
RailsAdmin.config{|c| c.authorize_with :cancan, AdminAbility }
|
304
|
+
@user = FactoryGirl.create :user
|
305
|
+
login_as @user
|
306
|
+
end
|
307
|
+
|
308
|
+
describe "with admin role only" do
|
309
|
+
before(:each) do
|
310
|
+
@user.update_attribute(:roles, [:admin])
|
311
|
+
end
|
312
|
+
|
313
|
+
it "GET /admin/team should render successfully" do
|
314
|
+
visit index_path(:model_name => "team")
|
315
|
+
page.status_code.should == 200
|
316
|
+
end
|
317
|
+
|
318
|
+
it "GET /admin/player/new should render successfully" do
|
319
|
+
visit new_path(:model_name => "player")
|
320
|
+
page.status_code.should == 200
|
321
|
+
end
|
322
|
+
|
323
|
+
it "GET /admin/player/1/edit should render successfully" do
|
324
|
+
@player = FactoryGirl.create :player
|
325
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
326
|
+
page.status_code.should == 200
|
327
|
+
end
|
328
|
+
|
329
|
+
it "GET /admin/player/1/edit with retired player should render successfully" do
|
330
|
+
@player = FactoryGirl.create :player, :retired => true
|
331
|
+
visit edit_path(:model_name => "player", :id => @player.id)
|
332
|
+
page.status_code.should == 200
|
333
|
+
end
|
334
|
+
|
335
|
+
it "GET /admin/player/1/delete should render successfully" do
|
336
|
+
@player = FactoryGirl.create :player
|
337
|
+
visit delete_path(:model_name => "player", :id => @player.id)
|
338
|
+
page.status_code.should == 200
|
339
|
+
end
|
340
|
+
|
341
|
+
it "GET /admin/player/1/delete with retired player should render successfully" do
|
342
|
+
@player = FactoryGirl.create :player, :retired => true
|
343
|
+
visit delete_path(:model_name => "player", :id => @player.id)
|
344
|
+
page.status_code.should == 200
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
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 => 'bulk_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 found Players"
|
22
|
+
@players.each { |player| should have_content("Select fields to export") }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails_admin/extensions/history/history'
|
3
|
+
|
4
|
+
describe "RailsAdmin Basic Bulk Destroy" do
|
5
|
+
subject { page }
|
6
|
+
|
7
|
+
describe "successful bulk delete of records" do
|
8
|
+
before do
|
9
|
+
RailsAdmin::History.destroy_all
|
10
|
+
RailsAdmin.config { |c| c.audit_with :history }
|
11
|
+
@players = 3.times.map { FactoryGirl.create(:player) }
|
12
|
+
@delete_ids = @players[0..1].map(&:id)
|
13
|
+
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => @delete_ids))
|
14
|
+
|
15
|
+
click_button "Yes, I'm sure"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should not contain deleted records" do
|
19
|
+
RailsAdmin::AbstractModel.new("Player").count.should == 1
|
20
|
+
RailsAdmin::History.count.should == @delete_ids.count
|
21
|
+
RailsAdmin::History.all.each do |history|
|
22
|
+
history.table.should == "Player"
|
23
|
+
end
|
24
|
+
RailsAdmin::History.all.each do |history|
|
25
|
+
@delete_ids.should include(history.item)
|
26
|
+
end
|
27
|
+
page.should have_selector(".alert-success", :text => "2 Players successfully deleted")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "cancelled bulk_deletion" do
|
32
|
+
before do
|
33
|
+
RailsAdmin::History.destroy_all
|
34
|
+
@players = 3.times.map { FactoryGirl.create(:player) }
|
35
|
+
@delete_ids = @players[0..1].map(&:id)
|
36
|
+
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => @delete_ids))
|
37
|
+
click_button "Cancel"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not delete records" do
|
41
|
+
RailsAdmin::AbstractModel.new("Player").count.should == 3
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "RailsAdmin Basic Create" do
|
4
|
+
subject { page }
|
5
|
+
|
6
|
+
describe "create" do
|
7
|
+
before(:each) do
|
8
|
+
visit new_path(:model_name => "player")
|
9
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
10
|
+
fill_in "player[number]", :with => "42"
|
11
|
+
fill_in "player[position]", :with => "Second baseman"
|
12
|
+
click_button "Save"
|
13
|
+
@player = RailsAdmin::AbstractModel.new("Player").first
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should create an object with correct attributes" do
|
17
|
+
@player.name.should eql("Jackie Robinson")
|
18
|
+
@player.number.should eql(42)
|
19
|
+
@player.position.should eql("Second baseman")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "create and edit" do
|
24
|
+
before(:each) do
|
25
|
+
visit new_path(:model_name => "player")
|
26
|
+
|
27
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
28
|
+
fill_in "player[number]", :with => "42"
|
29
|
+
fill_in "player[position]", :with => "Second baseman"
|
30
|
+
click_button "Save and edit"
|
31
|
+
|
32
|
+
@player = RailsAdmin::AbstractModel.new("Player").first
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should create an object with correct attributes" do
|
36
|
+
@player.name.should eql("Jackie Robinson")
|
37
|
+
@player.number.should eql(42)
|
38
|
+
@player.position.should eql("Second baseman")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "create and add another" do
|
43
|
+
before(:each) do
|
44
|
+
visit new_path(:model_name => "player")
|
45
|
+
|
46
|
+
fill_in "player[name]", :with => "Jackie Robinson"
|
47
|
+
fill_in "player[number]", :with => "42"
|
48
|
+
fill_in "player[position]", :with => "Second baseman"
|
49
|
+
click_button "Save and add another"
|
50
|
+
|
51
|
+
@player = RailsAdmin::AbstractModel.new("Player").first
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should create an object with correct attributes" do
|
55
|
+
@player.name.should eql("Jackie Robinson")
|
56
|
+
@player.number.should eql(42)
|
57
|
+
@player.position.should eql("Second baseman")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "create with has-one association" do
|
62
|
+
before(:each) do
|
63
|
+
@draft = FactoryGirl.create :draft
|
64
|
+
|
65
|
+
page.driver.post new_path(:model_name => "player", :player => {:name => "Jackie Robinson", :number => 42, :position => 'Second baseman', :draft_id => @draft.id})
|
66
|
+
|
67
|
+
@player = RailsAdmin::AbstractModel.new("Player").all.last # first is created by FactoryGirl
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should create an object with correct associations" do
|
71
|
+
@draft.reload
|
72
|
+
@player.draft.should eql(@draft)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "create with has-many association" do
|
77
|
+
before(:each) do
|
78
|
+
@divisions = 3.times.map { Division.create!(:name => "div #{Time.now.to_f}", :league => League.create!(:name => "league #{Time.now.to_f}")) }
|
79
|
+
page.driver.post new_path(:model_name => "league", :league => {:name => "National League", :division_ids =>[@divisions[0].id]})
|
80
|
+
@league = RailsAdmin::AbstractModel.new("League").all.last
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should create an object with correct associations" do
|
84
|
+
@divisions[0].reload
|
85
|
+
@league.divisions.should include(@divisions[0])
|
86
|
+
@league.divisions.should_not include(@divisions[1])
|
87
|
+
@league.divisions.should_not include(@divisions[2])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "create with has-and-belongs-to-many association" do
|
92
|
+
before(:each) do
|
93
|
+
@teams = 3.times.map { FactoryGirl.create :team }
|
94
|
+
page.driver.post new_path(:model_name => "fan", :fan => {:name => "John Doe", :team_ids => [@teams[0].id] })
|
95
|
+
@fan = RailsAdmin::AbstractModel.new("Fan").first
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should create an object with correct associations" do
|
99
|
+
@teams[0].reload
|
100
|
+
@fan.teams.should include(@teams[0])
|
101
|
+
@fan.teams.should_not include(@teams[1])
|
102
|
+
@fan.teams.should_not include(@teams[2])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "create with uniqueness constraint violated", :given => "a player exists" do
|
107
|
+
before(:each) do
|
108
|
+
@team = FactoryGirl.create :team
|
109
|
+
@player = FactoryGirl.create :player, :team => @team
|
110
|
+
|
111
|
+
page.driver.post new_path(:model_name => "player", :player => {:name => @player.name, :number => @player.number.to_s, :position => @player.position, :team_id => @team.id})
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should show an error message" do
|
115
|
+
should have_content("There is already a player with that number on this team")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "create with invalid object" do
|
120
|
+
before(:each) do
|
121
|
+
page.driver.post(new_path(:model_name => "player", :id => 1), :params => {:player => {}})
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should show an error message" do
|
125
|
+
should have_content("Player failed to be created")
|
126
|
+
should have_selector "form", :action => "/admin/players"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "create with object with errors on base" do
|
131
|
+
before(:each) do
|
132
|
+
visit new_path(:model_name => "player")
|
133
|
+
fill_in "player[name]", :with => "Jackie Robinson on steroids"
|
134
|
+
click_button "Save and add another"
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should show error base error message in flash" do
|
138
|
+
should have_content("Player failed to be created. Player is cheating")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "creation of Mongoid habtm model object" do
|
143
|
+
before(:each) do
|
144
|
+
visit new_path(:model_name => "tag")
|
145
|
+
fill_in "tag[name]", :with => "Funny"
|
146
|
+
click_button "Save"
|
147
|
+
@tag = RailsAdmin::AbstractModel.new("Tag").first
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should create an object with correct attributes" do
|
151
|
+
@tag.name.should eql("Funny")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|