0
+require 'spec/spec_helper'
0
+describe "ThinkingSphinx::ActiveRecord::Delta" do
0
+ describe "after_commit callback" do
0
+ Person.stub_method(:write_inheritable_array => true)
0
+ Person.unstub_method(:write_inheritable_array)
0
+ it "should add callbacks" do
0
+ Person.after_commit :toggle_delta
0
+ Person.should have_received(:write_inheritable_array).with(
0
+ :after_commit, [:toggle_delta]
0
+ describe "save_with_after_commit_callback method" do
0
+ :save_without_after_commit_callback => true,
0
+ it "should call the normal save method" do
0
+ @person.should have_received(:save_without_after_commit_callback)
0
+ it "should call the callbacks if the save was successful" do
0
+ @person.should have_received(:callback).with(:after_commit)
0
+ it "shouldn't call the callbacks if the save failed" do
0
+ @person.stub_method(:save_without_after_commit_callback => false)
0
+ @person.should_not have_received(:callback)
0
+ it "should return the normal save's result" do
0
+ @person.save.should be_true
0
+ @person.stub_method(:save_without_after_commit_callback => false)
0
+ @person.save.should be_false
0
+ describe "save_with_after_commit_callback! method" do
0
+ :save_without_after_commit_callback! => true,
0
+ it "should call the normal save! method" do
0
+ @person.should have_received(:save_without_after_commit_callback!)
0
+ it "should call the callbacks if the save! was successful" do
0
+ @person.should have_received(:callback).with(:after_commit)
0
+ it "shouldn't call the callbacks if the save! failed" do
0
+ @person.stub_method(:save_without_after_commit_callback! => false)
0
+ @person.should_not have_received(:callback)
0
+ it "should return the normal save's result" do
0
+ @person.save!.should be_true
0
+ @person.stub_method(:save_without_after_commit_callback! => false)
0
+ @person.save!.should be_false
0
+ describe "destroy_with_after_commit_callback method" do
0
+ :destroy_without_after_commit_callback => true,
0
+ it "should call the normal destroy method" do
0
+ @person.should have_received(:destroy_without_after_commit_callback)
0
+ it "should call the callbacks if the destroy was successful" do
0
+ @person.should have_received(:callback).with(:after_commit)
0
+ it "shouldn't call the callbacks if the destroy failed" do
0
+ @person.stub_method(:destroy_without_after_commit_callback => false)
0
+ @person.should_not have_received(:callback)
0
+ it "should return the normal save's result" do
0
+ @person.destroy.should be_true
0
+ @person.stub_method(:destroy_without_after_commit_callback => false)
0
+ @person.destroy.should be_false
0
+ describe "toggle_delta method" do
0
+ it "should set the delta value to true" do
0
+ @person.delta.should be_false
0
+ @person.send(:toggle_delta)
0
+ @person.delta.should be_true
0
+ describe "index_delta method" do
0
+ ThinkingSphinx::Configuration.stub_method(:environment => "spec")
0
+ ThinkingSphinx.stub_method(:deltas_enabled? => true)
0
+ @person.stub_method(:system => true)
0
+ ThinkingSphinx::Configuration.unstub_method(:environment)
0
+ ThinkingSphinx.unstub_method(:deltas_enabled?)
0
+ it "shouldn't index if delta indexing is disabled" do
0
+ ThinkingSphinx.stub_method(:deltas_enabled? => false)
0
+ @person.send(:index_delta)
0
+ @person.should_not have_received(:system)
0
+ it "shouldn't index if the environment is 'test'" do
0
+ ThinkingSphinx::Configuration.stub_method(:environment => "test")
0
+ @person.send(:index_delta)
0
+ @person.should_not have_received(:system)
0
+ it "should call indexer for the delta index" do
0
+ @person.send(:index_delta)
0
+ @person.should have_received(:system).with(
0
+ "indexer --config #{ThinkingSphinx::Configuration.new.config_file} --rotate person_delta"
0
\ No newline at end of file
Comments
No one has commented yet.