Sha256: 6aaa553d0c6d07e17c531807fbb735a9273dc00ee19ab72005d6108a482b8b1b

Contents?: true

Size: 1019 Bytes

Versions: 17

Compression:

Stored size: 1019 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

17 entries across 17 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.9.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.8.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.7.2 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.7.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.7.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.6.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.5.3 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.5.2 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.5.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.5.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.4.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.3.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.2.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.1.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.0.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.0.0 spec/rails_best_practices/core/model_associations_spec.rb