Sha256: 6d4ca4f8feeb986328d51afd6082797d884b364d4d53b94ed52b057f93e09a9f
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Mebla" do describe "synchronization" do before(:each) do Mebla.context.rebuild_index MongoidAlpha.create! :name => "Testing index", :value => 1, :cost => 2.0 end it "should index new documents automatically" do mdocument = MongoidAlpha.first lambda {Mebla.context.slingshot_index.retrieve(:mongoid_alpha, mdocument.id.to_s)}.should_not raise_error end it "should remove deleted documents from index automatically" do mdocument = MongoidAlpha.first doc_id = mdocument.id.to_s mdocument.destroy lambda {MongoidAlpha.slingshot_index.retrieve(:mongoid_alpha, doc_id)}.should raise_error end it "should update the index automatically when a document is updated" do udocument = MongoidAlpha.first udocument.update_attributes(:cost => 3.1) result = Mebla.context.slingshot_index.retrieve(:mongoid_alpha, udocument.id.to_s) result[:cost].should == 3.1 end end describe "embedded documents" do before(:each) do beta = MongoidBeta.create! :name => "Embedor parent" beta.mongoid_gammas.create :name => "Embedded", :value => 1 end it "should index embedded documents automatically and link to the parent" do mdocument = MongoidBeta.first.mongoid_gammas.first lambda { Slingshot::Configuration.client.get "#{Mebla::Configuration.instance.url}/#{Mebla.context.slingshot_index_name}/mongoid_gamma/#{mdocument.id.to_s}?routing=#{mdocument.mongoid_beta.id.to_s}" }.should_not raise_error end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mebla-1.0.0 | spec/mebla/synchronization_spec.rb |
mebla-1.0.0.rc2 | spec/mebla/synchronization_spec.rb |