# 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