From ca1441905d28f17737f5412164aecf0ea673cbe0 Mon Sep 17 00:00:00 2001
From: Erin Fahy <efahy@stanford.edu>
Date: Sat, 30 Jan 2016 09:32:03 -0800
Subject: [PATCH] creates routes and builds systems basic controller and view

---
 app/assets/javascripts/systems.js           |  2 ++
 app/assets/stylesheets/systems.css          |  4 ++++
 app/controllers/systems_controller.rb       |  5 +++++
 app/helpers/systems_helper.rb               |  2 ++
 app/views/systems/index.html.erb            | 15 +++++++++++++++
 config/routes.rb                            |  7 +++++++
 spec/controllers/systems_controller_spec.rb | 12 ++++++++++++
 spec/helpers/systems_helper_spec.rb         | 15 +++++++++++++++
 spec/views/system/index.html.erb_spec.rb    |  5 +++++
 spec/views/systems/index.html.erb_spec.rb   |  5 +++++
 10 files changed, 72 insertions(+)
 create mode 100644 app/assets/javascripts/systems.js
 create mode 100644 app/assets/stylesheets/systems.css
 create mode 100644 app/controllers/systems_controller.rb
 create mode 100644 app/helpers/systems_helper.rb
 create mode 100644 app/views/systems/index.html.erb
 create mode 100644 spec/controllers/systems_controller_spec.rb
 create mode 100644 spec/helpers/systems_helper_spec.rb
 create mode 100644 spec/views/system/index.html.erb_spec.rb
 create mode 100644 spec/views/systems/index.html.erb_spec.rb

diff --git a/app/assets/javascripts/systems.js b/app/assets/javascripts/systems.js
new file mode 100644
index 0000000..dee720f
--- /dev/null
+++ b/app/assets/javascripts/systems.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
diff --git a/app/assets/stylesheets/systems.css b/app/assets/stylesheets/systems.css
new file mode 100644
index 0000000..afad32d
--- /dev/null
+++ b/app/assets/stylesheets/systems.css
@@ -0,0 +1,4 @@
+/*
+  Place all the styles related to the matching controller here.
+  They will automatically be included in application.css.
+*/
diff --git a/app/controllers/systems_controller.rb b/app/controllers/systems_controller.rb
new file mode 100644
index 0000000..ccbc9fb
--- /dev/null
+++ b/app/controllers/systems_controller.rb
@@ -0,0 +1,5 @@
+class SystemsController < ApplicationController
+  def index
+    @systems = System.all
+  end
+end
diff --git a/app/helpers/systems_helper.rb b/app/helpers/systems_helper.rb
new file mode 100644
index 0000000..b82c204
--- /dev/null
+++ b/app/helpers/systems_helper.rb
@@ -0,0 +1,2 @@
+module SystemsHelper
+end
diff --git a/app/views/systems/index.html.erb b/app/views/systems/index.html.erb
new file mode 100644
index 0000000..c7c9c6c
--- /dev/null
+++ b/app/views/systems/index.html.erb
@@ -0,0 +1,15 @@
+<h1>Systems</h1>
+
+<table>
+  <tr>
+    <th>Hostname</th>
+    <th>OS</th>
+  </tr>
+
+<% @systems.each do |system| %>
+  <tr>
+    <td><%= system.hostname %></td>
+    <td><%= system.os %></td>
+  </tr>
+<% end %>
+</table>
diff --git a/config/routes.rb b/config/routes.rb
index 3f66539..be6afad 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,6 @@
 Rails.application.routes.draw do
+  get 'systems/index'
+
   # The priority is based upon order of creation: first created -> highest priority.
   # See how all your routes lay out with "rake routes".
 
@@ -53,4 +55,9 @@ Rails.application.routes.draw do
   #     # (app/controllers/admin/products_controller.rb)
   #     resources :products
   #   end
+
+  resources :systems
+  resources :packages
+  resources :vulnerabilities
+  root 'systems#index'
 end
diff --git a/spec/controllers/systems_controller_spec.rb b/spec/controllers/systems_controller_spec.rb
new file mode 100644
index 0000000..7ff77ec
--- /dev/null
+++ b/spec/controllers/systems_controller_spec.rb
@@ -0,0 +1,12 @@
+require 'rails_helper'
+
+RSpec.describe SystemsController, type: :controller do
+
+  describe "GET #index" do
+    it "returns http success" do
+      get :index
+      expect(response).to have_http_status(:success)
+    end
+  end
+
+end
diff --git a/spec/helpers/systems_helper_spec.rb b/spec/helpers/systems_helper_spec.rb
new file mode 100644
index 0000000..f85e77d
--- /dev/null
+++ b/spec/helpers/systems_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the SystemsHelper. For example:
+#
+# describe SystemsHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       expect(helper.concat_strings("this","that")).to eq("this that")
+#     end
+#   end
+# end
+RSpec.describe SystemsHelper, type: :helper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/system/index.html.erb_spec.rb b/spec/views/system/index.html.erb_spec.rb
new file mode 100644
index 0000000..9feb51f
--- /dev/null
+++ b/spec/views/system/index.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "system/index.html.erb", type: :view do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/systems/index.html.erb_spec.rb b/spec/views/systems/index.html.erb_spec.rb
new file mode 100644
index 0000000..df1c184
--- /dev/null
+++ b/spec/views/systems/index.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "systems/index.html.erb", type: :view do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
-- 
GitLab