Sha256: 10c138cb7414de2e1ca4604c9d5849138fe50478a2a9536f71857ddf0543648d

Contents?: true

Size: 967 Bytes

Versions: 76

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Item do
  before do
    class Location < LHS::Record
      endpoint 'http://sync/locations'
      endpoint 'http://sync/locations/{id}'
    end

    class Synchronization < LHS::Record
      endpoint 'http://sync/locations/{id}/sync'
    end

    stub_request(:get, "http://sync/locations/1")
      .to_return(body: {
        id: 1,
        name: 'localsearch'
      }.to_json)

    stub_request(:post, "http://sync/locations/1/sync")
      .with(body: {
        name: 'localsearch'
      }.to_json)
      .to_return(status: 201)
  end

  context 'convert records from class A to class B' do
    it "becomes a record of another class" do
      location = Location.find(1)
      synchronization = location.becomes(Synchronization)
      expect(synchronization).to be_kind_of(Synchronization)
      synchronization.save!
      expect(synchronization).to be_kind_of(Synchronization)
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
lhs-21.0.0 spec/item/becomes_spec.rb
lhs-20.1.4 spec/item/becomes_spec.rb
lhs-20.1.3.pre.paginationfix.3 spec/item/becomes_spec.rb
lhs-20.1.3.pre.paginationfix.2 spec/item/becomes_spec.rb
lhs-20.1.3.pre.paginationfix.1 spec/item/becomes_spec.rb
lhs-20.1.2 spec/item/becomes_spec.rb
lhs-20.1.1 spec/item/becomes_spec.rb
lhs-20.0.0 spec/item/becomes_spec.rb
lhs-19.10.0 spec/item/becomes_spec.rb
lhs-19.9.0 spec/item/becomes_spec.rb
lhs-19.8.2 spec/item/becomes_spec.rb
lhs-19.8.1 spec/item/becomes_spec.rb
lhs-19.8.0 spec/item/becomes_spec.rb
lhs-19.7.0 spec/item/becomes_spec.rb
lhs-19.6.0 spec/item/becomes_spec.rb
lhs-19.5.0 spec/item/becomes_spec.rb
lhs-19.5.0.pre.wherehref.1 spec/item/becomes_spec.rb
lhs-19.4.1 spec/item/becomes_spec.rb
lhs-19.4.0 spec/item/becomes_spec.rb
lhs-19.3.1 spec/item/becomes_spec.rb