Sha256: 94759cf330be96c6aec7d96329acd3d75ba18ade3d51403ebe7841bbf8de0a37

Contents?: true

Size: 764 Bytes

Versions: 15

Compression:

Stored size: 764 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_equal nil }
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
push_type_core-0.10.0 test/fields/push_type/asset_field_test.rb
push_type_core-0.10.0.beta.5 test/fields/push_type/asset_field_test.rb
push_type_core-0.10.0.beta.3 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.5 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.3 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.2 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.1 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.0 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.0.beta.4 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.0.beta.3 test/fields/push_type/asset_field_test.rb
push_type_core-0.9.0.beta.2 test/fields/push_type/asset_field_test.rb
push_type_core-0.8.2 test/fields/push_type/asset_field_test.rb
push_type_core-0.8.1 test/fields/push_type/asset_field_test.rb
push_type_core-0.8.0 test/fields/push_type/asset_field_test.rb
push_type_core-0.8.0.beta.3 test/fields/push_type/asset_field_test.rb