code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Risk to RiskyAttribute many to many
class RiskRiskyAttribute < ActiveRecord::Base
include CommonModel
attr_accessible :risk, :risky_attribute
belongs_to :risk
belongs_to :risky_attribute
is_versioned_ext
#def self.by_system_control(system_id, control_id, cycle)
# sc = SystemControl
# .where(:s... | Ruby |
class RelationshipType < ActiveRecord::Base
include AuthoredModel
include SanitizableAttributes
# attr_accessible :title, :body
self.primary_key = 'relationship_type'
has_many :relationships
is_versioned_ext
sanitize_attributes :description
end
| Ruby |
# A Program which links Directives
#
# The top of the Program -> Directive -> Control hierarchy
class Program < ActiveRecord::Base
include CommonModel
include SluggedModel
include SearchableModel
include AuthorizedModel
include RelatedModel
include SanitizableAttributes
include DatedModel
KINDS = [
... | Ruby |
class Option < ActiveRecord::Base
include AuthoredModel
include SanitizableAttributes
attr_accessible :role, :title, :description, :required
def to_s
title
end
scope :options_for, lambda { |role| where(:role => role) }
scope :ordered_by_title_desc, order("#{table_name}.title DESC")
is_versioned_... | Ruby |
class ObjectDocument < ActiveRecord::Base
include AuthoredModel
include AuthorizedModel
include RelatedModel
include DatedModel
attr_accessible :document, :documentable, :role, :notes, :start_date, :stop_date
belongs_to :document
belongs_to :documentable, :polymorphic => true
is_versioned_ext
def ... | Ruby |
class Meeting < ActiveRecord::Base
include CommonModel
attr_accessible :response, :start_at, :calendar_url
belongs_to :response
is_versioned_ext
validates_presence_of :response, :calendar_url
def display_name
"#{response.system.title} meeting"
end
def calendar_url
self[:calendar_url].gsub ... | Ruby |
class Categorization < ActiveRecord::Base
include AuthoredModel
attr_accessible :category, :categorizable
belongs_to :category
belongs_to :categorizable, :polymorphic => true
is_versioned_ext
end
| Ruby |
class WelcomeController < ApplicationController
skip_before_filter :require_user
access_control :acl do
allow all
end
def index
session[:return_to] = login_dispatch_path
if current_user
redirect_to programs_dash_path
end
end
def login_dispatch
if current_user.nil?
redirect... | Ruby |
class ObjectPeopleController < BaseMappingsController
# access_control :acl do
# allow :superuser
#
# actions :index do
# allow :read, :read_object_person
# end
#
# actions :create do
# allow :create, :create_object_person
# end
#
# actions :list_edit, :create do
# allow :update, :upd... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Handle Google Docs integration
class DocumentController < ApplicationController
include GdataHelper
include DocumentHelper
# access_control :acl do
# allow :superuser
#
# actions :index do
# ... | Ruby |
# Browse programs
class ProgramsController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :new, :create do
# allow :create, :create_program
# end
#
# actions :edit, :update do
# allow :update, :update_program, :of => :program
# end
#
# actions :show, :toolt... | Ruby |
# Handle unincorporated design views here
class DesignController < ApplicationController
include ApplicationHelper
layout 'dashboard'
before_filter :require_design_feature
# Render the requested partial under 'design/templates'
def templates
template_name = params[:name]
respond_to do |format|
... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle facilities
class FacilitiesController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :new, :create do
# a... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle markets
class MarketsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :new, :create do
# allow :... | Ruby |
class RiskRiskyAttributesController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
before_filter :check_risk_authorization
def index
@objects = RiskRiskyAttribute
if params[:risk_id].present?
@objects = @objects.where(:risk_id => params[:risk_id])
end
if p... | Ruby |
class ObjectDocumentsController < BaseMappingsController
# access_control :acl do
# allow :superuser
#
# actions :index do
# allow :read, :read_object_document
# end
#
# actions :create do
# allow :create, :create_object_document
# end
#
# actions :list_edit, :create do
# allow :updat... | Ruby |
class HelpController < ApplicationController
layout 'help'
# access_control :acl do
# allow logged_in
# end
# Render the requested partial under 'help'
def edit
slug = params[:help]['slug']
@help = Help.find_by_slug(slug) ||
Help.new(:slug => slug)
@help.title = params[:help]['title']
... | Ruby |
# Handle markets
class DataAssetsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :new, :create do
# allow :create, :create_data_asset
# end
#
# actions :edit, :update do
# allow :update, :update_data_asse... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Browse sections
class SectionsController < BaseObjectsController
include DirectivesHelper
cache_sweeper :section_sweeper, :only => [:create, :update, :destroy]
# access_control :acl do
# allow :sup... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Org Groups
class OrgGroupsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :re... | Ruby |
# Handle Responses
class ResponsesController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_response
# end
#
# actions :new, :create do
# allow :create, :create_response
# end
#
# a... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# This class is the base for all controllers used in this app
#require 'dm-rails/middleware/identity_map'
class ApplicationController < ActionController::Base
include ApplicationHelper
include Authorizati... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Handle evidence collection
class EvidenceController < ApplicationController
include GdataHelper
include DocumentHelper
include EvidenceHelper
include ApplicationHelper
# access_control :acl do
# ... | Ruby |
class ProgramDirectivesController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = ProgramDirective
if params[:program_id].present?
@objects = @objects.where(:program_id => params[:program_id])
if params[:directive_meta_kind].present?
@... | Ruby |
class BusinessObjectsController < BaseObjectsController
include BusinessObjectsHelper
end
| Ruby |
# Handle Risks
require 'csv'
class RisksController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_risk
# end
#
# actions :new, :create do
# allow :create, :create_risk
# end
#
# a... | Ruby |
# Handle Control Assessments
class ControlAssessmentsController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_control_assessment
# end
#
# actions :new, :create do
# allow :create, :crea... | Ruby |
# Handle Requests
class RequestsController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_request
# end
#
# actions :new, :create do
# allow :create, :create_request
# end
#
# actio... | Ruby |
# Author:: Daniel Ring (mailto:danring+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class CategoriesController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
no_base_action :tooltip
def index
@categories = Category
if params[... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Admin dashboard
class AdminDashController < ApplicationController
# access_control :acl do
# allow :superuser
# end
before_filter :check_admin_authorization
layout 'dashboard'
def index
... | Ruby |
class SystemSystemsController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = SystemSystem
if params[:parent_id].present?
@objects = @objects.where(:parent_id => params[:parent_id])
end
render :json => @objects, :include => :child
end
p... | Ruby |
class MeetingsController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
no_base_action :index, :show, :tooltip
private
def object_path
flow_pbc_list_path(@meeting.response.request.pbc_list_id)
end
def post_destroy_path
flow_pbc_list_... | Ruby |
# Author:: Slobodan Kovacevic (mailto:basti@reciprocitynow.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class OptionsController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
def index
@options = Option.all
if params[:s].present?
@op... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class AccountsController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :new, :create do
# allow :create, :create_account
# end
#
# actions :edit, :update do... | Ruby |
class PopulationSamplesController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
no_base_action :index, :show, :tooltip
private
def object_path
flow_pbc_list_path(@population_sample.response.request.pbc_list_id)
end
def post_destroy_path
... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Controls
class ControlsController < BaseObjectsController
include ControlsHelper
include AuthorizationHelper
before_filter :load_control, :only => [:sections,
... | Ruby |
class ControlRisksController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = ControlRisk
if params[:risk_id].present?
@objects = @objects.where(:risk_id => params[:risk_id])
end
if params[:control_id].present?
@objects = @objects.where... | Ruby |
class RelationshipsController < BaseMappingsController
# access_control :acl do
# allow :superuser
# allow :read, :read_relationship, :to => [:related_objects]
# end
def index
wants_risk = false
if is_risky_type?(params[:object_type]) || is_risky_type?(params[:related_model])
wants_risk = true... | Ruby |
# Handle RiskyAttributes
class RiskyAttributesController < BaseObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read, :read_risky_attribute
# end
#
# actions :new, :create do
# allow :create, :create_risky_a... | Ruby |
class BaseObjectsController < ApplicationController
include ApplicationHelper
before_filter :load_object,
:only => [ :show, :edit, :update, :delete, :destroy, :tooltip]
def index
object_set = model_class
if params[:s].present?
if object_set.respond_to?(:fulltext_search)
object_set = ob... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Programs overview
class ProgramsDashController < ApplicationController
include DashboardHelper
# access_control :acl do
# allow logged_in
# end
layout 'dashboard'
def index
@programs = allo... | Ruby |
# Handle PBC Lists
require 'csv'
class ImportException < Exception
end
class PbcListsController < BaseObjectsController
include ImportHelper
PBC_METADATA_MAP = Hash[*%w(
Type type
)]
PBC_REQUEST_MAP = Hash[*%w(
Request\ Type type_name
Control\ Code pbc_control_code
Control\ Description pbc_... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
require 'csv'
class DirectivesController < BaseObjectsController
# FIXME: Decide if the :section, controls, etc.
# methods should be moved, and what access controls they
# need.
before_filter :load_di... | Ruby |
class MappingController < ApplicationController
include ControlsHelper
layout 'dashboard'
respond_to :html, :json
cache_sweeper :section_sweeper, :only => [:map_rcontrol, :map_ccontrol, :update]
cache_sweeper :control_sweeper, :only => [:map_rcontrol, :map_ccontrol]
def show
@program = Program.find(p... | Ruby |
class UserSessionsController < ApplicationController
skip_before_filter :require_user, :except => :destroy
#before_filter :require_no_user, :only => [:new, :create]
#before_filter :require_user, :only => :destroy
layout 'welcome'
access_control :acl do
allow all
end
def login
if current_us... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Documents
class DocumentsController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :create, :new do
# allow :create, :create_document
# end
#
# acti... | Ruby |
class SystemControlsController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = SystemControl
if params[:system_id].present?
@objects = @objects.where(:system_id => params[:system_id])
end
if params[:control_id].present?
@objects = @obj... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Products
class ProductsController < BusinessObjectsController
# access_control :acl do
# # FIXME: Implement real authorization
#
# allow :superuser
#
# actions :index do
# allow :read,... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
require 'csv'
# HandleSystems
class SystemsController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :new, :create, :import do
# allow :create, :create_system
# ... | Ruby |
class BaseMappingsController < ApplicationController
include ApplicationHelper
def create
if params[:items].present?
errors, objects = {}, {}
ActiveRecord::Base.transaction do
params[:items].keys.each do |id|
item_errors, item_object = create_or_update_object(params[:items][id])
... | Ruby |
# Handle projects
class ProjectsController < BusinessObjectsController
access_control :acl do
# FIXME: Implement real authorization
allow :superuser
actions :new, :create do
allow :create, :create_project
end
actions :edit, :update do
allow :update, :update_project, :of => :project... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Transactions
class TransactionsController < BaseObjectsController
# access_control :acl do
# allow :superuser
# end
layout 'dashboard'
no_base_action :index, :show, :tooltip
private
... | Ruby |
class CategorizationsController < BaseMappingsController
# access_control :acl do
# allow :superuser
# end
def index
@objects = Categorization
if params[:object_id].present?
@objects = @objects.where(
:categorizable_type => params[:object_type],
:categorizable_id => params[:object... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class CyclesController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :new, :create do
# allow :create, :create_cycle
# end
#
# actions :show, :tooltip do
# ... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class PeopleController < BaseObjectsController
# access_control :acl do
# allow :superuser
#
# actions :index do
# allow :read, :read_person
# end
#
# actions :new, :create do
# allow :... | Ruby |
class RiskRowConverter < BaseRowConverter
@model_class = :Risk
def setup_object
object = setup_object_by_slug(attrs)
if !object.new_record?
add_warning(:slug, "Risk already exists and will be updated")
end
end
def reify
handle(:slug, SlugColumnHandler)
handle(:controls, LinkControl... | Ruby |
module ErrorWarningMessageObject
attr_accessor :errors, :warnings, :messages
def initialize
@base_errors = []
@errors = HashWithIndifferentAccess.new
@base_warnings = []
@warnings = HashWithIndifferentAccess.new
@base_messages = []
@messages = HashWithIndifferentAccess.new
super
end... | Ruby |
class SystemRowConverter < BaseRowConverter
@model_class = :System
def setup_object
object = setup_object_by_slug(attrs)
if object.new_record?
object.infrastructure = false if object.infrastructure.nil?
object.is_biz_process = true if @importer.options[:is_biz_process]
else
if object... | Ruby |
class SectionRowConverter < BaseRowConverter
@model_class = :Section
def setup_object
object = setup_object_by_slug(attrs)
if object.directive.present? && object.directive != @importer.options[:directive]
add_error(:slug, "Code is used in #{object.directive.meta_kind.to_s.titleize}: #{object.direc... | Ruby |
class ControlRowConverter < BaseRowConverter
@model_class = :Control
def setup_object
object = setup_object_by_slug(attrs)
if object.directive.present? && object.directive != @importer.options[:directive]
add_error(:slug, "Code is used in #{object.directive.meta_kind.to_s.titleize}: #{object.directi... | Ruby |
require 'csv'
class ImportException < Exception
end
class BaseConverter
attr_accessor :rows, :objects, :all_objects, :options, :warnings, :errors, :slugs
def initialize(rows_or_objects, options=nil)
@options = options || {}
if @options[:export]
@objects = rows_or_objects
@rows = []
els... | Ruby |
# Uncomment or put the following in Gemfile.local
# source 'http://rubygems.org'
if File.exist? 'Gemfile.local'
instance_eval(Bundler.read_file('Gemfile.local'), 'Gemfile.local', 1)
end
RAILS_VERSION = '= 3.2.13'
# Fulltext search
gem 'thinking-sphinx', '~> 2.0.14'
gem 'remotipart'
#gem 'gdata-ruby-util', '1.1.2... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
module BaseObjects
def create_base_objects
@prog = FactoryGirl.create(:program, :title => 'Program')
@opt_reg = FactoryGirl.create(:option, :title => 'Regulation', :role => 'directive_kind')
@opt_com = FactoryGirl.create(:option, :title => 'Company Policy', :role => 'directive_kind')
@creg = FactoryGi... | Ruby |
FactoryGirl.define do
sequence(:slug) do |n|
# FIXME: Do I need to generate slugs according to a convention, or
# do they only need to be unique?
# FIXME: Slugs will become invalid if parenting is ever changed
# anywhere in the ancestor heirarchy.
# FIXME: Slug validation makes factories for secti... | Ruby |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :control_assessment do
pbc_list { |c| c.association(:pbc_list) }
control { |c| c.association(:control) }
control_version "MyString"
internal_tod false
internal_toe false
external_tod false
e... | Ruby |
# Test some of the authorization basics for resource controllers.
#
# Usage:
#
# require 'authorized_controller'
#
# before :each do
# @model = <model> # The model that you're testing authorization for, e.g. Account
# @object = <obj> # An instance you want to test read and update actions against
# @index_objs = ... | Ruby |
require 'spork'
require 'simplecov'
require 'capybara/rspec'
if ENV['COVERAGE']
SimpleCov.start do
add_group 'Models', 'app/models'
add_group 'Helpers', 'app/helpers'
add_group 'Controllers', 'app/controllers'
add_group 'Admin C', 'app/controllers/admin'
add_filter 'config'
add_fil... | Ruby |
module UserSpecHelper
# Set the rspec environment so that we can call stub_model
def set_rspec(rspec)
@_rspec = rspec
end
def current_user(stubs = {})
return @current_user if @current_user
role = (stubs.delete(:role) || :user).to_s
if respond_to?(:stub_model)
@current_user = stub_model(... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
ActiveRecord::Base.transaction do
# Categories
# Control categories
control_categories = [
["Access Contr... | Ruby |
SIZE=20
ACCOUNTS = {
:root => :superuser,
:user => :user,
:owner1 => :user,
:owner2 => :user
}
ActiveRecord::Base.transaction do
# Accounts
ACCOUNTS.each do |name, role|
Account.
where(:email => "#{name}@t.com").
first_or_create!(
{:password => name, :password_confirmation => name... | Ruby |
class MoveImportHelpPaths < ActiveRecord::Migration
def up
help = Help.where(:slug => 'import').first
help.update_attribute(:slug, 'systems_import') if help
help = Help.where(:slug => 'import_controls').first
help.update_attribute(:slug, 'controls_import') if help
end
def down
end
end
| Ruby |
class AddKindToDirectives < ActiveRecord::Migration
def change
add_column :directives, :kind, :string
end
end
| Ruby |
class CreateMeetings < ActiveRecord::Migration
def change
create_table :meetings do |t|
t.references :response
t.datetime :start_at
t.string :calendar_url
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class AddControlColumns < ActiveRecord::Migration
def up
change_table :controls do |t|
t.string :version
t.datetime :start_date
t.datetime :stop_date
t.string :url
t.text :documentation_description
t.references :verify_frequency
t.remove :frequency
t.remove :frequen... | Ruby |
class CreateLocations < ActiveRecord::Migration
def change
create_table :locations do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class FixRiskyAttributeRelationships < ActiveRecord::Migration
RELATIONSHIP_TYPE_NAME_CHANGES = [
[ :risky_attribute_is_an_attribute_of_org_group, :org_group_has_risky_attribute ],
[ :risky_attribute_is_an_attribute_of_product, :product_has_risky_attribute ],
[ :risky_attribute_is_an_attribute_of_loca... | Ruby |
class CreateObjectDocuments < ActiveRecord::Migration
class BizProcessDocument < ActiveRecord::Base
end
class DocumentSystem < ActiveRecord::Base
end
class DocumentSystemControl < ActiveRecord::Base
end
def change
create_table :object_documents do |t|
t.string :role
t.text :notes
t.... | Ruby |
class UpdateLanguagesAndControlKinds < ActiveRecord::Migration
def up
o = Option.where(:role => 'control_kind', :title => 'Directive').first
if o
o.title = 'Administrative'
o.save
end
o = Option.where(:role => 'control_means', :title => 'Manual with Segregation of Duties').first
if o
... | Ruby |
class RemoveControlIdFromRequests < ActiveRecord::Migration
def up
# replace all controls with adequate control assessments
Request.all.each do |request|
if request.control_id.present?
control_assessment = ControlAssessment.where(:control_id => request.control_id, :pbc_list_id => request.pbc_lis... | Ruby |
class MovePbcListsColumnsToCycles < ActiveRecord::Migration
def up
change_table :cycles do |t|
t.string :title
t.string :audit_firm
t.string :audit_lead
t.text :description
t.string :status
t.text :notes
end
Cycle.reset_column_information
Cycle.all.each do |cycle|... | Ruby |
class UniqueSlug < ActiveRecord::Migration
def up
add_index :sections, :slug, :unique => true
add_index :controls, :slug, :unique => true
add_index :biz_processes, :slug, :unique => true
add_index :systems, :slug, :unique => true
add_index :programs, :slug, :unique => true
end
def down
re... | Ruby |
class AddToProgram < ActiveRecord::Migration
def up
change_table :programs do |t|
t.integer :frequency_type, :default => 1
t.integer :frequency, :default => 1
end
end
def down
change_table :programs do |t|
t.remove :frequency, :frequency_type
end
end
end
| Ruby |
class SetProgramIdOnCycles < ActiveRecord::Migration
def up
transaction do
Cycle.all.each do |cycle|
directive = Directive.find(cycle.directive_id)
program = directive.programs.first
cycle.update_attribute(:program_id, program.id)
end
end
end
def down
end
end
| Ruby |
class CreateOptions < ActiveRecord::Migration
def change
create_table :options do |t|
t.string :role, :null => false
t.string :title, :null => false
t.text :description
t.references :modified_by
t.timestamps
end
end
end
| Ruby |
class AddNaToSection < ActiveRecord::Migration
def change
add_column :sections, :na, :boolean, :null => false, :default => false
add_column :sections, :notes, :text
end
end
| Ruby |
class CreateMarkets < ActiveRecord::Migration
def change
create_table :markets do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class ChangeRelationshipsFromLocationToFacility < ActiveRecord::Migration
def up
Relationship.where(:source_type => 'Location').all.each do |rel|
rel.update_attribute(:source_type, 'Facility')
end
Relationship.where(:destination_type => 'Location').all.each do |rel|
rel.update_attribute(:desti... | Ruby |
class ChangePolymorphicTypesToProgramFromDirective < ActiveRecord::Migration
RELATIONSHIP_TYPE_NAME_CHANGES = [
[:directive_applies_to_data_asset, :program_applies_to_data_asset],
[:directive_applies_to_facility, :program_applies_to_facility],
[:directive_applies_to_market, :program_applies_to_marke... | Ruby |
class AddBaseProgramKinds < ActiveRecord::Migration
def up
Option.where(:role => 'program_type').destroy_all
role = 'program_kind'
Option.where(:role => role, :title => 'Not Applicable').destroy_all
[
'Regulation', 'Company Policy', 'Operational Group Policy', 'Data Asset Policy'
].each d... | Ruby |
class AddUrlToSections < ActiveRecord::Migration
def change
add_column :sections, :url, :string
end
end
| Ruby |
class RemoveDeprecatedDatabaseObjects < ActiveRecord::Migration
def up
# BizProcess is now a subset/type of System
# - data migration happened in 20120723223448_copy_biz_processes_to_systems.rb
drop_table :biz_process_controls
drop_table :biz_process_documents
drop_table :biz_process_people
dr... | Ruby |
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
class UpdateBaseRelationshipTypes < ActiveRecord::Migration
def up
RelationshipType.reset_column_information
new_relationship_types = [
# Relationship types are in alphabetical order!
{
:relationship_type => 'location_is_dependent_on_location',
:description => "Locations can be de... | Ruby |
class RemoveInvalidRiskyAttributes < ActiveRecord::Migration
def up
RiskyAttribute.where(:type_string => nil).each do |ra|
ra.destroy
end
RiskyAttribute.where(:type_string => "").each do |ra|
ra.destroy
end
RiskyAttribute.where(:type_string => "Org Group").each do |ra|
ra.updat... | Ruby |
class CreateObjectPeople < ActiveRecord::Migration
class BizProcessPerson < ActiveRecord::Base
end
class SystemPerson < ActiveRecord::Base
end
def change
create_table :object_people do |t|
t.string :role
t.text :notes
t.references :person, :null => false
t.references :personable, ... | Ruby |
class AddPopulationSampleFieldsToResponses < ActiveRecord::Migration
def change
add_column :responses, :population_document_id, :integer
add_column :responses, :population, :integer
add_column :responses, :sample_worksheet_document_id, :integer
add_column :responses, :samples, :integer
add_column ... | Ruby |
class FixCategories < ActiveRecord::Migration
def change
change_table :categorizations do |t|
t.belongs_to :modified_by
end
rename_column :categorizations, :stuff_id, :categorizable_id
rename_column :categorizations, :stuff_type, :categorizable_type
change_table :categories do |t|
t.b... | Ruby |
class ChangeCompanyControlsToPolicy < ActiveRecord::Migration
def up
transaction do
Directive.where(:kind => "Company Controls").each do |directive|
directive.kind = "Company Controls Policy"
directive.save!
end
end
end
def down
end
end
| Ruby |
class CreateRisks < ActiveRecord::Migration
def change
create_table :risks do |t|
t.string :slug
t.string :title
t.text :description
t.string :url
t.references :modified_by
t.datetime :start_date
t.datetime :stop_date
t.timestamps
end
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.