Sha256: c38ab1bf05a1e119bd4e92e1cd3a06b729a8e50e5ce5ae57a9e08f0d2a57c96c

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

# Copyright:: (c) Autotelik Media Ltd 2015
# Author ::   Tom Statter
# License::   MIT
#
require File.join(File.dirname(__FILE__), '/../spec_helper')

module DataShift

  module InboundData

    describe 'Inbound Data' do
      it 'should store details of inbound lookup' do
        ls = LookupSupport.new( Project, :title, 'my title')
        expect(ls).to be
      end

      it 'should store details of inbound column' do
        c = Column.new( 'Value As A String')
        expect(c).to be
      end

      it 'should store details of inbound column with its column number' do
        c = Column.new( 'Value As A String', 0)
        expect(c).to be
      end

      context 'lookups' do
        let(:create_project) { create(:project, title: 'my title') }

        let(:lookup) { LookupSupport.new( Project, :title, 'my title') }

        it 'should enable lookup of a domain object' do
          create_project
          result = lookup.klass.where( lookup.field => lookup.where_value ).first
          expect(result).to be_a Project
        end

        it 'should provide shortcut to return active record relation', fail: true do
          id = create_project.id
          result = lookup.find
          expect(result).to be_a ActiveRecord::Relation
          expect(result.first.id).to eq id
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
datashift-0.40.1 spec/datashift/inbound_data_spec.rb
datashift-0.40.0 spec/datashift/inbound_data_spec.rb