Sha256: d1f2e191c778b8fb369353f721c0e517c45fc186fc884f393c3e6fc4736a8788

Contents?: true

Size: 1.04 KB

Versions: 11

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

11 entries across 11 versions & 1 rubygems

Version Path
rails_best_practices-1.19.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.18.1 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.18.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.17.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.16.0 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.15.7 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.15.6 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.15.4 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.15.3 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.15.2 spec/rails_best_practices/core/model_associations_spec.rb
rails_best_practices-1.15.1 spec/rails_best_practices/core/model_associations_spec.rb