ngmoco-cache-money 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/UNSUPPORTED_FEATURES +1 -1
- data/lib/cache_money.rb +5 -3
- data/lib/cash/query/abstract.rb +3 -3
- data/spec/cash/write_through_spec.rb +22 -0
- metadata +3 -3
data/UNSUPPORTED_FEATURES
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* update_all, delete, update_counter, increment_counter, decrement_counter, counter_caches in general - counter caches are replaced by this gem, bear that in mind.
|
7
7
|
* attr_readonly - no technical obstacle, just not yet supported
|
8
8
|
* attributes before typecast behave unpredictably - hard to support
|
9
|
-
*
|
9
|
+
* Named bind variables :conditions => ["name = :name", { :name => "37signals!" }] - not hard to support
|
10
10
|
* printf style binds: :conditions => ["name = '%s'", "37signals!"] - not too hard to support
|
11
11
|
* objects as attributes that are serialized. story.title = {:foo => :bar}; customer.balance = Money.new(...) - these could be coerced using Column#type_cast?
|
12
12
|
|
data/lib/cache_money.rb
CHANGED
@@ -57,11 +57,13 @@ module Cash
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def transaction_with_cache_transaction(
|
60
|
+
def transaction_with_cache_transaction(*args)
|
61
61
|
if cache_config
|
62
|
-
|
62
|
+
transaction_without_cache_transaction(*args) do
|
63
|
+
repository.transaction { yield }
|
64
|
+
end
|
63
65
|
else
|
64
|
-
transaction_without_cache_transaction(
|
66
|
+
transaction_without_cache_transaction(*args)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
data/lib/cash/query/abstract.rb
CHANGED
@@ -187,9 +187,9 @@ module Cash
|
|
187
187
|
|
188
188
|
def find_from_keys(*missing_keys)
|
189
189
|
missing_ids = Array(missing_keys).flatten.collect { |key| key.split('/')[2].to_i }
|
190
|
-
options =
|
191
|
-
|
192
|
-
options
|
190
|
+
options = {}
|
191
|
+
order_sql = @options1[:order] || @options2[:order]
|
192
|
+
options[:order] = order_sql if order_sql
|
193
193
|
find_from_ids_without_cache(missing_ids, options)
|
194
194
|
end
|
195
195
|
end
|
@@ -219,5 +219,27 @@ module Cash
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
end
|
222
|
+
|
223
|
+
describe 'Transactions' do
|
224
|
+
def create_story_and_update
|
225
|
+
@story = Story.create!(:title => original_title = "original title")
|
226
|
+
|
227
|
+
Story.transaction do
|
228
|
+
@story.title = "new title"
|
229
|
+
@story.save
|
230
|
+
yield if block_given?
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'should commit on success' do
|
235
|
+
create_story_and_update
|
236
|
+
@story.reload.title.should == "new title"
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'should roll back transactions when ActiveRecord::Rollback is raised' do
|
240
|
+
create_story_and_update { raise ActiveRecord::Rollback }
|
241
|
+
@story.reload.title.should == "original title"
|
242
|
+
end
|
243
|
+
end
|
222
244
|
end
|
223
245
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 14
|
9
|
+
version: 0.2.14
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nick Kallen
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-08-
|
20
|
+
date: 2010-08-23 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|