File: concern_test.rb

package info (click to toggle)
ruby-with-advisory-lock 5.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 244 kB
  • sloc: ruby: 818; makefile: 14
file content (33 lines) | stat: -rw-r--r-- 973 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'test_helper'

class WithAdvisoryLockConcernTest < GemTestCase
  test 'adds with_advisory_lock to ActiveRecord classes' do
    assert_respond_to(Tag, :with_advisory_lock)
  end

  test 'adds with_advisory_lock to ActiveRecord instances' do
    assert_respond_to(Label.new, :with_advisory_lock)
  end

  test 'adds advisory_lock_exists? to ActiveRecord classes' do
    assert_respond_to(Tag, :advisory_lock_exists?)
  end

  test 'adds advisory_lock_exists? to ActiveRecord instances' do
    assert_respond_to(Label.new, :advisory_lock_exists?)
  end
end

class ActiveRecordQueryCacheTest < GemTestCase
  test 'does not disable quary cache by default' do
    Tag.connection.expects(:uncached).never
    Tag.with_advisory_lock('lock') { Tag.first }
  end

  test 'can disable ActiveRecord query cache' do
    Tag.connection.expects(:uncached).once
    Tag.with_advisory_lock('a-lock', disable_query_cache: true) { Tag.first }
  end
end