Sha256: 9ae8ef857d39b9a2009ee788c5fc5348bcdb6b72a1978e15d5af91326e7507b5

Contents?: true

Size: 894 Bytes

Versions: 8

Compression:

Stored size: 894 Bytes

Contents

require "spec_helper"

describe Protobuf::ActiveRecord::NestedAttributes do
  let(:user_message) {
    UserMessage.new(:name => "foo bar", :email => "foo@test.co", :photos => [{ :url => "https://test.co/test.png" }])
  }

  describe "._filter_attribute_fields", :aggregate_failures => true do
    it "includes nested attributes" do
      attribute_fields = User._filter_attribute_fields(user_message)
      expect(attribute_fields[:photos_attributes]).to eq(user_message.photos)
    end

    context "when" do
    end
  end

  describe ".new" do
    context "when a model accepts nested attributes" do
      it "transforms nested attributes", :aggregate_failures => true do
        user_message.photos.each do |photo_message|
          expect(Photo).to receive(:attributes_from_proto).with(photo_message).and_call_original
        end
        User.new(user_message)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
protobuf-activerecord-6.1.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-6.0.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-5.2.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-5.1.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-5.0.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-5.1.0.beta spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-5.0.0.beta spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-3.6.1 spec/protobuf/active_record/nested_attributes_spec.rb