Sha256: 234b60a3ac625b67de0e8aa40409d9c4cc222a7e0bd7ccb470d11c7db8aeb5b0

Contents?: true

Size: 892 Bytes

Versions: 5

Compression:

Stored size: 892 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

5 entries across 5 versions & 1 rubygems

Version Path
protobuf-activerecord-3.6.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-3.5.1 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-3.5.0 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-3.4.4 spec/protobuf/active_record/nested_attributes_spec.rb
protobuf-activerecord-3.4.4.pre spec/protobuf/active_record/nested_attributes_spec.rb