Sha256: e80e676b75ba40b48f598a620645f9ef59a908bce4960e934e0b9352fa3e0b93

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

require 'spec_helper'

describe ArResqueCounterCache::ActiveRecord do

  context "callbacks" do

    subject { User.create(:name => "Susan") }

    it "should increment" do
      ArResqueCounterCache::IncrementCountersWorker.should_receive(:cache_and_enqueue).with("User", subject.id, "posts_count", :increment)
      subject.posts.create(:body => "I have a cat!")
    end

    it "should increment" do
      ArResqueCounterCache::IncrementCountersWorker.stub(:cache_and_enqueue)
      post = subject.posts.create(:body => "I have a cat!")
      ArResqueCounterCache::IncrementCountersWorker.should_receive(:cache_and_enqueue).with("User", subject.id, "posts_count", :decrement)
      post.destroy
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ar-resque-counter-cache-3.0.0 spec/ar_resque_counter_cache/active_record_spec.rb
ar-resque-counter-cache-3.0.0.rc1 spec/ar_resque_counter_cache/active_record_spec.rb