Sha256: cf6694f022de7175e2640e5df5474e1ab1d7fc17b3482454887c331edf085710

Contents?: true

Size: 696 Bytes

Versions: 9

Compression:

Stored size: 696 Bytes

Contents

require 'spec_helper'

describe Socialization::ActiveRecordStores::Mixins::Base do
  describe ".update_counter" do
    it "increments counter cache if column exists" do
      followable = ImAFollowableWithCounterCache.create

      update_counter(followable, followers_count: +1)

      expect(followable.reload.followers_count).to eq(1)
    end

    it "does not raise any errors if column doesn't exist" do
      followable = ImAFollowable.create
      update_counter(followable, followers_count: +1)
    end
  end

  def update_counter(model, counter)
    klass = Object.new
    klass.extend(Socialization::ActiveRecordStores::Mixins::Base)
    klass.update_counter(model, counter)
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
socialization-2.0.2 spec/stores/active_record/mixins/base_spec.rb
socialization-2.0.1 spec/stores/active_record/mixins/base_spec.rb
socialization-2.0.0 spec/stores/active_record/mixins/base_spec.rb
socialization-1.2.3 spec/stores/active_record/mixins/base_spec.rb
socialization-1.2.2 spec/stores/active_record/mixins/base_spec.rb
socialization-1.2.1 spec/stores/active_record/mixins/base_spec.rb
twrk-socialization-1.2.0 spec/stores/active_record/mixins/base_spec.rb
twrk-socialization-0.0.1 spec/stores/active_record/mixins/base_spec.rb
socialization-1.2.0 spec/stores/active_record/mixins/base_spec.rb