diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb new file mode 100644 index 0000000..6cf35fb --- /dev/null +++ b/app/controllers/clients_controller.rb @@ -0,0 +1,17 @@ +class ClientsController < ApplicationController + before_action :set_client, only: :show + + # GET /clients + def index + @clients = Client.all + end + + # GET /clients/1 + def show; end + + private + + def set_client + @client = Client.find(params[:id]) + end +end diff --git a/app/views/clients/_client.html.erb b/app/views/clients/_client.html.erb new file mode 100644 index 0000000..6b4f6cd --- /dev/null +++ b/app/views/clients/_client.html.erb @@ -0,0 +1,7 @@ + + <%= link_to client.name, client %> + <%= client.uname %> + <%= client.auto_prune %> + <%= client.file_retention %> + <%= client.job_retention %> + diff --git a/app/views/clients/index.html.erb b/app/views/clients/index.html.erb new file mode 100644 index 0000000..5730c5e --- /dev/null +++ b/app/views/clients/index.html.erb @@ -0,0 +1,19 @@ +

My Hosts

+ +
+ + + + + + + + + + + + + <%= render partial: 'client', collection: @clients %> + +
NameUnameAutoPruneFileRetentionJobRetention
+
diff --git a/app/views/clients/show.html.erb b/app/views/clients/show.html.erb new file mode 100644 index 0000000..329bdc7 --- /dev/null +++ b/app/views/clients/show.html.erb @@ -0,0 +1,29 @@ +

<%= notice %>

+ + +
+ + + + + + + + + + + + + + + + + + + + + +
Name<%= @client.name %>
Uname<%= @client.uname %>
Auto Prune<%= @client.auto_prune %>
File Retention<%= @client.file_retention %>
Job Retention<%= @client.job_retention %>
+
+ +<%= link_to 'Back', clients_path %> diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb index 902d0f8..e736f56 100644 --- a/app/views/shared/_nav.html.erb +++ b/app/views/shared/_nav.html.erb @@ -1,29 +1,29 @@ diff --git a/config/routes.rb b/config/routes.rb index 1daf9a4..d56c812 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,2 +1,5 @@ Rails.application.routes.draw do + resources :clients, only: [:index, :show] + + root 'clients#index' end diff --git a/spec/routing/client_routing_spec.rb b/spec/routing/client_routing_spec.rb new file mode 100644 index 0000000..728caae --- /dev/null +++ b/spec/routing/client_routing_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe ClientsController do + it 'routes /clients' do + expect(get('/clients')).to route_to(controller: 'clients', action: 'index') + end + + it 'routes GET /' do + expect(get('/')).to route_to(controller: 'clients', action: 'index') + end + + it 'routes GET /clients/1' do + expect(get('/clients/1')).to route_to(controller: 'clients', action: 'show', id: '1') + end +end +