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,82 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.describe Jobs::FailuresController do
|
5
|
-
routes { Engine.routes }
|
6
|
-
|
7
|
-
describe "GET #index" do
|
8
|
-
describe "with a failed job" do
|
9
|
-
let(:job) { spy(failed?: true, id: 42) }
|
10
|
-
let(:slice_errors) do
|
11
|
-
[
|
12
|
-
{
|
13
|
-
'_id' =>
|
14
|
-
{
|
15
|
-
'error_class' => 'BoomError',
|
16
|
-
},
|
17
|
-
'message' => ['boom'],
|
18
|
-
'count' => '1337',
|
19
|
-
},
|
20
|
-
]
|
21
|
-
end
|
22
|
-
let(:selected_exception) { spy(count: 1337, first: current_failure) }
|
23
|
-
let(:current_failure) { {'exception' => 'Doh! Something blew up!'} }
|
24
|
-
|
25
|
-
before do
|
26
|
-
allow(RocketJob::Job).to receive(:find).and_return(job)
|
27
|
-
allow(job).to receive_message_chain('input.collection.aggregate') { slice_errors }
|
28
|
-
allow(job).to receive_message_chain('input.collection.find.limit') { selected_exception }
|
29
|
-
get :index, job_id: job.id
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'with slice errors' do
|
33
|
-
it 'succeeds' do
|
34
|
-
expect(response).to be_success
|
35
|
-
end
|
36
|
-
it 'returns the job' do
|
37
|
-
expect(assigns(:job)).to eq(job)
|
38
|
-
end
|
39
|
-
it 'returns the errors' do
|
40
|
-
expect(assigns(:slice_errors)).to eq(slice_errors)
|
41
|
-
end
|
42
|
-
it 'returns the first exception' do
|
43
|
-
expect(assigns(:failure_exception)).to eq(current_failure['exception'])
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with no slice errors' do
|
48
|
-
let(:slice_errors) { [] }
|
49
|
-
|
50
|
-
it 'succeeds' do
|
51
|
-
expect(response).to be_success
|
52
|
-
end
|
53
|
-
it 'returns the job' do
|
54
|
-
expect(assigns(:job)).to eq(job)
|
55
|
-
end
|
56
|
-
it 'returns no errors' do
|
57
|
-
expect(assigns(:slice_errors)).to eq(slice_errors)
|
58
|
-
end
|
59
|
-
it 'returns no exception' do
|
60
|
-
expect(assigns(:failure_exception)).to be_nil
|
61
|
-
end
|
62
|
-
it 'notifies the user' do
|
63
|
-
expect(flash[:notice]).to eq(I18n.t(:no_errors, scope: [:job, :failures]))
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "with a job that is not failed" do
|
69
|
-
let(:job) { spy(failed?: false, id: 42) }
|
70
|
-
|
71
|
-
before do
|
72
|
-
allow(RocketJob::Job).to receive(:find).and_return(job)
|
73
|
-
get :index, job_id: job.id
|
74
|
-
end
|
75
|
-
|
76
|
-
it "redirects to the job" do
|
77
|
-
expect(response).to redirect_to(job_path(job.id))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
module Jobs
|
5
|
-
RSpec.describe IndexFiltersController do
|
6
|
-
routes { Engine.routes }
|
7
|
-
|
8
|
-
states = %w(running paused completed aborted failed queued scheduled)
|
9
|
-
|
10
|
-
states.each_with_index do |state, i|
|
11
|
-
describe "GET ##{state}" do
|
12
|
-
describe "with no #{state} jobs" do
|
13
|
-
before do
|
14
|
-
get state.to_sym
|
15
|
-
end
|
16
|
-
|
17
|
-
it "succeeds" do
|
18
|
-
expect(response.status).to be(200)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'renders template' do
|
22
|
-
expect(response).to render_template(state)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns no jobs" do
|
26
|
-
expect(assigns(:jobs).count).to eq(0)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "with #{state} jobs" do
|
31
|
-
let(:not_state) { states[i-1] }
|
32
|
-
let(:state_job) {
|
33
|
-
if state == 'scheduled'
|
34
|
-
RocketJob::Job.create(state: :queued, run_at: Date.tomorrow)
|
35
|
-
else
|
36
|
-
RocketJob::Job.create(state: state)
|
37
|
-
end
|
38
|
-
}
|
39
|
-
|
40
|
-
before do
|
41
|
-
RocketJob::Job.create(state: not_state)
|
42
|
-
get state.to_sym
|
43
|
-
end
|
44
|
-
|
45
|
-
after do
|
46
|
-
RocketJob::Server.delete_all
|
47
|
-
RocketJob::Job.delete_all
|
48
|
-
end
|
49
|
-
|
50
|
-
it "succeeds" do
|
51
|
-
expect(response.status).to be(200)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'renders template' do
|
55
|
-
expect(response).to render_template(state)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "grabs a filtered list of rocket jobs" do
|
59
|
-
expect(assigns(:jobs)).to match_array([state_job])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,172 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.shared_examples "a jobs update controller" do
|
5
|
-
describe "with an invalid job id" do
|
6
|
-
before do
|
7
|
-
RocketJob::Job.delete_all
|
8
|
-
allow(RocketJob::Job).to receive(:find).and_return(nil)
|
9
|
-
do_action
|
10
|
-
end
|
11
|
-
|
12
|
-
it "redirects" do
|
13
|
-
expect(response).to redirect_to(jobs_path)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "adds a flash alert message" do
|
17
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:job, :find], id: 42))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
RSpec.describe JobsController do
|
23
|
-
routes { Engine.routes }
|
24
|
-
|
25
|
-
[:pause, :resume, :abort, :retry, :fail].each do |state|
|
26
|
-
describe "PATCH ##{state}" do
|
27
|
-
it_behaves_like "a jobs update controller" do
|
28
|
-
let(:do_action) { patch state, id: 42, job: {id: 42, priority: 12} }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "with a valid job id" do
|
32
|
-
let(:job) { spy(id: 42, to_param: 42) }
|
33
|
-
|
34
|
-
before do
|
35
|
-
allow(RocketJob::Job).to receive(:find).and_return(job)
|
36
|
-
patch state, id: 42, job: {id: 42, priority: 12}
|
37
|
-
end
|
38
|
-
|
39
|
-
it "redirects to the job" do
|
40
|
-
expect(response).to redirect_to(job_path(42))
|
41
|
-
end
|
42
|
-
|
43
|
-
it "transitions the job" do
|
44
|
-
expect(job).to have_received("#{state}!".to_sym)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'PATCH #run_now' do
|
51
|
-
let(:scheduled_job) { spy(id: 12, run_at: 2.days.from_now) }
|
52
|
-
|
53
|
-
before do
|
54
|
-
allow(RocketJob::Job).to receive(:find).and_return(scheduled_job)
|
55
|
-
patch :run_now, id: 12
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'redirects to the scheduled_jobs_path' do
|
59
|
-
expect(response).to redirect_to(scheduled_jobs_path)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'updates run_at' do
|
63
|
-
expect(scheduled_job).to have_received(:update_attribute).with(:run_at, nil)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
describe "PATCH #update" do
|
69
|
-
it_behaves_like "a jobs update controller" do
|
70
|
-
let(:do_action) { patch :update, id: 42, job: {id: 42, priority: 12} }
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "with a valid job id" do
|
74
|
-
let(:job) { spy(id: 42, to_param: 42) }
|
75
|
-
let(:job_sanitizer) { spy() }
|
76
|
-
|
77
|
-
before do
|
78
|
-
allow(RocketJob::Job).to receive(:find).and_return(job)
|
79
|
-
allow(JobSanitizer).to receive(:new).and_return(job_sanitizer)
|
80
|
-
patch :update, id: 42, job: {id: 42, priority: 12}
|
81
|
-
end
|
82
|
-
|
83
|
-
it "redirects to the job" do
|
84
|
-
expect(response).to redirect_to(job_path(42))
|
85
|
-
end
|
86
|
-
|
87
|
-
it "updates the job correctly" do
|
88
|
-
expect(job).to have_received(:update_attributes)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "calls sanitize" do
|
92
|
-
expect(job_sanitizer).to have_received(:sanitize)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "GET #show" do
|
98
|
-
let(:result) { spy(sort: []) }
|
99
|
-
|
100
|
-
before do
|
101
|
-
allow(RocketJob::Job).to receive(:limit).and_return(result)
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "with an invalid job id" do
|
105
|
-
before do
|
106
|
-
allow(RocketJob::Job).to receive(:find).and_return(nil)
|
107
|
-
get :show, id: 42
|
108
|
-
end
|
109
|
-
|
110
|
-
it "redirects" do
|
111
|
-
expect(response).to redirect_to(jobs_path)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "adds a flash alert message" do
|
115
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:job, :find], id: 42))
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "with a valid job id" do
|
120
|
-
before do
|
121
|
-
allow(RocketJob::Job).to receive(:find).and_return('job')
|
122
|
-
get :show, id: 42
|
123
|
-
end
|
124
|
-
|
125
|
-
it "succeeds" do
|
126
|
-
expect(response.status).to be(200)
|
127
|
-
end
|
128
|
-
|
129
|
-
it "assigns the job" do
|
130
|
-
expect(assigns(:job)).to be_present
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "GET #index" do
|
136
|
-
describe "with no jobs" do
|
137
|
-
before do
|
138
|
-
get :index
|
139
|
-
end
|
140
|
-
|
141
|
-
it "succeeds" do
|
142
|
-
expect(response.status).to be(200)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "returns no jobs" do
|
146
|
-
expect(assigns(:jobs).count).to eq(0)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "with jobs" do
|
151
|
-
let(:jobs) { ['fake_job1', 'fake_job2'] }
|
152
|
-
|
153
|
-
before do
|
154
|
-
allow(RocketJob::Job).to receive(:sort).and_return(jobs)
|
155
|
-
get :index
|
156
|
-
end
|
157
|
-
|
158
|
-
it "succeeds" do
|
159
|
-
expect(response.status).to be(200)
|
160
|
-
end
|
161
|
-
|
162
|
-
it "grabs a sorted list of rocket jobs" do
|
163
|
-
expect(RocketJob::Job).to have_received(:sort).with(_id: :desc)
|
164
|
-
end
|
165
|
-
|
166
|
-
it "returns the jobs" do
|
167
|
-
expect(assigns(:jobs)).to eq(jobs)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
module Servers
|
5
|
-
RSpec.describe IndexFiltersController do
|
6
|
-
routes { Engine.routes }
|
7
|
-
|
8
|
-
states = %w(starting running paused stopping)
|
9
|
-
|
10
|
-
states.each_with_index do |state, i|
|
11
|
-
describe "GET ##{state}" do
|
12
|
-
describe "with no #{state} servers" do
|
13
|
-
before do
|
14
|
-
get state.to_sym
|
15
|
-
end
|
16
|
-
|
17
|
-
it "succeeds" do
|
18
|
-
expect(response.status).to be(200)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'renders template' do
|
22
|
-
expect(response).to render_template(state)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns no jobs" do
|
26
|
-
expect(assigns(:servers).count).to eq(0)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "with #{state} servers" do
|
31
|
-
let(:not_state) { states[i-1] }
|
32
|
-
let!(:state_dirmon) { RocketJob::Server.create!(state: state) }
|
33
|
-
|
34
|
-
before do
|
35
|
-
RocketJob::Server.create!(state: not_state)
|
36
|
-
get state.to_sym
|
37
|
-
end
|
38
|
-
|
39
|
-
after do
|
40
|
-
RocketJob::Server.delete_all
|
41
|
-
end
|
42
|
-
|
43
|
-
it "succeeds" do
|
44
|
-
expect(response.status).to be(200)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'renders template' do
|
48
|
-
expect(response).to render_template(state)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "grabs a filtered list of servers" do
|
52
|
-
expect(assigns(:servers)).to match_array([state_dirmon])
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
module RocketJobMissionControl
|
4
|
-
RSpec.describe ServersController do
|
5
|
-
routes { Engine.routes }
|
6
|
-
|
7
|
-
[:stop, :pause, :resume].each do |server_action|
|
8
|
-
describe "PATCH ##{server_action}" do
|
9
|
-
describe "with a valid server id" do
|
10
|
-
let(:server) { spy(id: 42, to_param: 42) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
allow(RocketJob::Server).to receive(:find).and_return(server)
|
14
|
-
patch server_action, id: server.id
|
15
|
-
end
|
16
|
-
|
17
|
-
it "redirects to servers" do
|
18
|
-
expect(response).to redirect_to(servers_path)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "displays a flash message" do
|
22
|
-
expect(flash[:notice]).to eq(I18n.t(:success, scope: [:server, server_action]))
|
23
|
-
end
|
24
|
-
|
25
|
-
it "#{server_action} the server" do
|
26
|
-
expect(server).to have_received("#{server_action}!".to_sym)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "when the server fails to #{server_action}" do
|
31
|
-
before do
|
32
|
-
server = spy("#{server_action}!".to_sym => false)
|
33
|
-
allow(RocketJob::Server).to receive(:find).and_return(server)
|
34
|
-
patch server_action, id: server.id
|
35
|
-
end
|
36
|
-
|
37
|
-
it "redirects to servers" do
|
38
|
-
expect(response).to redirect_to(servers_path)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "displays a flash message" do
|
42
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:server, server_action]))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "PATCH #update_all" do
|
49
|
-
RocketJobMissionControl::ServersController::VALID_STATES.each do |server_action, action_message|
|
50
|
-
context "with '#{server_action}' as the server_action param" do
|
51
|
-
before do
|
52
|
-
allow(RocketJob::Server).to receive(server_action.to_sym)
|
53
|
-
patch :update_all, server_action: server_action
|
54
|
-
end
|
55
|
-
|
56
|
-
it "redirects to servers" do
|
57
|
-
expect(response).to redirect_to(servers_path)
|
58
|
-
end
|
59
|
-
it "displays a success message" do
|
60
|
-
state_message = I18n.t(:success, scope: [:server, :update_all], server_action: action_message)
|
61
|
-
expect(flash[:notice]).to eq(state_message)
|
62
|
-
end
|
63
|
-
it "does not display an error message" do
|
64
|
-
expect(flash[:alert]).to be_nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with an invalid server_action param" do
|
70
|
-
before do
|
71
|
-
patch :update_all, server_action: :bad_server_action
|
72
|
-
end
|
73
|
-
|
74
|
-
it "redirects to servers" do
|
75
|
-
expect(response).to redirect_to(servers_path)
|
76
|
-
end
|
77
|
-
it "does not display a success message" do
|
78
|
-
expect(flash[:notice]).to be_nil
|
79
|
-
end
|
80
|
-
it "displays an error message" do
|
81
|
-
expect(flash[:alert]).to eq(I18n.t(:invalid, scope: [:server, :update_all]))
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "DELETE #destroy" do
|
87
|
-
describe "with a valid server id" do
|
88
|
-
let(:server) { spy(id: 42, to_param: 42) }
|
89
|
-
|
90
|
-
before do
|
91
|
-
allow(RocketJob::Server).to receive(:find).and_return(server)
|
92
|
-
delete :destroy, id: server.id
|
93
|
-
end
|
94
|
-
|
95
|
-
it "redirects to servers" do
|
96
|
-
expect(response).to redirect_to(servers_path)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "displays a flash message" do
|
100
|
-
expect(flash[:notice]).to eq(I18n.t(:success, scope: [:server, :destroy]))
|
101
|
-
end
|
102
|
-
|
103
|
-
it "destroys the server" do
|
104
|
-
expect(server).to have_received(:destroy)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "when the server fails to be destroyed" do
|
109
|
-
before do
|
110
|
-
server = spy(destroy: false)
|
111
|
-
allow(RocketJob::Server).to receive(:find).and_return(server)
|
112
|
-
delete :destroy, id: server.id
|
113
|
-
end
|
114
|
-
|
115
|
-
it "redirects to servers" do
|
116
|
-
expect(response).to redirect_to(servers_path)
|
117
|
-
end
|
118
|
-
|
119
|
-
it "displays a flash message" do
|
120
|
-
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:server, :destroy]))
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|