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,37 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Extensions
|
3
|
+
module History
|
4
|
+
class AuditingAdapter
|
5
|
+
def initialize(controller, user_class = User)
|
6
|
+
@controller = controller
|
7
|
+
@user_class = user_class
|
8
|
+
require 'rails_admin/extensions/history/history'
|
9
|
+
end
|
10
|
+
|
11
|
+
def latest
|
12
|
+
::RailsAdmin::History.latest
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete_object(message, object, model, user)
|
16
|
+
::RailsAdmin::History.create_history_item(message, object, model, user)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_object(model, object, associations_before, associations_after, modified_associations, old_object, user)
|
20
|
+
::RailsAdmin::History.create_update_history(model, object, associations_before, associations_after, modified_associations, old_object, user)
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_object(message, object, abstract_model, user)
|
24
|
+
::RailsAdmin::History.create_history_item(message, object, abstract_model, user)
|
25
|
+
end
|
26
|
+
|
27
|
+
def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
28
|
+
::RailsAdmin::History.history_for_model(model, query, sort, sort_reverse, all, page, per_page)
|
29
|
+
end
|
30
|
+
|
31
|
+
def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
32
|
+
::RailsAdmin::History.history_for_object(model, object, query, sort, sort_reverse, all, page, per_page)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class RailsAdmin::History < ActiveRecord::Base
|
2
|
+
|
3
|
+
self.table_name = :rails_admin_histories
|
4
|
+
|
5
|
+
IGNORED_ATTRS = Set[:id, :created_at, :created_on, :deleted_at, :updated_at, :updated_on, :deleted_on]
|
6
|
+
|
7
|
+
def self.latest
|
8
|
+
self.limit(100)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create_update_history(model, object, associations_before, associations_after, modified_associations, old_object, user)
|
12
|
+
messages = []
|
13
|
+
changed_property_list = []
|
14
|
+
properties = model.properties.reject{|p| IGNORED_ATTRS.include?(p[:name])}
|
15
|
+
|
16
|
+
properties.each do |p|
|
17
|
+
property_name = p[:name].to_param
|
18
|
+
changed_property_list << property_name if old_object.safe_send(property_name) != object.safe_send(property_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
model.associations.each do |t|
|
22
|
+
assoc = changed_property_list.index(t[:foreign_key].to_param)
|
23
|
+
changed_property_list[assoc] = "associated #{t[:pretty_name]}" if assoc
|
24
|
+
end
|
25
|
+
|
26
|
+
associations_after.each do |key, current|
|
27
|
+
removed_ids = (associations_before[key] - current).map{|m| '#' + m.to_s}
|
28
|
+
added_ids = (current - associations_before[key]).map{|m| '#' + m.to_s}
|
29
|
+
messages << "Removed #{key.to_s.capitalize} #{removed_ids.join(', ')} associations" if removed_ids.any?
|
30
|
+
messages << "Added #{key.to_s.capitalize} #{added_ids.join(', ')} associations" if added_ids.any?
|
31
|
+
end
|
32
|
+
|
33
|
+
modified_associations.uniq.each { |t| changed_property_list << "associated #{t}" }
|
34
|
+
|
35
|
+
messages << "Changed #{changed_property_list.join(", ")}" unless changed_property_list.empty?
|
36
|
+
create_history_item(messages, object, model, user) unless messages.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.create_history_item(message, object, abstract_model, user)
|
40
|
+
create(
|
41
|
+
:message => [message].flatten.join(', '),
|
42
|
+
:item => object.id,
|
43
|
+
:table => abstract_model.pretty_name,
|
44
|
+
:username => user.try(:email)
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.history_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
49
|
+
history = where(:table => model.pretty_name)
|
50
|
+
history = history.where("message LIKE ? OR username LIKE ?", "%#{query}%", "%#{query}%") if query
|
51
|
+
if sort
|
52
|
+
history = history.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
|
53
|
+
else
|
54
|
+
history = history.order('created_at DESC')
|
55
|
+
end
|
56
|
+
all ? history : history.page(page.presence || "1").per(per_page)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.history_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
60
|
+
history = where(:table => model.pretty_name, :item => object.id)
|
61
|
+
history = history.where("message LIKE ? OR username LIKE ?", "%#{query}%", "%#{query}%") if query
|
62
|
+
if sort
|
63
|
+
history = history.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
|
64
|
+
else
|
65
|
+
history = history.order('created_at DESC')
|
66
|
+
end
|
67
|
+
all ? history : history.page(page.presence || "1").per(per_page)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Extensions
|
3
|
+
module PaperTrail
|
4
|
+
class VersionProxy
|
5
|
+
def initialize(version, user_class = User)
|
6
|
+
@version = version
|
7
|
+
@user_class = user_class
|
8
|
+
end
|
9
|
+
|
10
|
+
def message
|
11
|
+
"#{@version.event} #{@version.item_type} id #{@version.item_id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def created_at
|
15
|
+
@version.created_at
|
16
|
+
end
|
17
|
+
|
18
|
+
def table
|
19
|
+
@version.item_type
|
20
|
+
end
|
21
|
+
|
22
|
+
def username
|
23
|
+
@user_class.find_by_id(@version.whodunnit).try(:email) || @version.whodunnit
|
24
|
+
end
|
25
|
+
|
26
|
+
def item
|
27
|
+
@version.item_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class AuditingAdapter
|
32
|
+
COLUMN_MAPPING = {
|
33
|
+
:table => :item_type,
|
34
|
+
:username => :whodunnit,
|
35
|
+
:item => :item_id,
|
36
|
+
:created_at => :created_at,
|
37
|
+
:message => :event
|
38
|
+
}
|
39
|
+
|
40
|
+
def initialize(controller, user_class = User)
|
41
|
+
raise "PaperTrail not found" unless defined?(PaperTrail)
|
42
|
+
@controller = controller
|
43
|
+
@user_class = user_class
|
44
|
+
end
|
45
|
+
|
46
|
+
def latest
|
47
|
+
Version.limit(100).map{|version| VersionProxy.new(version, @user_class)}
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete_object(message, object, model, user)
|
51
|
+
# do nothing
|
52
|
+
end
|
53
|
+
|
54
|
+
def update_object(model, object, associations_before, associations_after, modified_associations, old_object, user)
|
55
|
+
# do nothing
|
56
|
+
end
|
57
|
+
|
58
|
+
def create_object(message, object, abstract_model, user)
|
59
|
+
# do nothing
|
60
|
+
end
|
61
|
+
|
62
|
+
def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
63
|
+
if sort.present?
|
64
|
+
sort = COLUMN_MAPPING[sort.to_sym]
|
65
|
+
else
|
66
|
+
sort = :created_at
|
67
|
+
sort_reverse = "true"
|
68
|
+
end
|
69
|
+
versions = Version.where :item_type => model.model.name
|
70
|
+
versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
|
71
|
+
versions = versions.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
|
72
|
+
versions = all ? versions : versions.page(page.presence || "1").per(per_page)
|
73
|
+
versions.map{|version| VersionProxy.new(version, @user_class)}
|
74
|
+
end
|
75
|
+
|
76
|
+
def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20))
|
77
|
+
if sort.present?
|
78
|
+
sort = COLUMN_MAPPING[sort.to_sym]
|
79
|
+
else
|
80
|
+
sort = :created_at
|
81
|
+
sort_reverse = "true"
|
82
|
+
end
|
83
|
+
versions = Version.where :item_type => model.model.name, :item_id => object.id
|
84
|
+
versions = versions.where("event LIKE ?", "%#{query}%") if query.present?
|
85
|
+
versions = versions.order(sort_reverse == "true" ? "#{sort} DESC" : sort)
|
86
|
+
versions = all ? versions : versions.page(page.presence || "1").per(per_page)
|
87
|
+
versions.map{|version| VersionProxy.new(version, @user_class)}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'i18n'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module I18nSupport
|
5
|
+
def abbr_day_names
|
6
|
+
begin
|
7
|
+
I18n.t('date.abbr_day_names', :raise => true)
|
8
|
+
rescue I18n::ArgumentError
|
9
|
+
I18n.t('date.abbr_day_names', :locale => :en)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def abbr_month_names
|
14
|
+
begin
|
15
|
+
names = I18n.t('date.abbr_month_names', :raise => true)
|
16
|
+
rescue I18n::ArgumentError
|
17
|
+
names = I18n.t('date.abbr_month_names', :locale => :en)
|
18
|
+
end
|
19
|
+
names[1..-1]
|
20
|
+
end
|
21
|
+
|
22
|
+
def date_format
|
23
|
+
I18n.t('date.formats.default', :default => I18n.t('date.formats.default', :locale => :en))
|
24
|
+
end
|
25
|
+
|
26
|
+
def day_names
|
27
|
+
begin
|
28
|
+
I18n.t('date.day_names', :raise => true)
|
29
|
+
rescue I18n::ArgumentError
|
30
|
+
I18n.t('date.day_names', :locale => :en)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def month_names
|
35
|
+
begin
|
36
|
+
names = I18n.t('date.month_names', :raise => true)
|
37
|
+
rescue I18n::ArgumentError
|
38
|
+
names = I18n.t('date.month_names', :locale => :en)
|
39
|
+
end
|
40
|
+
names[1..-1]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Hash
|
2
|
+
|
3
|
+
def symbolize
|
4
|
+
Hash.symbolize_hash(self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.symbolize_hash(obj)
|
8
|
+
case obj
|
9
|
+
when Array
|
10
|
+
obj.inject([]){|res, val|
|
11
|
+
res << case val
|
12
|
+
when Hash, Array
|
13
|
+
symbolize_hash(val)
|
14
|
+
when String
|
15
|
+
val.to_sym
|
16
|
+
else
|
17
|
+
val
|
18
|
+
end
|
19
|
+
res
|
20
|
+
}
|
21
|
+
when Hash
|
22
|
+
obj.inject({}){|res, (key, val)|
|
23
|
+
nkey = case key
|
24
|
+
when String
|
25
|
+
key.to_sym
|
26
|
+
else
|
27
|
+
key
|
28
|
+
end
|
29
|
+
nval = case val
|
30
|
+
when Hash, Array
|
31
|
+
symbolize_hash(val)
|
32
|
+
when String
|
33
|
+
val.to_sym
|
34
|
+
else
|
35
|
+
val
|
36
|
+
end
|
37
|
+
res[nkey] = nval
|
38
|
+
res
|
39
|
+
}
|
40
|
+
else
|
41
|
+
obj
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require RUBY_VERSION < '1.9' ? 'fastercsv' : 'csv'
|
3
|
+
|
4
|
+
module RailsAdmin
|
5
|
+
|
6
|
+
CSVClass = RUBY_VERSION < '1.9' ? ::FasterCSV : ::CSV
|
7
|
+
NON_ASCII_ENCODINGS = /(UTF\-16)|(UTF\-32)|(ISO\-2022\-JP)|(Big5\-HKSCS)|(UTF\-7)/
|
8
|
+
|
9
|
+
class CSVConverter
|
10
|
+
|
11
|
+
def initialize(objects = [], schema = {})
|
12
|
+
return self if (@objects = objects).blank?
|
13
|
+
|
14
|
+
@model = objects.first.class
|
15
|
+
@abstract_model = RailsAdmin::AbstractModel.new(@model)
|
16
|
+
@model_config = @abstract_model.config
|
17
|
+
@methods = [(schema[:only] || []) + (schema[:methods] || [])].flatten.compact
|
18
|
+
@fields = @model_config.export.fields.select{|f| @methods.include? f.name }
|
19
|
+
@empty = ::I18n.t('admin.export.empty_value_for_associated_objects')
|
20
|
+
@associations = {}
|
21
|
+
|
22
|
+
(schema.delete(:include) || {}).each do |key, values|
|
23
|
+
association = @model_config.export.fields.find{|f| f.name == key && f.association?}
|
24
|
+
model_config = association.associated_model_config
|
25
|
+
abstract_model = model_config.abstract_model
|
26
|
+
model = abstract_model.model
|
27
|
+
methods = [(values[:only] || []) + (values[:methods] || [])].flatten.compact
|
28
|
+
fields = model_config.export.fields.select{|f| methods.include? f.name }
|
29
|
+
|
30
|
+
@associations[key] = {
|
31
|
+
:association => association,
|
32
|
+
:model => model,
|
33
|
+
:abstract_model => abstract_model,
|
34
|
+
:model_config => model_config,
|
35
|
+
:fields => fields
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_csv(options)
|
41
|
+
options ||= {}
|
42
|
+
return '' if @objects.blank?
|
43
|
+
|
44
|
+
# encoding shenanigans first
|
45
|
+
@encoding_from = if [nil, '', 'utf8', 'utf-8', 'UTF8', 'UTF-8'].include?(encoding = Rails.configuration.database_configuration[Rails.env]['encoding'])
|
46
|
+
'UTF-8'
|
47
|
+
else
|
48
|
+
encoding
|
49
|
+
end
|
50
|
+
|
51
|
+
unless options[:encoding_to].blank?
|
52
|
+
@encoding_to = options[:encoding_to]
|
53
|
+
unless @encoding_to == @encoding_from
|
54
|
+
require 'iconv'
|
55
|
+
@iconv = (Iconv.new("#{@encoding_to}//TRANSLIT//IGNORE", @encoding_from) rescue (Rails.logger.error("Iconv cannot convert to #{@encoding_to}: #{$!}\nNo conversion will take place"); nil))
|
56
|
+
end
|
57
|
+
else
|
58
|
+
@encoding_to = @encoding_from
|
59
|
+
end
|
60
|
+
|
61
|
+
csv_string = CSVClass.generate(options[:generator] ? options[:generator].symbolize_keys.delete_if {|key, value| value.blank? } : {}) do |csv|
|
62
|
+
unless options[:skip_header]
|
63
|
+
csv << @fields.map do |field|
|
64
|
+
output(::I18n.t('admin.export.csv.header_for_root_methods', :name => field.label, :model => @abstract_model.pretty_name))
|
65
|
+
end +
|
66
|
+
@associations.map do |association_name, option_hash|
|
67
|
+
option_hash[:fields].map do |field|
|
68
|
+
output(::I18n.t('admin.export.csv.header_for_association_methods', :name => field.label, :association => option_hash[:association].label))
|
69
|
+
end
|
70
|
+
end.flatten
|
71
|
+
end
|
72
|
+
@objects.each do |o|
|
73
|
+
|
74
|
+
|
75
|
+
csv << @fields.map do |field|
|
76
|
+
output(field.with(:object => o).export_value)
|
77
|
+
end +
|
78
|
+
@associations.map do |association_name, option_hash|
|
79
|
+
|
80
|
+
associated_objects = [o.send(association_name)].flatten.compact
|
81
|
+
option_hash[:fields].map do |field|
|
82
|
+
output(associated_objects.map{ |ao| field.with(:object => ao).export_value.presence || @empty }.join(','))
|
83
|
+
end
|
84
|
+
end.flatten
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Add a BOM for utf8 encodings, helps with utf8 auto-detect for some versions of Excel.
|
89
|
+
# Don't add if utf8 but user don't want to touch input encoding:
|
90
|
+
# If user chooses utf8, he will open it in utf8 and BOM will disappear at reading.
|
91
|
+
# But that way "English" users who don't bother and chooses to let utf8 by default won't get BOM added
|
92
|
+
# and will not see it if Excel opens the file with a different encoding.
|
93
|
+
csv_string = "\xEF\xBB\xBF#{csv_string.respond_to?(:force_encoding) ? csv_string.force_encoding('UTF-8') : csv_string}" if options[:encoding_to] == 'UTF-8'
|
94
|
+
csv_string = ((@iconv ? @iconv.iconv(csv_string) : csv_string) rescue str) if @encoding_to =~ NON_ASCII_ENCODINGS # global conversion for non ASCII encodings
|
95
|
+
[!options[:skip_header], @encoding_to, csv_string]
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def output(str)
|
101
|
+
unless @encoding_to =~ NON_ASCII_ENCODINGS # can't use the csv generator with encodings that are no supersets of ASCII-7
|
102
|
+
(@iconv ? @iconv.iconv(str.to_s) : str.to_s) rescue str.to_s # convert piece by piece
|
103
|
+
else
|
104
|
+
str.to_s
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :rails_admin do
|
2
|
+
desc "Prepare Continuous Integration environment"
|
3
|
+
task :prepare_ci_env do
|
4
|
+
ENV['SKIP_RAILS_ADMIN_INITIALIZER'] = 'true'
|
5
|
+
adapter = ENV["CI_DB_ADAPTER"] || "sqlite3"
|
6
|
+
database = ENV["CI_DB_DATABASE"] || ("sqlite3" == adapter ? "db/development.sqlite3" : "ci_rails_admin")
|
7
|
+
|
8
|
+
configuration = {
|
9
|
+
"test" => {
|
10
|
+
"adapter" => adapter,
|
11
|
+
"database" => database,
|
12
|
+
"username" => ENV["CI_DB_USERNAME"],
|
13
|
+
"password" => ENV["CI_DB_PASSWORD"],
|
14
|
+
"host" => ENV["CI_DB_HOST"] || "localhost",
|
15
|
+
"encoding" => ENV["CI_DB_ENCODING"] || "utf8",
|
16
|
+
"pool" => (ENV["CI_DB_POOL"] || 5).to_int,
|
17
|
+
"timeout" => (ENV["CI_DB_TIMEOUT"] || 5000).to_int
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
filename = Rails.root.join("config/database.yml")
|
22
|
+
|
23
|
+
File.open(filename, "w") do |f|
|
24
|
+
f.write(configuration.to_yaml)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|