barkest_core 1.5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +254 -0
- data/MIT-LICENSE +20 -0
- data/README.md +364 -0
- data/Rakefile +37 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Bold.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-BoldItalic.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Italic.ttf +0 -0
- data/app/assets/fonts/barkest_core/ArchivoNarrow-Regular.ttf +0 -0
- data/app/assets/images/barkest_core/.keep +0 -0
- data/app/assets/images/barkest_core/barcode-B.svg +181 -0
- data/app/assets/javascripts/barkest_core/.keep +0 -0
- data/app/assets/javascripts/barkest_core/application.js +22 -0
- data/app/assets/javascripts/barkest_core/bootstrap-datepicker.js +1800 -0
- data/app/assets/javascripts/barkest_core/field_init.js +7 -0
- data/app/assets/javascripts/barkest_core/jquery.doubleScroll.js +112 -0
- data/app/assets/javascripts/barkest_core/masked_edit.js +25 -0
- data/app/assets/javascripts/barkest_core/system_status.js.erb +201 -0
- data/app/assets/stylesheets/barkest_core/.keep +0 -0
- data/app/assets/stylesheets/barkest_core/application.css +17 -0
- data/app/assets/stylesheets/barkest_core/custom.css.scss +264 -0
- data/app/assets/stylesheets/barkest_core/datepicker3.css +790 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/access_groups_controller.rb +74 -0
- data/app/controllers/account_activations_controller.rb +29 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/barkest_core/application_controller_base.rb +113 -0
- data/app/controllers/barkest_core/engine_controller_base.rb +15 -0
- data/app/controllers/barkest_core/testsub_controller.rb +21 -0
- data/app/controllers/contact_controller.rb +32 -0
- data/app/controllers/log_view_controller.rb +31 -0
- data/app/controllers/password_resets_controller.rb +126 -0
- data/app/controllers/sessions_controller.rb +64 -0
- data/app/controllers/status_controller.rb +150 -0
- data/app/controllers/system_config_controller.rb +238 -0
- data/app/controllers/system_update_controller.rb +164 -0
- data/app/controllers/test_access_controller.rb +44 -0
- data/app/controllers/test_report_controller.rb +75 -0
- data/app/controllers/users_controller.rb +218 -0
- data/app/helpers/.keep +0 -0
- data/app/helpers/barkest_core/application_helper.rb +134 -0
- data/app/helpers/barkest_core/form_helper.rb +469 -0
- data/app/helpers/barkest_core/html_helper.rb +70 -0
- data/app/helpers/barkest_core/misc_helper.rb +68 -0
- data/app/helpers/barkest_core/pdf_helper.rb +180 -0
- data/app/helpers/barkest_core/recaptcha_helper.rb +115 -0
- data/app/helpers/barkest_core/sessions_helper.rb +94 -0
- data/app/helpers/barkest_core/status_helper.rb +118 -0
- data/app/helpers/barkest_core/users_helper.rb +32 -0
- data/app/mailers/.keep +0 -0
- data/app/mailers/application_mailer.rb +5 -0
- data/app/mailers/barkest_core/application_mailer_base.rb +30 -0
- data/app/mailers/barkest_core/contact_form.rb +20 -0
- data/app/mailers/barkest_core/user_mailer.rb +44 -0
- data/app/models/.keep +0 -0
- data/app/models/access_group.rb +121 -0
- data/app/models/access_group_group_member.rb +13 -0
- data/app/models/access_group_user_member.rb +11 -0
- data/app/models/barkest_core/auth_config.rb +95 -0
- data/app/models/barkest_core/authorize_failure.rb +7 -0
- data/app/models/barkest_core/contact_message.rb +37 -0
- data/app/models/barkest_core/database_config.rb +223 -0
- data/app/models/barkest_core/db_table.rb +21 -0
- data/app/models/barkest_core/email_config.rb +132 -0
- data/app/models/barkest_core/global_status.rb +267 -0
- data/app/models/barkest_core/log_entry.rb +101 -0
- data/app/models/barkest_core/log_view_options.rb +51 -0
- data/app/models/barkest_core/ms_sql_db_definition.rb +441 -0
- data/app/models/barkest_core/ms_sql_definition.rb +221 -0
- data/app/models/barkest_core/ms_sql_function.rb +423 -0
- data/app/models/barkest_core/not_logged_in.rb +7 -0
- data/app/models/barkest_core/pdf_table_builder.rb +407 -0
- data/app/models/barkest_core/self_update_config.rb +37 -0
- data/app/models/barkest_core/user_alert.rb +29 -0
- data/app/models/barkest_core/user_alert_generators.rb +58 -0
- data/app/models/barkest_core/user_manager.rb +404 -0
- data/app/models/barkest_core/work_path.rb +74 -0
- data/app/models/disable_user.rb +18 -0
- data/app/models/ldap_access_group.rb +15 -0
- data/app/models/system_config.rb +99 -0
- data/app/models/user.rb +405 -0
- data/app/models/user_login_history.rb +11 -0
- data/app/views/.keep +0 -0
- data/app/views/access_groups/_form.html.erb +19 -0
- data/app/views/access_groups/edit.html.erb +2 -0
- data/app/views/access_groups/index.html.erb +32 -0
- data/app/views/access_groups/new.html.erb +2 -0
- data/app/views/access_groups/show.html.erb +4 -0
- data/app/views/barkest_core/contact_form/contact.html.erb +16 -0
- data/app/views/barkest_core/contact_form/contact.text.erb +13 -0
- data/app/views/barkest_core/testsub/_links.html.erb +5 -0
- data/app/views/barkest_core/testsub/page1.html.erb +3 -0
- data/app/views/barkest_core/testsub/page2.html.erb +2 -0
- data/app/views/barkest_core/testsub/page3.html.erb +2 -0
- data/app/views/barkest_core/user_mailer/account_activation.html.erb +7 -0
- data/app/views/barkest_core/user_mailer/account_activation.text.erb +6 -0
- data/app/views/barkest_core/user_mailer/invalid_password_reset.html.erb +3 -0
- data/app/views/barkest_core/user_mailer/invalid_password_reset.text.erb +5 -0
- data/app/views/barkest_core/user_mailer/password_reset.html.erb +8 -0
- data/app/views/barkest_core/user_mailer/password_reset.text.erb +7 -0
- data/app/views/contact/index.html.erb +24 -0
- data/app/views/layouts/_footer_copyright.html.erb +1 -0
- data/app/views/layouts/_menu_admin.html.erb +5 -0
- data/app/views/layouts/_menu_anon.html.erb +0 -0
- data/app/views/layouts/_menu_auth.html.erb +3 -0
- data/app/views/layouts/_menu_footer.html.erb +1 -0
- data/app/views/layouts/_nav_logo.html.erb +1 -0
- data/app/views/layouts/application.html.erb +2 -0
- data/app/views/layouts/barkest_core/_application.html.erb +24 -0
- data/app/views/layouts/barkest_core/_footer.html.erb +18 -0
- data/app/views/layouts/barkest_core/_header.html.erb +38 -0
- data/app/views/layouts/barkest_core/_html_mailer.html.erb +11 -0
- data/app/views/layouts/barkest_core/_menu_account.html.erb +14 -0
- data/app/views/layouts/barkest_core/_menu_sample.html.erb +1 -0
- data/app/views/layouts/barkest_core/_messages.html.erb +4 -0
- data/app/views/layouts/barkest_core/_shim.html.erb +4 -0
- data/app/views/layouts/barkest_core/_subheader.html.erb +1 -0
- data/app/views/layouts/barkest_core/_text_mailer.text.erb +4 -0
- data/app/views/layouts/mailer.html.erb +1 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/log_view/index.html.erb +100 -0
- data/app/views/password_resets/edit.html.erb +20 -0
- data/app/views/password_resets/new.html.erb +14 -0
- data/app/views/sessions/new.html.erb +27 -0
- data/app/views/shared/_error_messages.html.erb +29 -0
- data/app/views/shared/_generic_user_alert.html.erb +4 -0
- data/app/views/status/current.html.erb +34 -0
- data/app/views/status/test.html.erb +50 -0
- data/app/views/system_config/index.html.erb +25 -0
- data/app/views/system_config/show_auth.html.erb +28 -0
- data/app/views/system_config/show_database.html.erb +36 -0
- data/app/views/system_config/show_email.html.erb +21 -0
- data/app/views/system_config/show_self_update.html.erb +13 -0
- data/app/views/system_update/index.html.erb +31 -0
- data/app/views/system_update/new.html.erb +2 -0
- data/app/views/test_access/allow_anon.html.erb +2 -0
- data/app/views/test_access/require_admin.html.erb +2 -0
- data/app/views/test_access/require_group_x.html.erb +2 -0
- data/app/views/test_access/require_user.html.erb +2 -0
- data/app/views/test_report/index.csv.csvrb +23 -0
- data/app/views/test_report/index.html.erb +6 -0
- data/app/views/test_report/index.pdf.prawn +50 -0
- data/app/views/test_report/index.xlsx.axlsx +28 -0
- data/app/views/users/_user.html.erb +57 -0
- data/app/views/users/_user_details.html.erb +15 -0
- data/app/views/users/_user_details_for_list.html.erb +1 -0
- data/app/views/users/_user_form.html.erb +13 -0
- data/app/views/users/disable_confirm.html.erb +19 -0
- data/app/views/users/edit.html.erb +15 -0
- data/app/views/users/index.html.erb +9 -0
- data/app/views/users/new.html.erb +10 -0
- data/app/views/users/show.html.erb +46 -0
- data/bin/rails +12 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160617172539_create_access_groups.rb +10 -0
- data/db/migrate/20160617172725_create_users.rb +26 -0
- data/db/migrate/20160617172833_create_user_login_histories.rb +12 -0
- data/db/migrate/20160622151720_create_access_group_user_members.rb +9 -0
- data/db/migrate/20160622151925_create_access_group_group_members.rb +9 -0
- data/db/migrate/20160701005706_create_ldap_access_groups.rb +11 -0
- data/db/migrate/20161108155029_create_system_configs.rb +11 -0
- data/db/seeds/barkest_core_01_create_users.rb +42 -0
- data/db/seeds.rb +53 -0
- data/lib/barkest_core/concerns/association_with_defaults.rb +55 -0
- data/lib/barkest_core/concerns/boolean_parser.rb +88 -0
- data/lib/barkest_core/concerns/date_parser.rb +181 -0
- data/lib/barkest_core/concerns/email_tester.rb +55 -0
- data/lib/barkest_core/concerns/encrypted_fields.rb +156 -0
- data/lib/barkest_core/concerns/named_model.rb +73 -0
- data/lib/barkest_core/concerns/number_parser.rb +145 -0
- data/lib/barkest_core/concerns/utc_conversion.rb +60 -0
- data/lib/barkest_core/engine.rb +105 -0
- data/lib/barkest_core/extensions/active_record_extensions.rb +120 -0
- data/lib/barkest_core/extensions/application_configuration_extensions.rb +38 -0
- data/lib/barkest_core/extensions/application_extensions.rb +50 -0
- data/lib/barkest_core/extensions/axlsx_extenstions.rb +157 -0
- data/lib/barkest_core/extensions/fixture_set_extensions.rb +107 -0
- data/lib/barkest_core/extensions/generator_extensions.rb +271 -0
- data/lib/barkest_core/extensions/main_app_extensions.rb +35 -0
- data/lib/barkest_core/extensions/prawn_document_extensions.rb +367 -0
- data/lib/barkest_core/extensions/prawn_table_extensions.rb +131 -0
- data/lib/barkest_core/extensions/router_extensions.rb +106 -0
- data/lib/barkest_core/extensions/simple_formatter_extensions.rb +66 -0
- data/lib/barkest_core/extensions/test_case_extensions.rb +348 -0
- data/lib/barkest_core/extensions/time_extensions.rb +164 -0
- data/lib/barkest_core/handlers/csv_handler.rb +30 -0
- data/lib/barkest_core/version.rb +3 -0
- data/lib/barkest_core.rb +324 -0
- data/lib/generators/barkest/install_generator.rb +102 -0
- data/lib/generators/barkest_core/actions/01_patch_application_controller.rb +55 -0
- data/lib/generators/barkest_core/actions/02_patch_application_mailer.rb +56 -0
- data/lib/generators/barkest_core/actions/03_patch_assets.rb +62 -0
- data/lib/generators/barkest_core/actions/04_patch_layouts.rb +36 -0
- data/lib/generators/barkest_core/actions/05_patch_routes.rb +93 -0
- data/lib/generators/barkest_core/actions/06_patch_seeds.rb +60 -0
- data/lib/generators/barkest_core/actions/07_copy_migrations.rb +51 -0
- data/lib/generators/barkest_core/actions/08_configure_database.rb +52 -0
- data/lib/generators/barkest_core/actions/09_configure_secrets.rb +29 -0
- data/lib/generators/barkest_core/actions/99_patch_gitignore.rb +57 -0
- data/lib/generators/barkest_core/install_generator.rb +17 -0
- data/test/barkest_core_test.rb +83 -0
- data/test/controllers/access_groups_controller_test.rb +53 -0
- data/test/controllers/contact_controller_test.rb +10 -0
- data/test/controllers/sessions_controller_test.rb +10 -0
- data/test/controllers/users_controller_test.rb +10 -0
- data/test/dummy/.gitignore +10 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +3 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/app/views/system_config/show_fake.html.erb +3 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +27 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +47 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/db_updater_ext.rb +33 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/sys_config_ext.rb +12 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +95 -0
- data/test/dummy/db/seeds/barkest_core_01_create_users.rb +42 -0
- data/test/dummy/db/seeds.rb +51 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/sql/my_test_view.sql +3 -0
- data/test/fixtures/access_groups.yml +21 -0
- data/test/fixtures/users.yml +71 -0
- data/test/helpers/barkest_core/sessions_helper_test.rb +22 -0
- data/test/integration/access_group_mgmt_test.rb +33 -0
- data/test/integration/access_test.rb +24 -0
- data/test/integration/account_activations_access_test.rb +12 -0
- data/test/integration/contact_test.rb +98 -0
- data/test/integration/extra_partial_test.rb +41 -0
- data/test/integration/log_view_access_test.rb +12 -0
- data/test/integration/password_resets_test.rb +101 -0
- data/test/integration/reports_test.rb +53 -0
- data/test/integration/status_access_test.rb +27 -0
- data/test/integration/system_config_access_test.rb +24 -0
- data/test/integration/system_update_access_test.rb +19 -0
- data/test/integration/users_access_test.rb +34 -0
- data/test/integration/users_edit_test.rb +178 -0
- data/test/integration/users_index_test.rb +62 -0
- data/test/integration/users_login_test.rb +67 -0
- data/test/integration/users_signup_test.rb +54 -0
- data/test/mailers/.keep +0 -0
- data/test/mailers/barkest_core/contact_form_test.rb +28 -0
- data/test/mailers/barkest_core/user_mailer_test.rb +43 -0
- data/test/mailers/previews/barkest_core/contact_form_preview.rb +17 -0
- data/test/mailers/previews/barkest_core/user_mailer_preview.rb +26 -0
- data/test/models/access_group_group_member_test.rb +28 -0
- data/test/models/access_group_test.rb +114 -0
- data/test/models/access_group_user_member_test.rb +28 -0
- data/test/models/barkest_core/auth_config_test.rb +57 -0
- data/test/models/barkest_core/bool_parser_test.rb +28 -0
- data/test/models/barkest_core/contact_message_test.rb +61 -0
- data/test/models/barkest_core/database_config_test.rb +33 -0
- data/test/models/barkest_core/date_parser_test.rb +110 -0
- data/test/models/barkest_core/email_config_test.rb +57 -0
- data/test/models/barkest_core/global_status_test.rb +50 -0
- data/test/models/barkest_core/ms_sql_db_updater_test.rb +115 -0
- data/test/models/barkest_core/ms_sql_definition_test.rb +102 -0
- data/test/models/barkest_core/ms_sql_function_test.rb +131 -0
- data/test/models/barkest_core/number_parser_test.rb +29 -0
- data/test/models/barkest_core/self_update_config_test.rb +29 -0
- data/test/models/barkest_core/user_alert_test.rb +19 -0
- data/test/models/barkest_core/user_manager_test.rb +34 -0
- data/test/models/barkest_core/work_path_test.rb +26 -0
- data/test/models/disable_user_test.rb +27 -0
- data/test/models/generic_time_test.rb +66 -0
- data/test/models/ldap_access_group_test.rb +31 -0
- data/test/models/pdf_table_builder_test.rb +6 -0
- data/test/models/system_config_test.rb +78 -0
- data/test/models/user_login_history_test.rb +37 -0
- data/test/models/user_test.rb +130 -0
- data/test/test_helper.rb +63 -0
- metadata +798 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Runs the rake task to install the BarkestCore migrations.
|
|
4
|
+
def copy_migrations
|
|
5
|
+
tell '=' * 79
|
|
6
|
+
if ask_for_bool('Would you like to install the BarkestCore database migrations?', true)
|
|
7
|
+
tell 'Copying database migrations...' unless options.quiet?
|
|
8
|
+
|
|
9
|
+
ts = Time.now.strftime('%Y%m%d%H%M%S').to_i
|
|
10
|
+
ext = '.barkest_core.rb'
|
|
11
|
+
|
|
12
|
+
unless Dir.exist?('db/migrate')
|
|
13
|
+
perform '> creating \'db/migrate\' directory...' do
|
|
14
|
+
Dir.mkdir 'db/migrate'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
existing = Dir.glob("db/migrate/*#{ext}")
|
|
19
|
+
|
|
20
|
+
find_existing = Proc.new do |file|
|
|
21
|
+
fn = File.basename(file)[0...-3].partition('_')[2]
|
|
22
|
+
|
|
23
|
+
existing.find do |ex|
|
|
24
|
+
fn == File.basename(ex)[0...(-ext.length)].partition('_')[2]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Dir.glob(File.expand_path('../../../../../db/migrate/*.rb', __FILE__)).each do |file|
|
|
29
|
+
target_file = find_existing.call(file)
|
|
30
|
+
contents = File.read(file)
|
|
31
|
+
if target_file
|
|
32
|
+
cur_contents = File.read(target_file)
|
|
33
|
+
if cur_contents.strip == contents.strip
|
|
34
|
+
tell "> '#{target_file}' is good.", :bright_green
|
|
35
|
+
else
|
|
36
|
+
perform "> updating '#{target_file}'..." do
|
|
37
|
+
File.write target_file, contents
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
else
|
|
41
|
+
target_file = "db/migrate/#{ts}_#{File.basename(file)[0...-3].partition('_')[2]}#{ext}"
|
|
42
|
+
ts += 1
|
|
43
|
+
perform "> creating '#{target_file}'..." do
|
|
44
|
+
File.write target_file, contents
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Generates a database.yml configuration file.
|
|
4
|
+
def configure_database
|
|
5
|
+
config_file = 'config/database.yml'
|
|
6
|
+
|
|
7
|
+
attributes = [
|
|
8
|
+
['adapter', :ask_for_string, %w(sqlite3 postgresql sqlserver mysql2), 'database_adapter'],
|
|
9
|
+
['pool', :ask_for_int, (1..1000), 'connection_pool_size'],
|
|
10
|
+
['timeout', :ask_for_int, (500..300000)],
|
|
11
|
+
{ 'sqlite3' =>
|
|
12
|
+
[
|
|
13
|
+
[ 'database', :ask_for_string, nil, 'sqlite_database', 'db/my-db.sqlite3' ]
|
|
14
|
+
],
|
|
15
|
+
'postgresql' =>
|
|
16
|
+
[
|
|
17
|
+
[ 'host', :ask_for_string, nil, 'pg_host' ],
|
|
18
|
+
[ 'port', :ask_for_int, (1..65535), 'pg_port', 5432 ],
|
|
19
|
+
[ 'username', :ask_for_string, nil, 'pg_username' ],
|
|
20
|
+
[ 'password', :ask_for_secret, nil, 'pg_password' ],
|
|
21
|
+
[ 'database', :ask_for_string, nil, 'pg_database' ]
|
|
22
|
+
],
|
|
23
|
+
'sqlserver' =>
|
|
24
|
+
[
|
|
25
|
+
[ 'host', :ask_for_string, nil, 'sql_host' ],
|
|
26
|
+
[ 'port', :ask_for_int, (1..65535), 'sql_port', 1433 ],
|
|
27
|
+
[ 'username', :ask_for_string, nil, 'sql_username' ],
|
|
28
|
+
[ 'password', :ask_for_secret, nil, 'sql_password' ],
|
|
29
|
+
[ 'database', :ask_for_string, nil, 'sql_database', 'my_db' ]
|
|
30
|
+
],
|
|
31
|
+
'mysql2' =>
|
|
32
|
+
[
|
|
33
|
+
[ 'host', :ask_for_string, nil, 'mysql_host' ],
|
|
34
|
+
[ 'port', :ask_for_int, (1..65535), 'mysql_port', 3306 ],
|
|
35
|
+
[ 'username', :ask_for_string, nil, 'mysql_username' ],
|
|
36
|
+
[ 'password', :ask_for_secret, nil, 'mysql_password' ],
|
|
37
|
+
[ 'database', :ask_for_string, nil, 'mysql_database', 'my_db' ]
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
default = {
|
|
43
|
+
'adapter' => 'sqlite3',
|
|
44
|
+
'pool' => 5,
|
|
45
|
+
'timeout' => 5000,
|
|
46
|
+
'database' => 'db/my-data.sqlite3'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
configure_the 'database connection', config_file, attributes, 'adapter', default, 'barkest_core'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Generates a secrets.yml configuration file.
|
|
5
|
+
def configure_secrets
|
|
6
|
+
config_file = 'config/secrets.yml'
|
|
7
|
+
|
|
8
|
+
attributes = [
|
|
9
|
+
[ 'recaptcha_public_key', :ask_for_string ],
|
|
10
|
+
[ 'recaptcha_private_key', :ask_for_string ],
|
|
11
|
+
[ 'secret_key_base', :ask_for_secret_key_base ],
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
default = {}
|
|
15
|
+
|
|
16
|
+
configure_the 'application secrets', config_file, attributes, nil, default
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def ask_for_secret_key_base(question, default = '')
|
|
22
|
+
default = default.to_s
|
|
23
|
+
puts "Current secret key base: #{default[0...20]}..." unless options.quiet?
|
|
24
|
+
tell 'Changing the secret key base will invalidate encrypted values.', :yellow
|
|
25
|
+
return default unless ask_for_bool('Do you want to change the secret key base to a new random value?', false)
|
|
26
|
+
SecureRandom.urlsafe_base64(72)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
BarkestCore::InstallGenerator.class_eval do
|
|
2
|
+
##
|
|
3
|
+
# Patches .gitignore to ignore *.yml configuration files.
|
|
4
|
+
def patch_gitignore
|
|
5
|
+
file = '.gitignore'
|
|
6
|
+
|
|
7
|
+
dummy = Dir.exist?('test/dummy')
|
|
8
|
+
|
|
9
|
+
if File.exist?(file)
|
|
10
|
+
lines = File.read(file).split("\n")
|
|
11
|
+
|
|
12
|
+
protect_cfg = false
|
|
13
|
+
protect_dummy_cfg = false
|
|
14
|
+
|
|
15
|
+
cfg_regex = /^\s*config\/\*.yml\s*$/
|
|
16
|
+
dummy_cfg_regex = /^\s*test\/dummy\/config\/\*.yml\s*$/
|
|
17
|
+
|
|
18
|
+
lines.each do |line|
|
|
19
|
+
protect_cfg = true if cfg_regex.match(line)
|
|
20
|
+
protect_dummy_cfg = true if dummy_cfg_regex.match(line)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
changed = false
|
|
24
|
+
unless protect_cfg
|
|
25
|
+
if ask_for_bool("Your .gitignore does not protect your YAML configuration files.\nWould you like to add a line to protect them?", true)
|
|
26
|
+
lines << 'config/*.yml'
|
|
27
|
+
changed = true
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if dummy && !protect_dummy_cfg
|
|
32
|
+
if ask_for_bool("Your .gitignore does not protect your dummy application's YAML configuration files.\nWould you like to add a line to protect them?", true)
|
|
33
|
+
lines << 'test/dummy/config/*.yml'
|
|
34
|
+
changed = true
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if changed
|
|
39
|
+
perform '> updating \'.gitignore\'...' do
|
|
40
|
+
File.write file, lines.join("\n")
|
|
41
|
+
end
|
|
42
|
+
else
|
|
43
|
+
tell '> \'.gitignore\' is good.', :bright_green
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
else
|
|
47
|
+
if ask_for_bool('Would you like to create a .gitignore that protects your YAML files?', true)
|
|
48
|
+
perform '> creating \'.gitignore\'...' do
|
|
49
|
+
contents = %w(.bundle/ .sass-cache/ config/*.yml db/*.sqlite3 db/*.sqlite3-journal doc/ log/*.log pkg/ tmp/ vendor/bundle/)
|
|
50
|
+
contents += contents.map{|v| "test/dummy/#{v}"} if dummy
|
|
51
|
+
|
|
52
|
+
File.write file, contents.join("\n")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
module BarkestCore
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Installs BarkestCore into an application.
|
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
|
8
|
+
|
|
9
|
+
desc 'Installs the BarkestCore functionality into your application.'
|
|
10
|
+
|
|
11
|
+
# actions are stored in the 'actions' directory.
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# load the actions
|
|
17
|
+
Dir.glob(File.expand_path('../actions/*.rb', __FILE__)).each { |action| require action }
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class BarkestCoreTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
test 'should be able to request restart' do
|
|
6
|
+
|
|
7
|
+
# we shouldn't know how to do this ...
|
|
8
|
+
# anyway, we're essentially purging the restart file
|
|
9
|
+
# so any other tests that may have touched it won't
|
|
10
|
+
# cause this test to fail.
|
|
11
|
+
file = BarkestCore.send(:restart_file)
|
|
12
|
+
File.delete(file) if File.exist?(file)
|
|
13
|
+
|
|
14
|
+
# the file shouldn't exists, so this should return false.
|
|
15
|
+
assert_not BarkestCore.restart_pending?
|
|
16
|
+
|
|
17
|
+
BarkestCore.request_restart
|
|
18
|
+
assert BarkestCore.restart_pending?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test 'should be able to add key gem patterns' do
|
|
22
|
+
assert BarkestCore.add_key_gem_pattern 'something'
|
|
23
|
+
assert BarkestCore.add_key_gem_pattern( /^something/ )
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
test 'should be able to list key gems' do
|
|
27
|
+
list = BarkestCore.gem_list
|
|
28
|
+
assert_not list.blank?
|
|
29
|
+
# key gems should include 'rails'
|
|
30
|
+
assert list.find {|v| v[0] == 'rails'}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test 'should be able to set auth_config defaults' do
|
|
34
|
+
# get the defaults and make sure they are set.
|
|
35
|
+
cfg = BarkestCore.auth_config_defaults(nil)
|
|
36
|
+
assert_not_nil cfg
|
|
37
|
+
assert_not cfg.keys.include?(:something)
|
|
38
|
+
|
|
39
|
+
# change the defaults and ensure our key is set.
|
|
40
|
+
cfg = BarkestCore.auth_config_defaults(something: :else)
|
|
41
|
+
assert cfg.keys.include?(:something)
|
|
42
|
+
|
|
43
|
+
# get the defaults and ensure our key is still set.
|
|
44
|
+
cfg = BarkestCore.auth_config_defaults(nil)
|
|
45
|
+
assert cfg.keys.include?(:something)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test 'should be able to set email_config defaults' do
|
|
49
|
+
# get the defaults and make sure they are set.
|
|
50
|
+
cfg = BarkestCore.email_config_defaults(nil)
|
|
51
|
+
assert_not_nil cfg
|
|
52
|
+
assert_not cfg.keys.include?(:something)
|
|
53
|
+
|
|
54
|
+
# change the defaults and ensure our key is set.
|
|
55
|
+
cfg = BarkestCore.email_config_defaults(something: :else)
|
|
56
|
+
assert cfg.keys.include?(:something)
|
|
57
|
+
|
|
58
|
+
# get the defaults and ensure our key is still set.
|
|
59
|
+
cfg = BarkestCore.email_config_defaults(nil)
|
|
60
|
+
assert cfg.keys.include?(:something)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test 'should be able to register db_config defaults' do
|
|
64
|
+
# needs a db_name
|
|
65
|
+
assert_not BarkestCore.register_db_config_defaults(nil, nil)
|
|
66
|
+
assert_not BarkestCore.register_db_config_defaults('', nil)
|
|
67
|
+
assert_not BarkestCore.register_db_config_defaults(:"", nil)
|
|
68
|
+
assert_not BarkestCore.register_db_config_defaults(' ', nil)
|
|
69
|
+
assert_not BarkestCore.register_db_config_defaults(:" ", nil)
|
|
70
|
+
|
|
71
|
+
# can't register for barkest_core
|
|
72
|
+
assert_not BarkestCore.register_db_config_defaults(:barkest_core, nil)
|
|
73
|
+
assert_not BarkestCore.register_db_config_defaults('barkest_core', nil)
|
|
74
|
+
|
|
75
|
+
# can register for anything else
|
|
76
|
+
assert BarkestCore.register_db_config_defaults(:something, nil)
|
|
77
|
+
assert BarkestCore.register_db_config_defaults('something', nil)
|
|
78
|
+
assert BarkestCore.register_db_config_defaults(:something, value: true, adapter: :none)
|
|
79
|
+
assert BarkestCore.register_db_config_defaults('something', value: false, adapter: :none)
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class AccessGroupsControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
setup do
|
|
6
|
+
@access_group = access_groups(:one)
|
|
7
|
+
@admin = users(:admin)
|
|
8
|
+
log_in_as(@admin)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
test "should get index" do
|
|
12
|
+
get :index
|
|
13
|
+
assert_response :success
|
|
14
|
+
assert_not_nil assigns(:access_groups)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "should get new" do
|
|
18
|
+
get :new
|
|
19
|
+
assert_response :success
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
test "should create access_group" do
|
|
23
|
+
assert_difference('AccessGroup.count') do
|
|
24
|
+
post :create, access_group: { name: 'Access Group X' }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
assert_redirected_to access_groups_url
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "should show access_group" do
|
|
31
|
+
get :show, id: @access_group
|
|
32
|
+
assert_response :success
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test "should get edit" do
|
|
36
|
+
get :edit, id: @access_group
|
|
37
|
+
assert_response :success
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
test "should update access_group" do
|
|
41
|
+
patch :update, id: @access_group, access_group: { name: 'Access Group X' }
|
|
42
|
+
assert_redirected_to access_groups_url
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
test "should destroy access_group" do
|
|
46
|
+
assert_difference('AccessGroup.count', -1) do
|
|
47
|
+
delete :destroy, id: @access_group
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
assert_redirected_to access_groups_path
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require 'barkest_core/application'
|
|
14
|
+
//= require_tree .
|