Sha256: 125969ad692e32bff7be471280f22aea26a35a7dd7670b777a9db51d2a12b1ea

Contents?: true

Size: 761 Bytes

Versions: 8

Compression:

Stored size: 761 Bytes

Contents

require 'test_helper'

module PushType
  class AssetFieldTest < ActiveSupport::TestCase

    class TestPage < PushType::Node
      field :foo_id, :asset
    end

    let(:node)  { TestPage.create FactoryGirl.attributes_for(:node, foo_id: asset.id) }
    let(:asset) { FactoryGirl.create :asset }
    let(:field) { node.fields[:foo_id] }
    
    it { field.template.must_equal 'asset' }
    it { field.relation_class.must_equal PushType::Asset }
    it { field.json_value.must_equal asset.id }
    it { field.value.must_equal asset.id }

    it { node.foo_id.must_equal asset.id }
    it { node.foo.must_equal asset }

    describe 'with missing relations' do
      before do
        asset.destroy
      end

      it { node.foo.must_be_nil }
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
push_type_core-0.11.2 test/fields/push_type/asset_field_test.rb
push_type_core-0.11.1 test/fields/push_type/asset_field_test.rb
push_type_core-0.11.0.beta.2 test/fields/push_type/asset_field_test.rb
push_type_core-0.11.0.beta.1 test/fields/push_type/asset_field_test.rb
push_type_core-0.10.4 test/fields/push_type/asset_field_test.rb
push_type_core-0.10.3 test/fields/push_type/asset_field_test.rb
push_type_core-0.10.2 test/fields/push_type/asset_field_test.rb
push_type_core-0.10.1 test/fields/push_type/asset_field_test.rb