Sha256: c820e08cf8820de90ff2cd64bad97827ad1a634e4b1f7ec312a266f5d1e7e143

Contents?: true

Size: 854 Bytes

Versions: 11

Compression:

Stored size: 854 Bytes

Contents

FactoryGirl.define do

  factory :g5_updatable_client, class: "G5Updatable::Client" do
    sequence(:urn) { |n| "client_urn_#{n}" }
    uid { "http://client.com/#{urn}" }
  end

  factory :g5_updatable_location, class: "G5Updatable::Location" do
    association :client, factory: :g5_updatable_client
    sequence(:urn) { |n| "location_urn_#{n}" }
    sequence(:phone_number) {|n| "123-321-#{n}" }
    uid { "#{client.urn}/locations/#{urn}" }
    initialize_with do
      attrs = {}
      attributes.each do |key, value|
        if G5Updatable::Location.instance_methods.include?(key) ||
            G5Updatable::Location.column_names.include?(key.to_s)
          attrs[key] = value
        else
          attrs[:properties] ||= {}
          attrs[:properties][key] = value
        end
      end
      G5Updatable::Location.new(attrs)
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
g5_updatable-0.7.2 lib/g5_updatable/factories.rb
g5_updatable-0.7.1 lib/g5_updatable/factories.rb
g5_updatable-0.7.0 lib/g5_updatable/factories.rb
g5_updatable-0.6.1 lib/g5_updatable/factories.rb
g5_updatable-0.6.0 lib/g5_updatable/factories.rb
g5_updatable-0.5.1 lib/g5_updatable/factories.rb
g5_updatable-0.5.0 lib/g5_updatable/factories.rb
g5_updatable-0.4.3 lib/g5_updatable/factories.rb
g5_updatable-0.4.2 lib/g5_updatable/factories.rb
g5_updatable-0.4.1 lib/g5_updatable/factories.rb
g5_updatable-0.4.0 lib/g5_updatable/factories.rb