la_maquina 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +2 -3
- data/README.md +25 -6
- data/Rakefile +1 -1
- data/lib/la_maquina/ciguenal.rb +12 -8
- data/lib/la_maquina/error_notifier/base.rb +11 -0
- data/lib/la_maquina/error_notifier/honeybadger_notifier.rb +12 -0
- data/lib/la_maquina/error_notifier/silent_notifier.rb +10 -0
- data/lib/la_maquina/error_notifier.rb +6 -0
- data/lib/la_maquina/piston/base.rb +11 -0
- data/lib/la_maquina/piston/cache_piston.rb +39 -0
- data/lib/la_maquina/piston.rb +3 -6
- data/lib/la_maquina/version.rb +1 -1
- data/lib/la_maquina/volante.rb +13 -9
- data/lib/la_maquina.rb +6 -7
- data/test/ciguenal_test.rb +30 -0
- data/test/dummy/app/models/admin.rb +3 -3
- data/test/dummy/app/models/admin_trait.rb +3 -3
- data/test/dummy/app/models/admin_trait_modifier.rb +3 -3
- data/test/dummy/app/models/guest.rb +2 -2
- data/test/dummy/app/models/guest_trait.rb +3 -3
- data/test/dummy/app/models/guest_trait_modifier.rb +3 -2
- data/test/dummy/app/models/property.rb +3 -2
- data/test/dummy/app/models/standalone.rb +3 -2
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/config/initializers/la_maquina.rb +3 -0
- data/test/dummy/lib/dummy_comm_object.rb +5 -0
- data/test/dummy/lib/exploding_comm_object.rb +5 -0
- data/test/dummy/lib/test_notifier.rb +6 -0
- data/test/dummy/lib/test_piston.rb +5 -0
- data/test/la_maquina_test.rb +2 -2
- data/test/volante_test.rb +136 -0
- metadata +22 -20
- data/lib/la_maquina/pistons/cache_piston.rb +0 -37
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/app/models/danny_trejo.rb +0 -5
- data/test/dummy/app/models/machete.rb +0 -8
- data/test/dummy/config/initializers/cache_machine.rb +0 -2
- data/test/dummy/lib/dummy_cache_machine_comm_object.rb +0 -5
- data/test/dummy/lib/exploding_cache_machine_comm_object.rb +0 -5
- data/test/dummy/log/test.log +0 -3980
- data/test/master_cache_object_test.rb +0 -23
- data/test/subordinate_cache_object_test.rb +0 -136
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ce3d8574213b0db902e504ad4b66e30e0961951
|
|
4
|
+
data.tar.gz: 258fec304013d1b468633d04c4cbc4f3408522a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18fbd41257b6fa9a3e423887fa2a0c345b1e51e5d0bd4de656abdd69430215f508060a54696fdebc2318e06ab9845e12f68a5b0749e814456c4b4323aa208864
|
|
7
|
+
data.tar.gz: 37f9ca36e459a12e4bdf199381af7eb8b007f38a9a5e2a5a62a52ffa35d54256c42addd9bcfedbcb6998b4a27d459d94d56a0ebc00a79c52818ff0de0fdb83b7
|
data/.gitignore
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
|
|
5
|
-
redis
|
|
4
|
+
la_maquina (0.0.2)
|
|
6
5
|
|
|
7
6
|
GEM
|
|
8
7
|
remote: https://rubygems.org/
|
|
@@ -120,7 +119,7 @@ PLATFORMS
|
|
|
120
119
|
|
|
121
120
|
DEPENDENCIES
|
|
122
121
|
bundler (~> 1.6)
|
|
123
|
-
|
|
122
|
+
la_maquina!
|
|
124
123
|
rails (>= 4.2.0)
|
|
125
124
|
rake
|
|
126
125
|
redis
|
data/README.md
CHANGED
|
@@ -42,7 +42,7 @@ class Machete < ActiveRecord::Base
|
|
|
42
42
|
belongs_to :danny_trejo
|
|
43
43
|
|
|
44
44
|
include LaMaquina::Volante
|
|
45
|
-
|
|
45
|
+
notifies :danny_trejo
|
|
46
46
|
end
|
|
47
47
|
```
|
|
48
48
|
and we want to let `DannyTrejo` know when his `Machete` has been updated so that we can reindex him.
|
|
@@ -50,7 +50,7 @@ and we want to let `DannyTrejo` know when his `Machete` has been updated so that
|
|
|
50
50
|
`Machete` is set up to fire on update, so we'll set up a listener Piston that looks like this:
|
|
51
51
|
|
|
52
52
|
```ruby
|
|
53
|
-
class SunspotPiston < LaMaquina::Piston
|
|
53
|
+
class SunspotPiston < LaMaquina::Piston::Base
|
|
54
54
|
class << self
|
|
55
55
|
def fire!(klass = "", id = nil)
|
|
56
56
|
indexed_class.find(id).index!
|
|
@@ -69,13 +69,32 @@ Which finds the klass, does a find on it and fires off [Sunspot](https://github.
|
|
|
69
69
|
|
|
70
70
|
### Setup
|
|
71
71
|
|
|
72
|
-
The setup is pretty straightforward: you do all the setting up in `config/la_maquina.rb
|
|
72
|
+
The setup is pretty straightforward: you do all the setting up in `config/initializers/la_maquina.rb`.
|
|
73
73
|
|
|
74
|
-
The
|
|
74
|
+
The 3 things you have to do are: set up the pistons(if they need configuring), install them, and configure the error_handler.
|
|
75
75
|
For example, if you're using the CachePiston and need to set up Redis, here's how your `la_maquina.rb` will look
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
LaMaquina::
|
|
77
|
+
```ruby
|
|
78
|
+
LaMaquina::Piston::CachePiston.redis = Redis::Namespace.new(:cache_piston, redis: Redis.new)
|
|
79
|
+
LaMaquina::Ciguenal.install LaMaquina::Piston::CachePiston, TestPiston
|
|
80
|
+
LaMaquina.error_notifier = LaMaquina::ErrorNotifier::HoneybadgerNotifier
|
|
81
|
+
```
|
|
82
|
+
#### ErrorNotifier
|
|
83
|
+
LaMaquina by default comes with an `ErrorNotifier::Base` that will explode in a very unhelpful manner. To override it, you need to change it in the config above and roll a new `ErrorNotifier` that responds to `notify(error, details)`. For example, if you're using Honeybadger, you can use the included `LaMaquina::ErrorNotifiers::HoneybadgerNotifier, which looks like:
|
|
84
|
+
```ruby
|
|
85
|
+
class HoneybadgerNotifier < LaMaquina::ErrorNotifier::Base
|
|
86
|
+
self.notify(error = nil, details = {})
|
|
87
|
+
Honeybadger.notify( :error_class => "CacheMachineError: #{error.class.name}",
|
|
88
|
+
:error_message => error.message,
|
|
89
|
+
:parameters => details
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
If you *don't* care about your exceptions and want to ignore them, there's a notifier you can use, `SilentNotifier`, making that last line in your `config/initializers/la_maquina.rb` be
|
|
95
|
+
```ruby
|
|
96
|
+
LaMaquina::Cinegual.error_notifier = LaMaquina::ErrorNotifier::SilentNotifier
|
|
97
|
+
```
|
|
79
98
|
|
|
80
99
|
## Contributing
|
|
81
100
|
|
data/Rakefile
CHANGED
data/lib/la_maquina/ciguenal.rb
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
module
|
|
1
|
+
module LaMaquina
|
|
2
2
|
class Ciguenal
|
|
3
3
|
|
|
4
4
|
class << self
|
|
5
|
-
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
attr_accessor :pistons
|
|
8
|
+
end
|
|
9
|
+
self.pistons = []
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
|
|
13
|
+
def notify!(klass = "", id = nil)
|
|
6
14
|
pistons.each do |piston|
|
|
7
15
|
piston.fire! klass, id
|
|
8
16
|
end
|
|
9
17
|
end
|
|
10
18
|
|
|
11
|
-
def
|
|
12
|
-
|
|
19
|
+
def install(*attrs)
|
|
20
|
+
attrs.each do |piston|
|
|
13
21
|
self.pistons << piston
|
|
14
22
|
end
|
|
15
23
|
end
|
|
16
24
|
|
|
17
|
-
protected
|
|
18
|
-
|
|
19
|
-
attr_accessor :pistons
|
|
20
|
-
self.pistons = []
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module LaMaquina
|
|
2
|
+
module ErrorNotifier
|
|
3
|
+
class HoneybadgerNotifier < LaMaquina::ErrorNotifier::Base
|
|
4
|
+
def notify(error, details = {})
|
|
5
|
+
Honeybadger.notify( :error_class => "CacheMachineError: #{error.class.name}",
|
|
6
|
+
:error_message => error.message,
|
|
7
|
+
:parameters => details
|
|
8
|
+
)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module LaMaquina
|
|
2
|
+
module Piston
|
|
3
|
+
class CachePiston < LaMaquina::Piston::Base
|
|
4
|
+
class << self
|
|
5
|
+
attr_accessor :redis
|
|
6
|
+
|
|
7
|
+
def fire!(klass = "", id = nil)
|
|
8
|
+
|
|
9
|
+
updated_at = SecureRandom.uuid()
|
|
10
|
+
redis_key_string = redis_key klass, id
|
|
11
|
+
# make a class var with a default
|
|
12
|
+
|
|
13
|
+
cache_key = "#{redis_key_string}/#{updated_at}"
|
|
14
|
+
redis.set redis_key_string, cache_key
|
|
15
|
+
|
|
16
|
+
cache_key
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def cache_key(klass, id)
|
|
20
|
+
|
|
21
|
+
redis_key_string = redis_key klass, id
|
|
22
|
+
|
|
23
|
+
key = redis.get redis_key_string
|
|
24
|
+
# key found
|
|
25
|
+
return key if key
|
|
26
|
+
|
|
27
|
+
# there's no key; we can't very well rerun nil for cache_key. Let's make a new entry
|
|
28
|
+
touch_cache klass, id
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
protected
|
|
32
|
+
|
|
33
|
+
def redis_key(klass, id)
|
|
34
|
+
"#{klass}/#{id}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/la_maquina/piston.rb
CHANGED
data/lib/la_maquina/version.rb
CHANGED
data/lib/la_maquina/volante.rb
CHANGED
|
@@ -4,11 +4,15 @@ module LaMaquina
|
|
|
4
4
|
include ActiveRecord::Callbacks
|
|
5
5
|
|
|
6
6
|
included do
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
class << self
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
attr_accessor :notified_objects
|
|
10
|
+
end
|
|
11
11
|
|
|
12
|
+
self.notified_objects = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class << self
|
|
12
16
|
def notifies(object, opts = {})
|
|
13
17
|
notified_objects << {:object => object, :options => opts}
|
|
14
18
|
end
|
|
@@ -18,7 +22,7 @@ module LaMaquina
|
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def notify!
|
|
21
|
-
notified_objects.each do |notified|
|
|
25
|
+
self.class.notified_objects.each do |notified|
|
|
22
26
|
|
|
23
27
|
object = notified[:object]
|
|
24
28
|
options = notified[:options]
|
|
@@ -35,11 +39,11 @@ module LaMaquina
|
|
|
35
39
|
LaMaquina::Ciguenal.notify!(klass, id)
|
|
36
40
|
end
|
|
37
41
|
rescue => e
|
|
38
|
-
LaMaquina.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
LaMaquina.error_notifier.notify( e,
|
|
43
|
+
:notified_class => klass,
|
|
44
|
+
:notified_id => id,
|
|
45
|
+
:notifier_class => LaMaquina.format_object_name(self),
|
|
46
|
+
:notifier_id => self.id)
|
|
43
47
|
end
|
|
44
48
|
end
|
|
45
49
|
end
|
data/lib/la_maquina.rb
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
require "la_maquina/version"
|
|
2
2
|
|
|
3
3
|
module LaMaquina
|
|
4
|
-
autoload :Ciguenal,
|
|
5
|
-
autoload :
|
|
6
|
-
autoload :
|
|
4
|
+
autoload :Ciguenal, 'la_maquina/ciguenal'
|
|
5
|
+
autoload :ErrorNotifier, 'la_maquina/error_notifier'
|
|
6
|
+
autoload :Piston, 'la_maquina/piston'
|
|
7
|
+
autoload :Volante, 'la_maquina/volante'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
mattr_accessor :update_error_handler
|
|
9
|
+
mattr_accessor :error_notifier
|
|
10
|
+
error_notifier ||= LaMaquina::ErrorNotifier::Base
|
|
12
11
|
|
|
13
12
|
def self.format_object_name(object)
|
|
14
13
|
object.class.to_s.demodulize.underscore
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class CiguenalTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@admin = admins(:wheel)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_can_fire_pistons
|
|
10
|
+
@admin.name = "lol"
|
|
11
|
+
@admin.save!
|
|
12
|
+
|
|
13
|
+
assert_equal "admin/#{@admin.id}", $fire_message
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# def test_touch_cache_updates_cache_key
|
|
17
|
+
# key = LaMaquina::Ciguenal.cache_key :admin, @admin.id
|
|
18
|
+
|
|
19
|
+
# sleep(1)
|
|
20
|
+
# LaMaquina::Ciguenal.touch_cache :admin, @admin.id
|
|
21
|
+
|
|
22
|
+
# assert_not_equal key, LaMaquina::Ciguenal.cache_key(:admin, @admin.id)
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
# def test_cache_key_generates_new_key
|
|
26
|
+
# Redis.current.del LaMaquina::Ciguenal.redis_key(:admin, @admin.id)
|
|
27
|
+
|
|
28
|
+
# assert_not_nil LaMaquina::Ciguenal.cache_key(:admin, @admin.id)
|
|
29
|
+
# end
|
|
30
|
+
end
|
|
@@ -4,8 +4,8 @@ class Admin < ActiveRecord::Base
|
|
|
4
4
|
|
|
5
5
|
has_many :properties, :as => :user
|
|
6
6
|
|
|
7
|
-
include
|
|
8
|
-
|
|
7
|
+
include LaMaquina::Volante
|
|
8
|
+
notifies :self
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
notifies :self, :using => ::DummyCommObject
|
|
11
11
|
end
|
|
@@ -2,8 +2,8 @@ class AdminTrait < ActiveRecord::Base
|
|
|
2
2
|
belongs_to :user, :class_name => "Admin"
|
|
3
3
|
belongs_to :thing, :class_name => "Trait"
|
|
4
4
|
|
|
5
|
-
include
|
|
5
|
+
include LaMaquina::Volante
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
notifies :user, :class => Admin
|
|
8
|
+
notifies :thing, :class_name => "Trait"
|
|
9
9
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class AdminTraitModifier < ActiveRecord::Base
|
|
2
2
|
belongs_to :admin_trait
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include LaMaquina::Volante
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
notifies :user, :through => :admin_trait, :class_name => "Admin"
|
|
7
|
+
notifies :thing, :through => :admin_trait, :class => Trait
|
|
8
8
|
end
|
data/test/la_maquina_test.rb
CHANGED
|
@@ -3,13 +3,13 @@ require 'test_helper'
|
|
|
3
3
|
class LaMaquinaTest < ActiveSupport::TestCase
|
|
4
4
|
|
|
5
5
|
def test_object_name_formatting
|
|
6
|
-
assert_equal "admin",
|
|
6
|
+
assert_equal "admin", LaMaquina.format_object_name(admins(:su))
|
|
7
7
|
assert_equal "admin_trait", LaMaquina.format_object_name(admin_traits(:wheels_something_else))
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def test_class_name_formatting
|
|
12
|
-
assert_equal "admin",
|
|
12
|
+
assert_equal "admin", LaMaquina.format_class_name(Admin)
|
|
13
13
|
assert_equal "admin_trait", LaMaquina.format_class_name(AdminTrait)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MasterCacheObjectTest < ActiveSupport::TestCase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# def test_update_subordinate_objects_suports_explicit_class_and_class_name
|
|
8
|
+
# admin_attr = admin_traits(:wheels_something_else)
|
|
9
|
+
# admin_key = CacheMachine::MasterCacheObject.cache_key :admin, admin_attr.user.id
|
|
10
|
+
# trait_key = CacheMachine::MasterCacheObject.cache_key :trait, admin_attr.thing.id
|
|
11
|
+
|
|
12
|
+
# # sleep to prevent key clash
|
|
13
|
+
# sleep(1)
|
|
14
|
+
|
|
15
|
+
# admin_attr.value = "lol"
|
|
16
|
+
# admin_attr.save!
|
|
17
|
+
|
|
18
|
+
# assert_not_equal admin_key, CacheMachine::MasterCacheObject.cache_key(:admin, admin_attr.user.id)
|
|
19
|
+
# assert_not_equal trait_key, CacheMachine::MasterCacheObject.cache_key(:trait, admin_attr.thing.id)
|
|
20
|
+
# end
|
|
21
|
+
|
|
22
|
+
# def test_update_subordinate_object_can_update_self
|
|
23
|
+
# wheel = admins(:wheel)
|
|
24
|
+
# key = CacheMachine::MasterCacheObject.cache_key :admin, wheel.id
|
|
25
|
+
|
|
26
|
+
# sleep(1)
|
|
27
|
+
|
|
28
|
+
# wheel.name = "WHEEL!"
|
|
29
|
+
# wheel.save!
|
|
30
|
+
|
|
31
|
+
# assert_not_equal key, CacheMachine::MasterCacheObject.cache_key(:admin, wheel.id)
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# def test_update_subordinate_object_supports_implict_class
|
|
36
|
+
|
|
37
|
+
# guest_attr = guest_traits(:gregs_something)
|
|
38
|
+
# guest_key = CacheMachine::MasterCacheObject.cache_key :guest, guest_attr.guest.id
|
|
39
|
+
# trait_key = CacheMachine::MasterCacheObject.cache_key :trait, guest_attr.trait.id
|
|
40
|
+
|
|
41
|
+
# # sleep to prevent key clash
|
|
42
|
+
# sleep(1)
|
|
43
|
+
|
|
44
|
+
# guest_attr.value = "who cares"
|
|
45
|
+
# guest_attr.save!
|
|
46
|
+
|
|
47
|
+
# assert_not_equal guest_key, CacheMachine::MasterCacheObject.cache_key(:guest, guest_attr.guest.id)
|
|
48
|
+
# assert_not_equal trait_key, CacheMachine::MasterCacheObject.cache_key(:trait, guest_attr.trait.id)
|
|
49
|
+
# end
|
|
50
|
+
|
|
51
|
+
# def test_update_subordinate_object_supports_polymorphism
|
|
52
|
+
# su_whatever = properties(:su_whatever)
|
|
53
|
+
# gregs_thing = properties(:gregs_thing)
|
|
54
|
+
|
|
55
|
+
# su_key = CacheMachine::MasterCacheObject.cache_key :admin, su_whatever.user.id
|
|
56
|
+
# gt_key = CacheMachine::MasterCacheObject.cache_key :guest, gregs_thing.user.id
|
|
57
|
+
|
|
58
|
+
# sleep(1)
|
|
59
|
+
|
|
60
|
+
# su_whatever.value = "blah"
|
|
61
|
+
# gregs_thing.value = "blah blah"
|
|
62
|
+
|
|
63
|
+
# su_whatever.save!
|
|
64
|
+
# gregs_thing.save!
|
|
65
|
+
|
|
66
|
+
# assert_not_equal su_key, CacheMachine::MasterCacheObject.cache_key(:admin, su_whatever.user.id)
|
|
67
|
+
# assert_not_equal gt_key, CacheMachine::MasterCacheObject.cache_key(:guest, gregs_thing.user.id)
|
|
68
|
+
# end
|
|
69
|
+
|
|
70
|
+
# def test_subordingate_object_creation_updates_master
|
|
71
|
+
# greg = guests(:greg)
|
|
72
|
+
# key = CacheMachine::MasterCacheObject.cache_key :guest, greg.id
|
|
73
|
+
|
|
74
|
+
# sleep(1)
|
|
75
|
+
|
|
76
|
+
# greg.guest_traits.create!(:value => "some bullshit")
|
|
77
|
+
|
|
78
|
+
# assert_not_equal key, CacheMachine::MasterCacheObject.cache_key(:guest, greg.id)
|
|
79
|
+
# end
|
|
80
|
+
|
|
81
|
+
# def test_subordingate_object_destruction_updates_master
|
|
82
|
+
# wheel = admins(:wheel)
|
|
83
|
+
# wheel_attr = admin_traits(:wheels_something_else)
|
|
84
|
+
|
|
85
|
+
# key = CacheMachine::MasterCacheObject.cache_key :admin, wheel.id
|
|
86
|
+
|
|
87
|
+
# sleep(1)
|
|
88
|
+
|
|
89
|
+
# wheel_attr.destroy
|
|
90
|
+
|
|
91
|
+
# assert_not_equal key, CacheMachine::MasterCacheObject.cache_key(:admin, wheel.id)
|
|
92
|
+
# end
|
|
93
|
+
|
|
94
|
+
# def test_subordinate_object_can_update_through
|
|
95
|
+
# modifier = guest_trait_modifiers(:gregs_something_modifier)
|
|
96
|
+
# key = CacheMachine::MasterCacheObject.cache_key(:guest, modifier.guest_trait.guest.id)
|
|
97
|
+
|
|
98
|
+
# sleep(1)
|
|
99
|
+
|
|
100
|
+
# modifier.modifier = "something something darkside"
|
|
101
|
+
# modifier.save!
|
|
102
|
+
|
|
103
|
+
# assert_not_equal key, CacheMachine::MasterCacheObject.cache_key(:guest, modifier.guest_trait.guest.id)
|
|
104
|
+
# end
|
|
105
|
+
|
|
106
|
+
# def test_subordinate_object_can_update_through_with_explicit_target_class
|
|
107
|
+
# modifier = admin_trait_modifiers(:wheels_something_else_modifier)
|
|
108
|
+
# admin_key = CacheMachine::MasterCacheObject.cache_key :admin, modifier.admin_trait.user.id
|
|
109
|
+
# trait_key = CacheMachine::MasterCacheObject.cache_key :trait, modifier.admin_trait.thing.id
|
|
110
|
+
|
|
111
|
+
# sleep(1)
|
|
112
|
+
|
|
113
|
+
# modifier.modifier = "something something darkside"
|
|
114
|
+
# modifier.save!
|
|
115
|
+
|
|
116
|
+
# assert_not_equal admin_key, CacheMachine::MasterCacheObject.cache_key(:admin, modifier.admin_trait.user.id)
|
|
117
|
+
# assert_not_equal trait_key, CacheMachine::MasterCacheObject.cache_key(:trait, modifier.admin_trait.thing.id)
|
|
118
|
+
# end
|
|
119
|
+
|
|
120
|
+
# def test_touch_cache_through_gem
|
|
121
|
+
# admin = admins(:su)
|
|
122
|
+
# admin.update_attribute(:name, "lol")
|
|
123
|
+
|
|
124
|
+
# assert_equal $dummy_cache_params[:subordinate_class], "admin"
|
|
125
|
+
# end
|
|
126
|
+
|
|
127
|
+
# def test_touch_cache_can_handle_comm_object_failures
|
|
128
|
+
# thing = standalones(:thing)
|
|
129
|
+
# thing.value = "something new"
|
|
130
|
+
# thing.save
|
|
131
|
+
|
|
132
|
+
# assert_equal $error.class, RuntimeError
|
|
133
|
+
# assert_equal $error.to_s, "oh noes!"
|
|
134
|
+
# assert_equal $deets[:master_class], "standalone"
|
|
135
|
+
# end
|
|
136
|
+
end
|