naf 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/naf.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
|
|
3
|
+
# Maintain your gem's version:
|
|
4
|
+
require "naf/version"
|
|
5
|
+
|
|
6
|
+
# Describe your gem and declare its dependencies:
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = "naf"
|
|
9
|
+
s.version = Naf::VERSION
|
|
10
|
+
s.license = 'New BSD License'
|
|
11
|
+
s.date = '2013-10-11'
|
|
12
|
+
s.summary = "Creates infrastructure for a customizable and robust Postgres-backed script scheduling/running"
|
|
13
|
+
s.description = "Infrastructure includes abstractions for machines, runners, affinities, easily importable to any Rails app"
|
|
14
|
+
s.authors = ["Keith Gabryelski", "Leonardo Meira", "Nathaniel Lim", "Aleksandr Dembskiy"]
|
|
15
|
+
s.email = ['keith@fiksu.com', 'lmeira@fiksu.com']
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.homepage = 'http://github.com/fiksu/naf'
|
|
19
|
+
|
|
20
|
+
s.add_dependency "rails", ">= 3.2"
|
|
21
|
+
s.add_dependency "partitioned"
|
|
22
|
+
s.add_dependency "log4r_remote_syslog_outputter", ">= 0.0.1"
|
|
23
|
+
s.add_dependency "jquery-rails"
|
|
24
|
+
s.add_dependency 'will_paginate'
|
|
25
|
+
s.add_dependency 'facter'
|
|
26
|
+
s.add_development_dependency "pg"
|
|
27
|
+
s.add_development_dependency "rspec-rails"
|
|
28
|
+
s.add_development_dependency "factory_girl_rails", "~> 4.0.0"
|
|
29
|
+
s.add_development_dependency 'awesome_print'
|
|
30
|
+
end
|
data/script/rails
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/naf/engine', __FILE__)
|
|
6
|
+
|
|
7
|
+
require 'rails/all'
|
|
8
|
+
require 'rails/engine/commands'
|
|
9
|
+
|
|
10
|
+
load File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe AffinitiesController do
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
it "should respond with the affinity index" do
|
|
8
|
+
Affinity.should_receive(:all).and_return([])
|
|
9
|
+
get :index
|
|
10
|
+
response.should be_success
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should respond with the affinity show" do
|
|
14
|
+
id = 5
|
|
15
|
+
Affinity.should_receive(:find).with("5").and_return(nil)
|
|
16
|
+
get :show, id: id
|
|
17
|
+
response.should be_success
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should respond with affinity edit" do
|
|
21
|
+
id = 5
|
|
22
|
+
Affinity.should_receive(:find).with("5").and_return(nil)
|
|
23
|
+
get :edit, id: id
|
|
24
|
+
response.should render_template("naf/affinities/edit")
|
|
25
|
+
response.should be_success
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should respond with affinity new" do
|
|
29
|
+
Affinity.should_receive(:new).and_return(nil)
|
|
30
|
+
get :new
|
|
31
|
+
response.should render_template("naf/affinities/new")
|
|
32
|
+
response.should be_success
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
context "on the create action" do
|
|
37
|
+
let(:valid_affinity) { mock_model(Affinity, save: true, id: 5, validate_affinity_name: nil) }
|
|
38
|
+
let(:invalid_affinity) { mock_model(Affinity, save: false, validate_affinity_name: nil) }
|
|
39
|
+
|
|
40
|
+
it "should redirect to show when valid" do
|
|
41
|
+
Affinity.should_receive(:new).and_return(valid_affinity)
|
|
42
|
+
post :create, affinity: {}
|
|
43
|
+
response.should redirect_to(affinity_path(valid_affinity.id))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should re-render to new when invalid" do
|
|
47
|
+
Affinity.should_receive(:new).and_return(invalid_affinity)
|
|
48
|
+
post :create, affinity: {}
|
|
49
|
+
response.should render_template("naf/affinities/new")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "on the updated action" do
|
|
54
|
+
let(:valid_affinity) { mock_model(Affinity, update_attributes: true, id: 5) }
|
|
55
|
+
let(:invalid_affinity) { mock_model(Affinity, update_attributes: false, id: 5) }
|
|
56
|
+
|
|
57
|
+
it "should redirect to show when valid" do
|
|
58
|
+
Affinity.should_receive(:find).with("5").and_return(valid_affinity)
|
|
59
|
+
post :update, id: 5, affinity: {}
|
|
60
|
+
response.should redirect_to(affinity_path(valid_affinity.id))
|
|
61
|
+
end
|
|
62
|
+
it "should re-render to new when invalid" do
|
|
63
|
+
Affinity.should_receive(:find).and_return(invalid_affinity)
|
|
64
|
+
post :update, id: 5, affinity: {}
|
|
65
|
+
response.should render_template("naf/affinities/edit")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Ensure that some instance variables are set
|
|
70
|
+
after(:each) do
|
|
71
|
+
cols = assigns(:cols)
|
|
72
|
+
attributes = assigns(:attributes)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe ApplicationScheduleAffinityTabsController do
|
|
5
|
+
|
|
6
|
+
let(:model_class) { ApplicationScheduleAffinityTab }
|
|
7
|
+
|
|
8
|
+
it "should respond with index action nested under application schedule" do
|
|
9
|
+
model_class.should_receive(:where).with({ application_schedule_id: "1" }).and_return([])
|
|
10
|
+
get :index, application_schedule_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
|
+
model_class.should_receive(:find).with("5").and_return(nil)
|
|
17
|
+
schedule = double('schedule')
|
|
18
|
+
schedule.should_receive(:application).and_return(nil)
|
|
19
|
+
ApplicationSchedule.should_receive(:find).with("1").and_return(schedule)
|
|
20
|
+
get :show, id: 5, application_schedule_id: 1
|
|
21
|
+
response.should render_template("naf/record")
|
|
22
|
+
response.should be_success
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should respond with the edit action" do
|
|
26
|
+
model_class.should_receive(:find).with("5").and_return(nil)
|
|
27
|
+
schedule = double('schedule')
|
|
28
|
+
schedule.should_receive(:application).and_return(nil)
|
|
29
|
+
ApplicationSchedule.should_receive(:find).with("1").and_return(schedule)
|
|
30
|
+
get :edit, id: 5, application_schedule_id: 1
|
|
31
|
+
response.should render_template("naf/application_schedule_affinity_tabs/edit")
|
|
32
|
+
response.should be_success
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should respond with the new action" do
|
|
36
|
+
model_class.should_receive(:new).and_return(nil)
|
|
37
|
+
schedule = double('schedule')
|
|
38
|
+
schedule.should_receive(:application).and_return(nil)
|
|
39
|
+
ApplicationSchedule.should_receive(:find).with("1").and_return(schedule)
|
|
40
|
+
get :new, id: 5, application_schedule_id: 1
|
|
41
|
+
response.should render_template("naf/application_schedule_affinity_tabs/new")
|
|
42
|
+
response.should be_success
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "on the create action" do
|
|
46
|
+
let(:valid_tab) { mock_model(model_class, save: true, id: 5, application_schedule_id: 1, application_id: 1) }
|
|
47
|
+
let(:invalid_tab) { mock_model(model_class, save: false) }
|
|
48
|
+
let(:schedule) { mock_model(ApplicationSchedule, id: 1) }
|
|
49
|
+
let(:application) { mock_model(Application, id: 1) }
|
|
50
|
+
|
|
51
|
+
subject do
|
|
52
|
+
post :create, application_schedule_id: 1, application_id: 1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
before(:each) do
|
|
56
|
+
Application.should_receive(:find).with("1").and_return(application)
|
|
57
|
+
ApplicationSchedule.should_receive(:find).with("1").and_return(schedule)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should redirect to show when valid" do
|
|
61
|
+
model_class.should_receive(:new).and_return(valid_tab)
|
|
62
|
+
valid_tab.stub(:affinity_name).and_return("Test Name")
|
|
63
|
+
path = application_application_schedule_application_schedule_affinity_tab_path(application, schedule, valid_tab)
|
|
64
|
+
subject.should redirect_to(path)
|
|
65
|
+
end
|
|
66
|
+
it "should re-render to new when invalid" do
|
|
67
|
+
model_class.should_receive(:new).and_return(invalid_tab)
|
|
68
|
+
subject.should render_template("naf/application_schedule_affinity_tabs/new")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context "on the update action" do
|
|
73
|
+
let(:valid_tab) { mock_model(model_class, update_attributes: true, id: 5, application_schedule_id: 1, application_id: 1) }
|
|
74
|
+
let(:invalid_tab) { mock_model(model_class, update_attributes: false, id: 5, application_schedule_id: 1, application_id: 1) }
|
|
75
|
+
let(:schedule) { mock_model(ApplicationSchedule, id: 1) }
|
|
76
|
+
let(:application) { mock_model(Application, id: 1) }
|
|
77
|
+
|
|
78
|
+
subject do
|
|
79
|
+
put :update, application_schedule_id: 1, application_id: 1, id: 5
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
before(:each) do
|
|
83
|
+
Application.should_receive(:find).with("1").and_return(application)
|
|
84
|
+
ApplicationSchedule.should_receive(:find).with("1").and_return(schedule)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should redirect to show when valid" do
|
|
88
|
+
model_class.should_receive(:find).and_return(valid_tab)
|
|
89
|
+
valid_tab.stub(:affinity_name).and_return("Test Name")
|
|
90
|
+
path = application_application_schedule_application_schedule_affinity_tab_path(application, schedule, valid_tab)
|
|
91
|
+
subject.should redirect_to(path)
|
|
92
|
+
end
|
|
93
|
+
it "should re-render to edit when invalid" do
|
|
94
|
+
model_class.should_receive(:find).and_return(invalid_tab)
|
|
95
|
+
subject.should render_template("naf/application_schedule_affinity_tabs/edit")
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Ensure that some instance variables are set
|
|
100
|
+
after(:each) do
|
|
101
|
+
cols = assigns(:cols)
|
|
102
|
+
attributes = assigns(:attributes)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe ApplicationsController do
|
|
5
|
+
|
|
6
|
+
it "should respond with the index action" do
|
|
7
|
+
get :index
|
|
8
|
+
response.should render_template("naf/applications/index")
|
|
9
|
+
response.should be_success
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should respond with show action" do
|
|
13
|
+
id = 5
|
|
14
|
+
Application.should_receive(:find).with("5").and_return(nil)
|
|
15
|
+
get :show, id: id
|
|
16
|
+
response.should be_success
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "with regard to the edit action" do
|
|
20
|
+
|
|
21
|
+
it "should build a new application schedule if it was destroyed" do
|
|
22
|
+
@id = 5
|
|
23
|
+
controller.stub(:check_application_run_group_name).and_return(nil)
|
|
24
|
+
app_mock = mock_model(Application)
|
|
25
|
+
schedule_mock = mock_model(ApplicationSchedule)
|
|
26
|
+
schedule_prerequisites = mock_model(ApplicationSchedulePrerequisite)
|
|
27
|
+
Application.should_receive(:find).with("5").and_return(app_mock)
|
|
28
|
+
app_mock.should_receive(:application_schedule).and_return(nil)
|
|
29
|
+
app_mock.should_receive(:build_application_schedule).and_return(schedule_mock)
|
|
30
|
+
schedule_mock.should_receive(:application_schedule_prerequisites).and_return(schedule_prerequisites)
|
|
31
|
+
schedule_prerequisites.should_receive(:build).and_return(nil)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should respond without building a new application schedule" do
|
|
35
|
+
@id = 5
|
|
36
|
+
controller.stub(:check_application_run_group_name).and_return(nil)
|
|
37
|
+
app_mock = mock_model(Application)
|
|
38
|
+
schedule_mock = mock_model(ApplicationSchedule)
|
|
39
|
+
schedule_prerequisites = mock_model(ApplicationSchedulePrerequisite)
|
|
40
|
+
app_mock.should_receive(:application_schedule).and_return(schedule_mock)
|
|
41
|
+
Application.should_receive(:find).with("5").and_return(app_mock)
|
|
42
|
+
schedule_mock.should_receive(:application_schedule_prerequisites).and_return(schedule_prerequisites)
|
|
43
|
+
schedule_prerequisites.should_not_receive(:build)
|
|
44
|
+
app_mock.should_not_receive(:build_application_schedule)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
after(:each) do
|
|
48
|
+
get :edit, id: @id
|
|
49
|
+
response.should render_template("naf/applications/edit")
|
|
50
|
+
response.should be_success
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should respond with affinity new" do
|
|
55
|
+
app = double('app')
|
|
56
|
+
app_schedule = double('application_schedule')
|
|
57
|
+
schedule_prerequisites = double('schedule_prerequisites')
|
|
58
|
+
Application.should_receive(:new).and_return(app)
|
|
59
|
+
app.should_receive(:build_application_schedule).and_return(app_schedule)
|
|
60
|
+
app_schedule.should_receive(:application_schedule_prerequisites).and_return(schedule_prerequisites)
|
|
61
|
+
schedule_prerequisites.should_receive(:build).and_return(nil)
|
|
62
|
+
get :new
|
|
63
|
+
response.should render_template("naf/applications/new")
|
|
64
|
+
response.should be_success
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "on the create action" do
|
|
68
|
+
let(:valid_app) { mock_model(Application, save: true, application_schedule: nil, id: 5) }
|
|
69
|
+
let(:invalid_app) { mock_model(Application, save: false) }
|
|
70
|
+
|
|
71
|
+
it "should redirect to show when valid" do
|
|
72
|
+
Application.should_receive(:new).and_return(valid_app)
|
|
73
|
+
post :create, application: {}
|
|
74
|
+
response.should redirect_to(application_path(valid_app.id))
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should re-render to new when invalid" do
|
|
78
|
+
invalid_app.stub(:build_application_schedule)
|
|
79
|
+
Application.should_receive(:new).and_return(invalid_app)
|
|
80
|
+
post :create, application: {}
|
|
81
|
+
response.should render_template("naf/applications/new")
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "on the updated action" do
|
|
86
|
+
let(:valid_app) { mock_model(Application, update_attributes: true, application_schedule: nil, id: 5) }
|
|
87
|
+
let(:invalid_app) { mock_model(Application, update_attributes: false, id: 5) }
|
|
88
|
+
|
|
89
|
+
it "should redirect to show when valid" do
|
|
90
|
+
Application.should_receive(:find).with("5").and_return(valid_app)
|
|
91
|
+
post :update, id: 5, application: {}
|
|
92
|
+
response.should redirect_to(application_path(valid_app.id))
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should re-render to new when invalid" do
|
|
96
|
+
Application.should_receive(:find).and_return(invalid_app)
|
|
97
|
+
post :update, id: 5, application: {}
|
|
98
|
+
response.should render_template("naf/applications/edit")
|
|
99
|
+
end
|
|
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,96 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe HistoricalJobAffinityTabsController do
|
|
5
|
+
let(:model_class) { HistoricalJobAffinityTab }
|
|
6
|
+
|
|
7
|
+
it "should respond with index action nested under a job" do
|
|
8
|
+
model_class.should_receive(:where).with({ historical_job_id: "1" }).and_return([])
|
|
9
|
+
get :index, historical_job_id: 1
|
|
10
|
+
response.should render_template("naf/datatable")
|
|
11
|
+
response.should be_success
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should respond with the show action" do
|
|
15
|
+
HistoricalJob.should_receive(:find).with("1").and_return(nil)
|
|
16
|
+
model_class.should_receive(:find).with("5").and_return(nil)
|
|
17
|
+
get :show, id: 5, historical_job_id: 1
|
|
18
|
+
response.should render_template("naf/record")
|
|
19
|
+
response.should be_success
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should respond with the edit action" do
|
|
23
|
+
HistoricalJob.should_receive(:find).with("1").and_return(nil)
|
|
24
|
+
model_class.should_receive(:find).with("5").and_return(nil)
|
|
25
|
+
get :edit, id: 5, historical_job_id: 1
|
|
26
|
+
response.should render_template("naf/historical_job_affinity_tabs/edit")
|
|
27
|
+
response.should be_success
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should respond with the new action" do
|
|
31
|
+
HistoricalJob.should_receive(:find).with("1").and_return(nil)
|
|
32
|
+
model_class.should_receive(:new).and_return(nil)
|
|
33
|
+
get :new, historical_job_id: 1
|
|
34
|
+
response.should render_template("naf/historical_job_affinity_tabs/new")
|
|
35
|
+
response.should be_success
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "on the create action" do
|
|
39
|
+
let(:valid_tab) { mock_model(model_class, save: true, id: 5, historical_job_id: 1) }
|
|
40
|
+
let(:invalid_tab) { mock_model(model_class, save: false) }
|
|
41
|
+
let(:job) { mock_model(HistoricalJob, id: 1) }
|
|
42
|
+
|
|
43
|
+
subject do
|
|
44
|
+
post :create, job_affinity_tab: { historical_job_id: 1 }, historical_job_id: 1
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
HistoricalJob.should_receive(:find).with("1").and_return(job)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should redirect to show when valid" do
|
|
52
|
+
model_class.should_receive(:new).and_return(valid_tab)
|
|
53
|
+
valid_tab.stub(:affinity_name).and_return("Test Name")
|
|
54
|
+
path = historical_job_historical_job_affinity_tab_path(job, valid_tab)
|
|
55
|
+
subject.should redirect_to(path)
|
|
56
|
+
end
|
|
57
|
+
it "should re-render to new when invalid" do
|
|
58
|
+
model_class.should_receive(:new).and_return(invalid_tab)
|
|
59
|
+
subject.should render_template("naf/historical_job_affinity_tabs/new")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "on the update action" do
|
|
64
|
+
let(:valid_job) { mock_model(model_class, update_attributes: true, id: 5, historical_job_id: 1) }
|
|
65
|
+
let(:invalid_job) { mock_model(model_class, update_attributes: false, id: 5, historical_job_id: 1) }
|
|
66
|
+
let(:job) { mock_model(HistoricalJob, id: 1) }
|
|
67
|
+
|
|
68
|
+
subject do
|
|
69
|
+
put :update, job_affinity_tab: { historical_job_id: 1 }, id: 5, historical_job_id: 1
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
before do
|
|
73
|
+
HistoricalJob.should_receive(:find).with("1").and_return(job)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should redirect to show when valid" do
|
|
77
|
+
model_class.should_receive(:find).and_return(valid_job)
|
|
78
|
+
valid_job.stub(:affinity_name).and_return("Test Name")
|
|
79
|
+
path = historical_job_historical_job_affinity_tab_path(job, valid_job)
|
|
80
|
+
subject.should redirect_to(path)
|
|
81
|
+
end
|
|
82
|
+
it "should re-render to edit when invalid" do
|
|
83
|
+
model_class.should_receive(:find).and_return(invalid_job)
|
|
84
|
+
subject.should render_template("naf/historical_job_affinity_tabs/edit")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Ensure that some instance variables are set
|
|
90
|
+
after do
|
|
91
|
+
cols = assigns(:cols)
|
|
92
|
+
attributes = assigns(:attributes)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
end
|