Skip to content
Snippets Groups Projects
Commit 3883e017 authored by Erin Fahy's avatar Erin Fahy
Browse files

creates system, package & vulnerability models

parent c98ba57d
No related branches found
No related tags found
No related merge requests found
class Package < ActiveRecord::Base
has_and_belongs_to_many :vulnerabilities
has_and_belongs_to_many :systems
end
class System < ActiveRecord::Base
has_and_belongs_to_many :packages
has_many :vulnerabilities, through: :packages
end
class Vulnerability < ActiveRecord::Base
has_and_belongs_to_many :packages
has_many :systems, through: :packages
end
class CreateSystems < ActiveRecord::Migration
def change
create_table :systems do |t|
t.string :hostname
t.string :os
t.timestamps null: false
end
add_index :systems, :os
end
end
class CreatePackages < ActiveRecord::Migration
def change
create_table :packages do |t|
t.string :name
t.string :version
t.string :repository
t.timestamps null: false
end
add_index :packages, :repository
end
end
class CreateVulnerabilities < ActiveRecord::Migration
def change
create_table :vulnerabilities do |t|
t.string :advisory_id
t.string :severity
t.date :date_reported
t.text :synopsis
t.string :cve_id
t.timestamps null: false
end
add_index :vulnerabilities, :severity
end
end
FactoryGirl.define do
factory :package do
name "MyString"
version "MyString"
repository "MyString"
end
end
FactoryGirl.define do
factory :system do
hostname "MyString"
os "MyString"
end
end
FactoryGirl.define do
factory :vulnerability do
advisory_id "MyString"
severity "MyString"
date_reported "2016-01-29"
synopsis "MyText"
cve_id "MyString"
end
end
require 'rails_helper'
RSpec.describe Package, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'rails_helper'
RSpec.describe System, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'rails_helper'
RSpec.describe Vulnerability, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment