naf 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +17 -0
- data/LICENSE +2 -0
- data/README.rdoc +22 -0
- data/RELEASE_NOTES.rdoc +18 -0
- data/Rakefile +43 -0
- data/app/assets/images/bg-grad.png +0 -0
- data/app/assets/images/clock.png +0 -0
- data/app/assets/images/control_play_blue.png +0 -0
- data/app/assets/images/down_arrow.gif +0 -0
- data/app/assets/images/papertrail_job.png +0 -0
- data/app/assets/images/papertrail_machine.png +0 -0
- data/app/assets/images/papertrail_machine_runner.png +0 -0
- data/app/assets/images/terminate.png +0 -0
- data/app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/ui-bg_flat_0_ffffff_40x100.png +0 -0
- data/app/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/images/ui-bg_glass_0_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_65_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/images/ui-bg_highlight-soft_0_f4f4f4_1x100.png +0 -0
- data/app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/images/up_arrow.gif +0 -0
- data/app/assets/javascripts/dataTablesTemplates/applications.js +94 -0
- data/app/assets/javascripts/dataTablesTemplates/jobs.js +163 -0
- data/app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js +60 -0
- data/app/assets/javascripts/dataTablesTemplates/machine_runners.js +82 -0
- data/app/assets/javascripts/dataTablesTemplates/machines.js +93 -0
- data/app/assets/javascripts/date.js +104 -0
- data/app/assets/javascripts/iso8601.js +41 -0
- data/app/assets/javascripts/jquery.dataTables.custom.js +62 -0
- data/app/assets/javascripts/jquery.dataTables.js +6862 -0
- data/app/assets/javascripts/naf.js +30 -0
- data/app/assets/javascripts/underscore.js +713 -0
- data/app/assets/stylesheets/jquery_ui/jquery-ui-1.8.5.custom.css.erb +572 -0
- data/app/assets/stylesheets/min_naf.css +14 -0
- data/app/assets/stylesheets/min_naf/layout.css.scss +355 -0
- data/app/assets/stylesheets/naf.css +14 -0
- data/app/assets/stylesheets/naf/layout.css.scss +497 -0
- data/app/controllers/naf/affinities_controller.rb +61 -0
- data/app/controllers/naf/application_controller.rb +43 -0
- data/app/controllers/naf/application_schedule_affinity_tabs_controller.rb +75 -0
- data/app/controllers/naf/applications_controller.rb +153 -0
- data/app/controllers/naf/historical_job_affinity_tabs_controller.rb +65 -0
- data/app/controllers/naf/historical_jobs_controller.rb +159 -0
- data/app/controllers/naf/janitorial_assignments_controller.rb +77 -0
- data/app/controllers/naf/logger_names_controller.rb +58 -0
- data/app/controllers/naf/logger_styles_controller.rb +59 -0
- data/app/controllers/naf/machine_affinity_slots_controller.rb +69 -0
- data/app/controllers/naf/machine_runner_invocations_controller.rb +59 -0
- data/app/controllers/naf/machine_runners_controller.rb +26 -0
- data/app/controllers/naf/machines_controller.rb +95 -0
- data/app/helpers/naf/application_helper.rb +275 -0
- data/app/models/log4r/papertrail_outputter.rb +19 -0
- data/app/models/logical/naf/application.rb +183 -0
- data/app/models/logical/naf/construction_zone/ad_hoc_work_order.rb +22 -0
- data/app/models/logical/naf/construction_zone/application_schedule_work_order.rb +15 -0
- data/app/models/logical/naf/construction_zone/application_work_order.rb +25 -0
- data/app/models/logical/naf/construction_zone/boss.rb +123 -0
- data/app/models/logical/naf/construction_zone/foreman.rb +53 -0
- data/app/models/logical/naf/construction_zone/proletariat.rb +40 -0
- data/app/models/logical/naf/construction_zone/work_order.rb +100 -0
- data/app/models/logical/naf/create_infrastructure.rb +48 -0
- data/app/models/logical/naf/job.rb +357 -0
- data/app/models/logical/naf/job_creator.rb +155 -0
- data/app/models/logical/naf/job_fetcher.rb +167 -0
- data/app/models/logical/naf/job_statuses/errored.rb +27 -0
- data/app/models/logical/naf/job_statuses/finished.rb +26 -0
- data/app/models/logical/naf/job_statuses/finished_less_minute.rb +25 -0
- data/app/models/logical/naf/job_statuses/queued.rb +32 -0
- data/app/models/logical/naf/job_statuses/running.rb +34 -0
- data/app/models/logical/naf/job_statuses/terminated.rb +25 -0
- data/app/models/logical/naf/job_statuses/waiting.rb +43 -0
- data/app/models/logical/naf/machine.rb +85 -0
- data/app/models/logical/naf/machine_runner.rb +46 -0
- data/app/models/logical/naf/machine_runner_invocation.rb +50 -0
- data/app/models/logical/naf/pickler.rb +74 -0
- data/app/models/logical/naf/unpickler.rb +98 -0
- data/app/models/naf/affinity.rb +145 -0
- data/app/models/naf/affinity_classification.rb +44 -0
- data/app/models/naf/application.rb +100 -0
- data/app/models/naf/application_run_group_restriction.rb +39 -0
- data/app/models/naf/application_schedule.rb +181 -0
- data/app/models/naf/application_schedule_affinity_tab.rb +86 -0
- data/app/models/naf/application_schedule_prerequisite.rb +50 -0
- data/app/models/naf/application_type.rb +72 -0
- data/app/models/naf/by_historical_job_id.rb +86 -0
- data/app/models/naf/historical_job.rb +334 -0
- data/app/models/naf/historical_job_affinity_tab.rb +61 -0
- data/app/models/naf/historical_job_prerequisite.rb +19 -0
- data/app/models/naf/janitorial_archive_assignment.rb +36 -0
- data/app/models/naf/janitorial_assignment.rb +37 -0
- data/app/models/naf/janitorial_create_assignment.rb +36 -0
- data/app/models/naf/janitorial_drop_assignment.rb +36 -0
- data/app/models/naf/logger_level.rb +21 -0
- data/app/models/naf/logger_name.rb +23 -0
- data/app/models/naf/logger_style.rb +58 -0
- data/app/models/naf/logger_style_name.rb +28 -0
- data/app/models/naf/machine.rb +257 -0
- data/app/models/naf/machine_affinity_slot.rb +78 -0
- data/app/models/naf/machine_runner.rb +51 -0
- data/app/models/naf/machine_runner_invocation.rb +71 -0
- data/app/models/naf/naf_base.rb +9 -0
- data/app/models/naf/queued_job.rb +164 -0
- data/app/models/naf/running_job.rb +80 -0
- data/app/models/process/naf/application.rb +164 -0
- data/app/models/process/naf/janitor.rb +117 -0
- data/app/models/process/naf/machine_manager.rb +150 -0
- data/app/models/process/naf/machine_upgrader.rb +112 -0
- data/app/models/process/naf/runner.rb +539 -0
- data/app/views/naf/affinities/_form.html.erb +50 -0
- data/app/views/naf/affinities/edit.html.erb +11 -0
- data/app/views/naf/affinities/index.html.erb +57 -0
- data/app/views/naf/affinities/new.html.erb +15 -0
- data/app/views/naf/affinities/show.html.erb +48 -0
- data/app/views/naf/application_schedule_affinity_tabs/_form.html.erb +31 -0
- data/app/views/naf/application_schedule_affinity_tabs/edit.html.erb +12 -0
- data/app/views/naf/application_schedule_affinity_tabs/new.html.erb +11 -0
- data/app/views/naf/applications/_application_schedule.html.erb +80 -0
- data/app/views/naf/applications/_application_schedule_prerequisites.html.erb +14 -0
- data/app/views/naf/applications/_form.html.erb +109 -0
- data/app/views/naf/applications/_search_container.html.erb +94 -0
- data/app/views/naf/applications/_show.html.erb +34 -0
- data/app/views/naf/applications/edit.html.erb +11 -0
- data/app/views/naf/applications/index.html.erb +51 -0
- data/app/views/naf/applications/index.json.erb +11 -0
- data/app/views/naf/applications/new.html.erb +11 -0
- data/app/views/naf/applications/show.html.erb +203 -0
- data/app/views/naf/datatable.html.erb +49 -0
- data/app/views/naf/historical_job_affinity_tabs/_form.html.erb +36 -0
- data/app/views/naf/historical_job_affinity_tabs/edit.html.erb +11 -0
- data/app/views/naf/historical_job_affinity_tabs/new.html.erb +11 -0
- data/app/views/naf/historical_jobs/_form.html.erb +94 -0
- data/app/views/naf/historical_jobs/_runners.html.erb +22 -0
- data/app/views/naf/historical_jobs/_search_container.html.erb +140 -0
- data/app/views/naf/historical_jobs/edit.html.erb +11 -0
- data/app/views/naf/historical_jobs/index.html.erb +48 -0
- data/app/views/naf/historical_jobs/index.json.erb +26 -0
- data/app/views/naf/historical_jobs/new.html.erb +61 -0
- data/app/views/naf/historical_jobs/show.html.erb +201 -0
- data/app/views/naf/janitorial_assignments/_form.html.erb +38 -0
- data/app/views/naf/janitorial_assignments/_rows.html.erb +17 -0
- data/app/views/naf/janitorial_assignments/edit.html.erb +11 -0
- data/app/views/naf/janitorial_assignments/index.html.erb +56 -0
- data/app/views/naf/janitorial_assignments/index.js.erb +1 -0
- data/app/views/naf/janitorial_assignments/new.html.erb +11 -0
- data/app/views/naf/layouts/jquery_datatables.json.erb +6 -0
- data/app/views/naf/logger_names/_form.html.erb +18 -0
- data/app/views/naf/logger_names/edit.html.erb +11 -0
- data/app/views/naf/logger_names/new.html.erb +11 -0
- data/app/views/naf/logger_names/show.html.erb +44 -0
- data/app/views/naf/logger_styles/_form.html.erb +30 -0
- data/app/views/naf/logger_styles/_logger_style_names.html.erb +19 -0
- data/app/views/naf/logger_styles/edit.html.erb +11 -0
- data/app/views/naf/logger_styles/new.html.erb +11 -0
- data/app/views/naf/logger_styles/show.html.erb +48 -0
- data/app/views/naf/machine_affinity_slots/_form.html.erb +36 -0
- data/app/views/naf/machine_affinity_slots/edit.html.erb +11 -0
- data/app/views/naf/machine_affinity_slots/new.html.erb +11 -0
- data/app/views/naf/machine_runner_invocations/_filter.html.erb +21 -0
- data/app/views/naf/machine_runner_invocations/index.html.erb +36 -0
- data/app/views/naf/machine_runner_invocations/index.json.erb +16 -0
- data/app/views/naf/machine_runner_invocations/show.html.erb +91 -0
- data/app/views/naf/machine_runners/index.html.erb +82 -0
- data/app/views/naf/machine_runners/index.json.erb +16 -0
- data/app/views/naf/machine_runners/show.html.erb +113 -0
- data/app/views/naf/machines/_filter.html.erb +26 -0
- data/app/views/naf/machines/_form.html.erb +62 -0
- data/app/views/naf/machines/_show.html.erb +169 -0
- data/app/views/naf/machines/edit.html.erb +11 -0
- data/app/views/naf/machines/index.html.erb +51 -0
- data/app/views/naf/machines/index.json.erb +23 -0
- data/app/views/naf/machines/new.html.erb +11 -0
- data/app/views/naf/machines/show.html.erb +92 -0
- data/app/views/naf/record.html.erb +46 -0
- data/app/views/naf/shared/_application.html.erb +50 -0
- data/app/views/naf/shared/_information_container.html.erb +19 -0
- data/app/views/naf/shared/_select_per_page.html.erb +72 -0
- data/ci/test-build.sh +17 -0
- data/ci/travis.sh +26 -0
- data/config/initializers/naf.rb +3 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20120820023848_naf_schema.rb +413 -0
- data/doc/README_FOR_APP +2 -0
- data/lib/generators/naf_generator.rb +45 -0
- data/lib/generators/templates/config/logging/af.yml +26 -0
- data/lib/generators/templates/config/logging/naf.yml +22 -0
- data/lib/generators/templates/config/logging/nafjob.yml +16 -0
- data/lib/generators/templates/config/logging/nafrunner.yml +17 -0
- data/lib/generators/templates/naf.rb +11 -0
- data/lib/generators/templates/naf_layout.html.erb +15 -0
- data/lib/naf.rb +48 -0
- data/lib/naf/configuration.rb +23 -0
- data/lib/naf/engine.rb +18 -0
- data/lib/naf/version.rb +3 -0
- data/lib/tasks/naf_tasks.rake +370 -0
- data/naf.gemspec +30 -0
- data/script/rails +10 -0
- data/spec/controllers/naf/affinities_controller_spec.rb +79 -0
- data/spec/controllers/naf/application_controller_spec.rb +10 -0
- data/spec/controllers/naf/application_schedule_affinity_tabs_controller_spec.rb +106 -0
- data/spec/controllers/naf/applications_controller_spec.rb +109 -0
- data/spec/controllers/naf/historical_job_affinity_tabs_controller_spec.rb +96 -0
- data/spec/controllers/naf/historical_jobs_controller_spec.rb +19 -0
- data/spec/controllers/naf/machine_affinity_slots_controller_spec.rb +109 -0
- data/spec/controllers/naf/machines_controller_spec.rb +74 -0
- data/spec/dummy/.gitignore +12 -0
- data/spec/dummy/README +19 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +14 -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/models/my_script.rb +8 -0
- data/spec/dummy/app/models/other/base.rb.sample +10 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/naf_layout.html.erb +15 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database-non_primary.yml +20 -0
- data/spec/dummy/config/database-primary.yml +16 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/naf.rb.non_primary +4 -0
- data/spec/dummy/config/initializers/naf.rb.primary +3 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/logging/af.yml +26 -0
- data/spec/dummy/config/logging/naf.yml +22 -0
- data/spec/dummy/config/logging/nafjob.yml +16 -0
- data/spec/dummy/config/logging/nafrunner.yml +17 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/.gitignore +2 -0
- data/spec/dummy/lib/tasks/dummy.rake +60 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/naf.rb +433 -0
- data/spec/helpers/naf/application_helper_spec.rb +0 -0
- data/spec/models/logical/naf/application_spec.rb +69 -0
- data/spec/models/logical/naf/job_creator_spec.rb +32 -0
- data/spec/models/logical/naf/job_fetcher_spec.rb +140 -0
- data/spec/models/logical/naf/job_spec.rb +282 -0
- data/spec/models/logical/naf/machine_spec.rb +61 -0
- data/spec/models/naf/affinity_classification_spec.rb +56 -0
- data/spec/models/naf/affinity_spec.rb +100 -0
- data/spec/models/naf/application_run_group_restriction_spec.rb +57 -0
- data/spec/models/naf/application_schedule_affinity_tab_spec.rb +85 -0
- data/spec/models/naf/application_schedule_prerequisite_spec.rb +35 -0
- data/spec/models/naf/application_schedule_spec.rb +166 -0
- data/spec/models/naf/application_spec.rb +128 -0
- data/spec/models/naf/application_type_spec.rb +104 -0
- data/spec/models/naf/historical_job_affinity_tab_spec.rb +59 -0
- data/spec/models/naf/historical_job_prerequisite_spec.rb +25 -0
- data/spec/models/naf/historical_job_spec.rb +334 -0
- data/spec/models/naf/logger_level_spec.rb +34 -0
- data/spec/models/naf/logger_name_spec.rb +35 -0
- data/spec/models/naf/logger_style_name_spec.rb +39 -0
- data/spec/models/naf/logger_style_spec.rb +89 -0
- data/spec/models/naf/machine_affinity_slot_spec.rb +77 -0
- data/spec/models/naf/machine_runner_invocation_spec.rb +38 -0
- data/spec/models/naf/machine_runner_spec.rb +37 -0
- data/spec/models/naf/machine_spec.rb +425 -0
- data/spec/models/naf/naf_base_spec.rb +14 -0
- data/spec/models/naf/queued_job_spec.rb +171 -0
- data/spec/models/naf/running_job_spec.rb +107 -0
- data/spec/models/process/naf/application_spec.rb +8 -0
- data/spec/models/process/naf/janitor_spec.rb +10 -0
- data/spec/models/process/naf/runner_spec.rb +10 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/engine_routing.rb +27 -0
- data/spec/support/script_spec_helper.rb +58 -0
- metadata +590 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Naf
|
4
|
+
describe HistoricalJobsController do
|
5
|
+
it "should respond with the index action" do
|
6
|
+
get :index
|
7
|
+
response.should render_template("naf/historical_jobs/index")
|
8
|
+
response.should be_success
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should respond with the show action" do
|
12
|
+
id = 5
|
13
|
+
Naf::HistoricalJob.should_receive(:find).with("5").and_return(nil)
|
14
|
+
Logical::Naf::Job.should_receive(:new).and_return(nil)
|
15
|
+
get :show, id: id
|
16
|
+
response.should be_success
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Naf
|
4
|
+
describe MachineAffinitySlotsController do
|
5
|
+
|
6
|
+
let(:model_class) { MachineAffinitySlot}
|
7
|
+
|
8
|
+
it "should respond with index action nested under machine" do
|
9
|
+
model_class.should_receive(:where).with({ machine_id: "1" }).and_return([])
|
10
|
+
get :index, machine_id: 1
|
11
|
+
response.should render_template("naf/datatable")
|
12
|
+
response.should be_success
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should respond with the show action" do
|
16
|
+
Machine.should_receive(:find).with("1").and_return(nil)
|
17
|
+
model_class.should_receive(:find).with("5").and_return(nil)
|
18
|
+
get :show, id: 5, machine_id: 1
|
19
|
+
response.should render_template("naf/record")
|
20
|
+
response.should be_success
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should respond with the destroy action and redirect to nested index" do
|
24
|
+
slot = mock_model(model_class, machine_id: 1, id: 5)
|
25
|
+
machine = mock_model(Machine, id: 1)
|
26
|
+
Machine.should_receive(:find).with("1").and_return(machine)
|
27
|
+
model_class.should_receive(:find).with("5").and_return(slot)
|
28
|
+
slot.stub(:affinity_name).and_return("Test Name")
|
29
|
+
delete :destroy, id: 5, machine_id: 1
|
30
|
+
index_path = machine_machine_affinity_slots_path(machine)
|
31
|
+
response.should redirect_to(index_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should respond with the edit action" do
|
35
|
+
Machine.should_receive(:find).with("1").and_return(nil)
|
36
|
+
model_class.should_receive(:find).with("5").and_return(nil)
|
37
|
+
get :edit, id: 5, machine_id: 1
|
38
|
+
response.should render_template("naf/machine_affinity_slots/edit")
|
39
|
+
response.should be_success
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should respond with the new action" do
|
43
|
+
Machine.should_receive(:find).with("1").and_return(nil)
|
44
|
+
model_class.should_receive(:new).and_return(nil)
|
45
|
+
get :new, machine_id: 1
|
46
|
+
response.should render_template("naf/machine_affinity_slots/new")
|
47
|
+
response.should be_success
|
48
|
+
end
|
49
|
+
|
50
|
+
context "on the create action" do
|
51
|
+
let(:valid_slot) { mock_model(model_class, save: true, id: 5, machine_id: 1)}
|
52
|
+
let(:invalid_slot) { mock_model(model_class, save: false) }
|
53
|
+
let(:machine) { mock_model(Machine, id: 1) }
|
54
|
+
|
55
|
+
subject do
|
56
|
+
post :create, machine_affinity_slot: { machine_id: 1 }, machine_id: 1
|
57
|
+
end
|
58
|
+
|
59
|
+
before(:each) do
|
60
|
+
Machine.should_receive(:find).with("1").and_return(machine)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should redirect to show when valid" do
|
64
|
+
model_class.should_receive(:new).and_return(valid_slot)
|
65
|
+
valid_slot.stub(:affinity_name).and_return("Test Name")
|
66
|
+
path = machine_machine_affinity_slot_path(machine, valid_slot)
|
67
|
+
subject.should redirect_to(path)
|
68
|
+
end
|
69
|
+
it "should re-render to new when invalid" do
|
70
|
+
model_class.should_receive(:new).and_return(invalid_slot)
|
71
|
+
subject.should render_template("naf/machine_affinity_slots/new")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "on the update action" do
|
76
|
+
let(:valid_slot) { mock_model(model_class, update_attributes: true, id: 5, machine_id: 1) }
|
77
|
+
let(:invalid_slot) { mock_model(model_class, update_attributes: false, id: 5, machine_id: 1) }
|
78
|
+
let(:machine) { mock_model(Machine, id: 1) }
|
79
|
+
|
80
|
+
subject do
|
81
|
+
put :update, machine_affinity_slot: { machine_id: 1 }, id: 5, machine_id: 1
|
82
|
+
end
|
83
|
+
|
84
|
+
before(:each) do
|
85
|
+
Machine.should_receive(:find).with(1).and_return(machine)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should redirect to show when valid" do
|
89
|
+
model_class.should_receive(:find).and_return(valid_slot)
|
90
|
+
valid_slot.stub(:affinity_name).and_return("Test Name")
|
91
|
+
path = machine_machine_affinity_slot_path(machine, valid_slot)
|
92
|
+
subject.should redirect_to(path)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should re-render to edit when invalid" do
|
96
|
+
model_class.should_receive(:find).and_return(invalid_slot)
|
97
|
+
subject.should render_template("naf/machine_affinity_slots/edit")
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
# Ensure that some instance variables are set
|
103
|
+
after(:each) do
|
104
|
+
cols = assigns(:cols)
|
105
|
+
attributes = assigns(:attributes)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Naf
|
4
|
+
describe MachinesController do
|
5
|
+
|
6
|
+
it "should respond with the index action" do
|
7
|
+
get :index
|
8
|
+
response.should render_template("naf/machines/index")
|
9
|
+
response.should be_success
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should respond with the show action" do
|
13
|
+
id = 5
|
14
|
+
Machine.should_receive(:find).with("5").and_return(nil)
|
15
|
+
get :show, id: id
|
16
|
+
response.should be_success
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should respond with the edit action" do
|
20
|
+
id = 5
|
21
|
+
Machine.should_receive(:find).with("5").and_return(nil)
|
22
|
+
get :edit, id: id
|
23
|
+
response.should render_template("naf/machines/edit")
|
24
|
+
response.should be_success
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should respond with affinity new" do
|
28
|
+
Machine.should_receive(:new).and_return(nil)
|
29
|
+
get :new
|
30
|
+
response.should render_template("naf/machines/new")
|
31
|
+
response.should be_success
|
32
|
+
end
|
33
|
+
|
34
|
+
context "on the create action" do
|
35
|
+
let(:valid_machine) { mock_model(Machine, save: true, id: 5) }
|
36
|
+
let(:invalid_machine) { mock_model(Machine, save: false) }
|
37
|
+
|
38
|
+
it "should redirect to show when valid" do
|
39
|
+
Machine.should_receive(:new).and_return(valid_machine)
|
40
|
+
post :create, machine: {}
|
41
|
+
response.should redirect_to(machine_path(valid_machine.id))
|
42
|
+
end
|
43
|
+
it "should re-render to new when invalid" do
|
44
|
+
Machine.should_receive(:new).and_return(invalid_machine)
|
45
|
+
post :create, machine: {}
|
46
|
+
response.should render_template("naf/machines/new")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "on the updated action" do
|
51
|
+
let(:valid_machine) { mock_model(Machine, update_attributes: true, id: 5) }
|
52
|
+
let(:invalid_machine) { mock_model(Machine, update_attributes: false, id: 5) }
|
53
|
+
|
54
|
+
it "should redirect to show when valid" do
|
55
|
+
Machine.should_receive(:find).with("5").and_return(valid_machine)
|
56
|
+
post :update, id: 5, machine: {}
|
57
|
+
response.should redirect_to(machine_path(valid_machine.id))
|
58
|
+
end
|
59
|
+
it "should re-render to new when invalid" do
|
60
|
+
Machine.should_receive(:find).and_return(invalid_machine)
|
61
|
+
post :update, id: 5, machine: {}
|
62
|
+
response.should render_template("naf/machines/edit")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# Ensure that some instance variables are set
|
68
|
+
after(:each) do
|
69
|
+
cols = assigns(:cols)
|
70
|
+
attributes = assigns(:attributes)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
data/spec/dummy/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Dummy project for Naf: Network Application Framework
|
2
|
+
=================================
|
3
|
+
|
4
|
+
This example shows how the gem works.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
============
|
8
|
+
|
9
|
+
Go to the "project_path/spec/dummy" in your console:
|
10
|
+
|
11
|
+
1) Edit 'config/database.yml'
|
12
|
+
|
13
|
+
2) Run "rake db:create"
|
14
|
+
|
15
|
+
3) Run "rake db:migrate"
|
16
|
+
|
17
|
+
4) Run "rails server"
|
18
|
+
|
19
|
+
5) Paste this line "localhost:3000/job_system/"
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,16 @@
|
|
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 vendor/assets/javascripts of plugins, if any, 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
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require naf
|
15
|
+
//= require jquery_ujs
|
16
|
+
//= require_tree .
|
@@ -0,0 +1,14 @@
|
|
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require naf
|
13
|
+
*= require_tree .
|
14
|
+
*/
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Other
|
2
|
+
class Base < ActiveRecord::Base
|
3
|
+
establish_connection "naf_#{Rails.env}"
|
4
|
+
self.abstract_class = true
|
5
|
+
def self.reset_warehousing_connection
|
6
|
+
self.connection.disconnect!
|
7
|
+
self.establish_connection "warehousing_#{Rails.env}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= yield :javascripts %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Naf - a Rails Job Scheduling Engine</title>
|
5
|
+
<%= stylesheet_link_tag "naf", media: "all" %>
|
6
|
+
<%= javascript_include_tag "naf" %>
|
7
|
+
<%= yield :javascripts %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "active_resource/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
Bundler.require
|
12
|
+
require "naf"
|
13
|
+
|
14
|
+
module Dummy
|
15
|
+
class Application < Rails::Application
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
17
|
+
# Application configuration should go into files in config/initializers
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
19
|
+
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
26
|
+
|
27
|
+
# Activate observers that should always be running.
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
29
|
+
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
33
|
+
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
36
|
+
# config.i18n.default_locale = :de
|
37
|
+
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
39
|
+
config.encoding = "utf-8"
|
40
|
+
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
42
|
+
config.filter_parameters += [:password]
|
43
|
+
|
44
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
45
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
46
|
+
# like if you have constraints or database-specific column types
|
47
|
+
config.active_record.schema_format = :sql
|
48
|
+
|
49
|
+
# Enforce whitelist mode for mass assignment.
|
50
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
51
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
52
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
53
|
+
config.active_record.whitelist_attributes = true
|
54
|
+
|
55
|
+
# Enable the asset pipeline
|
56
|
+
config.assets.enabled = true
|
57
|
+
|
58
|
+
# Version of your assets, change this if you want to expire all your assets
|
59
|
+
config.assets.version = '1.0'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
common: &common
|
2
|
+
adapter: postgresql
|
3
|
+
username: postgres
|
4
|
+
encoding: UTF8
|
5
|
+
|
6
|
+
development:
|
7
|
+
<<: *common
|
8
|
+
database: main_development
|
9
|
+
|
10
|
+
test:
|
11
|
+
<<: *common
|
12
|
+
database: main_test
|
13
|
+
|
14
|
+
naf_development:
|
15
|
+
<<: *common
|
16
|
+
database: naf_development
|
17
|
+
|
18
|
+
naf_test:
|
19
|
+
<<: *common
|
20
|
+
database: naf_test
|