Sha256: b1a9fa1dd52acfed328b2c43e5b56f50201ca5aba7e9a3f4e09729338080b90f

Contents?: true

Size: 1.19 KB

Versions: 13

Compression:

Stored size: 1.19 KB

Contents

require "spec_helper"
require "rack/test/uploaded_file"
require "time"

describe ActiveMetadata do

  context "model methods" do

    it "should exist a method acts_as_metadata in the model" do
      Document.respond_to?(:acts_as_metadata).should be_true
    end

    it "should find the active_metadata_ancestors if no active_metadata_ancestors params has been provided" do
      @document = Document.create! { |d| d.name = "John" }
      @document.metadata_id.should eq @document.id
      @document.metadata_class.should eq @document.class.to_s
    end

    it "should find the metadata_root.id if an active_metadata_ancestors params has been specified" do
      @document = Document.create! { |d| d.name = "John" }
      @section = @document.create_section :title => "new section"
      @section.metadata_id.should eq @document.id
      @section.metadata_class.should eq @document.class.to_s
    end

  end

  context "saving a child object before active_metadata_ancestors" do

    it "should raise an exception cause ancestor id is not defined" do
      lambda{Section.create! :title => 'section title'}.should raise_error(RuntimeError,"[active_metdata] - Ancestor model is not yet persisted")
    end

  end


end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active_metadata-0.7.4 spec/lib/active_metadata_spec.rb
active_metadata-0.7.3 spec/lib/active_metadata_spec.rb
active_metadata-0.7.2 spec/lib/active_metadata_spec.rb
active_metadata-0.7.1 spec/lib/active_metadata_spec.rb
active_metadata-0.7.0 spec/lib/active_metadata_spec.rb
active_metadata-0.6.9 spec/lib/active_metadata_spec.rb
active_metadata-0.6.7 spec/lib/active_metadata_spec.rb
active_metadata-0.6.6 spec/lib/active_metadata_spec.rb
active_metadata-0.6.5 spec/lib/active_metadata_spec.rb
active_metadata-0.6.4 spec/lib/active_metadata_spec.rb
active_metadata-0.6.3 spec/lib/active_metadata_spec.rb
active_metadata-0.6.2 spec/lib/active_metadata_spec.rb
active_metadata-0.6.1 spec/lib/active_metadata_spec.rb