Sha256: 69a4ae970605caa9c335198864793bfebc2a7e1fc74bcb2e5c64e5ccd082d275
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
require 'spec_helper' describe "nested hash resources" do before do class NestedResource < ActiveTriples::Resource property :title, predicate: ::RDF::DC.title ## Necessary to get AT to create hash URIs. def initialize(uri, parent) if uri.try(:node?) uri = RDF::URI("#nested_#{uri.to_s.gsub('_:','')}") elsif uri.start_with?("#") uri = RDF::URI(uri) end super end def final_parent parent end end class ExampleOwner < ActiveFedora::Base property :relation, predicate: ::RDF::DC.relation, class_name: NestedResource accepts_nested_attributes_for :relation end end after do Object.send(:remove_const, :NestedResource) Object.send(:remove_const, :ExampleOwner) end it "should be able to nest resources" do obj = ExampleOwner.new obj.attributes = { :relation_attributes => [ { :title => "Test" } ] } obj.save! expect(obj.reload.relation.first.title).to eq ["Test"] end end
Version data entries
5 entries across 5 versions & 1 rubygems