diff --git a/app/controllers/filesets_controller.rb b/app/controllers/filesets_controller.rb
new file mode 100644
index 0000000..e8ec205
--- /dev/null
+++ b/app/controllers/filesets_controller.rb
@@ -0,0 +1,27 @@
+class FilesetsController < ApplicationController
+ def new
+ @fileset = Fileset.new
+ end
+
+ def show
+ end
+
+ def create
+ @fileset = Fileset.new(fetch_params)
+
+ if @fileset.save
+ redirect_to root_path
+ else
+ render :new
+ end
+ end
+
+ def destroy
+ end
+
+ private
+
+ def fetch_params
+ params.require(:fileset).permit(:name, exclude_directions: [], include_files: [])
+ end
+end
diff --git a/app/views/filesets/_form.html.erb b/app/views/filesets/_form.html.erb
new file mode 100644
index 0000000..f35e602
--- /dev/null
+++ b/app/views/filesets/_form.html.erb
@@ -0,0 +1,29 @@
+<%= bootstrap_form_for(@fileset, layout: :horizontal,
+ label_col: 'col-xs-3', control_col: 'col-xs-8') do |f| %>
+ <% if @fileset.errors.any? %>
+
+
<%= pluralize(@fileset.errors.count, "error") %> prohibited this fileset from being saved:
+
+
+ <% @fileset.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= f.text_field :name %>
+ <%= f.text_field :include_files, label: 'Files', placeholder: '/', multiple: true %>
+ <%= f.text_field :include_files, label: 'Files', placeholder: '/media', multiple: true %>
+ <%= f.text_field :exclude_directions, label: 'Exclude', placeholder: '/proc', multiple: true %>
+ <%= f.text_field :exclude_directions, label: 'Exclude', placeholder: '/bacula', multiple: true %>
+
+
+
+
+<% end %>
diff --git a/app/views/filesets/new.html.erb b/app/views/filesets/new.html.erb
new file mode 100644
index 0000000..e38af6c
--- /dev/null
+++ b/app/views/filesets/new.html.erb
@@ -0,0 +1,5 @@
+New Fileset
+
+
+ <%= render 'form' %>
+
diff --git a/config/routes.rb b/config/routes.rb
index 9efa18a..fbaae22 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,10 +1,11 @@
Rails.application.routes.draw do
resources :clients, only: [:index, :show]
resources :hosts, only: [:new, :create, :show, :edit, :update, :destroy] do
resources :jobs, only: [:new, :create, :show, :edit, :update, :destroy]
end
resources :schedules, only: [:show, :new, :edit, :create, :update, :destroy]
+ resources :filesets, only: [:show, :new, :create, :destroy]
root 'clients#index'
end
diff --git a/spec/controllers/filesets_controller_spec.rb b/spec/controllers/filesets_controller_spec.rb
new file mode 100644
index 0000000..e3399f4
--- /dev/null
+++ b/spec/controllers/filesets_controller_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper'
+
+describe FilesetsController do
+ describe 'GET #new' do
+ before { get :new }
+
+ it 'initializes a fileset' do
+ expect(assigns(:fileset)).to be
+ end
+
+ it 'renders' do
+ expect(response).to render_template(:new)
+ end
+ end
+
+ describe 'POST #create' do
+ context 'with valid params' do
+ let(:params) do
+ {
+ fileset: { name: FactoryGirl.build(:fileset).name,
+ exclude_directions: ['/proc', '/tmp'],
+ include_files: ['/home', '/media']
+ }
+ }
+ end
+
+ it 'creates the fileset' do
+ expect { post :create, params }.
+ to change { Fileset.count }.by(1)
+ end
+
+ it 'redirects to root' do
+ post :create, params
+ expect(response).to redirect_to(root_path)
+ end
+ end
+
+ context 'with invalid params' do
+ let(:params) { { fileset: { invalid: :foo } } }
+
+ it 'initializes a fileset with errors' do
+ post :create, params
+ expect(assigns(:fileset)).to be
+ end
+
+ it 'does not create the fileset' do
+ expect { post :create, params }.
+ to_not change { Fileset.count }
+ end
+
+ it 'renders :new' do
+ post :create, params
+ expect(response).to render_template(:new)
+ end
+ end
+ end
+end
diff --git a/spec/routing/fileset_routing_spec.rb b/spec/routing/fileset_routing_spec.rb
new file mode 100644
index 0000000..b4b2f97
--- /dev/null
+++ b/spec/routing/fileset_routing_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe FilesetsController do
+ it 'routes GET /filesets/new' do
+ expect(get('/filesets/new')).to route_to( { controller: 'filesets', action: 'new'})
+ end
+
+ it 'routes POST /filesets' do
+ expect(post('/filesets')).to route_to( { controller: 'filesets', action: 'create'})
+ end
+
+ it 'routes GET /filesets/1' do
+ expect(get('/filesets/1')).
+ to route_to( { controller: 'filesets', action: 'show', id: '1' })
+ end
+
+ it 'routes DELETE /filesets/1' do
+ expect(delete('/filesets/1')).
+ to route_to( { controller: 'filesets', action: 'destroy', id: '1' })
+ end
+end