Sha256: 46360ba865be9ef95efbe32a5f4222c025b54289cbb589d3c73ee9e0b95339a3

Contents?: true

Size: 1011 Bytes

Versions: 9

Compression:

Stored size: 1011 Bytes

Contents

require 'spec_helper'

describe RailsBestPractices::Core::ModelAssociations do
  let(:model_associations) { RailsBestPractices::Core::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
    model_associations.get_association("Project", "project_manager").should == {:meta => :belongs_to, :class_name => "ProjectManager"}
    model_associations.get_association("Project", "people").should == {:meta => :has_many, :class_name => "Person"}
    model_associations.get_association("Project", "unknown").should be_nil
  end

  it "should check is model associatiosn" do
    model_associations.is_association?("Project", "project_manager").should be_true
    model_associations.is_association?("Project", "people").should be_true
    model_associations.is_association?("Project", "unknown").should be_false
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
rails_best_practices-0.10.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.10.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-raydog153-0.9.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.9.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.8.2 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.8.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.8.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.7.5 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-0.7.4 spec/rails_best_practices/core/model_associations_spec.rb