kasket 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kasket.rb +1 -1
- data/lib/kasket/configuration_mixin.rb +3 -2
- data/lib/kasket/write_mixin.rb +8 -0
- data/test/transaction_test.rb +27 -0
- metadata +4 -2
data/lib/kasket.rb
CHANGED
@@ -9,7 +9,7 @@ module Kasket
|
|
9
9
|
module ConfigurationMixin
|
10
10
|
|
11
11
|
def without_kasket(&block)
|
12
|
-
old_value = @use_kasket
|
12
|
+
old_value = @use_kasket
|
13
13
|
@use_kasket = false
|
14
14
|
yield
|
15
15
|
ensure
|
@@ -17,7 +17,7 @@ module Kasket
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def use_kasket?
|
20
|
-
@use_kasket
|
20
|
+
@use_kasket == true
|
21
21
|
end
|
22
22
|
|
23
23
|
def kasket_parser
|
@@ -69,6 +69,7 @@ module Kasket
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def has_kasket_on(*args)
|
72
|
+
@use_kasket = true
|
72
73
|
attributes = args.sort! { |x, y| x.to_s <=> y.to_s }
|
73
74
|
if attributes != [:id] && !kasket_indices.include?([:id])
|
74
75
|
has_kasket_on(:id)
|
data/lib/kasket/write_mixin.rb
CHANGED
@@ -12,6 +12,12 @@ module Kasket
|
|
12
12
|
remove_from_kasket(args[0])
|
13
13
|
update_counters_without_kasket_clearing(*args)
|
14
14
|
end
|
15
|
+
|
16
|
+
def transaction_with_kasket_disabled(*args)
|
17
|
+
without_kasket do
|
18
|
+
transaction_without_kasket_disabled(*args) { yield }
|
19
|
+
end
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
module InstanceMethods
|
@@ -66,8 +72,10 @@ module Kasket
|
|
66
72
|
model_class.after_destroy :clear_kasket_indices
|
67
73
|
|
68
74
|
model_class.alias_method_chain :reload, :kasket_clearing
|
75
|
+
|
69
76
|
|
70
77
|
class << model_class
|
78
|
+
alias_method_chain :transaction, :kasket_disabled
|
71
79
|
alias_method_chain :update_counters, :kasket_clearing
|
72
80
|
end
|
73
81
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TransactionTest < ActiveSupport::TestCase
|
4
|
+
context "Transactions" do
|
5
|
+
should "have kasket disabled" do
|
6
|
+
assert_equal true, Post.use_kasket?
|
7
|
+
Post.transaction do
|
8
|
+
assert_equal false, Post.use_kasket?
|
9
|
+
end
|
10
|
+
assert_equal true, Post.use_kasket?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "Nested transactions" do
|
15
|
+
setup { Comment.has_kasket }
|
16
|
+
should "disable kasket" do
|
17
|
+
Post.transaction do
|
18
|
+
assert_equal true, Comment.use_kasket?
|
19
|
+
assert_equal false, Post.use_kasket?
|
20
|
+
Comment.transaction do
|
21
|
+
assert_equal false, Post.use_kasket?
|
22
|
+
assert_equal false, Comment.use_kasket?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kasket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-02-02 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- test/parser_test.rb
|
100
100
|
- test/read_mixin_test.rb
|
101
101
|
- test/test_models.rb
|
102
|
+
- test/transaction_test.rb
|
102
103
|
has_rdoc: true
|
103
104
|
homepage: http://github.com/staugaard/kasket
|
104
105
|
licenses: []
|
@@ -137,3 +138,4 @@ test_files:
|
|
137
138
|
- test/parser_test.rb
|
138
139
|
- test/read_mixin_test.rb
|
139
140
|
- test/test_models.rb
|
141
|
+
- test/transaction_test.rb
|