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,322 @@
|
|
1
|
+
require 'support/generators'
|
2
|
+
|
3
|
+
RSpec.describe Adminos::Generators::InstallGenerator, type: :generator do
|
4
|
+
|
5
|
+
|
6
|
+
context 'default' do
|
7
|
+
prepare_app(folder_name: 'dummy')
|
8
|
+
|
9
|
+
context 'models' do
|
10
|
+
describe 'app/models/user.rb' do
|
11
|
+
subject { file('app/models/user.rb') }
|
12
|
+
it { is_expected.to exist }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'app/models/page.rb' do
|
16
|
+
subject { file('app/models/page.rb') }
|
17
|
+
it { is_expected.to exist }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'app/models/ability.rb' do
|
21
|
+
subject { file('app/models/ability.rb') }
|
22
|
+
it { is_expected.to exist }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'app/models/settings.rb' do
|
26
|
+
subject { file('app/models/settings.rb') }
|
27
|
+
it { is_expected.to exist }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'app/models/authentication.rb' do
|
31
|
+
subject { file('app/models/authentication.rb') }
|
32
|
+
it { is_expected.to exist }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'controllers' do
|
37
|
+
describe 'app/controllers/pages_controller.rb' do
|
38
|
+
subject { file('app/controllers/pages_controller.rb') }
|
39
|
+
it { is_expected.to exist }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'app/controllers/application_controller.rb' do
|
43
|
+
subject { file('app/controllers/application_controller.rb') }
|
44
|
+
it { is_expected.to exist }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'app/controllers/authentications_controller.rb' do
|
48
|
+
subject { file('app/controllers/authentications_controller.rb') }
|
49
|
+
it { is_expected.to exist }
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'app/controllers/admin/base_controller.rb' do
|
53
|
+
subject { file('app/controllers/admin/base_controller.rb') }
|
54
|
+
it { is_expected.to exist }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'app/controllers/admin/helps_controller.rb' do
|
58
|
+
subject { file('app/controllers/admin/helps_controller.rb') }
|
59
|
+
it { is_expected.to exist }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'app/controllers/admin/pages_controller.rb' do
|
63
|
+
subject { file('app/controllers/admin/pages_controller.rb') }
|
64
|
+
it { is_expected.to exist }
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'app/controllers/admin/settings_controller.rb' do
|
68
|
+
subject { file('app/controllers/admin/settings_controller.rb') }
|
69
|
+
it { is_expected.to exist }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'app/controllers/admin/users_controller.rb' do
|
73
|
+
subject { file('app/controllers/admin/users_controller.rb') }
|
74
|
+
it { is_expected.to exist }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'app/controllers/admin/versions_controller.rb' do
|
78
|
+
subject { file('app/controllers/admin/versions_controller.rb') }
|
79
|
+
it { is_expected.to exist }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'app/controllers/admin/users_controller.rb' do
|
83
|
+
subject { file('app/controllers/admin/users_controller.rb') }
|
84
|
+
it { is_expected.to exist }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'views' do
|
89
|
+
describe 'app/views/admin' do
|
90
|
+
subject { file('app/views/admin') }
|
91
|
+
it { is_expected.to exist }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'app/views/admin/base' do
|
95
|
+
subject { file('app/views/admin/base') }
|
96
|
+
it { is_expected.to exist }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'app/views/admin/helps' do
|
100
|
+
subject { file('app/views/admin/helps') }
|
101
|
+
it { is_expected.to exist }
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'app/views/admin/pages' do
|
105
|
+
subject { file('app/views/admin/pages') }
|
106
|
+
it { is_expected.to exist }
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'app/views/admin/settings' do
|
110
|
+
subject { file('app/views/admin/settings') }
|
111
|
+
it { is_expected.to exist }
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'app/views/admin/versions' do
|
115
|
+
subject { file('app/views/admin/versions') }
|
116
|
+
it { is_expected.to exist }
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'app/views/admin/users' do
|
120
|
+
subject { file('app/views/admin/users') }
|
121
|
+
it { is_expected.to exist }
|
122
|
+
end
|
123
|
+
|
124
|
+
describe 'app/views/authentications' do
|
125
|
+
subject { file('app/views/authentications') }
|
126
|
+
it { is_expected.to exist }
|
127
|
+
end
|
128
|
+
|
129
|
+
describe 'app/views/devise' do
|
130
|
+
subject { file('app/views/devise') }
|
131
|
+
it { is_expected.to exist }
|
132
|
+
end
|
133
|
+
|
134
|
+
describe 'app/views/kaminari' do
|
135
|
+
subject { file('app/views/kaminari') }
|
136
|
+
it { is_expected.to exist }
|
137
|
+
end
|
138
|
+
|
139
|
+
describe 'app/views/layouts' do
|
140
|
+
subject { file('app/views/layouts') }
|
141
|
+
it { is_expected.to exist }
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'app/views/shared' do
|
145
|
+
subject { file('app/views/shared') }
|
146
|
+
it { is_expected.to exist }
|
147
|
+
end
|
148
|
+
|
149
|
+
describe 'app/views/pages/show.slim' do
|
150
|
+
subject { file('app/views/pages/show.slim') }
|
151
|
+
it { is_expected.to exist }
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'config' do
|
156
|
+
describe '.ruby-version' do
|
157
|
+
subject { file('.ruby-version') }
|
158
|
+
it { is_expected.to contain /#{RUBY_VERSION}/ }
|
159
|
+
end
|
160
|
+
|
161
|
+
describe 'config/initializers/simple_form.rb' do
|
162
|
+
subject { file('config/initializers/simple_form.rb') }
|
163
|
+
it { is_expected.to exist }
|
164
|
+
end
|
165
|
+
|
166
|
+
describe 'config/initializers/kaminari_config.rb' do
|
167
|
+
subject { file( 'config/initializers/kaminari_config.rb') }
|
168
|
+
it { is_expected.to exist }
|
169
|
+
end
|
170
|
+
|
171
|
+
describe 'config/locales/devise.ru.yml' do
|
172
|
+
subject { file( 'config/locales/devise.ru.yml') }
|
173
|
+
it { is_expected.to exist }
|
174
|
+
end
|
175
|
+
|
176
|
+
describe 'config/locales/adminos.ru.yml' do
|
177
|
+
subject { file( 'config/locales/adminos.ru.yml') }
|
178
|
+
it { is_expected.to exist }
|
179
|
+
end
|
180
|
+
|
181
|
+
describe 'config/routes.rb' do
|
182
|
+
subject { file( 'config/routes.rb') }
|
183
|
+
it { is_expected.to exist }
|
184
|
+
end
|
185
|
+
|
186
|
+
describe 'config/application.rb' do
|
187
|
+
subject { file( 'config/application.rb') }
|
188
|
+
it { is_expected.to contain /config.time_zone = 'Moscow'/ }
|
189
|
+
it { is_expected.to contain /config.i18n.default_locale = :ru/ }
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context 'mailers' do
|
194
|
+
describe 'app/mailers/notifier.rb' do
|
195
|
+
subject { file( 'app/mailers/notifier.rb') }
|
196
|
+
it { is_expected.to exist }
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'assets' do
|
201
|
+
describe 'app/assets/stylesheets/admin/application.scss' do
|
202
|
+
subject { file('app/assets/stylesheets/admin/application.scss') }
|
203
|
+
it { is_expected.to exist }
|
204
|
+
end
|
205
|
+
describe 'app/assets/javascripts/admin/application.js' do
|
206
|
+
subject { file('app/assets/javascripts/admin/application.js') }
|
207
|
+
it { is_expected.to exist }
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'deploy' do
|
212
|
+
describe 'config/deploy.rb' do
|
213
|
+
subject { file('config/deploy.rb') }
|
214
|
+
it { is_expected.to exist }
|
215
|
+
end
|
216
|
+
|
217
|
+
describe 'config/deploy/staging.rb' do
|
218
|
+
subject { file('config/deploy/staging.rb') }
|
219
|
+
it { is_expected.to exist }
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'general' do
|
224
|
+
describe 'public/404.html' do
|
225
|
+
subject { file('public/404.html') }
|
226
|
+
it { is_expected.to exist }
|
227
|
+
end
|
228
|
+
|
229
|
+
describe 'public/500.html' do
|
230
|
+
subject { file('public/500.html') }
|
231
|
+
it { is_expected.to exist }
|
232
|
+
end
|
233
|
+
|
234
|
+
describe 'Capfile' do
|
235
|
+
subject { file('Capfile') }
|
236
|
+
it { is_expected.to exist }
|
237
|
+
end
|
238
|
+
|
239
|
+
describe 'Gemfile' do
|
240
|
+
subject { file('Gemfile') }
|
241
|
+
it { is_expected.to exist }
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'with locales en,nl' do
|
247
|
+
prepare_app(folder_name: 'dummy_en', locales: 'en,nl')
|
248
|
+
|
249
|
+
context 'models' do
|
250
|
+
describe 'app/models/page.rb' do
|
251
|
+
subject { file('app/models/page.rb') }
|
252
|
+
it { is_expected.to contain /translates :name, .*/ }
|
253
|
+
it { is_expected.to contain /accepts_nested_attributes_for :translations/ }
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context 'controllers' do
|
258
|
+
describe 'app/controllers/admin/pages_controller.rb' do
|
259
|
+
subject { file('app/controllers/admin/pages_controller.rb') }
|
260
|
+
it { is_expected.to contain /filter_by_locale: true/ }
|
261
|
+
end
|
262
|
+
|
263
|
+
describe 'app/controllers/application_controller.rb' do
|
264
|
+
subject { file('app/controllers/application_controller.rb') }
|
265
|
+
it { is_expected.to contain /, :set_locale/ }
|
266
|
+
it { is_expected.to contain /def default_url_options/ }
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
context 'views' do
|
271
|
+
describe 'app/views/admin/base/_fields.slim' do
|
272
|
+
subject { file('app/views/admin/base/_fields.slim') }
|
273
|
+
it { is_expected.to exist }
|
274
|
+
end
|
275
|
+
|
276
|
+
describe 'app/views/admin/base/_pills.slim' do
|
277
|
+
subject { file('app/views/admin/base/_pills.slim') }
|
278
|
+
it { is_expected.to exist }
|
279
|
+
end
|
280
|
+
|
281
|
+
describe 'app/views/admin/pages/_general_fields.slim' do
|
282
|
+
subject { file('app/views/admin/pages/_general_fields.slim') }
|
283
|
+
it { is_expected.to exist }
|
284
|
+
end
|
285
|
+
|
286
|
+
describe 'app/views/admin/pages/_locale_fields.slim' do
|
287
|
+
subject { file('app/views/admin/pages/_locale_fields.slim') }
|
288
|
+
it { is_expected.to exist }
|
289
|
+
end
|
290
|
+
|
291
|
+
describe 'app/views/shared/admin/_sidebar.slim' do
|
292
|
+
subject { file('app/views/shared/admin/_sidebar.slim') }
|
293
|
+
it { is_expected.to contain /I18n.available_locales.each do |locale|/ }
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
context 'config' do
|
298
|
+
describe 'config/initializers/globalize_fields.rb' do
|
299
|
+
subject { file('config/initializers/globalize_fields.rb') }
|
300
|
+
it { is_expected.to exist }
|
301
|
+
end
|
302
|
+
|
303
|
+
describe 'config/routes.rb' do
|
304
|
+
subject { file('config/routes.rb') }
|
305
|
+
it { is_expected.to contain /scope '\(:locale\)'/ }
|
306
|
+
end
|
307
|
+
|
308
|
+
describe 'config/application.rb' do
|
309
|
+
subject { file('config/application.rb') }
|
310
|
+
it { is_expected.to contain /config.i18n.available_locales = \[:ru, :en, :nl\]/ }
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
context 'Gemfile' do
|
315
|
+
describe 'Gemfile' do
|
316
|
+
subject { file('Gemfile') }
|
317
|
+
it { is_expected.to contain /gem 'globalize'/ }
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'active_record'
|
4
|
+
require 'sqlite3'
|
5
|
+
# require 'nulldb_rspec'
|
6
|
+
|
7
|
+
require 'adminos'
|
8
|
+
require 'support/ammeter'
|
9
|
+
|
10
|
+
require 'generators/adminos/i18n_generator'
|
11
|
+
require 'generators/adminos/adminos_generator'
|
12
|
+
require 'generators/adminos/ci_generator'
|
13
|
+
require 'generators/adminos/install_generator'
|
14
|
+
|
15
|
+
require 'adminos/helpers/models/flag_attrs'
|
16
|
+
require 'adminos/helpers/models/array_attrs'
|
17
|
+
# require 'adminos/helpers/models/dom_id'
|
18
|
+
|
19
|
+
SimpleCov.start
|
20
|
+
|
21
|
+
ActiveRecord::Base.establish_connection adapter: :sqlite3, database: 'dummy_test'
|
22
|
+
|
23
|
+
Dir["#{File.dirname __dir__}/spec/support/**/*.rb"].each { |f| require f }
|
24
|
+
# ActiveRecord::Base.establish_connection :adapter => :nulldb
|
25
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
26
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
27
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
28
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
29
|
+
# files.
|
30
|
+
#
|
31
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
32
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
33
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
34
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
35
|
+
# a separate helper file that requires the additional dependencies and performs
|
36
|
+
# the additional setup, and require it from the spec files that actually need
|
37
|
+
# it.y
|
38
|
+
#
|
39
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
40
|
+
RSpec.configure do |config|
|
41
|
+
# rspec-expectations config goes here. You can use an alternate
|
42
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
43
|
+
# assertions if you prefer.
|
44
|
+
config.include Database, type: :model
|
45
|
+
|
46
|
+
config.expect_with :rspec do |expectations|
|
47
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
48
|
+
# and `failure_message` of custom matchers include text for helper methods
|
49
|
+
# defined using `chain`, e.g.:
|
50
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
51
|
+
# # => "be bigger than 2 and smaller than 4"
|
52
|
+
# ...rather than:
|
53
|
+
# # => "be bigger than 2"
|
54
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
55
|
+
end
|
56
|
+
|
57
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
58
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
59
|
+
config.mock_with :rspec do |mocks|
|
60
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
61
|
+
# a real object. This is generally recommended, and will default to
|
62
|
+
# `true` in RSpec 4.
|
63
|
+
mocks.verify_partial_doubles = true
|
64
|
+
end
|
65
|
+
|
66
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
67
|
+
# have no way to turn it off -- the option exists only for backwards
|
68
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
69
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
70
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
71
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
72
|
+
|
73
|
+
# This allows you to limit a spec run to individual examples or groups
|
74
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
75
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
76
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
77
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
78
|
+
config.filter_run_when_matching :focus
|
79
|
+
|
80
|
+
# Allows RSpec to persist some state between runs in order to support
|
81
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
82
|
+
# you configure your source control system to ignore this file.
|
83
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
84
|
+
|
85
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
86
|
+
# recommended. For more details, see:
|
87
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
88
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
89
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
90
|
+
config.disable_monkey_patching!
|
91
|
+
|
92
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
93
|
+
# be too noisy due to issues in dependencies.
|
94
|
+
config.warnings = true
|
95
|
+
|
96
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
97
|
+
# file, and it's useful to allow more verbose output when running an
|
98
|
+
# individual spec file.
|
99
|
+
if config.files_to_run.one?
|
100
|
+
# Use the documentation formatter for detailed output,
|
101
|
+
# unless a formatter has already been configured
|
102
|
+
# (e.g. via a command-line flag).
|
103
|
+
config.default_formatter = "doc"
|
104
|
+
end
|
105
|
+
|
106
|
+
# Print the 10 slowest examples and example groups at the
|
107
|
+
# end of the spec run, to help surface which specs are running
|
108
|
+
# particularly slow.
|
109
|
+
config.profile_examples = 10
|
110
|
+
|
111
|
+
# Run specs in random order to surface order dependencies. If you find an
|
112
|
+
# order dependency and want to debug it, you can fix the order by providing
|
113
|
+
# the seed, which is printed after each run.
|
114
|
+
# --seed 1234
|
115
|
+
config.order = :random
|
116
|
+
|
117
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
118
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
119
|
+
# test failures related to randomization by passing the same `--seed` value
|
120
|
+
# as the one that triggered the failure.
|
121
|
+
Kernel.srand config.seed
|
122
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
require 'action_view'
|
3
|
+
require 'ammeter/init'
|
4
|
+
|
5
|
+
module Ammeter
|
6
|
+
module RSpec
|
7
|
+
module Rails
|
8
|
+
# Delegates to Rails::Generators::TestCase to work with RSpec.
|
9
|
+
module GeneratorExampleGroup
|
10
|
+
delegate :capture, to: Ammeter::OutputCapturer
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'database_cleaner'
|
2
|
+
|
3
|
+
module Database
|
4
|
+
def drop_table
|
5
|
+
ActiveRecord::Base.connection.drop_table :mock_table
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# config.use_transactional_fixtures = false
|
10
|
+
|
11
|
+
config.before(:suite) do
|
12
|
+
DatabaseCleaner.clean_with(:truncation)
|
13
|
+
end
|
14
|
+
|
15
|
+
config.before(:each) do
|
16
|
+
DatabaseCleaner.strategy = :transaction
|
17
|
+
end
|
18
|
+
|
19
|
+
config.before(:each) do
|
20
|
+
DatabaseCleaner.start
|
21
|
+
end
|
22
|
+
|
23
|
+
config.after(:each) do
|
24
|
+
DatabaseCleaner.clean
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
module Testing
|
4
|
+
module Behaviour
|
5
|
+
def prepare_destination # :doc:
|
6
|
+
# rm_rf(destination_root)
|
7
|
+
# mkdir_p(destination_root)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module RSpec
|
15
|
+
module Adminos
|
16
|
+
module Specs
|
17
|
+
module Generators
|
18
|
+
module PrepareApp
|
19
|
+
def system!(*args, quiet: !ENV['VERBOSE'])
|
20
|
+
# https://github.com/bundler/bundler/issues/1424
|
21
|
+
Bundler.with_clean_env do
|
22
|
+
ENV['DISABLE_SPRING'] = '1'
|
23
|
+
puts "Running: #{args.join(' ')}" unless quiet
|
24
|
+
system(*args)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate(command, quiet: !ENV['VERBOSE'])
|
29
|
+
Dir.chdir(destination_root) do
|
30
|
+
system! %(bin/rails generate #{command}), quiet: quiet
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module Macros
|
36
|
+
def generate(command, quiet: !ENV['VERBOSE'])
|
37
|
+
Dir.chdir(destination_root) do
|
38
|
+
system! %(bin/rails generate #{command}), quiet: quiet
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def system!(*args, quiet: !ENV['VERBOSE'])
|
43
|
+
# https://github.com/bundler/bundler/issues/1424
|
44
|
+
Bundler.with_clean_env do
|
45
|
+
ENV['DISABLE_SPRING'] = '1'
|
46
|
+
puts "Running: #{args.join(' ')}" unless quiet
|
47
|
+
system(*args)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def generate_rails(path, force: true, quiet: !ENV['VERBOSE'])
|
52
|
+
path = Pathname(path)
|
53
|
+
path.rmtree if force && path.exist?
|
54
|
+
path.dirname.mkpath
|
55
|
+
system!("rails new #{path} --no-rc -d postgresql#{' --quiet' if quiet}", quiet: quiet)
|
56
|
+
Dir.chdir(path) do
|
57
|
+
system! %(echo "gem 'adminos', path: '../../../adminos'" >> Gemfile), quiet: quiet
|
58
|
+
system! "bundle install#{' --no-verbose' if quiet}", quiet: quiet
|
59
|
+
yield if block_given?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def generate_adminos(path, force: true, locales: false, quiet: !ENV['VERBOSE'])
|
64
|
+
locales = locales.join(',') if locales.is_a?(Array)
|
65
|
+
generate_rails(path, force: force, quiet: quiet) do
|
66
|
+
generate %(adminos:install --is-test=true --force#{" --locales=#{locales}" if locales}#{' --quiet' if quiet}), quiet: quiet
|
67
|
+
end
|
68
|
+
path
|
69
|
+
end
|
70
|
+
|
71
|
+
def prepare_destination_first_time # :doc:
|
72
|
+
FileUtils.rm_rf(destination_root)
|
73
|
+
FileUtils.mkdir_p(destination_root)
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_default_destination(folder_name)
|
77
|
+
destination File.expand_path("../../../tmp/#{folder_name}", __FILE__)
|
78
|
+
end
|
79
|
+
|
80
|
+
def prepare_app(folder_name: folder_name, locales: false)
|
81
|
+
set_default_destination(folder_name)
|
82
|
+
prepare_destination_first_time
|
83
|
+
generate_adminos(destination_root, quiet: true, locales: locales)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.included(klass)
|
88
|
+
super(klass)
|
89
|
+
klass.extend(Macros)
|
90
|
+
klass.include(PrepareApp)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
RSpec.configure do |config|
|
98
|
+
config.include RSpec::Adminos::Specs::Generators, :type => :generator
|
99
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
shared_examples 'everything works' do
|
2
|
+
it 'should run all tasks in the generator' do
|
3
|
+
gen = generator(arguments)
|
4
|
+
expect(gen).to receive :bundle_dependencies
|
5
|
+
expect(gen).to receive :configure_application
|
6
|
+
expect(gen).to receive :localize_russian
|
7
|
+
expect(gen).to receive :localize_devise
|
8
|
+
expect(gen).to receive :inject_routes
|
9
|
+
expect(gen).to receive :localize_pages
|
10
|
+
expect(gen).to receive :inject_files
|
11
|
+
capture(:stdout) { gen.invoke_all }
|
12
|
+
end
|
13
|
+
|
14
|
+
it "generator runs without errors" do
|
15
|
+
expect { run_generator(arguments) }.not_to raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
shared_examples 'Gemfile' do
|
20
|
+
describe 'the Gemfile' do
|
21
|
+
subject { file('Gemfile') }
|
22
|
+
|
23
|
+
it { is_expected.to exist }
|
24
|
+
it { is_expected.to contain(/gem 'globalize'/) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
shared_examples 'config/application.rb' do
|
29
|
+
describe 'config/application.rb' do
|
30
|
+
subject { file('config/application.rb') }
|
31
|
+
|
32
|
+
it { is_expected.to exist }
|
33
|
+
it { is_expected.to contain(/config\.i18n/) }
|
34
|
+
end
|
35
|
+
end
|