Sha256: 5ec454df922cf595512516535b79b54ad9889db05ef61cb1dcb1fd90781b2633

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Upgrow
  class ModelSchemaTest < ActiveSupport::TestCase
    setup do
      @schema = ModelSchema.new
    end

    test '#association_names is empty by default' do
      assert_empty @schema.attribute_names
    end

    test '#association_names returns the defined associations' do
      @schema.association(:user)
      @schema.association(:tags)

      assert_equal [:user, :tags], @schema.association_names
    end

    test '#association defines an association' do
      @schema.association(:user)

      assert_equal [:user], @schema.association_names
    end

    test '#association does not define the same association twice' do
      @schema.association(:user)
      @schema.association(:user)

      assert_equal [:user], @schema.association_names
    end

    test '#dup creates a Schema with independent association names' do
      @schema.association(:user)
      new_schema = @schema.dup
      new_schema.association(:tags)

      assert_equal [:user], @schema.association_names
      assert_equal [:user, :tags], new_schema.association_names
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
upgrow-0.0.5 test/upgrow/model_schema_test.rb
upgrow-0.0.4 test/upgrow/model_schema_test.rb
upgrow-0.0.3 test/upgrow/model_schema_test.rb