Sha256: 73e171c7ab8d686f37ee781fc22adfc39938cd12a91c572b9f694f2fc97f3167

Contents?: true

Size: 1.54 KB

Versions: 19

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Mdm::Ref do
  context 'associations' do
    # shoulda matchers don't have support for :primary_key option, so need to
    # test this association manually
    context 'module_refs' do
      context 'with Mdm::Module::Refs' do
        context 'with same name' do
          let(:name) do
            FactoryGirl.generate :mdm_ref_name
          end

          let!(:module_ref) do
            FactoryGirl.create(:mdm_module_ref, :name => name)
          end

          let!(:ref) do
            FactoryGirl.create(:mdm_ref, :name => name)
          end

          it 'should have module_refs in assocation' do
            ref.module_refs.should =~ [module_ref]
          end
        end
      end
    end

    # @todo https://www.pivotaltracker.com/story/show/48915453
    it { should have_many(:vulns_refs).class_name('Mdm::VulnRef') }
  end

  context 'database' do
    context 'columns' do
      it { should have_db_column(:name).of_type(:string) }
      it { should have_db_column(:ref_id).of_type(:integer) }

      context 'timestamps' do
        it { should have_db_column(:created_at).of_type(:datetime) }
        it { should have_db_column(:updated_at).of_type(:datetime) }
      end
    end

    context 'indices' do
      it { should have_db_index(:name) }
    end
  end

  context 'factories' do
    context 'mdm_ref' do
      subject(:mdm_ref) do
        FactoryGirl.build :mdm_ref
      end

      it { should be_valid }
    end
  end

  context 'mass assignment security' do
    it { should allow_mass_assignment_of(:name) }
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
metasploit_data_models-0.15.2-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.15.2 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.15.1-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.15.1 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.15.0 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.4-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.4 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.3-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.3 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.2-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.2 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.1-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.14.1 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.12.1-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.12.1 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.12.0-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.12.0 spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.11.2-java spec/app/models/mdm/ref_spec.rb
metasploit_data_models-0.11.2 spec/app/models/mdm/ref_spec.rb