rocketjob_mission_control 3.0.0.rc1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +10 -6
- data/app/assets/javascripts/rocket_job_mission_control/application.js +4 -3
- data/app/assets/javascripts/rocket_job_mission_control/base.js +12 -0
- data/app/assets/javascripts/rocket_job_mission_control/datatable.js +40 -0
- data/app/assets/javascripts/rocket_job_mission_control/dirmon_entries.js +16 -0
- data/app/assets/javascripts/rocket_job_mission_control/selectize.js +6 -0
- data/app/controllers/rocket_job_mission_control/active_workers_controller.rb +16 -5
- data/app/controllers/rocket_job_mission_control/application_controller.rb +2 -0
- data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +47 -67
- data/app/controllers/rocket_job_mission_control/jobs_controller.rb +113 -19
- data/app/controllers/rocket_job_mission_control/servers_controller.rb +71 -28
- data/app/datatables/rocket_job_mission_control/abstract_datatable.rb +3 -3
- data/app/datatables/rocket_job_mission_control/active_workers_datatable.rb +8 -14
- data/app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb +7 -15
- data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +128 -13
- data/app/datatables/rocket_job_mission_control/servers_datatable.rb +13 -15
- data/app/helpers/rocket_job_mission_control/application_helper.rb +58 -0
- data/app/helpers/rocket_job_mission_control/jobs_helper.rb +15 -7
- data/app/helpers/rocket_job_mission_control/servers_helper.rb +1 -1
- data/app/models/rocket_job_mission_control/job_sanitizer.rb +47 -0
- data/app/models/rocket_job_mission_control/query.rb +24 -18
- data/app/views/layouts/rocket_job_mission_control/application.html.erb +43 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_flash.html.erb +20 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_header.html.erb +45 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.erb +12 -0
- data/app/views/rocket_job_mission_control/active_workers/index.html.erb +40 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_form.html.erb +60 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.erb +38 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.erb +17 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/edit.html.erb +4 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/index.html.erb +33 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/new.html.erb +8 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/show.html.erb +29 -0
- data/app/views/rocket_job_mission_control/jobs/_pagination.html.erb +26 -0
- data/app/views/rocket_job_mission_control/jobs/_sidebar.html.erb +32 -0
- data/app/views/rocket_job_mission_control/jobs/_status.html.erb +42 -0
- data/app/views/rocket_job_mission_control/jobs/edit.html.erb +32 -0
- data/app/views/rocket_job_mission_control/jobs/exception.html.erb +19 -0
- data/app/views/rocket_job_mission_control/jobs/exceptions.html.erb +40 -0
- data/app/views/rocket_job_mission_control/jobs/index.html.erb +33 -0
- data/app/views/rocket_job_mission_control/jobs/show.html.erb +68 -0
- data/app/views/rocket_job_mission_control/servers/_sidebar.html.erb +31 -0
- data/app/views/rocket_job_mission_control/servers/index.html.erb +56 -0
- data/config/locales/en.yml +3 -10
- data/config/routes.rb +20 -17
- data/lib/rocket_job_mission_control/engine.rb +10 -0
- data/lib/rocket_job_mission_control/version.rb +1 -1
- data/test/compare_hashes.rb +17 -0
- data/test/controllers/rocket_job_mission_control/application_controller_test.rb +49 -0
- data/test/controllers/rocket_job_mission_control/dirmon_entries_controller_test.rb +417 -0
- data/test/controllers/rocket_job_mission_control/jobs_controller_test.rb +363 -0
- data/test/controllers/rocket_job_mission_control/servers_controller_test.rb +251 -0
- data/test/helpers/rocket_job_mission_control/application_helper_test.rb +54 -0
- data/test/helpers/rocket_job_mission_control/jobs_helper_test.rb +85 -0
- data/test/helpers/rocket_job_mission_control/pagination_helper_test.rb +23 -0
- data/test/helpers/rocket_job_mission_control/servers_helper_test.rb +64 -0
- data/test/helpers/rocket_job_mission_control/slices_helper_test.rb +30 -0
- data/test/models/rocket_job_mission_control/job_sanitizer_test.rb +92 -0
- data/test/models/rocket_job_mission_control/query_test.rb +136 -0
- data/test/test_helper.rb +23 -0
- metadata +75 -175
- data/app/assets/javascripts/rocket_job_mission_control/base.js.coffee +0 -11
- data/app/assets/javascripts/rocket_job_mission_control/datatable.js.coffee +0 -33
- data/app/assets/javascripts/rocket_job_mission_control/dirmon_entries.js.coffee +0 -13
- data/app/assets/javascripts/rocket_job_mission_control/selectize.js.coffee +0 -5
- data/app/assets/stylesheets/rocket_job_mission_control/jquery.bootstrap-touchspin.scss +0 -45
- data/app/controllers/rocket_job_mission_control/dirmon_entries/index_filters_controller.rb +0 -45
- data/app/controllers/rocket_job_mission_control/jobs/failures_controller.rb +0 -30
- data/app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb +0 -90
- data/app/controllers/rocket_job_mission_control/servers/index_filters_controller.rb +0 -49
- data/app/datatables/rocket_job_mission_control/completed_jobs_datatable.rb +0 -27
- data/app/datatables/rocket_job_mission_control/interrupted_jobs_datatable.rb +0 -26
- data/app/datatables/rocket_job_mission_control/queued_jobs_datatable.rb +0 -23
- data/app/datatables/rocket_job_mission_control/running_jobs_datatable.rb +0 -47
- data/app/datatables/rocket_job_mission_control/scheduled_jobs_datatable.rb +0 -31
- data/app/models/job_failures.rb +0 -20
- data/app/models/job_sanitizer.rb +0 -17
- data/app/views/layouts/rocket_job_mission_control/application.html.haml +0 -45
- data/app/views/layouts/rocket_job_mission_control/partials/_header.html.haml +0 -32
- data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.haml +0 -11
- data/app/views/rocket_job_mission_control/active_workers/index.html.haml +0 -24
- data/app/views/rocket_job_mission_control/dirmon_entries/_form.html.haml +0 -37
- data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +0 -30
- data/app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.haml +0 -27
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +0 -23
- data/app/views/rocket_job_mission_control/dirmon_entries/edit.html.haml +0 -4
- data/app/views/rocket_job_mission_control/dirmon_entries/index.html.haml +0 -18
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/disabled.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/enabled.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/failed.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/index_filters/pending.html.haml +0 -17
- data/app/views/rocket_job_mission_control/dirmon_entries/new.html.haml +0 -6
- data/app/views/rocket_job_mission_control/dirmon_entries/show.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/_sidebar.html.haml +0 -28
- data/app/views/rocket_job_mission_control/jobs/_status.html.haml +0 -45
- data/app/views/rocket_job_mission_control/jobs/edit.html.haml +0 -34
- data/app/views/rocket_job_mission_control/jobs/exceptions.html.haml +0 -29
- data/app/views/rocket_job_mission_control/jobs/failures/_pagination.html.haml +0 -16
- data/app/views/rocket_job_mission_control/jobs/failures/index.html.haml +0 -32
- data/app/views/rocket_job_mission_control/jobs/index.html.haml +0 -25
- data/app/views/rocket_job_mission_control/jobs/index_filters/aborted.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/index_filters/completed.html.haml +0 -24
- data/app/views/rocket_job_mission_control/jobs/index_filters/failed.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/index_filters/paused.html.haml +0 -23
- data/app/views/rocket_job_mission_control/jobs/index_filters/queued.html.haml +0 -24
- data/app/views/rocket_job_mission_control/jobs/index_filters/running.html.haml +0 -25
- data/app/views/rocket_job_mission_control/jobs/index_filters/scheduled.html.haml +0 -24
- data/app/views/rocket_job_mission_control/jobs/show.html.haml +0 -51
- data/app/views/rocket_job_mission_control/servers/_actions.html.haml +0 -9
- data/app/views/rocket_job_mission_control/servers/_sidebar.html.haml +0 -20
- data/app/views/rocket_job_mission_control/servers/index.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/paused.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/running.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/starting.html.haml +0 -37
- data/app/views/rocket_job_mission_control/servers/index_filters/stopping.html.haml +0 -37
- data/spec/controllers/application_controller_spec.rb +0 -47
- data/spec/controllers/dirmon_entries/index_filters_controller_spec.rb +0 -77
- data/spec/controllers/dirmon_entries_controller_spec.rb +0 -383
- data/spec/controllers/jobs/failures_controller_spec.rb +0 -82
- data/spec/controllers/jobs/index_filters_controller_spec.rb +0 -66
- data/spec/controllers/jobs_controller_spec.rb +0 -172
- data/spec/controllers/workers/index_filters_controller_spec.rb +0 -59
- data/spec/controllers/workers_controller_spec.rb +0 -125
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/mongoid.yml +0 -88
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config/symmetric-encryption.yml +0 -8
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -118933
- data/spec/helpers/application_helper_spec.rb +0 -58
- data/spec/helpers/jobs_helper_spec.rb +0 -35
- data/spec/helpers/pagination_helper_spec.rb +0 -21
- data/spec/helpers/servers_helper_spec.rb +0 -16
- data/spec/helpers/slices_helper_spec.rb +0 -33
- data/spec/models/job_failures_spec.rb +0 -14
- data/spec/models/job_sanitizer_spec.rb +0 -16
- data/spec/rails_helper.rb +0 -47
- data/spec/spec_helper.rb +0 -84
- data/vendor/assets/javascripts/jquery.bootstrap-touchspin.js +0 -686
- data/vendor/assets/javascripts/prism.js +0 -6
- data/vendor/assets/stylesheets/jquery.bootstrap-touchspin.css +0 -45
- data/vendor/assets/stylesheets/prism.scss +0 -160
@@ -1,37 +0,0 @@
|
|
1
|
-
#servers
|
2
|
-
.server-list
|
3
|
-
.list
|
4
|
-
.row
|
5
|
-
.col-md-6
|
6
|
-
%h2 Running Servers
|
7
|
-
.col-md-6
|
8
|
-
.col-sm-10
|
9
|
-
.server-collection-actions
|
10
|
-
- if @servers.present?
|
11
|
-
%ol.pull-right
|
12
|
-
.btn-group
|
13
|
-
- [:stop_all, :pause_all, :resume_all, :destroy_zombies].each do |action|
|
14
|
-
= link_to("#{action.to_s.humanize.capitalize}",
|
15
|
-
rocket_job_mission_control.update_all_servers_path(server_action: action),
|
16
|
-
method: :patch,
|
17
|
-
data: { confirm: t(:confirm, scope: [:server, :update_all], action: action.to_s.singularize.humanize.downcase) },
|
18
|
-
class: 'btn btn-default')
|
19
|
-
.col-sm-2.pull-right
|
20
|
-
.btn.btn-default.pull-right.dt-reload{ data: { behavior: 'reload' } }
|
21
|
-
%i.fa.fa-refresh
|
22
|
-
%table.table.datatable.servers-datatable{ style: "width: 100%", data: { source: "#{running_servers_url(format: 'json')}" } }
|
23
|
-
%thead
|
24
|
-
%tr
|
25
|
-
%th Hostname : PID
|
26
|
-
%th Workers (Current/Max)
|
27
|
-
%th Started
|
28
|
-
%th Heartbeat
|
29
|
-
%th Actions
|
30
|
-
%tbody
|
31
|
-
|
32
|
-
:javascript
|
33
|
-
jQuery(function() {
|
34
|
-
new RjmcDatatable(
|
35
|
-
$('.servers-datatable'),
|
36
|
-
[{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
|
37
|
-
});
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#servers
|
2
|
-
.server-list
|
3
|
-
.list
|
4
|
-
.row
|
5
|
-
.col-md-6
|
6
|
-
%h2 Starting Servers
|
7
|
-
.col-md-6
|
8
|
-
.col-sm-10
|
9
|
-
.server-collection-actions
|
10
|
-
- if @servers.present?
|
11
|
-
%ol.pull-right
|
12
|
-
.btn-group
|
13
|
-
- [:stop_all, :pause_all, :resume_all, :destroy_zombies].each do |action|
|
14
|
-
= link_to("#{action.to_s.humanize.capitalize}",
|
15
|
-
rocket_job_mission_control.update_all_servers_path(server_action: action),
|
16
|
-
method: :patch,
|
17
|
-
data: { confirm: t(:confirm, scope: [:server, :update_all], action: action.to_s.singularize.humanize.downcase) },
|
18
|
-
class: 'btn btn-default')
|
19
|
-
.col-sm-2.pull-right
|
20
|
-
.btn.btn-default.pull-right.dt-reload{ data: { behavior: 'reload' } }
|
21
|
-
%i.fa.fa-refresh
|
22
|
-
%table.table.datatable.servers-datatable{ style: "width: 100%", data: { source: "#{starting_servers_url(format: 'json')}" } }
|
23
|
-
%thead
|
24
|
-
%tr
|
25
|
-
%th Hostname : PID
|
26
|
-
%th Workers (Current/Max)
|
27
|
-
%th Started
|
28
|
-
%th Heartbeat
|
29
|
-
%th Actions
|
30
|
-
%tbody
|
31
|
-
|
32
|
-
:javascript
|
33
|
-
jQuery(function() {
|
34
|
-
new RjmcDatatable(
|
35
|
-
$('.servers-datatable'),
|
36
|
-
[{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
|
37
|
-
});
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#servers
|
2
|
-
.server-list
|
3
|
-
.list
|
4
|
-
.row
|
5
|
-
.col-md-6
|
6
|
-
%h2 Stopping Servers
|
7
|
-
.col-md-6
|
8
|
-
.col-sm-10
|
9
|
-
.server-collection-actions
|
10
|
-
- if @servers.present?
|
11
|
-
%ol.pull-right
|
12
|
-
.btn-group
|
13
|
-
- [:pause_all, :resume_all, :destroy_zombies].each do |action|
|
14
|
-
= link_to("#{action.to_s.humanize.capitalize}",
|
15
|
-
rocket_job_mission_control.update_all_servers_path(server_action: action),
|
16
|
-
method: :patch,
|
17
|
-
data: { confirm: t(:confirm, scope: [:server, :update_all], action: action.to_s.singularize.humanize.downcase) },
|
18
|
-
class: 'btn btn-default')
|
19
|
-
.col-sm-2.pull-right
|
20
|
-
.btn.btn-default.pull-right.dt-reload{ data: { behavior: 'reload' } }
|
21
|
-
%i.fa.fa-refresh
|
22
|
-
%table.table.datatable.servers-datatable{ style: "width: 100%", data: { source: "#{stopping_servers_url(format: 'json')}" } }
|
23
|
-
%thead
|
24
|
-
%tr
|
25
|
-
%th Hostname : PID
|
26
|
-
%th Workers (Current/Max)
|
27
|
-
%th Started
|
28
|
-
%th Heartbeat
|
29
|
-
%th Actions
|
30
|
-
%tbody
|
31
|
-
|
32
|
-
:javascript
|
33
|
-
jQuery(function() {
|
34
|
-
new RjmcDatatable(
|
35
|
-
$('.servers-datatable'),
|
36
|
-
[{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
|
37
|
-
});
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.describe ApplicationController, type: :controller do
|
5
|
-
controller do
|
6
|
-
def index
|
7
|
-
@time_zone = Time.zone
|
8
|
-
|
9
|
-
render text: 'Time Zoned'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#with_time_zone" do
|
14
|
-
let(:session_params) { {} }
|
15
|
-
let(:expected_time_zone) { 'UTC' }
|
16
|
-
|
17
|
-
before do
|
18
|
-
get :index, {}, session_params
|
19
|
-
end
|
20
|
-
|
21
|
-
context "with a session present" do
|
22
|
-
context "that contains a time zone" do
|
23
|
-
let(:expected_time_zone) { 'America/Los_Angeles' }
|
24
|
-
let(:session_params) { {'time_zone' => expected_time_zone} }
|
25
|
-
|
26
|
-
it "sets the time zone correctly" do
|
27
|
-
expect(assigns(:time_zone).name).to eq(expected_time_zone)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'that does not contain a time zone' do
|
32
|
-
let(:session_params) { {'user_id' => '42'} }
|
33
|
-
|
34
|
-
it 'sets the time zone correctly' do
|
35
|
-
expect(assigns(:time_zone).name).to eq(expected_time_zone)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with no session present" do
|
41
|
-
it "sets the time zone correctly" do
|
42
|
-
expect(assigns(:time_zone).name).to eq(expected_time_zone)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
class AJob < RocketJob::Job
|
4
|
-
def perform
|
5
|
-
23
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
module RocketJobMissionControl
|
10
|
-
module DirmonEntries
|
11
|
-
RSpec.describe IndexFiltersController do
|
12
|
-
routes { Engine.routes }
|
13
|
-
|
14
|
-
states = %w(pending enabled failed disabled)
|
15
|
-
|
16
|
-
states.each_with_index do |state, i|
|
17
|
-
describe "GET ##{state}" do
|
18
|
-
describe "with no #{state} dirmons" do
|
19
|
-
before do
|
20
|
-
get state.to_sym
|
21
|
-
end
|
22
|
-
|
23
|
-
it "succeeds" do
|
24
|
-
expect(response.status).to be(200)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'renders template' do
|
28
|
-
expect(response).to render_template(state)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns no jobs" do
|
32
|
-
expect(assigns(:dirmons).count).to eq(0)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "with #{state} dirmons" do
|
37
|
-
let(:not_state) { states[i-1] }
|
38
|
-
let!(:state_dirmon) {
|
39
|
-
RocketJob::DirmonEntry.create!(
|
40
|
-
state: state,
|
41
|
-
pattern: '21',
|
42
|
-
job_class_name: 'AJob'
|
43
|
-
)
|
44
|
-
}
|
45
|
-
|
46
|
-
before do
|
47
|
-
RocketJob::DirmonEntry.create!(
|
48
|
-
name: 'Test',
|
49
|
-
state: not_state,
|
50
|
-
pattern: '21',
|
51
|
-
job_class_name: 'AJob'
|
52
|
-
)
|
53
|
-
get state.to_sym
|
54
|
-
end
|
55
|
-
|
56
|
-
after do
|
57
|
-
RocketJob::DirmonEntry.delete_all
|
58
|
-
end
|
59
|
-
|
60
|
-
it "succeeds" do
|
61
|
-
expect(response.status).to be(200)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'renders template' do
|
65
|
-
expect(response).to render_template(state)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "grabs a filtered list of dirmons" do
|
69
|
-
expect(assigns(:dirmons)).to match_array([state_dirmon])
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,383 +0,0 @@
|
|
1
|
-
require_relative '../rails_helper'
|
2
|
-
|
3
|
-
class NoParamsJob < RocketJob::Job
|
4
|
-
def perform
|
5
|
-
100_000
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
module RocketJobMissionControl
|
10
|
-
RSpec.describe DirmonEntriesController do
|
11
|
-
routes { Engine.routes }
|
12
|
-
|
13
|
-
let(:dirmon_list) { spy(sort: []) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
allow(RocketJob::DirmonEntry).to receive(:limit).and_return(dirmon_list)
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'PATCH #enable' do
|
20
|
-
before do
|
21
|
-
patch :enable, id: existing_dirmon.id
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:existing_dirmon) do
|
25
|
-
RocketJob::DirmonEntry.create!(
|
26
|
-
name: 'Test',
|
27
|
-
job_class_name: 'NoParamsJob',
|
28
|
-
pattern: 'the_path',
|
29
|
-
state: starting_state,
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when transition is allowed' do
|
34
|
-
let(:starting_state) { 'pending' }
|
35
|
-
|
36
|
-
it { expect(response).to redirect_to(dirmon_entry_path(existing_dirmon.id)) }
|
37
|
-
|
38
|
-
it 'changes the state to enabled' do
|
39
|
-
expect(existing_dirmon.reload.state).to eq(:enabled)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when transition is not allowed' do
|
44
|
-
let(:starting_state) { 'enabled' }
|
45
|
-
|
46
|
-
it { expect(response).to render_template(:show) }
|
47
|
-
|
48
|
-
it 'alerts the user' do
|
49
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:dirmon_entry, :enable]))
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe 'PATCH #disable' do
|
55
|
-
let(:existing_dirmon) do
|
56
|
-
RocketJob::DirmonEntry.create!(
|
57
|
-
name: 'Test',
|
58
|
-
job_class_name: 'NoParamsJob',
|
59
|
-
pattern: 'the_path',
|
60
|
-
state: starting_state,
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
before do
|
65
|
-
patch :disable, id: existing_dirmon.id
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'when transition is allowed' do
|
69
|
-
let(:starting_state) { :enabled }
|
70
|
-
|
71
|
-
it { expect(response).to redirect_to(dirmon_entry_path(existing_dirmon.id)) }
|
72
|
-
|
73
|
-
it 'changes the state to disabled' do
|
74
|
-
expect(existing_dirmon.reload.state).to eq(:disabled)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when transition is not allowed' do
|
79
|
-
let(:starting_state) { :disabled }
|
80
|
-
|
81
|
-
it { expect(response).to render_template(:show) }
|
82
|
-
|
83
|
-
it 'alerts the user' do
|
84
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:dirmon_entry, :disable]))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'GET #new' do
|
90
|
-
let(:entry_params) { {} }
|
91
|
-
|
92
|
-
before do
|
93
|
-
get :new, entry_params
|
94
|
-
end
|
95
|
-
|
96
|
-
it { expect(response.status).to eq(200) }
|
97
|
-
|
98
|
-
it 'assigns a new entry' do
|
99
|
-
expect(assigns(:dirmon_entry)).to be_present
|
100
|
-
expect(assigns(:dirmon_entry)).to_not be_persisted
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'with form params' do
|
104
|
-
let(:entry_params) { {rocket_job_dirmon_entry: {name: 'new entry'}} }
|
105
|
-
|
106
|
-
it { expect(response.status).to eq(200) }
|
107
|
-
|
108
|
-
it 'assigns the params to new entry' do
|
109
|
-
expect(assigns(:dirmon_entry)).to be_present
|
110
|
-
expect(assigns(:dirmon_entry).name).to eq('new entry')
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'with a valid job_class_name' do
|
114
|
-
let(:entry_params) { {rocket_job_dirmon_entry: {job_class_name: 'NoParamsJob'}} }
|
115
|
-
|
116
|
-
it { expect(response.status).to eq(200) }
|
117
|
-
|
118
|
-
it 'assigns the job class' do
|
119
|
-
expect(assigns(:dirmon_entry)).to be_present
|
120
|
-
expect(assigns(:dirmon_entry).job_class).to eq(NoParamsJob)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context 'with an invalid job_class_name' do
|
125
|
-
let(:entry_params) { {rocket_job_dirmon_entry: {job_class_name: 'BadJob'}} }
|
126
|
-
|
127
|
-
it { expect(response.status).to eq(200) }
|
128
|
-
|
129
|
-
it 'adds an error' do
|
130
|
-
expect(assigns(:dirmon_entry)).to be_present
|
131
|
-
expect(assigns(:dirmon_entry).errors[:job_class_name]).to be_present
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
describe 'PATCH #update' do
|
139
|
-
let(:existing_dirmon) do
|
140
|
-
RocketJob::DirmonEntry.create!(
|
141
|
-
name: 'Test',
|
142
|
-
job_class_name: 'NoParamsJob',
|
143
|
-
pattern: 'the_path',
|
144
|
-
)
|
145
|
-
end
|
146
|
-
|
147
|
-
before do
|
148
|
-
patch :update, id: existing_dirmon.id, rocket_job_dirmon_entry: dirmon_params
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'with valid parameters' do
|
152
|
-
let(:dirmon_params) do
|
153
|
-
{
|
154
|
-
pattern: 'the_path2',
|
155
|
-
job_class_name: 'NoParamsJob',
|
156
|
-
}
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'redirects to the updated entry' do
|
160
|
-
expect(response).to redirect_to(dirmon_entry_path(existing_dirmon))
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'updates the entry' do
|
164
|
-
expect(existing_dirmon.reload.pattern).to eq('the_path2')
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'displays a success message' do
|
168
|
-
expect(flash[:success]).to eq(I18n.t(:success, scope: [:dirmon_entry, :update]))
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
context 'with invalid parameters' do
|
173
|
-
let(:dirmon_params) do
|
174
|
-
{
|
175
|
-
job_class_name: 'FakeAndBadJob',
|
176
|
-
}
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'renders the edit template' do
|
180
|
-
expect(response.status).to eq(200)
|
181
|
-
expect(response).to render_template(:edit)
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'has errors on the entry' do
|
185
|
-
expect(assigns(:dirmon_entry)).to_not be_valid
|
186
|
-
end
|
187
|
-
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe 'POST #create' do
|
192
|
-
context 'with valid parameters' do
|
193
|
-
|
194
|
-
[
|
195
|
-
{job_class_name: 'NoParamsJob', expected_value: []}
|
196
|
-
].each do |arguments|
|
197
|
-
context "and arguments are '#{arguments}'" do
|
198
|
-
let(:dirmon_params) do
|
199
|
-
{
|
200
|
-
name: 'Test',
|
201
|
-
pattern: '/files/*',
|
202
|
-
job_class_name: arguments[:job_class_name],
|
203
|
-
properties: {description: '', priority: '42'}
|
204
|
-
}
|
205
|
-
end
|
206
|
-
|
207
|
-
before do
|
208
|
-
post :create, rocket_job_dirmon_entry: dirmon_params
|
209
|
-
end
|
210
|
-
|
211
|
-
it 'creates the entry' do
|
212
|
-
expect(assigns(:dirmon_entry)).to be_persisted
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'has no errors' do
|
216
|
-
expect(assigns(:dirmon_entry).errors.messages).to be_empty
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'redirects to created entry' do
|
220
|
-
expect(response).to redirect_to(dirmon_entry_path(assigns(:dirmon_entry)))
|
221
|
-
end
|
222
|
-
|
223
|
-
it 'does not load all entries' do
|
224
|
-
expect(dirmon_list).to_not have_received(:sort)
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'does not save blank properties' do
|
228
|
-
expect(assigns(:dirmon_entry).properties[:description]).to eq(nil)
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'saves properties' do
|
232
|
-
expect(assigns(:dirmon_entry).properties[:priority]).to eq('42')
|
233
|
-
end
|
234
|
-
|
235
|
-
[:name, :pattern, :job_class_name].each do |attribute|
|
236
|
-
it "assigns the correct value for #{attribute}" do
|
237
|
-
expect(assigns(:dirmon_entry)[attribute]).to eq(dirmon_params[attribute])
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
context 'with invalid parameters' do
|
245
|
-
let(:dirmon_params) do
|
246
|
-
{
|
247
|
-
name: 'Test',
|
248
|
-
job_class_name: 'FakeAndBadJob'
|
249
|
-
}
|
250
|
-
end
|
251
|
-
|
252
|
-
before do
|
253
|
-
post :create, rocket_job_dirmon_entry: dirmon_params
|
254
|
-
end
|
255
|
-
|
256
|
-
context 'on model attributes' do
|
257
|
-
it 'renders the new template' do
|
258
|
-
expect(response.status).to eq(200)
|
259
|
-
expect(response).to render_template(:new)
|
260
|
-
end
|
261
|
-
|
262
|
-
it 'has errors on the entry' do
|
263
|
-
expect(assigns(:dirmon_entry)).to_not be_valid
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe 'GET #edit' do
|
270
|
-
before do
|
271
|
-
@entry = RocketJob::DirmonEntry.create(
|
272
|
-
name: 'Test',
|
273
|
-
pattern: '/files/',
|
274
|
-
job_class_name: 'NoParamsJob'
|
275
|
-
)
|
276
|
-
get :edit, id: @entry.id
|
277
|
-
end
|
278
|
-
|
279
|
-
it { expect(response.status).to eq(200) }
|
280
|
-
|
281
|
-
it 'assigns the entry' do
|
282
|
-
expect(assigns(:dirmon_entry)).to be_present
|
283
|
-
expect(assigns(:dirmon_entry)).to eq(@entry)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
describe 'GET #show' do
|
288
|
-
describe 'with an invalid id' do
|
289
|
-
before do
|
290
|
-
allow(RocketJob::DirmonEntry).to receive(:find).and_return(nil)
|
291
|
-
get :show, id: 42
|
292
|
-
end
|
293
|
-
|
294
|
-
it 'redirects' do
|
295
|
-
expect(response).to redirect_to(dirmon_entries_path)
|
296
|
-
end
|
297
|
-
|
298
|
-
it 'adds a flash alert message' do
|
299
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:dirmon_entry, :find], id: 42))
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
describe 'with a valid id' do
|
304
|
-
before do
|
305
|
-
allow(RocketJob::DirmonEntry).to receive(:find).and_return('entry')
|
306
|
-
get :show, id: 42
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'succeeds' do
|
310
|
-
expect(response.status).to be(200)
|
311
|
-
end
|
312
|
-
|
313
|
-
it 'assigns the entry' do
|
314
|
-
expect(assigns(:dirmon_entry)).to be_present
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe 'DELETE #destroy' do
|
320
|
-
let(:existing_dirmon) do
|
321
|
-
RocketJob::DirmonEntry.create!(
|
322
|
-
name: 'Test',
|
323
|
-
job_class_name: 'NoParamsJob',
|
324
|
-
pattern: 'the_path'
|
325
|
-
)
|
326
|
-
end
|
327
|
-
|
328
|
-
describe 'with a valid id' do
|
329
|
-
before { delete :destroy, id: existing_dirmon.id }
|
330
|
-
|
331
|
-
it 'redirects to index' do
|
332
|
-
expect(response).to redirect_to(dirmon_entries_path)
|
333
|
-
end
|
334
|
-
|
335
|
-
it 'displays a success message' do
|
336
|
-
expect(flash[:success]).to eq(I18n.t(:success, scope: [:dirmon_entry, :destroy]))
|
337
|
-
end
|
338
|
-
|
339
|
-
it 'deletes the entry' do
|
340
|
-
expect(RocketJob::DirmonEntry.where(id: existing_dirmon.id).exists?).to eq(false)
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
describe 'GET #index' do
|
346
|
-
describe 'with no entries' do
|
347
|
-
before do
|
348
|
-
RocketJob::DirmonEntry.destroy_all
|
349
|
-
get :index
|
350
|
-
end
|
351
|
-
|
352
|
-
it 'succeeds' do
|
353
|
-
expect(response.status).to be(200)
|
354
|
-
end
|
355
|
-
|
356
|
-
it 'returns no entries' do
|
357
|
-
expect(assigns(:dirmons).count).to eq(0)
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
describe 'with jobs' do
|
362
|
-
let(:dirmons) { ['fake_dirmon1', 'fake_dirmon2'] }
|
363
|
-
|
364
|
-
before do
|
365
|
-
allow(RocketJob::DirmonEntry).to receive(:all).and_return(dirmons)
|
366
|
-
get :index
|
367
|
-
end
|
368
|
-
|
369
|
-
it 'succeeds' do
|
370
|
-
expect(response.status).to be(200)
|
371
|
-
end
|
372
|
-
|
373
|
-
it 'grabs all dirmons with empty where' do
|
374
|
-
expect(RocketJob::DirmonEntry).to have_received(:all)
|
375
|
-
end
|
376
|
-
|
377
|
-
it 'returns the entries' do
|
378
|
-
expect(assigns(:dirmons)).to eq(dirmons)
|
379
|
-
end
|
380
|
-
end
|
381
|
-
end
|
382
|
-
end
|
383
|
-
end
|