Sha256: c6c74e841c9c22bdbe8b9eb2ccc99ac9f47187c603bddcfbdd84802e0f28cf8e

Contents?: true

Size: 693 Bytes

Versions: 7

Compression:

Stored size: 693 Bytes

Contents

require 'spec_helper'

describe 'Form with injected commands' do
  subject(:form) { form_class.build(params) }

  let(:params) { { title: 'Task one' } }

  let(:form_class) do
    Class.new(ROM::Model::Form) do
      commands users: :create, tasks: :create

      inject_commands_for :tasks

      mappings tasks: :entity

      input do
        set_model_name 'Task'

        attribute :title
      end

      def commit!
        tasks.create[attributes]
      end
    end
  end

  it 'auto-maps result using injected commands' do
    form.save

    value = form.result

    expect(value).to be_a(Task)
    expect(value.id).to_not be(nil)
    expect(value.title).to eql('Task one')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-rails-0.9.0 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.9.0.beta1 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.8.0 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.7.0 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.6.0 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.6.0.rc1 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.6.0.beta1 spec/integration/form_with_injected_commands_spec.rb