Sha256: 89cb5cf523db4c679bebb3a65c4271b6531b0e2ef1b54fe0ea30191f5cd0be80

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true
require 'test_helper'

module Kadmin
  # NOTE: Uses the Person model from the dummy app for testing
  class FormTest < ActiveSupport::TestCase
    def test_initialize
      person = Person.create(first_name: 'first', last_name: 'last', gender: 'm', date_of_birth: 2.years.ago)
      form = Kadmin::Form.new(person)

      assert_equal person, form.model
      assert_empty form.errors
      assert form.valid?
      assert_equal person, form.to_model
    end

    class MainForm < Kadmin::Form
      delegate_association :items, to: 'Kadmin::FormTest::ItemForm'
      delegate_attributes :owner
    end

    class ItemForm < Kadmin::Form
    end

    class Package
      include ActiveModel::Model
      attr_accessor :id, :owner

      def persisted?
        return !self.id.nil?
      end

      def items_attributes(item_attributes)
        item_attributes.each do |attributes|
          
        end
      end
    end

    class Item
      include ActiveModel::Model
      attr_accessor :id, :name, :weight, :package_id

      def persisted?
        return !self.id.nil?
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kadmin-0.6.8 test/components/form_test.rb
kadmin-0.6.7 test/components/form_test.rb
kadmin-0.6.6 test/components/form_test.rb
kadmin-0.6.5 test/components/form_test.rb
kadmin-0.6.4 test/components/form_test.rb
kadmin-0.6.3 test/components/form_test.rb
kadmin-0.6.1 test/components/form_test.rb
kadmin-0.5.7 test/components/form_test.rb
kadmin-0.5.6 test/components/form_test.rb
kadmin-0.4.2 test/components/form_test.rb
kadmin-0.4.1 test/components/form_test.rb
kadmin-0.4.0 test/components/form_test.rb