adminos 1.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +25 -0
- data/.gitlab-ci.yml +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +120 -0
- data/.rubocop_todo.yml +58 -0
- data/Gemfile +25 -0
- data/Guardfile +70 -0
- data/LICENSE.txt +22 -0
- data/README.md +88 -0
- data/Rakefile +20 -0
- data/adminos.gemspec +37 -0
- data/adminos.png +0 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/apple-touch-icon.png +0 -0
- data/app/assets/images/favicon-16x16.png +0 -0
- data/app/assets/images/favicon-32x32.png +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/safari-pinned-tab.svg +23 -0
- data/app/inputs/cropp_input.rb +45 -0
- data/bin/bundle +105 -0
- data/bin/gem +39 -0
- data/bin/rspec +29 -0
- data/exe/adminos +5 -0
- data/lib/adminos/cli.rb +71 -0
- data/lib/adminos/controllers/admin_extension.rb +34 -0
- data/lib/adminos/controllers/helpers.rb +24 -0
- data/lib/adminos/controllers/resource.rb +169 -0
- data/lib/adminos/extensions/globalize_actiontext.rb +28 -0
- data/lib/adminos/extensions/globalize_fields.rb +19 -0
- data/lib/adminos/extensions/nested_set.rb +27 -0
- data/lib/adminos/extensions/string.rb +5 -0
- data/lib/adminos/generators/gemfile_merge.rb +85 -0
- data/lib/adminos/generators/utilities.rb +87 -0
- data/lib/adminos/helpers/admin.rb +190 -0
- data/lib/adminos/helpers/bootstrap.rb +64 -0
- data/lib/adminos/helpers/models/apply_sortable_order.rb +10 -0
- data/lib/adminos/helpers/models/array_attrs.rb +17 -0
- data/lib/adminos/helpers/models/cropped.rb +20 -0
- data/lib/adminos/helpers/models/dom_id.rb +16 -0
- data/lib/adminos/helpers/models/flag_attrs.rb +43 -0
- data/lib/adminos/helpers/models/if_blank_set_to_nil_params.rb +19 -0
- data/lib/adminos/helpers/models/move_to.rb +17 -0
- data/lib/adminos/helpers/models/nested_set/duplication.rb +31 -0
- data/lib/adminos/helpers/models/nested_set/materialize_path.rb +50 -0
- data/lib/adminos/helpers/models/nested_set/place_to.rb +35 -0
- data/lib/adminos/helpers/models/nested_set/safe_destroy.rb +34 -0
- data/lib/adminos/helpers/models/recognizable.rb +28 -0
- data/lib/adminos/helpers/models/slugged.rb +20 -0
- data/lib/adminos/helpers/models/soft_destroy.rb +61 -0
- data/lib/adminos/helpers/models/wysiwyg.rb +105 -0
- data/lib/adminos/helpers/view.rb +137 -0
- data/lib/adminos/operations/check_environment.rb +18 -0
- data/lib/adminos/operations/extract_environment.rb +42 -0
- data/lib/adminos/operations/load_environment.rb +30 -0
- data/lib/adminos/stateful_link/action_any_of.rb +76 -0
- data/lib/adminos/stateful_link/helper.rb +31 -0
- data/lib/adminos.rb +42 -0
- data/lib/adminos_template.rb +15 -0
- data/lib/generators/adminos/adminos_generator.rb +164 -0
- data/lib/generators/adminos/ci_generator.rb +124 -0
- data/lib/generators/adminos/field_generator.rb +105 -0
- data/lib/generators/adminos/i18n_generator.rb +76 -0
- data/lib/generators/adminos/install_generator.rb +238 -0
- data/lib/generators/templates/adminos/adminos.ru.yml +15 -0
- data/lib/generators/templates/adminos/fields.slim +21 -0
- data/lib/generators/templates/adminos/locales/general_fields.slim +7 -0
- data/lib/generators/templates/adminos/locales/locale_fields.slim +10 -0
- data/lib/generators/templates/adminos/locales/migration.rb.erb +18 -0
- data/lib/generators/templates/adminos/locales/model.rb.erb +6 -0
- data/lib/generators/templates/adminos/sidebar.slim +2 -0
- data/lib/generators/templates/adminos/sorts/body.slim +3 -0
- data/lib/generators/templates/adminos/sorts/headers.slim +3 -0
- data/lib/generators/templates/adminos/types/default/controller.rb.erb +18 -0
- data/lib/generators/templates/adminos/types/default/migration.rb +5 -0
- data/lib/generators/templates/adminos/types/default/model.rb +20 -0
- data/lib/generators/templates/adminos/types/default/model_includes.rb +4 -0
- data/lib/generators/templates/adminos/types/default/views/index.slim +14 -0
- data/lib/generators/templates/adminos/types/section/controller.rb.erb +10 -0
- data/lib/generators/templates/adminos/types/section/migration.rb +12 -0
- data/lib/generators/templates/adminos/types/section/model.rb +62 -0
- data/lib/generators/templates/adminos/types/section/model_includes.rb +7 -0
- data/lib/generators/templates/adminos/types/section/views/_object.slim +24 -0
- data/lib/generators/templates/adminos/types/section/views/_objects.slim +6 -0
- data/lib/generators/templates/adminos/types/section/views/index.slim +7 -0
- data/lib/generators/templates/adminos/types/sortable/controller.rb.erb +10 -0
- data/lib/generators/templates/adminos/types/sortable/migration.rb +9 -0
- data/lib/generators/templates/adminos/types/sortable/model.rb +35 -0
- data/lib/generators/templates/adminos/types/sortable/model_includes.rb +6 -0
- data/lib/generators/templates/adminos/types/sortable/views/_object.slim +17 -0
- data/lib/generators/templates/adminos/types/sortable/views/_objects.slim +6 -0
- data/lib/generators/templates/adminos/types/sortable/views/index.slim +7 -0
- data/lib/generators/templates/adminos/types/table/controller.rb.erb +19 -0
- data/lib/generators/templates/adminos/types/table/views/index.slim +31 -0
- data/lib/generators/templates/ci/.gitlab-ci.yml +40 -0
- data/lib/generators/templates/ci/audit/Gemfile +3 -0
- data/lib/generators/templates/ci/lint/Gemfile +3 -0
- data/lib/generators/templates/ci/lint/rubocop.yml +116 -0
- data/lib/generators/templates/ci/rakelib/audit.rake +13 -0
- data/lib/generators/templates/ci/rakelib/lint.rake +13 -0
- data/lib/generators/templates/ci/spec/Gemfile +9 -0
- data/lib/generators/templates/field/locales/locale_fields.slim +4 -0
- data/lib/generators/templates/field/locales/migration.rb.erb +13 -0
- data/lib/generators/templates/field/locales/model.rb.erb +6 -0
- data/lib/generators/templates/i18n/Gemfile +1 -0
- data/lib/generators/templates/i18n/add_translation_table_to_page.rb +15 -0
- data/lib/generators/templates/i18n/auto/app/validators/locale_validator.rb +23 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/base/_fields.slim +1 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/base/_pills.slim +19 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/pages/_general_fields.slim +8 -0
- data/lib/generators/templates/i18n/auto/app/views/admin/pages/_locale_fields.slim +13 -0
- data/lib/generators/templates/i18n/auto/config/initializers/globalize_fields.rb +1 -0
- data/lib/generators/templates/i18n/controller.rb +12 -0
- data/lib/generators/templates/i18n/devise/devise.ru.yml +60 -0
- data/lib/generators/templates/i18n/devise/views/_links.erb +25 -0
- data/lib/generators/templates/i18n/devise/views/confirmations/new.slim +8 -0
- data/lib/generators/templates/i18n/devise/views/mailer/confirmation_instructions.slim +4 -0
- data/lib/generators/templates/i18n/devise/views/mailer/reset_password_instructions.slim +5 -0
- data/lib/generators/templates/i18n/devise/views/mailer/unlock_instructions.slim +4 -0
- data/lib/generators/templates/i18n/devise/views/passwords/edit.slim +7 -0
- data/lib/generators/templates/i18n/devise/views/passwords/new.slim +5 -0
- data/lib/generators/templates/i18n/devise/views/registrations/edit.slim +25 -0
- data/lib/generators/templates/i18n/devise/views/registrations/new.slim +7 -0
- data/lib/generators/templates/i18n/devise/views/sessions/new.slim +22 -0
- data/lib/generators/templates/i18n/devise/views/unlocks/new.slim +11 -0
- data/lib/generators/templates/i18n/locales.slim +3 -0
- data/lib/generators/templates/i18n/page.rb +5 -0
- data/lib/generators/templates/install/.gitignore +11 -0
- data/lib/generators/templates/install/Gemfile +57 -0
- data/lib/generators/templates/install/Procfile +1 -0
- data/lib/generators/templates/install/_sidebar.slim.erb +44 -0
- data/lib/generators/templates/install/add_authentications/authentication.rb +7 -0
- data/lib/generators/templates/install/add_authentications/authentications_controller.rb +95 -0
- data/lib/generators/templates/install/add_authentications/authentications_migration.rb +12 -0
- data/lib/generators/templates/install/add_authentications/views/authentications/_form.slim +5 -0
- data/lib/generators/templates/install/add_authentications/views/authentications/_modal.slim +7 -0
- data/lib/generators/templates/install/add_pages/page.rb +116 -0
- data/lib/generators/templates/install/add_pages/pages_controller.rb +6 -0
- data/lib/generators/templates/install/add_pages/pages_migration.rb +25 -0
- data/lib/generators/templates/install/add_pages/views/pages/show.slim +4 -0
- data/lib/generators/templates/install/admin.slim +36 -0
- data/lib/generators/templates/install/admin_panel/pages/admin_pages_controller.rb +9 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_fields.slim +26 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_object.slim +25 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/_objects.slim +6 -0
- data/lib/generators/templates/install/admin_panel/pages/views/admin_pages/index.slim +7 -0
- data/lib/generators/templates/install/admin_panel/users/admin_users_controller.rb +29 -0
- data/lib/generators/templates/install/admin_panel/users/views/admin_users/_fields.slim +4 -0
- data/lib/generators/templates/install/admin_panel/users/views/admin_users/index.slim +33 -0
- data/lib/generators/templates/install/admin_panel/versions/admin_versions_controller.rb +29 -0
- data/lib/generators/templates/install/admin_panel/versions/views/admin_versions/index.slim +47 -0
- data/lib/generators/templates/install/admin_panel/versions/views/admin_versions/show.slim +18 -0
- data/lib/generators/templates/install/application.slim.erb +31 -0
- data/lib/generators/templates/install/auto/.editorconfig +14 -0
- data/lib/generators/templates/install/auto/.env.staging +2 -0
- data/lib/generators/templates/install/auto/Capfile +14 -0
- data/lib/generators/templates/install/auto/Guardfile +18 -0
- data/lib/generators/templates/install/auto/Procfile +1 -0
- data/lib/generators/templates/install/auto/Procfile.local +2 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/admin/application.js +3 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/admin/cocoon_fields.js +43 -0
- data/lib/generators/templates/install/auto/app/assets/javascripts/application.js +1 -0
- data/lib/generators/templates/install/auto/app/assets/stylesheets/admin/application.scss +1 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/base_controller.rb +16 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/helps_controller.rb +4 -0
- data/lib/generators/templates/install/auto/app/controllers/admin/settings_controller.rb +26 -0
- data/lib/generators/templates/install/auto/app/controllers/application_controller.rb +50 -0
- data/lib/generators/templates/install/auto/app/controllers/index_controller.rb +2 -0
- data/lib/generators/templates/install/auto/app/helpers/nested_helper.rb +75 -0
- data/lib/generators/templates/install/auto/app/helpers/versions_helper.rb +33 -0
- data/lib/generators/templates/install/auto/app/inputs/carrierwave_input.rb +52 -0
- data/lib/generators/templates/install/auto/app/inputs/checkbox_input.rb +13 -0
- data/lib/generators/templates/install/auto/app/inputs/rich_text_input.rb +9 -0
- data/lib/generators/templates/install/auto/app/mailers/notifier.rb +9 -0
- data/lib/generators/templates/install/auto/app/models/settings.rb +27 -0
- data/lib/generators/templates/install/auto/app/services/export_xlsx.rb +76 -0
- data/lib/generators/templates/install/auto/app/views/active_storage/blobs/_blob.html.erb +17 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_form.slim +33 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_object.slim +27 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/_objects.slim +19 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/drop.js.erb +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/edit.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/index.slim +14 -0
- data/lib/generators/templates/install/auto/app/views/admin/base/new.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/admin/helps/index.slim +29 -0
- data/lib/generators/templates/install/auto/app/views/admin/settings/edit.slim +27 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_first_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_gap.slim +7 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_last_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_next_page.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_paginator.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/_prev_page.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_first_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_gap.slim +8 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_last_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_next_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_paginator.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/kaminari/admin/_prev_page.slim +10 -0
- data/lib/generators/templates/install/auto/app/views/layouts/admin/base.slim +17 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_back_button.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_footer.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_search_form.slim +6 -0
- data/lib/generators/templates/install/auto/app/views/shared/admin/_topbar.slim +11 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_alert_close.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_contacts_page_link_tag.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_link_button_to.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_method_ajax_request_link_to.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_method_link_to.slim +12 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_navigation_menu.html.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_print_tag.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_search_tag_for.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_show_breadcrumbs.slim +7 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_show_flash_alert.slim +9 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_sortable_column.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_span_link_to.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/_sub_navigation.slim +14 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_batch_actions_tag.slim +16 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_button_new.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_collection_header.slim +4 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_locked_sign.slim +3 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_nav_published_sign.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_children.slim +2 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_duplication.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_edit.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_object_link_new.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_page_header.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_published_sign.slim +1 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_show_breadcrumbs.slim +6 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_top_menu_item.slim +5 -0
- data/lib/generators/templates/install/auto/app/views/shared/helpers/admin/_unpublished_sign.slim +1 -0
- data/lib/generators/templates/install/auto/browserslist +3 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/database.yml.erb +10 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/nginx.conf.erb +28 -0
- data/lib/generators/templates/install/auto/config/deploy/shared/unicorn.rb.erb +35 -0
- data/lib/generators/templates/install/auto/config/deploy/staging.rb +12 -0
- data/lib/generators/templates/install/auto/config/environments/staging.rb +84 -0
- data/lib/generators/templates/install/auto/config/initializers/awesome_nested_set.rb +1 -0
- data/lib/generators/templates/install/auto/config/initializers/content_security_policy.rb +26 -0
- data/lib/generators/templates/install/auto/config/initializers/friendly_id.rb +1 -0
- data/lib/generators/templates/install/auto/config/initializers/kaminari_config.rb +15 -0
- data/lib/generators/templates/install/auto/config/initializers/simple_form.rb +238 -0
- data/lib/generators/templates/install/auto/config/initializers/slim.rb +2 -0
- data/lib/generators/templates/install/auto/config/locales/adminos.en.yml +164 -0
- data/lib/generators/templates/install/auto/config/locales/adminos.ru.yml +292 -0
- data/lib/generators/templates/install/auto/lib/capistrano/substitute_strings.rb +12 -0
- data/lib/generators/templates/install/auto/lib/capistrano/tasks/setup_config.cap +39 -0
- data/lib/generators/templates/install/auto/lib/capistrano/template.rb +33 -0
- data/lib/generators/templates/install/auto/public/404.html +26 -0
- data/lib/generators/templates/install/auto/public/500.html +25 -0
- data/lib/generators/templates/install/database.yml +19 -0
- data/lib/generators/templates/install/deploy.rb.erb +21 -0
- data/lib/generators/templates/install/install_devise/ability.rb +49 -0
- data/lib/generators/templates/install/install_devise/application.rb +7 -0
- data/lib/generators/templates/install/install_devise/prepare_users.rb +1 -0
- data/lib/generators/templates/install/install_devise/user.rb +21 -0
- data/lib/generators/templates/install/prepare_settings.rb +4 -0
- data/lib/generators/templates/install/routes/pages.rb +18 -0
- data/lib/generators/templates/install/routes.rb.erb +53 -0
- data/lib/generators/templates/install/settings_migration.rb +16 -0
- data/lib/generators/templates/install/webpack/custom.js +36 -0
- data/lib/generators/templates/install/webpack/environment.js +4 -0
- data/lib/generators/templates/install/webpack/javascript/admin/js/index.js +2 -0
- data/lib/generators/templates/install/webpack/javascript/admin/styles/admin.scss +2 -0
- data/lib/generators/templates/install/webpack/javascript/packs/admin.js +2 -0
- data/package-lock.json +3 -0
- data/spec/config/database.yml +2 -0
- data/spec/db/schema.rb +0 -0
- data/spec/lib/adminos/helpers/models/apply_sortable_order.rb +26 -0
- data/spec/lib/adminos/helpers/models/array_attrs_spec.rb +38 -0
- data/spec/lib/adminos/helpers/models/dom_id_spec.rb +41 -0
- data/spec/lib/adminos/helpers/models/flag_attrs_spec.rb +115 -0
- data/spec/lib/adminos/helpers/models/if_blank_set_to_nil_params_spec.rb +36 -0
- data/spec/lib/adminos/helpers/models/recognizable_spec.rb +40 -0
- data/spec/lib/adminos/helpers/models/slugged.rb +40 -0
- data/spec/lib/generators/adminos/adminos_generator_spec.rb +106 -0
- data/spec/lib/generators/adminos/ci_generator_spec.rb +88 -0
- data/spec/lib/generators/adminos/i18n_generator_spec.rb +31 -0
- data/spec/lib/generators/adminos/install_generator_rspec.rb +322 -0
- data/spec/spec_helper.rb +122 -0
- data/spec/support/ammeter.rb +14 -0
- data/spec/support/database.rb +29 -0
- data/spec/support/generators.rb +99 -0
- data/spec/support/post.rb +8 -0
- data/spec/support/shared/generator.rb +35 -0
- metadata +632 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
const {
|
2
|
+
environment
|
3
|
+
} = require('@rails/webpacker')
|
4
|
+
const webpack = require('webpack')
|
5
|
+
|
6
|
+
module.exports = {
|
7
|
+
resolve: {
|
8
|
+
alias: {
|
9
|
+
jquery: 'jquery/src/jquery'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
// resolve-url-loader must be used before sass-loader
|
15
|
+
environment.loaders.get('sass').use.splice(-1, 0, {
|
16
|
+
loader: 'resolve-url-loader'
|
17
|
+
});
|
18
|
+
|
19
|
+
|
20
|
+
// Insert before a given plugin
|
21
|
+
environment.plugins.insert('CommonChunkVendor',
|
22
|
+
new webpack.optimize.CommonsChunkPlugin({
|
23
|
+
name: 'vendor', // Vendor code
|
24
|
+
minChunks: (module) => module.context && module.context.indexOf('node_modules') !== -1
|
25
|
+
}), {
|
26
|
+
before: 'manifest'
|
27
|
+
})
|
28
|
+
|
29
|
+
// Add an additional plugin of your choosing : ProvidePlugin
|
30
|
+
environment.plugins.prepend(
|
31
|
+
'Provide',
|
32
|
+
new webpack.ProvidePlugin({
|
33
|
+
$: 'jquery',
|
34
|
+
jQuery: 'jquery'
|
35
|
+
})
|
36
|
+
)
|
data/package-lock.json
ADDED
data/spec/db/schema.rb
ADDED
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec.describe Adminos::ApplySortableOrder, type: :model do
|
2
|
+
|
3
|
+
let(:mock_class) { build_mock_class }
|
4
|
+
|
5
|
+
before(:all) { create_table }
|
6
|
+
after(:all) { drop_table }
|
7
|
+
|
8
|
+
describe 'apply_sortable_order' do
|
9
|
+
it { expect(build_mock_class).to respond_to(:apply_sortable_order) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_mock_class
|
13
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
14
|
+
include Adminos::ApplySortableOrder
|
15
|
+
|
16
|
+
self.table_name = 'mock_table'
|
17
|
+
reset_column_information
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_table
|
22
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
23
|
+
t.integer :position
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe Adminos::ArrayAttrs, type: :model do
|
2
|
+
|
3
|
+
let(:mock_class) { build_mock_class }
|
4
|
+
|
5
|
+
before(:all) { create_table }
|
6
|
+
after(:all) { drop_table }
|
7
|
+
|
8
|
+
|
9
|
+
describe 'array_attrs' do
|
10
|
+
let!(:record) { build_mock_class.create }
|
11
|
+
|
12
|
+
it { expect(record).to respond_to(:body_to_a) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'instace methods' do
|
16
|
+
let!(:record) { build_mock_class.create(body: "line1\nLine2\nLine3") }
|
17
|
+
|
18
|
+
it { expect(record.body_to_a).to match_array(['line1', 'Line2', 'Line3'])}
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def build_mock_class
|
23
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
24
|
+
include Adminos::ArrayAttrs
|
25
|
+
|
26
|
+
array_attrs :body
|
27
|
+
|
28
|
+
self.table_name = 'mock_table'
|
29
|
+
reset_column_information
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_table
|
34
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
35
|
+
t.text :body
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
RSpec.describe Adminos::DomId, type: :model do
|
2
|
+
|
3
|
+
let(:mock_class) { build_mock_class }
|
4
|
+
|
5
|
+
before(:all) { create_table }
|
6
|
+
after(:all) { drop_table }
|
7
|
+
|
8
|
+
describe 'with_dom_id' do
|
9
|
+
let!(:record) { build_mock_class.create }
|
10
|
+
|
11
|
+
it { expect(build_mock_class).to respond_to(:with_dom_id) }
|
12
|
+
it { expect(record).to respond_to(:dom_id) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'dom_id' do
|
16
|
+
let!(:record) { build_mock_class.create }
|
17
|
+
|
18
|
+
it { expect(record.dom_id).to eq "mock_table_#{record.id}" }
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_mock_class
|
22
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
23
|
+
include Adminos::DomId
|
24
|
+
|
25
|
+
with_dom_id :id
|
26
|
+
|
27
|
+
self.table_name = 'mock_table'
|
28
|
+
reset_column_information
|
29
|
+
|
30
|
+
def self.name
|
31
|
+
'MockTable'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_table
|
37
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
38
|
+
t.text :body
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
RSpec.describe Adminos::FlagAttrs, type: :model do
|
2
|
+
|
3
|
+
let(:mock_class) { build_mock_class }
|
4
|
+
|
5
|
+
before(:all) { create_table }
|
6
|
+
after(:all) { drop_table }
|
7
|
+
|
8
|
+
describe 'class methods' do
|
9
|
+
describe 'flag_attrs' do
|
10
|
+
let!(:record) { build_mock_class.create }
|
11
|
+
|
12
|
+
it { expect(record).to respond_to(:set_published_on) }
|
13
|
+
it { expect(record).to respond_to(:set_published_off) }
|
14
|
+
|
15
|
+
it { expect(build_mock_class).to respond_to(:set_published_on) }
|
16
|
+
it { expect(build_mock_class).to respond_to(:set_published_off) }
|
17
|
+
|
18
|
+
it { expect(build_mock_class).to respond_to(:set_each_published_on) }
|
19
|
+
it { expect(build_mock_class).to respond_to(:set_each_published_off) }
|
20
|
+
|
21
|
+
it { expect(build_mock_class).to respond_to(:published) }
|
22
|
+
it { expect(build_mock_class).to respond_to(:not_published) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'methods' do
|
27
|
+
describe 'instance methods' do
|
28
|
+
describe 'define_method :"set_#{name}_on"' do
|
29
|
+
let!(:record) { build_mock_class.create(published: false) }
|
30
|
+
before { record.set_published_on }
|
31
|
+
|
32
|
+
it { expect(record.published).to be true }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'define_method :"set_#{name}_off"' do
|
36
|
+
let!(:record) { build_mock_class.create(published: true) }
|
37
|
+
|
38
|
+
before { record.set_published_off }
|
39
|
+
|
40
|
+
it { expect(record.published).to be false }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'class methods' do
|
45
|
+
describe 'define_method :"set_each_#{name}_on" ' do
|
46
|
+
let!(:record_1) { build_mock_class.create(published: false) }
|
47
|
+
let!(:record_2) { build_mock_class.create(published: false) }
|
48
|
+
|
49
|
+
before { build_mock_class.set_each_published_on }
|
50
|
+
|
51
|
+
it { expect(record_1.reload.published).to be true }
|
52
|
+
it { expect(record_2.reload.published).to be true }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'define_method :"set_each_#{name}_off" ' do
|
56
|
+
let!(:record_1) { build_mock_class.create(published: false) }
|
57
|
+
let!(:record_2) { build_mock_class.create(published: false) }
|
58
|
+
|
59
|
+
before { build_mock_class.set_each_published_off }
|
60
|
+
|
61
|
+
it { expect(record_1.reload.published).to be false }
|
62
|
+
it { expect(record_2.reload.published).to be false }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'define_method :"set_#{name}_on"' do
|
66
|
+
let!(:record_1) { build_mock_class.create(published: false) }
|
67
|
+
let!(:record_2) { build_mock_class.create(published: false) }
|
68
|
+
|
69
|
+
before { build_mock_class.set_published_on }
|
70
|
+
|
71
|
+
it { expect(record_1.reload.published).to be true }
|
72
|
+
it { expect(record_2.reload.published).to be true }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'define_method :"set_#{name}_off"' do
|
76
|
+
let!(:record_1) { build_mock_class.create(published: true) }
|
77
|
+
let!(:record_2) { build_mock_class.create(published: true) }
|
78
|
+
|
79
|
+
before { build_mock_class.set_published_off }
|
80
|
+
|
81
|
+
it { expect(record_1.reload.published).to be false }
|
82
|
+
it { expect(record_2.reload.published).to be false }
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'scope :"#{name}"' do
|
86
|
+
let!(:records) { Array.new(2) { build_mock_class.create(published: true) } }
|
87
|
+
|
88
|
+
it { expect(build_mock_class.published).to contain_exactly(*records) }
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'scope :"not_#{name}"' do
|
92
|
+
let!(:records) { Array.new(2) { build_mock_class.create(published: false) } }
|
93
|
+
|
94
|
+
it { expect(build_mock_class.not_published).to contain_exactly(*records) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_mock_class
|
100
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
101
|
+
include Adminos::FlagAttrs
|
102
|
+
|
103
|
+
flag_attrs :published
|
104
|
+
|
105
|
+
self.table_name = 'mock_table'
|
106
|
+
reset_column_information
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_table
|
111
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
112
|
+
t.boolean :published
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
RSpec.describe Adminos::IfBlankSetToNilParams, type: :model do
|
2
|
+
|
3
|
+
let(:mock_class) { build_mock_class }
|
4
|
+
|
5
|
+
before(:all) { create_table }
|
6
|
+
after(:all) { drop_table }
|
7
|
+
|
8
|
+
describe 'if_blank_set_to_nil_params' do
|
9
|
+
let!(:record) { build_mock_class.create(body: " ") }
|
10
|
+
|
11
|
+
it { expect(build_mock_class).to respond_to(:if_blank_set_to_nil_params) }
|
12
|
+
it { expect(record.body).to be nil }
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def build_mock_class
|
17
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
18
|
+
include Adminos::IfBlankSetToNilParams
|
19
|
+
|
20
|
+
if_blank_set_to_nil_params :body
|
21
|
+
|
22
|
+
self.table_name = 'mock_table'
|
23
|
+
reset_column_information
|
24
|
+
|
25
|
+
def self.name
|
26
|
+
'MockTable'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_table
|
32
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
33
|
+
t.text :body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'friendly_id'
|
2
|
+
|
3
|
+
RSpec.describe Adminos::Recognizable, type: :model do
|
4
|
+
|
5
|
+
let(:mock_class) { build_mock_class }
|
6
|
+
|
7
|
+
before(:all) { create_table }
|
8
|
+
after(:all) { drop_table }
|
9
|
+
|
10
|
+
describe 'if_blank_set_to_nil_params' do
|
11
|
+
let!(:record) { build_mock_class.create(name: "test string") }
|
12
|
+
|
13
|
+
it { expect(build_mock_class).to respond_to(:acts_as_recognizable) }
|
14
|
+
it { expect(record).to respond_to(:normalize_friendly_id) }
|
15
|
+
it { expect(record.slug).to eq 'test-string' }
|
16
|
+
it { expect(record.name).to eq 'test string' }
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_mock_class
|
20
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
21
|
+
include Adminos::Recognizable
|
22
|
+
|
23
|
+
acts_as_recognizable :name
|
24
|
+
|
25
|
+
self.table_name = 'mock_table'
|
26
|
+
reset_column_information
|
27
|
+
|
28
|
+
def self.name
|
29
|
+
'MockTable'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_table
|
35
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
36
|
+
t.text :name
|
37
|
+
t.text :slug
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'friendly_id'
|
2
|
+
|
3
|
+
RSpec.describe Adminos::Slugged, type: :model do
|
4
|
+
|
5
|
+
let(:mock_class) { build_mock_class }
|
6
|
+
|
7
|
+
before(:all) { create_table }
|
8
|
+
after(:all) { drop_table }
|
9
|
+
|
10
|
+
describe 'if_blank_set_to_nil_params' do
|
11
|
+
let!(:record) { build_mock_class.create(name: "test/new/string") }
|
12
|
+
|
13
|
+
it { expect(build_mock_class).to respond_to(:slugged) }
|
14
|
+
it { expect(record.slug).to eq 'test-new-string' }
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_mock_class
|
18
|
+
@build_mock_class ||= Class.new(ActiveRecord::Base) do
|
19
|
+
include Adminos::Slugged
|
20
|
+
|
21
|
+
slugged :name
|
22
|
+
|
23
|
+
self.table_name = 'mock_table'
|
24
|
+
reset_column_information
|
25
|
+
|
26
|
+
def self.name
|
27
|
+
'MockTable'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_table
|
33
|
+
build_mock_class.reset_column_information
|
34
|
+
|
35
|
+
ActiveRecord::Base.connection.create_table :mock_table do |t|
|
36
|
+
t.text :name
|
37
|
+
t.text :slug
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'support/generators'
|
2
|
+
|
3
|
+
RSpec.describe Adminos::Generators::AdminosGenerator, type: :generator do
|
4
|
+
|
5
|
+
context 'default locales' do
|
6
|
+
prepare_app(folder_name: 'dummy')
|
7
|
+
|
8
|
+
%w(default section sortable table).each do |type|
|
9
|
+
context "the generated files for type: #{type}" do
|
10
|
+
name = "event_#{type}"
|
11
|
+
let(:command) { "adminos #{name.classify} --type #{type} --quiet" }
|
12
|
+
|
13
|
+
before { generate(command) }
|
14
|
+
|
15
|
+
describe "app/models/#{name}.rb" do
|
16
|
+
subject { file("app/models/#{name}.rb") }
|
17
|
+
it { is_expected.to exist }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "app/controllers/admin/#{name.pluralize}_controller.rb" do
|
21
|
+
subject { file("app/controllers/admin/#{name.pluralize}_controller.rb") }
|
22
|
+
it { is_expected.to exist }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "config/routes.rb" do
|
26
|
+
subject { file("config/routes.rb") }
|
27
|
+
it { is_expected.to contain /resources :#{name.pluralize}, except: :show/ }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "app/views/shared/admin/_sidebar.slim" do
|
31
|
+
subject { file("app/views/shared/admin/_sidebar.slim") }
|
32
|
+
it { is_expected.to contain /\= top_menu_item active: 'admin\/#{name.pluralize}\#'/ }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "config/locales/adminos.ru.yml" do
|
36
|
+
subject { file("config/locales/adminos.ru.yml") }
|
37
|
+
it { is_expected.to contain /#{name.pluralize}:/ }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "app/views/admin/#{name.pluralize}/_fields.slim" do
|
41
|
+
subject { file("app/views/admin/#{name.pluralize}/_fields.slim") }
|
42
|
+
|
43
|
+
it { is_expected.to exist }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "app/views/admin/#{name.pluralize}/index.slim" do
|
47
|
+
subject { file("app/views/admin/#{name.pluralize}/index.slim") }
|
48
|
+
|
49
|
+
it { is_expected.to exist }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with ru, :en locales' do
|
56
|
+
prepare_app(folder_name: 'dummy_en', locales: 'en,ru')
|
57
|
+
|
58
|
+
%w(default).each do |type|
|
59
|
+
context "the generated files for type: #{type}" do
|
60
|
+
name = "event_#{type}"
|
61
|
+
let(:command) { "adminos #{name.classify} --type #{type} --locale --force --quiet" }
|
62
|
+
|
63
|
+
before { generate(command) }
|
64
|
+
|
65
|
+
describe "app/views/admin/#{name.pluralize}/_locale_fields.slim" do
|
66
|
+
subject { file("app/views/admin/#{name.pluralize}/_locale_fields.slim") }
|
67
|
+
|
68
|
+
it { is_expected.to exist }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "app/views/admin/#{name.pluralize}/_general_fields.slim" do
|
72
|
+
subject { file("app/views/admin/#{name.pluralize}/_general_fields.slim") }
|
73
|
+
|
74
|
+
it { is_expected.to exist }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "app/models/#{name}.rb" do
|
78
|
+
subject { file("app/models/#{name}.rb") }
|
79
|
+
|
80
|
+
it { is_expected.to exist }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "config/routes.rb" do
|
84
|
+
subject { file("config/routes.rb") }
|
85
|
+
it { is_expected.to contain /resources :#{name.pluralize}, except: :show/ }
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
describe "config/locales/adminos.ru.yml" do
|
90
|
+
subject { file("config/locales/adminos.ru.yml") }
|
91
|
+
it { is_expected.to contain /#{name.pluralize}:/ }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "app/controllers/admin/#{name.pluralize}_controller.rb" do
|
95
|
+
subject { file("app/controllers/admin/#{name.pluralize}_controller.rb") }
|
96
|
+
it { is_expected.to exist }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "app/views/admin/#{name.pluralize}" do
|
100
|
+
subject { file("app/views/admin/#{name.pluralize}") }
|
101
|
+
it { is_expected.to exist }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'support/generators'
|
2
|
+
|
3
|
+
RSpec.describe Adminos::Generators::CiGenerator, type: :generator do
|
4
|
+
set_default_destination('dummy_ci')
|
5
|
+
generate_rails(destination_root)
|
6
|
+
generate('adminos:ci')
|
7
|
+
|
8
|
+
context 'CI' do
|
9
|
+
describe ".gitlab-ci.ym" do
|
10
|
+
subject { file(".gitlab-ci.yml") }
|
11
|
+
|
12
|
+
it { is_expected.to exist }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'spec' do
|
17
|
+
describe "Gemfile" do
|
18
|
+
subject { file("Gemfile") }
|
19
|
+
it { is_expected.to contain /gem 'rspec-rails'/ }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "bin/rspec" do
|
23
|
+
subject { file("bin/rspec") }
|
24
|
+
it { is_expected.to exist }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".gitlab-ci.ym" do
|
28
|
+
subject { file(".gitlab-ci.yml") }
|
29
|
+
|
30
|
+
it { is_expected.to contain /^spec\:/ }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'audit' do
|
35
|
+
describe "Gemfile" do
|
36
|
+
subject { file("Gemfile") }
|
37
|
+
it { is_expected.to contain /gem 'bundler-audit'/ }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "bin/bundler-audit" do
|
41
|
+
subject { file("bin/bundler-audit") }
|
42
|
+
it { is_expected.to exist }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "rakelib/audit.rake" do
|
46
|
+
subject { file("rakelib/audit.rake") }
|
47
|
+
it { is_expected.to exist }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".gitlab-ci.yml" do
|
51
|
+
subject { file(".gitlab-ci.yml") }
|
52
|
+
it { is_expected.to contain /^audit\:/ }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'lint' do
|
57
|
+
describe "Gemfile" do
|
58
|
+
subject { file("Gemfile") }
|
59
|
+
|
60
|
+
it { is_expected.to contain /gem 'rubocop'/ }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "bin/rubocop" do
|
64
|
+
subject { file("bin/rubocop") }
|
65
|
+
it { is_expected.to exist }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "rakelib/lint.rake" do
|
69
|
+
subject { file("rakelib/lint.rake") }
|
70
|
+
it { is_expected.to exist }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".rubocop.yml" do
|
74
|
+
subject { file(".rubocop.yml") }
|
75
|
+
it { is_expected.to exist }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".rubocop_todo.yml" do
|
79
|
+
subject { file(".rubocop_todo.yml") }
|
80
|
+
it { is_expected.to exist }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".gitlab-ci.yml" do
|
84
|
+
subject { file(".gitlab-ci.yml") }
|
85
|
+
it { is_expected.to contain /^lint\:/ }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'support/generators'
|
2
|
+
|
3
|
+
RSpec.describe Adminos::Generators::I18nGenerator, type: :generator do
|
4
|
+
prepare_app(folder_name: 'dummy')
|
5
|
+
|
6
|
+
context 'when using defaults' do
|
7
|
+
let(:arguments) { [] }
|
8
|
+
|
9
|
+
it_behaves_like 'everything works'
|
10
|
+
|
11
|
+
describe 'the generated files' do
|
12
|
+
before { run_generator(arguments) }
|
13
|
+
|
14
|
+
it_behaves_like 'Gemfile'
|
15
|
+
it_behaves_like 'config/application.rb'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when all included' do
|
20
|
+
let(:arguments) { %w[--devise --pages --russian] }
|
21
|
+
|
22
|
+
it_behaves_like 'everything works'
|
23
|
+
|
24
|
+
describe 'the generated files' do
|
25
|
+
before { run_generator(arguments) }
|
26
|
+
|
27
|
+
it_behaves_like 'Gemfile'
|
28
|
+
it_behaves_like 'config/application.rb'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|