kuroko2 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +15 -0
- data/Rakefile +26 -0
- data/app/assets/images/kuroko2/avatar.png +0 -0
- data/app/assets/images/kuroko2/kuroko-logo-horizontal.png +0 -0
- data/app/assets/javascripts/kuroko2/application.js +28 -0
- data/app/assets/javascripts/kuroko2/bootstrap.js +2363 -0
- data/app/assets/javascripts/kuroko2/definition_linker.js +20 -0
- data/app/assets/javascripts/kuroko2/instance_linker.js +10 -0
- data/app/assets/javascripts/kuroko2/job_definition_stats.js +67 -0
- data/app/assets/javascripts/kuroko2/job_definitions.js +79 -0
- data/app/assets/javascripts/kuroko2/job_instances.js +88 -0
- data/app/assets/javascripts/kuroko2/job_timelines.js.coffee +24 -0
- data/app/assets/javascripts/kuroko2/narrow_job_definitions.js +30 -0
- data/app/assets/stylesheets/kuroko2/admin-lte.css +3402 -0
- data/app/assets/stylesheets/kuroko2/application.scss +86 -0
- data/app/assets/stylesheets/kuroko2/bootstrap.css +6799 -0
- data/app/assets/stylesheets/kuroko2/fonts.scss +1 -0
- data/app/assets/stylesheets/kuroko2/job_definitions.scss +19 -0
- data/app/assets/stylesheets/kuroko2/users.scss +7 -0
- data/app/controllers/kuroko2/api/application_controller.rb +49 -0
- data/app/controllers/kuroko2/api/job_instances_controller.rb +46 -0
- data/app/controllers/kuroko2/api/stats_controller.rb +28 -0
- data/app/controllers/kuroko2/application_controller.rb +43 -0
- data/app/controllers/kuroko2/dashboard_controller.rb +27 -0
- data/app/controllers/kuroko2/execution_logs_controller.rb +19 -0
- data/app/controllers/kuroko2/executions_controller.rb +28 -0
- data/app/controllers/kuroko2/job_definition_stats_controller.rb +54 -0
- data/app/controllers/kuroko2/job_definitions_controller.rb +100 -0
- data/app/controllers/kuroko2/job_instances_controller.rb +87 -0
- data/app/controllers/kuroko2/job_schedules_controller.rb +39 -0
- data/app/controllers/kuroko2/job_suspend_schedules_controller.rb +38 -0
- data/app/controllers/kuroko2/job_timelines_controller.rb +56 -0
- data/app/controllers/kuroko2/logs_controller.rb +15 -0
- data/app/controllers/kuroko2/sessions_controller.rb +32 -0
- data/app/controllers/kuroko2/stars_controller.rb +30 -0
- data/app/controllers/kuroko2/tokens_controller.rb +47 -0
- data/app/controllers/kuroko2/users_controller.rb +62 -0
- data/app/controllers/kuroko2/workers_controller.rb +5 -0
- data/app/errors/http/bad_request.rb +4 -0
- data/app/errors/http/forbidden.rb +4 -0
- data/app/errors/http/unauthorized.rb +4 -0
- data/app/helpers/kuroko2/application_helper.rb +8 -0
- data/app/helpers/kuroko2/dashboard_helper.rb +4 -0
- data/app/helpers/kuroko2/executions_helper.rb +4 -0
- data/app/helpers/kuroko2/job_definitions_helper.rb +38 -0
- data/app/helpers/kuroko2/job_instances_helper.rb +71 -0
- data/app/helpers/kuroko2/job_schedules_helper.rb +4 -0
- data/app/helpers/kuroko2/logs_helper.rb +4 -0
- data/app/helpers/kuroko2/sessions_helper.rb +4 -0
- data/app/helpers/kuroko2/stars_helper.rb +4 -0
- data/app/helpers/kuroko2/tokens_helper.rb +4 -0
- data/app/helpers/kuroko2/users_helper.rb +4 -0
- data/app/helpers/kuroko2/workers_helper.rb +4 -0
- data/app/jobs/kuroko2/application_job.rb +4 -0
- data/app/mailers/kuroko2/application_mailer.rb +6 -0
- data/app/mailers/kuroko2/notifications.rb +63 -0
- data/app/models/concerns/kuroko2/table_name_customizable.rb +16 -0
- data/app/models/kuroko2/admin_assignment.rb +6 -0
- data/app/models/kuroko2/api/application_resource.rb +10 -0
- data/app/models/kuroko2/api/job_instance_resource.rb +7 -0
- data/app/models/kuroko2/application_record.rb +5 -0
- data/app/models/kuroko2/execution.rb +55 -0
- data/app/models/kuroko2/job_definition.rb +147 -0
- data/app/models/kuroko2/job_definition_tag.rb +6 -0
- data/app/models/kuroko2/job_instance.rb +118 -0
- data/app/models/kuroko2/job_schedule.rb +93 -0
- data/app/models/kuroko2/job_suspend_schedule.rb +35 -0
- data/app/models/kuroko2/log.rb +3 -0
- data/app/models/kuroko2/memory_consumption_log.rb +49 -0
- data/app/models/kuroko2/memory_expectancy.rb +21 -0
- data/app/models/kuroko2/process_signal.rb +14 -0
- data/app/models/kuroko2/star.rb +6 -0
- data/app/models/kuroko2/tag.rb +8 -0
- data/app/models/kuroko2/tick.rb +12 -0
- data/app/models/kuroko2/token.rb +101 -0
- data/app/models/kuroko2/user.rb +48 -0
- data/app/models/kuroko2/worker.rb +12 -0
- data/app/views/kaminari/history/_paginator.html.slim +15 -0
- data/app/views/kaminari/list/_paginator.html.slim +17 -0
- data/app/views/kuroko2/dashboard/_taglist.html.slim +13 -0
- data/app/views/kuroko2/dashboard/index.html.slim +49 -0
- data/app/views/kuroko2/execution_logs/index.json.jbuilder +16 -0
- data/app/views/kuroko2/executions/index.html.slim +35 -0
- data/app/views/kuroko2/job_definition_stats/execution_time.json.jbuilder +13 -0
- data/app/views/kuroko2/job_definition_stats/index.html.slim +48 -0
- data/app/views/kuroko2/job_definition_stats/memory.json.jbuilder +10 -0
- data/app/views/kuroko2/job_definitions/_alert.html.slim +7 -0
- data/app/views/kuroko2/job_definitions/_form.html.slim +93 -0
- data/app/views/kuroko2/job_definitions/_list.html.slim +26 -0
- data/app/views/kuroko2/job_definitions/_search_results.html.slim +51 -0
- data/app/views/kuroko2/job_definitions/_taglist.html.slim +13 -0
- data/app/views/kuroko2/job_definitions/edit.html.slim +15 -0
- data/app/views/kuroko2/job_definitions/index.html.slim +11 -0
- data/app/views/kuroko2/job_definitions/new.html.slim +12 -0
- data/app/views/kuroko2/job_definitions/show.html.slim +90 -0
- data/app/views/kuroko2/job_instances/_instance.html.slim +42 -0
- data/app/views/kuroko2/job_instances/index.html.slim +58 -0
- data/app/views/kuroko2/job_instances/show.html.slim +19 -0
- data/app/views/kuroko2/job_instances/working.html.slim +37 -0
- data/app/views/kuroko2/job_schedules/index.html.slim +32 -0
- data/app/views/kuroko2/job_suspend_schedules/index.html.slim +27 -0
- data/app/views/kuroko2/job_timelines/dataset.json.jbuilder +11 -0
- data/app/views/kuroko2/job_timelines/index.html.slim +31 -0
- data/app/views/kuroko2/kaminari/history/_paginator.html.slim +15 -0
- data/app/views/kuroko2/kaminari/list/_paginator.html.slim +17 -0
- data/app/views/kuroko2/layouts/application.html.slim +68 -0
- data/app/views/kuroko2/logs/index.html.slim +33 -0
- data/app/views/kuroko2/notifications/executor_not_assigned.text.erb +22 -0
- data/app/views/kuroko2/notifications/job_failure.html.slim +21 -0
- data/app/views/kuroko2/notifications/job_failure.text.erb +18 -0
- data/app/views/kuroko2/notifications/notify_long_elapsed_time.text.erb +9 -0
- data/app/views/kuroko2/notifications/process_absence.text.erb +22 -0
- data/app/views/kuroko2/notifications/remind_failure.html.slim +21 -0
- data/app/views/kuroko2/notifications/remind_failure.text.erb +10 -0
- data/app/views/kuroko2/sessions/new.html.slim +20 -0
- data/app/views/kuroko2/tokens/index.html.slim +42 -0
- data/app/views/kuroko2/users/index.html.slim +55 -0
- data/app/views/kuroko2/users/show.html.slim +76 -0
- data/app/views/kuroko2/workers/index.html.slim +40 -0
- data/app/views/layouts/kuroko2/application.html.slim +72 -0
- data/app/views/layouts/mailer.html.erb +13 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/bin/cleanup_old_instances.rb +9 -0
- data/bin/remind_failure.rb +5 -0
- data/config/initializers/000_kuroko2.rb +16 -0
- data/config/initializers/assets.rb +9 -0
- data/config/initializers/garage.rb +2 -0
- data/config/initializers/kaminari_config.rb +3 -0
- data/config/initializers/omniauth.rb +5 -0
- data/config/locales/en.yml +28 -0
- data/config/routes.rb +54 -0
- data/db/migrate/001_create_job_definitions.rb +22 -0
- data/db/migrate/002_create_job_instances.rb +17 -0
- data/db/migrate/003_create_job_schedules.rb +14 -0
- data/db/migrate/004_create_ticks.rb +7 -0
- data/db/migrate/005_create_logs.rb +13 -0
- data/db/migrate/006_create_tokens.rb +21 -0
- data/db/migrate/007_create_executions.rb +26 -0
- data/db/migrate/008_create_process_signals.rb +15 -0
- data/db/migrate/009_create_users.rb +20 -0
- data/db/migrate/010_create_admin_assignments.rb +12 -0
- data/db/migrate/011_create_stars.rb +12 -0
- data/db/migrate/012_create_workers.rb +15 -0
- data/db/migrate/018_create_job_definition_tags.rb +13 -0
- data/db/migrate/019_create_tags.rb +11 -0
- data/db/migrate/021_create_memory_expectancies.rb +17 -0
- data/db/migrate/025_create_job_suspend_schedules.rb +12 -0
- data/lib/kuroko2/command/executor.rb +62 -0
- data/lib/kuroko2/command/kill.rb +24 -0
- data/lib/kuroko2/command/monitor.rb +109 -0
- data/lib/kuroko2/command/shell.rb +163 -0
- data/lib/kuroko2/configuration.rb +19 -0
- data/lib/kuroko2/engine.rb +59 -0
- data/lib/kuroko2/execution_logger/cloud_watch_logs.rb +92 -0
- data/lib/kuroko2/execution_logger/void.rb +13 -0
- data/lib/kuroko2/execution_logger.rb +20 -0
- data/lib/kuroko2/memory_sampler.rb +50 -0
- data/lib/kuroko2/return_to_validator.rb +14 -0
- data/lib/kuroko2/servers/base.rb +30 -0
- data/lib/kuroko2/servers/command_executor.rb +27 -0
- data/lib/kuroko2/servers/job_scheduler.rb +25 -0
- data/lib/kuroko2/servers/workflow_processor.rb +25 -0
- data/lib/kuroko2/util/logger.rb +19 -0
- data/lib/kuroko2/util/rails_logger_formatter.rb +9 -0
- data/lib/kuroko2/version.rb +3 -0
- data/lib/kuroko2/workflow/assertion_error.rb +6 -0
- data/lib/kuroko2/workflow/engine.rb +141 -0
- data/lib/kuroko2/workflow/engine_error.rb +6 -0
- data/lib/kuroko2/workflow/node.rb +124 -0
- data/lib/kuroko2/workflow/notifier/concerns/chat_message_builder.rb +39 -0
- data/lib/kuroko2/workflow/notifier/hipchat.rb +88 -0
- data/lib/kuroko2/workflow/notifier/mail.rb +44 -0
- data/lib/kuroko2/workflow/notifier/slack.rb +121 -0
- data/lib/kuroko2/workflow/notifier.rb +31 -0
- data/lib/kuroko2/workflow/processor.rb +40 -0
- data/lib/kuroko2/workflow/scheduler.rb +42 -0
- data/lib/kuroko2/workflow/script_parser.rb +66 -0
- data/lib/kuroko2/workflow/shell_scanner.rb +34 -0
- data/lib/kuroko2/workflow/syntax_error.rb +6 -0
- data/lib/kuroko2/workflow/task/auto_skip_error.rb +20 -0
- data/lib/kuroko2/workflow/task/base.rb +32 -0
- data/lib/kuroko2/workflow/task/env.rb +45 -0
- data/lib/kuroko2/workflow/task/execute.rb +128 -0
- data/lib/kuroko2/workflow/task/expected_time.rb +9 -0
- data/lib/kuroko2/workflow/task/fork.rb +45 -0
- data/lib/kuroko2/workflow/task/kuroko_runner.rb +24 -0
- data/lib/kuroko2/workflow/task/noop.rb +13 -0
- data/lib/kuroko2/workflow/task/queue.rb +27 -0
- data/lib/kuroko2/workflow/task/rails_env.rb +24 -0
- data/lib/kuroko2/workflow/task/sequence.rb +13 -0
- data/lib/kuroko2/workflow/task/sleep.rb +29 -0
- data/lib/kuroko2/workflow/task/sub_process.rb +53 -0
- data/lib/kuroko2/workflow/task/time_base.rb +44 -0
- data/lib/kuroko2/workflow/task/timeout.rb +9 -0
- data/lib/kuroko2/workflow/task/wait.rb +143 -0
- data/lib/kuroko2.rb +26 -0
- data/lib/tasks/kuroko2_tasks.rake +4 -0
- data/spec/command/kill_spec.rb +20 -0
- data/spec/command/monitor_spec.rb +68 -0
- data/spec/command/shell_spec.rb +87 -0
- data/spec/controllers/dashboard_controller_spec.rb +5 -0
- data/spec/controllers/executions_controller_spec.rb +23 -0
- data/spec/controllers/job_definition_stats_controller_spec.rb +95 -0
- data/spec/controllers/job_definitions_controller_spec.rb +89 -0
- data/spec/controllers/job_instances_controller_spec.rb +62 -0
- data/spec/controllers/job_schedules_controller_spec.rb +39 -0
- data/spec/controllers/job_suspend_schedules_controller_spec.rb +39 -0
- data/spec/controllers/job_timelines_controller_spec.rb +114 -0
- data/spec/controllers/logs_controller_spec.rb +5 -0
- data/spec/controllers/sessions_controller_spec.rb +58 -0
- data/spec/controllers/stars_controller_spec.rb +28 -0
- data/spec/controllers/tokens_controller_spec.rb +5 -0
- data/spec/controllers/users_controller_spec.rb +51 -0
- data/spec/controllers/workers_controller_spec.rb +5 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config/application.rb +25 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +29 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +23 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/kuroko2.yml +35 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/schema.rb +217 -0
- data/spec/dummy/lib/dummy_extention.rb +14 -0
- data/spec/dummy/lib/kuroko2/workflow/task/custom_task1.rb +13 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/execution_logger/cloud_watch_logs_spec.rb +95 -0
- data/spec/factories/execution_factory.rb +13 -0
- data/spec/factories/job_definition_factory.rb +21 -0
- data/spec/factories/job_instance_factory.rb +4 -0
- data/spec/factories/job_schedule_factory.rb +10 -0
- data/spec/factories/job_suspend_schedule_factory.rb +8 -0
- data/spec/factories/memory_expectancy_factory.rb +5 -0
- data/spec/factories/process_signal_factory.rb +4 -0
- data/spec/factories/star_factory.rb +4 -0
- data/spec/factories/tick_factory.rb +4 -0
- data/spec/factories/token_factory.rb +10 -0
- data/spec/factories/user_factory.rb +11 -0
- data/spec/factories/worker_factory.rb +8 -0
- data/spec/features/dashborad_spec.rb +82 -0
- data/spec/features/job_definition_spec.rb +74 -0
- data/spec/features/job_instance_spec.rb +94 -0
- data/spec/features/sign_in_and_out_spec.rb +17 -0
- data/spec/features/users_spec.rb +90 -0
- data/spec/features/workers_spec.rb +44 -0
- data/spec/helpers/executions_helper_spec.rb +4 -0
- data/spec/helpers/job_definition_helper_spec.rb +42 -0
- data/spec/helpers/job_schedules_helper_spec.rb +4 -0
- data/spec/helpers/logs_helper_spec.rb +4 -0
- data/spec/helpers/tokens_helper_spec.rb +4 -0
- data/spec/helpers/users_helper_spec.rb +4 -0
- data/spec/helpers/workers_helper_spec.rb +4 -0
- data/spec/mailers/notifications_spec.rb +54 -0
- data/spec/memory_sampler_spec.rb +11 -0
- data/spec/models/admin_assignment_spec.rb +4 -0
- data/spec/models/execution_spec.rb +26 -0
- data/spec/models/job_definition_spec.rb +163 -0
- data/spec/models/job_instance_spec.rb +115 -0
- data/spec/models/job_schedule_spec.rb +121 -0
- data/spec/models/job_suspend_schedule_spec.rb +32 -0
- data/spec/models/memory_consumption_log_spec.rb +50 -0
- data/spec/models/memory_expectancy_spec.rb +26 -0
- data/spec/models/star_spec.rb +4 -0
- data/spec/models/tick_spec.rb +23 -0
- data/spec/models/token_spec.rb +54 -0
- data/spec/models/user_spec.rb +17 -0
- data/spec/models/worker_spec.rb +5 -0
- data/spec/rails_helper.rb +81 -0
- data/spec/requests/api/job_instances_spec.rb +96 -0
- data/spec/requests/api/stats_spec.rb +45 -0
- data/spec/return_to_validator_spec.rb +28 -0
- data/spec/settings_spec.rb +10 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/support/feature_sign_in_helper.rb +31 -0
- data/spec/support/sign_in_helper.rb +5 -0
- data/spec/support/wait_for_ajax.rb +11 -0
- data/spec/workflow/engine_spec.rb +241 -0
- data/spec/workflow/node_spec.rb +62 -0
- data/spec/workflow/notifier/hipchat_spec.rb +117 -0
- data/spec/workflow/notifier/mail_spec.rb +86 -0
- data/spec/workflow/notifier/slack_spec.rb +110 -0
- data/spec/workflow/script_parser_spec.rb +119 -0
- data/spec/workflow/shell_scanner_spec.rb +47 -0
- data/spec/workflow/task/auto_skip_error_spec.rb +35 -0
- data/spec/workflow/task/env_spec.rb +47 -0
- data/spec/workflow/task/execute_spec.rb +127 -0
- data/spec/workflow/task/expected_time_spec.rb +52 -0
- data/spec/workflow/task/fork_spec.rb +30 -0
- data/spec/workflow/task/queue_spec.rb +45 -0
- data/spec/workflow/task/rails_env_spec.rb +30 -0
- data/spec/workflow/task/sleep_spec.rb +22 -0
- data/spec/workflow/task/sub_process_spec.rb +32 -0
- data/spec/workflow/task/wait_spec.rb +162 -0
- metadata +1038 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Kuroko2::JobSuspendSchedulesController do
|
4
|
+
routes { Kuroko2::Engine.routes }
|
5
|
+
|
6
|
+
before { sign_in }
|
7
|
+
|
8
|
+
let(:schedules) { create_list(:job_suspend_schedule, 1) }
|
9
|
+
let(:definition) { create(:job_definition, job_suspend_schedules: schedules) }
|
10
|
+
|
11
|
+
describe '#index' do
|
12
|
+
it do
|
13
|
+
get :index, params: { job_definition_id: definition.id }
|
14
|
+
|
15
|
+
expect(response).to have_http_status(:ok)
|
16
|
+
expect(assigns(:suspend_schedule)).to be_new_record
|
17
|
+
expect(assigns(:suspend_schedules)).to eq schedules
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#create' do
|
22
|
+
it do
|
23
|
+
post :create, params: { job_definition_id: definition.id, job_suspend_schedule: { cron: '* * * * *' } }
|
24
|
+
|
25
|
+
expect(response).to have_http_status(:created)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#destroy' do
|
30
|
+
|
31
|
+
it do
|
32
|
+
delete :destroy, params: { job_definition_id: definition.id, id: schedules.first.id }
|
33
|
+
definition.reload
|
34
|
+
|
35
|
+
expect(response).to have_http_status(:ok)
|
36
|
+
expect(definition.job_schedules.size).to be 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Kuroko2::JobTimelinesController do
|
4
|
+
routes { Kuroko2::Engine.routes }
|
5
|
+
|
6
|
+
let(:instance_num) { 2 }
|
7
|
+
let(:definition) do
|
8
|
+
create(
|
9
|
+
:job_definition_with_instances,
|
10
|
+
job_instances_count: instance_num,
|
11
|
+
job_instances_token_status: Kuroko2::Token::FINISHED
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:target_user) { assigns(:_current_user) }
|
16
|
+
|
17
|
+
before do
|
18
|
+
sign_in
|
19
|
+
definition.job_instances.first.update!(created_at: 1.week.ago)
|
20
|
+
Kuroko2::Star.create!(job_definition: definition, user: target_user)
|
21
|
+
definition.text_tags = 'test'
|
22
|
+
definition.save!
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#index' do
|
26
|
+
before { get :index }
|
27
|
+
|
28
|
+
it do
|
29
|
+
expect(response).to have_http_status(:ok)
|
30
|
+
expect(response).to render_template('index')
|
31
|
+
expect(assigns(:user)).to eq assigns(:_current_user)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#dataset' do
|
36
|
+
context 'without parameters' do
|
37
|
+
before { get :dataset, xhr: true }
|
38
|
+
|
39
|
+
it do
|
40
|
+
expect(response).to have_http_status(:ok)
|
41
|
+
expect(assigns(:user)).to eq assigns(:_current_user)
|
42
|
+
expect(assigns(:instances).size).to eq 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with period parameter' do
|
47
|
+
before { get :dataset, params: { period: period }, xhr: true }
|
48
|
+
|
49
|
+
context 'with period is 1 hour' do
|
50
|
+
let(:period) { '1h' }
|
51
|
+
it { expect(assigns(:instances).size).to eq 1 }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with period is 1 day' do
|
55
|
+
let(:period) { '1d' }
|
56
|
+
it { expect(assigns(:instances).size).to eq 1 }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with period is 2 weeks' do
|
60
|
+
let(:period) { '2w' }
|
61
|
+
it { expect(assigns(:instances).size).to eq 2 }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with user_id parameter' do
|
66
|
+
let(:target_user) { create(:user) }
|
67
|
+
before { get :dataset, params: { user_id: target_user.id }, xhr: true }
|
68
|
+
|
69
|
+
it do
|
70
|
+
expect(response).to have_http_status(:ok)
|
71
|
+
expect(assigns(:user)).to eq target_user
|
72
|
+
expect(assigns(:instances).size).to eq 1
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'if user is group user' do
|
76
|
+
let(:group_user) { create(:user) }
|
77
|
+
|
78
|
+
before do
|
79
|
+
Kuroko2::AdminAssignment.create!(job_definition: definition, user: group_user)
|
80
|
+
get :dataset, params: { user_id: group_user.id }, xhr: true
|
81
|
+
end
|
82
|
+
|
83
|
+
it do
|
84
|
+
expect(response).to have_http_status(:ok)
|
85
|
+
expect(assigns(:user)).to eq group_user
|
86
|
+
expect(assigns(:instances).size).to eq 1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'with tag parameter' do
|
92
|
+
let(:target_user) { create(:user) }
|
93
|
+
before do
|
94
|
+
get :dataset, params: { user_id: target_user.id, period: '2w', tag: ['test'] }, xhr: true
|
95
|
+
end
|
96
|
+
|
97
|
+
it do
|
98
|
+
expect(response).to have_http_status(:ok)
|
99
|
+
expect(assigns(:instances).size).to eq 2
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when tag does not exist' do
|
103
|
+
before do
|
104
|
+
get :dataset, params: { user_id: target_user.id, period: '2w', tag: ['test2'] }, xhr: true
|
105
|
+
end
|
106
|
+
|
107
|
+
it do
|
108
|
+
expect(response).to have_http_status(:ok)
|
109
|
+
expect(assigns(:instances).size).to eq 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Kuroko2::SessionsController do
|
4
|
+
routes { Kuroko2::Engine.routes }
|
5
|
+
|
6
|
+
describe '#create' do
|
7
|
+
let(:auth_hash) do
|
8
|
+
{
|
9
|
+
provider: 'google_oauth2',
|
10
|
+
uid: uid,
|
11
|
+
info: {
|
12
|
+
name: 'John Doe',
|
13
|
+
email: 'john@example.com',
|
14
|
+
first_name: 'John',
|
15
|
+
last_name: 'Doe',
|
16
|
+
image: 'https://lh3.googleusercontent.com/url/photo.jpg'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
let(:uid) { '123456789' }
|
21
|
+
|
22
|
+
before do
|
23
|
+
request.env['omniauth.auth'] = auth_hash
|
24
|
+
end
|
25
|
+
|
26
|
+
subject { get :create, params: { provider: :google_oauth2 } }
|
27
|
+
|
28
|
+
context 'without user' do
|
29
|
+
it 'creates new user and redirect to root_url' do
|
30
|
+
is_expected.to redirect_to root_path
|
31
|
+
expect(controller.current_user.uid).to eq uid
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with user' do
|
36
|
+
let!(:user) { create(:user, uid: uid) }
|
37
|
+
|
38
|
+
it 'creates new user and redirect to root_url' do
|
39
|
+
is_expected.to redirect_to root_path
|
40
|
+
expect(controller.current_user.id).to eq user.id
|
41
|
+
expect(controller.current_user.uid).to eq uid
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#new' do
|
47
|
+
subject! { get :new }
|
48
|
+
|
49
|
+
it { is_expected.to render_template('new') }
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#destroy' do
|
53
|
+
subject! { delete :destroy }
|
54
|
+
|
55
|
+
it { is_expected.to redirect_to(sign_in_path) }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Kuroko2::StarsController do
|
4
|
+
routes { Kuroko2::Engine.routes }
|
5
|
+
|
6
|
+
before { sign_in }
|
7
|
+
|
8
|
+
describe '#create' do
|
9
|
+
subject! { post :create, params: { job_definition_id: definition.id }, xhr: true }
|
10
|
+
let(:definition) { create :job_definition }
|
11
|
+
|
12
|
+
it do
|
13
|
+
expect(response).to have_http_status(:created)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#destroy' do
|
18
|
+
subject! { delete :destroy, params: { job_definition_id: definition.id, id: star.id }, xhr: true }
|
19
|
+
let(:star) { create :star, user: controller.current_user, job_definition: definition }
|
20
|
+
let(:definition) { create :job_definition }
|
21
|
+
|
22
|
+
it do
|
23
|
+
expect(response).to have_http_status(:ok)
|
24
|
+
expect(Kuroko2::Star.exists?(star.id)).to be_falsey
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Kuroko2::UsersController do
|
4
|
+
routes { Kuroko2::Engine.routes }
|
5
|
+
|
6
|
+
before { sign_in(users.first) }
|
7
|
+
let(:users) { create_list(:user, 2) }
|
8
|
+
|
9
|
+
describe '#index' do
|
10
|
+
subject! { get :index }
|
11
|
+
it { expect(assigns(:users).to_a).to eq users }
|
12
|
+
|
13
|
+
context 'with groups parameter' do
|
14
|
+
before do
|
15
|
+
users.each {|u| u.update_attributes!(provider: 'group_mail') }
|
16
|
+
end
|
17
|
+
it { expect(assigns(:users).to_a).to eq users }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#show' do
|
22
|
+
let(:user) { job_definition.admins.first }
|
23
|
+
let(:job_definition) { create(:job_definition) }
|
24
|
+
|
25
|
+
subject! { get :show, params: { id: user.id } }
|
26
|
+
|
27
|
+
it do
|
28
|
+
expect(assigns(:user)).to eq user
|
29
|
+
expect(assigns(:definitions)).to include job_definition
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#create' do
|
34
|
+
let(:name) { 'Test Users' }
|
35
|
+
let(:email) { 'test@example.com' }
|
36
|
+
|
37
|
+
subject! { post(:create, params: { user: { name: name, email: email } }) }
|
38
|
+
|
39
|
+
it { expect(response).to redirect_to(users_path) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#destroy' do
|
43
|
+
let(:user) { users.last }
|
44
|
+
subject! { delete(:destroy, params: { id: user.id }) }
|
45
|
+
|
46
|
+
it do
|
47
|
+
expect(response).to redirect_to(users_path)
|
48
|
+
expect(Kuroko2::User.exists?(user.id)).to be_falsey
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
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. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
# puts "\n== Copying sample files =="
|
22
|
+
# unless File.exist?('config/database.yml')
|
23
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
24
|
+
# end
|
25
|
+
|
26
|
+
puts "\n== Preparing database =="
|
27
|
+
system! 'bin/rails db:setup'
|
28
|
+
|
29
|
+
puts "\n== Removing old logs and tempfiles =="
|
30
|
+
system! 'bin/rails log:clear tmp:clear'
|
31
|
+
|
32
|
+
puts "\n== Restarting application server =="
|
33
|
+
system! 'bin/rails restart'
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Updating database =="
|
22
|
+
system! 'bin/rails db:migrate'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system! 'bin/rails restart'
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(*Rails.groups)
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
16
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
17
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
18
|
+
|
19
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
20
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
21
|
+
# config.i18n.default_locale = :de
|
22
|
+
|
23
|
+
config.autoload_paths << Rails.root.join('lib')
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install mysql2
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'mysql2'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: mysql2
|
9
|
+
encoding: utf8mb4
|
10
|
+
charset: utf8mb4
|
11
|
+
collation: utf8mb4_general_ci
|
12
|
+
pool: 5
|
13
|
+
username: root
|
14
|
+
password:
|
15
|
+
host: 127.0.0.1
|
16
|
+
development:
|
17
|
+
<<: *default
|
18
|
+
database: kuroko2_dummy_development
|
19
|
+
|
20
|
+
# Warning: The database defined as "test" will be erased and
|
21
|
+
# re-generated from your development database when you run "rake".
|
22
|
+
# Do not set this db to the same as development or production.
|
23
|
+
test:
|
24
|
+
<<: *default
|
25
|
+
database: kuroko2_dummy_test
|
26
|
+
|
27
|
+
production:
|
28
|
+
<<: *default
|
29
|
+
database: kuroko2_dummy_production
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
16
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
17
|
+
config.action_controller.perform_caching = true
|
18
|
+
|
19
|
+
config.cache_store = :memory_store
|
20
|
+
config.public_file_server.headers = {
|
21
|
+
'Cache-Control' => 'public, max-age=172800'
|
22
|
+
}
|
23
|
+
else
|
24
|
+
config.action_controller.perform_caching = false
|
25
|
+
|
26
|
+
config.cache_store = :null_store
|
27
|
+
end
|
28
|
+
|
29
|
+
# Don't care if the mailer can't send.
|
30
|
+
config.action_mailer.raise_delivery_errors = false
|
31
|
+
|
32
|
+
config.action_mailer.perform_caching = false
|
33
|
+
|
34
|
+
# Print deprecation notices to the Rails logger.
|
35
|
+
config.active_support.deprecation = :log
|
36
|
+
|
37
|
+
# Raise an error on page load if there are pending migrations.
|
38
|
+
config.active_record.migration_error = :page_load
|
39
|
+
|
40
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
41
|
+
# This option may cause significant delays in view rendering with a large
|
42
|
+
# number of complex assets.
|
43
|
+
config.assets.debug = true
|
44
|
+
|
45
|
+
# Suppress logger output for asset requests.
|
46
|
+
config.assets.quiet = true
|
47
|
+
|
48
|
+
# Raises error for missing translations
|
49
|
+
# config.action_view.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
52
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
53
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
54
|
+
end
|