diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb new file mode 100644 index 0000000..388df9f --- /dev/null +++ b/app/controllers/jobs_controller.rb @@ -0,0 +1,36 @@ +class JobsController < ApplicationController + before_action :fetch_job, only: [:show, :edit, :update, :destroy] + + # GET /jobs + def new + @job_template = JobTemplate.new + end + + # POST /jobs + def create + @job_template = JobTemplate.new(fetch_params) + end + + # GET /jobs/1 + def show; end + + # GET /jobs/1/edit + def edit;end + + # PUT /jobs/1 + def update;end + + # DELETE /jobs/1 + def destroy + end + + private + + def fetch_job + @job_template = JobTemplate.find(params[:id]) + end + + def fetch_params + params.require(:job_template).permit(:name, :job_type, :fileset_id, :schedule_id) + end +end diff --git a/config/routes.rb b/config/routes.rb index 61803d0..9f077b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,8 @@ Rails.application.routes.draw do resources :clients, only: [:index, :show] resources :hosts, only: [:new, :create, :show, :edit, :update, :destroy] + resources :jobs, only: [:new, :create, :show, :edit, :update, :destroy] + root 'clients#index' end diff --git a/spec/routing/job_routing_spec.rb b/spec/routing/job_routing_spec.rb new file mode 100644 index 0000000..3623de5 --- /dev/null +++ b/spec/routing/job_routing_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe HostsController do + it 'routes GET /jobs/new' do + expect(get('/jobs/new')).to route_to( { controller: 'jobs', action: 'new' }) + end + + it 'routes POST /jobs' do + expect(post('/jobs')).to route_to( { controller: 'jobs', action: 'create' }) + end + + it 'routes GET /jobs/1' do + expect(get('/jobs/1')).to route_to( { controller: 'jobs', action: 'show', id: '1' }) + end + + it 'routes GET /jobs/1/edit' do + expect(get('/jobs/1/edit')).to route_to( { controller: 'jobs', action: 'edit', id: '1' }) + end + + it 'routes PUT /jobs/1' do + expect(put('/jobs/1')).to route_to( { controller: 'jobs', action: 'update', id: '1' }) + end + + it 'routes DELETE /jobs/1' do + expect(delete('/jobs/1')).to route_to( { controller: 'jobs', action: 'destroy', id: '1' }) + end +end