Sha256: 013bf33e5700aaef948158dd91c61ec532e031e1c074c9864ddb1c515bc06307

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

module RailsBestPractices::Core
  describe ModelAssociations do
    let(:model_associations) { ModelAssociations.new }

    before :each do
      model_associations.add_association('Project', 'project_manager', 'belongs_to')
      model_associations.add_association('Project', 'people', 'has_many', 'Person')
    end

    it 'should get model associations' do
      expect(model_associations.get_association('Project', 'project_manager')).to eq({'meta' => 'belongs_to', 'class_name' => 'ProjectManager'})
      expect(model_associations.get_association('Project', 'people')).to eq({'meta' => 'has_many', 'class_name' => 'Person'})
      expect(model_associations.get_association('Project', 'unknown')).to be_nil
    end

    it 'should check is model associatiosn' do
      expect(model_associations.is_association?('Project', 'project_manager')).to eq true
      expect(model_associations.is_association?('Project', 'people')).to eq true
      expect(model_associations.is_association?('Project', 'unknown')).to eq false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_best_practices-1.19.1 spec/rails_best_practices/core/model_associations_spec.rb