la_maquina 0.2.0 → 1.0.0
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 -1
- data/Gemfile.lock +1 -1
- data/README.md +16 -3
- data/lib/la_maquina/notifier.rb +39 -18
- data/lib/la_maquina/version.rb +1 -1
- data/test/dummy/app/models/admin.rb +12 -4
- data/test/dummy/app/models/admin_thing.rb +4 -0
- data/test/dummy/app/models/admin_trait.rb +2 -2
- data/test/dummy/app/models/admin_trait_modifier.rb +1 -1
- data/test/dummy/app/models/guest.rb +10 -1
- data/test/dummy/app/models/guest_thing.rb +4 -0
- data/test/dummy/app/models/thing.rb +2 -0
- data/test/dummy/db/migrate/20150228015009_schema.rb +17 -1
- data/test/dummy/db/schema.rb +78 -1
- data/test/dummy/lib/clever_comm_object.rb +5 -0
- data/test/dummy/log/development.log +3 -0
- data/test/dummy/test/fixtures/admin_things.yml +3 -0
- data/test/dummy/test/fixtures/admin_traits.yml +8 -2
- data/test/dummy/test/fixtures/guest_things.yml +3 -0
- data/test/dummy/test/fixtures/guest_traits.yml +6 -1
- data/test/dummy/test/fixtures/things.yml +2 -0
- data/test/unit/la_maquina_test.rb +0 -8
- data/test/unit/notifier_test.rb +114 -4
- metadata +17 -5
- data/test/dummy/db/test.sqlite3 +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e105bcb7993122b4bb988002ab8b18bc7eec6cf1
|
|
4
|
+
data.tar.gz: 6611913c1eacfe261935e89d4c1d841cb7c3344f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 03dd116c53d0a2780daec310bae5321d13f1b8b76eb07f409e4c8439589147b65c41bd5411bd2ca7e1cd1218f6fb6ed595917407e277c1cf927344f3bad622cc
|
|
7
|
+
data.tar.gz: 3abddd32d8049cee0e3a6078ae7baadbe4b02cc8555ae7aaac21a8693364fc0c88e79dae271db399c3b7a0017080b61ab4f669ec80eb9beb2230ec6b8a8a7b0d
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# La Maquina
|
|
2
2
|
|
|
3
|
-
Non-database-based arbitrary updates of
|
|
3
|
+
Non-database-based arbitrary updates of associated ActiveRecord models.
|
|
4
4
|
|
|
5
5
|
Let's say you have 2 models
|
|
6
6
|
```ruby
|
|
@@ -57,9 +57,9 @@ to use it, in your `ActiveRecord::Base` model
|
|
|
57
57
|
```ruby
|
|
58
58
|
include LaMaquina::Notifier
|
|
59
59
|
```
|
|
60
|
-
It can either notify LaMaquina about the object itself with `notifies_about :self`, or about
|
|
60
|
+
It can either notify LaMaquina about the object itself with `notifies_about :self`, or about another association with the following options:
|
|
61
61
|
|
|
62
|
-
* `:through`: same as rails.
|
|
62
|
+
* `:through`: same as rails.
|
|
63
63
|
* `:polymorphic`: same as rails. Note: expects rails default target `_type` and targe `_id` fields to be present
|
|
64
64
|
* `:class_name`: takes a modulized camelcased string name of the target class
|
|
65
65
|
* `:class`: takes a class constant of the target class type
|
|
@@ -243,6 +243,19 @@ Or install it yourself as:
|
|
|
243
243
|
$ gem install la_maquina
|
|
244
244
|
|
|
245
245
|
|
|
246
|
+
## Testing
|
|
247
|
+
|
|
248
|
+
As of today, the tests rely on solr (I need to get rid of that, I know), so to test you need to
|
|
249
|
+
|
|
250
|
+
$ cd la_maquina/test/dummy
|
|
251
|
+
$ bundle install
|
|
252
|
+
$ rake db:migrate RAILS_ENV=test
|
|
253
|
+
$ bundle exec rake sunspot:solr:start RAILS_ENV=test
|
|
254
|
+
$ bundle exec rake sunspot:reindex RAILS_ENV=test
|
|
255
|
+
|
|
256
|
+
$ cd ../../
|
|
257
|
+
$ rake
|
|
258
|
+
|
|
246
259
|
## Contributing
|
|
247
260
|
|
|
248
261
|
1. Fork it ( https://github.com/[my-github-username]/la_maquina/fork )
|
data/lib/la_maquina/notifier.rb
CHANGED
|
@@ -13,8 +13,8 @@ module LaMaquina
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class << self
|
|
16
|
-
def notifies_about(
|
|
17
|
-
notified_objects << {:
|
|
16
|
+
def notifies_about(target, opts = {})
|
|
17
|
+
notified_objects << {:target => target, :options => opts}
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -24,21 +24,23 @@ module LaMaquina
|
|
|
24
24
|
def notify!
|
|
25
25
|
self.class.notified_objects.each do |notified|
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
target = notified[:target]
|
|
28
28
|
options = notified[:options]
|
|
29
29
|
|
|
30
30
|
comm_object = options[:using]
|
|
31
31
|
|
|
32
|
-
klass =
|
|
33
|
-
|
|
32
|
+
klass = notified_class( target, options )
|
|
33
|
+
ids = notified_id( target, options )
|
|
34
34
|
|
|
35
35
|
notifier_class = LaMaquina.format_object_name(self)
|
|
36
36
|
|
|
37
37
|
begin
|
|
38
|
-
|
|
39
|
-
comm_object
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
ids.each do |id|
|
|
39
|
+
if comm_object
|
|
40
|
+
comm_object.notify(:notified_class => klass, :notified_id => id, :notifier_class => notifier_class)
|
|
41
|
+
else
|
|
42
|
+
LaMaquina::Engine.notify! klass, id, notifier_class
|
|
43
|
+
end
|
|
42
44
|
end
|
|
43
45
|
rescue => e
|
|
44
46
|
LaMaquina.error_notifier.notify( e,
|
|
@@ -52,13 +54,17 @@ module LaMaquina
|
|
|
52
54
|
|
|
53
55
|
private
|
|
54
56
|
|
|
55
|
-
def
|
|
56
|
-
if
|
|
57
|
+
def notified_class(target, options)
|
|
58
|
+
if target == :self
|
|
57
59
|
return LaMaquina.format_object_name(self)
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
if options[:polymorphic]
|
|
61
|
-
|
|
63
|
+
if self.respond_to? "#{target}_type"
|
|
64
|
+
return LaMaquina.format_class_name(self.send("#{target}_type"))
|
|
65
|
+
else
|
|
66
|
+
return LaMaquina.format_class_name(self.send(target).class)
|
|
67
|
+
end
|
|
62
68
|
end
|
|
63
69
|
|
|
64
70
|
if options[:class_name]
|
|
@@ -69,19 +75,34 @@ module LaMaquina
|
|
|
69
75
|
return LaMaquina.format_class_name(options[:class])
|
|
70
76
|
end
|
|
71
77
|
|
|
72
|
-
return
|
|
78
|
+
return target.to_s.singularize
|
|
73
79
|
end
|
|
74
80
|
|
|
75
|
-
def notified_id(
|
|
76
|
-
if
|
|
77
|
-
return self.id
|
|
81
|
+
def notified_id(target, options)
|
|
82
|
+
if target == :self
|
|
83
|
+
return [self.id]
|
|
78
84
|
end
|
|
79
85
|
|
|
80
86
|
if options[:through]
|
|
81
|
-
|
|
87
|
+
ids = []
|
|
88
|
+
join_objects = Array(self.send(options[:through]))
|
|
89
|
+
|
|
90
|
+
join_objects.each do |obj|
|
|
91
|
+
if obj.respond_to? "#{target}_id"
|
|
92
|
+
ids << obj.send("#{target}_id")
|
|
93
|
+
else
|
|
94
|
+
ids << Array(obj.send(target)).map(&:id)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
return ids
|
|
82
99
|
end
|
|
83
100
|
|
|
84
|
-
self.
|
|
101
|
+
if self.respond_to? "#{target}_id"
|
|
102
|
+
Array self.send("#{target}_id")
|
|
103
|
+
else
|
|
104
|
+
Array(self.send(target)).map(&:id)
|
|
105
|
+
end
|
|
85
106
|
end
|
|
86
107
|
end
|
|
87
108
|
end
|
data/lib/la_maquina/version.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
class Admin < ActiveRecord::Base
|
|
2
|
-
has_many :admin_traits
|
|
3
|
-
has_many :traits, :
|
|
2
|
+
has_many :admin_traits, foreign_key: :user_id
|
|
3
|
+
has_many :traits, through: :admin_traits, source: :blah
|
|
4
|
+
has_one :admin_thing
|
|
5
|
+
has_one :thing, through: :admin_thing
|
|
4
6
|
|
|
5
|
-
has_many :properties, :
|
|
7
|
+
has_many :properties, as: :user
|
|
6
8
|
|
|
7
9
|
searchable do
|
|
8
10
|
text :name
|
|
@@ -11,5 +13,11 @@ class Admin < ActiveRecord::Base
|
|
|
11
13
|
include LaMaquina::Notifier
|
|
12
14
|
notifies_about :self
|
|
13
15
|
|
|
14
|
-
notifies_about :self,
|
|
16
|
+
notifies_about :self, using: ::DummyCommObject
|
|
17
|
+
|
|
18
|
+
notifies_about :traits, using: ::CleverCommObject
|
|
19
|
+
notifies_about :admin_traits, using: ::CleverCommObject
|
|
20
|
+
|
|
21
|
+
notifies_about :thing, using: ::CleverCommObject
|
|
22
|
+
notifies_about :admin_thing, using: ::CleverCommObject
|
|
15
23
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
class AdminTrait < ActiveRecord::Base
|
|
2
2
|
belongs_to :user, :class_name => "Admin"
|
|
3
|
-
belongs_to :
|
|
3
|
+
belongs_to :blah, :class_name => "Trait"
|
|
4
4
|
|
|
5
5
|
include LaMaquina::Notifier
|
|
6
6
|
|
|
7
7
|
notifies_about :user, :class => Admin
|
|
8
|
-
notifies_about :
|
|
8
|
+
notifies_about :blah, :class_name => "Trait"
|
|
9
9
|
end
|
|
@@ -4,5 +4,5 @@ class AdminTraitModifier < ActiveRecord::Base
|
|
|
4
4
|
include LaMaquina::Notifier
|
|
5
5
|
|
|
6
6
|
notifies_about :user, :through => :admin_trait, :class_name => "Admin"
|
|
7
|
-
notifies_about :
|
|
7
|
+
notifies_about :blah, :through => :admin_trait, :class => Trait
|
|
8
8
|
end
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
class Guest < ActiveRecord::Base
|
|
2
2
|
has_many :guest_traits
|
|
3
|
-
has_many :traits, :
|
|
3
|
+
has_many :traits, through: :guest_traits
|
|
4
|
+
|
|
5
|
+
has_one :guest_thing
|
|
6
|
+
has_one :thing, through: :guest_thing
|
|
4
7
|
|
|
5
8
|
has_many :properties, :as => :user
|
|
6
9
|
|
|
7
10
|
include LaMaquina::Notifier
|
|
8
11
|
|
|
9
12
|
notifies_about :self
|
|
13
|
+
|
|
14
|
+
notifies_about :traits
|
|
15
|
+
notifies_about :guest_traits
|
|
16
|
+
|
|
17
|
+
notifies_about :thing
|
|
18
|
+
notifies_about :guest_thing
|
|
10
19
|
end
|
|
@@ -20,7 +20,7 @@ class Schema < ActiveRecord::Migration
|
|
|
20
20
|
|
|
21
21
|
create_table :admin_traits do |t|
|
|
22
22
|
t.belongs_to :user
|
|
23
|
-
t.belongs_to :
|
|
23
|
+
t.belongs_to :blah
|
|
24
24
|
t.string :value
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -42,6 +42,22 @@ class Schema < ActiveRecord::Migration
|
|
|
42
42
|
create_table :standalones do |t|
|
|
43
43
|
t.string :value
|
|
44
44
|
end
|
|
45
|
+
|
|
46
|
+
create_table :admin_things do |t|
|
|
47
|
+
t.belongs_to :admin
|
|
48
|
+
t.string :value
|
|
49
|
+
t.belongs_to :thing
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
create_table :guest_things do |t|
|
|
53
|
+
t.belongs_to :guest
|
|
54
|
+
t.string :value
|
|
55
|
+
t.belongs_to :thing
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
create_table :things do |t|
|
|
59
|
+
t.string :value
|
|
60
|
+
end
|
|
45
61
|
end
|
|
46
62
|
end
|
|
47
63
|
|
data/test/dummy/db/schema.rb
CHANGED
|
@@ -11,5 +11,82 @@
|
|
|
11
11
|
#
|
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
|
13
13
|
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
|
14
|
+
ActiveRecord::Schema.define(version: 20150228015009) do
|
|
15
|
+
|
|
16
|
+
create_table "admin_thing", force: :cascade do |t|
|
|
17
|
+
t.integer "admin_id"
|
|
18
|
+
t.string "value"
|
|
19
|
+
t.integer "thing_id"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
create_table "admin_things", force: :cascade do |t|
|
|
23
|
+
t.integer "admin_id"
|
|
24
|
+
t.string "value"
|
|
25
|
+
t.integer "thing_id"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
create_table "admin_trait_modifiers", force: :cascade do |t|
|
|
29
|
+
t.integer "admin_trait_id"
|
|
30
|
+
t.string "modifier"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
create_table "admin_traits", force: :cascade do |t|
|
|
34
|
+
t.integer "user_id"
|
|
35
|
+
t.integer "blah_id"
|
|
36
|
+
t.string "value"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
create_table "admins", force: :cascade do |t|
|
|
40
|
+
t.string "name"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
create_table "guest_thing", force: :cascade do |t|
|
|
44
|
+
t.integer "guest_id"
|
|
45
|
+
t.string "value"
|
|
46
|
+
t.integer "thing_id"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
create_table "guest_things", force: :cascade do |t|
|
|
50
|
+
t.integer "guest_id"
|
|
51
|
+
t.string "value"
|
|
52
|
+
t.integer "thing_id"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
create_table "guest_trait_modifiers", force: :cascade do |t|
|
|
56
|
+
t.integer "guest_trait_id"
|
|
57
|
+
t.string "modifier"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
create_table "guest_traits", force: :cascade do |t|
|
|
61
|
+
t.integer "guest_id"
|
|
62
|
+
t.integer "trait_id"
|
|
63
|
+
t.string "value"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
create_table "guests", force: :cascade do |t|
|
|
67
|
+
t.string "name"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
create_table "properties", force: :cascade do |t|
|
|
71
|
+
t.integer "user_id"
|
|
72
|
+
t.string "user_type"
|
|
73
|
+
t.string "value"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
create_table "standalones", force: :cascade do |t|
|
|
77
|
+
t.string "value"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
create_table "thing", force: :cascade do |t|
|
|
81
|
+
t.string "value"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
create_table "things", force: :cascade do |t|
|
|
85
|
+
t.string "value"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
create_table "traits", force: :cascade do |t|
|
|
89
|
+
t.string "name"
|
|
90
|
+
end
|
|
91
|
+
|
|
15
92
|
end
|
|
@@ -48,3 +48,6 @@ SQLite3::SQLException: no such table: admins: SELECT "admins".* FROM "admins"
|
|
|
48
48
|
[1m[36m (13.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
|
49
49
|
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
|
50
50
|
[1m[36m (11.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
|
51
|
+
[1m[32mSOLR Request (126.3ms)[0m [ path=[1m[1mupdate[0m parameters={} ]
|
|
52
|
+
[1m[36mAdmin Load (0.2ms)[0m [1mSELECT "admins".* FROM "admins" ORDER BY "admins"."id" ASC LIMIT 50[0m
|
|
53
|
+
SQLite3::SQLException: no such table: admins: SELECT "admins".* FROM "admins" ORDER BY "admins"."id" ASC LIMIT 50
|
|
@@ -16,12 +16,4 @@ class LaMaquinaTest < ActiveSupport::TestCase
|
|
|
16
16
|
assert_equal "admin", LaMaquina.format_class_name(Admin)
|
|
17
17
|
assert_equal "admin_trait", LaMaquina.format_class_name(AdminTrait)
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_full_stack
|
|
22
|
-
@admin.name = "lol"
|
|
23
|
-
@admin.save!
|
|
24
|
-
|
|
25
|
-
assert_equal "admin/#{@admin.id}", $fire_message
|
|
26
|
-
end
|
|
27
19
|
end
|
data/test/unit/notifier_test.rb
CHANGED
|
@@ -11,13 +11,13 @@ class NotifierTest < ActiveSupport::TestCase
|
|
|
11
11
|
def test_notifier_suports_explicit_class_and_class_name
|
|
12
12
|
admin_attr = admin_traits(:wheels_something_else)
|
|
13
13
|
admin_key = LaMaquina::Piston::CachePiston.cache_key :admin, admin_attr.user.id
|
|
14
|
-
trait_key = LaMaquina::Piston::CachePiston.cache_key :trait, admin_attr.
|
|
14
|
+
trait_key = LaMaquina::Piston::CachePiston.cache_key :trait, admin_attr.blah.id
|
|
15
15
|
|
|
16
16
|
admin_attr.value = "lol"
|
|
17
17
|
admin_attr.save!
|
|
18
18
|
|
|
19
19
|
assert_not_equal admin_key, LaMaquina::Piston::CachePiston.cache_key(:admin, admin_attr.user.id)
|
|
20
|
-
assert_not_equal trait_key, LaMaquina::Piston::CachePiston.cache_key(:trait, admin_attr.
|
|
20
|
+
assert_not_equal trait_key, LaMaquina::Piston::CachePiston.cache_key(:trait, admin_attr.blah.id)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_notifier_can_update_self
|
|
@@ -94,13 +94,13 @@ class NotifierTest < ActiveSupport::TestCase
|
|
|
94
94
|
def test_notifier_can_update_through_with_explicit_target_class
|
|
95
95
|
modifier = admin_trait_modifiers(:wheels_something_else_modifier)
|
|
96
96
|
admin_key = LaMaquina::Piston::CachePiston.cache_key :admin, modifier.admin_trait.user.id
|
|
97
|
-
trait_key = LaMaquina::Piston::CachePiston.cache_key :trait, modifier.admin_trait.
|
|
97
|
+
trait_key = LaMaquina::Piston::CachePiston.cache_key :trait, modifier.admin_trait.blah.id
|
|
98
98
|
|
|
99
99
|
modifier.modifier = "something something darkside"
|
|
100
100
|
modifier.save!
|
|
101
101
|
|
|
102
102
|
assert_not_equal admin_key, LaMaquina::Piston::CachePiston.cache_key(:admin, modifier.admin_trait.user.id)
|
|
103
|
-
assert_not_equal trait_key, LaMaquina::Piston::CachePiston.cache_key(:trait, modifier.admin_trait.
|
|
103
|
+
assert_not_equal trait_key, LaMaquina::Piston::CachePiston.cache_key(:trait, modifier.admin_trait.blah.id)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def test_notify_through_intermediate_object
|
|
@@ -108,6 +108,8 @@ class NotifierTest < ActiveSupport::TestCase
|
|
|
108
108
|
admin.update_attribute(:name, "lol")
|
|
109
109
|
|
|
110
110
|
assert $dummy_params, "comm_object wasn't called"
|
|
111
|
+
|
|
112
|
+
# NOTE: this value is the last notifies_about with a `using: DummyCommObject` in the file because DummyCommObject is indeed a dummy.
|
|
111
113
|
assert_equal "admin", $dummy_params[:notified_class]
|
|
112
114
|
end
|
|
113
115
|
|
|
@@ -120,4 +122,112 @@ class NotifierTest < ActiveSupport::TestCase
|
|
|
120
122
|
assert_equal "oh noes!", $error.to_s
|
|
121
123
|
assert_equal "standalone", $deets[:notified_class]
|
|
122
124
|
end
|
|
125
|
+
|
|
126
|
+
def test_notifier_can_update_has_one
|
|
127
|
+
greg = guests(:greg)
|
|
128
|
+
|
|
129
|
+
key = LaMaquina::Piston::CachePiston.cache_key :guest_thing, greg.guest_thing.id
|
|
130
|
+
|
|
131
|
+
greg.touch
|
|
132
|
+
|
|
133
|
+
assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:guest_thing, greg.guest_thing.id)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_notifier_can_update_has_one_through
|
|
137
|
+
greg = guests(:greg)
|
|
138
|
+
|
|
139
|
+
key = LaMaquina::Piston::CachePiston.cache_key :thing, greg.thing.id
|
|
140
|
+
|
|
141
|
+
greg.touch
|
|
142
|
+
|
|
143
|
+
assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:thing, greg.thing.id)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_notifier_can_update_has_one_with_comm_object
|
|
147
|
+
su = admins(:su)
|
|
148
|
+
|
|
149
|
+
key = LaMaquina::Piston::CachePiston.cache_key :admin_thing, su.admin_thing.id
|
|
150
|
+
|
|
151
|
+
su.touch
|
|
152
|
+
|
|
153
|
+
assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:admin_thing, su.admin_thing.id)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_notifier_can_update_has_one_through_with_comm_object
|
|
157
|
+
su = admins(:su)
|
|
158
|
+
|
|
159
|
+
key = LaMaquina::Piston::CachePiston.cache_key :thing, su.thing.id
|
|
160
|
+
|
|
161
|
+
su.touch
|
|
162
|
+
|
|
163
|
+
assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:thing, su.thing.id)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def test_notifier_can_update_has_many
|
|
167
|
+
greg = guests(:greg)
|
|
168
|
+
|
|
169
|
+
trait_keys = greg.guest_traits.map{ |guest_trait|
|
|
170
|
+
{
|
|
171
|
+
gt: guest_trait,
|
|
172
|
+
key: LaMaquina::Piston::CachePiston.cache_key( :guest_trait, guest_trait.id )
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
greg.touch
|
|
177
|
+
|
|
178
|
+
trait_keys.each do |pair|
|
|
179
|
+
assert_not_equal pair[:key], LaMaquina::Piston::CachePiston.cache_key(:guest_trait, pair[:gt].id)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_notifier_can_update_has_many_through
|
|
184
|
+
greg = guests(:greg)
|
|
185
|
+
|
|
186
|
+
trait_keys = greg.traits.map{ |trait|
|
|
187
|
+
{
|
|
188
|
+
t: trait,
|
|
189
|
+
key: LaMaquina::Piston::CachePiston.cache_key( :trait, trait.id )
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
greg.touch
|
|
194
|
+
|
|
195
|
+
trait_keys.each do |pair|
|
|
196
|
+
assert_not_equal pair[:key], LaMaquina::Piston::CachePiston.cache_key(:thing, pair[:t].id)
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def test_notifier_can_update_has_many_with_comm_object
|
|
201
|
+
su = admins(:su)
|
|
202
|
+
|
|
203
|
+
trait_keys = su.admin_traits.map{ |admin_trait|
|
|
204
|
+
{
|
|
205
|
+
gt: admin_trait,
|
|
206
|
+
key: LaMaquina::Piston::CachePiston.cache_key( :admin_trait, admin_trait.id )
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
su.touch
|
|
211
|
+
|
|
212
|
+
trait_keys.each do |pair|
|
|
213
|
+
assert_not_equal pair[:key], LaMaquina::Piston::CachePiston.cache_key(:admin_trait, pair[:gt].id)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def test_notifier_can_update_has_many_through_with_comm_object
|
|
218
|
+
su = admins(:su)
|
|
219
|
+
|
|
220
|
+
trait_keys = su.traits.map{ |trait|
|
|
221
|
+
{
|
|
222
|
+
t: trait,
|
|
223
|
+
key: LaMaquina::Piston::CachePiston.cache_key( :trait, trait.id )
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
su.touch
|
|
228
|
+
|
|
229
|
+
trait_keys.each do |pair|
|
|
230
|
+
assert_not_equal pair[:key], LaMaquina::Piston::CachePiston.cache_key(:thing, pair[:t].id)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
123
233
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: la_maquina
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Orlov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -87,13 +87,16 @@ files:
|
|
|
87
87
|
- test/dummy/Rakefile
|
|
88
88
|
- test/dummy/app/models/.keep
|
|
89
89
|
- test/dummy/app/models/admin.rb
|
|
90
|
+
- test/dummy/app/models/admin_thing.rb
|
|
90
91
|
- test/dummy/app/models/admin_trait.rb
|
|
91
92
|
- test/dummy/app/models/admin_trait_modifier.rb
|
|
92
93
|
- test/dummy/app/models/guest.rb
|
|
94
|
+
- test/dummy/app/models/guest_thing.rb
|
|
93
95
|
- test/dummy/app/models/guest_trait.rb
|
|
94
96
|
- test/dummy/app/models/guest_trait_modifier.rb
|
|
95
97
|
- test/dummy/app/models/property.rb
|
|
96
98
|
- test/dummy/app/models/standalone.rb
|
|
99
|
+
- test/dummy/app/models/thing.rb
|
|
97
100
|
- test/dummy/app/models/trait.rb
|
|
98
101
|
- test/dummy/config.ru
|
|
99
102
|
- test/dummy/config/application.rb
|
|
@@ -122,7 +125,7 @@ files:
|
|
|
122
125
|
- test/dummy/db/development.sqlite3
|
|
123
126
|
- test/dummy/db/migrate/20150228015009_schema.rb
|
|
124
127
|
- test/dummy/db/schema.rb
|
|
125
|
-
- test/dummy/
|
|
128
|
+
- test/dummy/lib/clever_comm_object.rb
|
|
126
129
|
- test/dummy/lib/dummy_comm_object.rb
|
|
127
130
|
- test/dummy/lib/exploding_comm_object.rb
|
|
128
131
|
- test/dummy/lib/exploding_piston.rb
|
|
@@ -135,14 +138,17 @@ files:
|
|
|
135
138
|
- test/dummy/public/422.html
|
|
136
139
|
- test/dummy/public/500.html
|
|
137
140
|
- test/dummy/public/favicon.ico
|
|
141
|
+
- test/dummy/test/fixtures/admin_things.yml
|
|
138
142
|
- test/dummy/test/fixtures/admin_trait_modifiers.yml
|
|
139
143
|
- test/dummy/test/fixtures/admin_traits.yml
|
|
140
144
|
- test/dummy/test/fixtures/admins.yml
|
|
145
|
+
- test/dummy/test/fixtures/guest_things.yml
|
|
141
146
|
- test/dummy/test/fixtures/guest_trait_modifiers.yml
|
|
142
147
|
- test/dummy/test/fixtures/guest_traits.yml
|
|
143
148
|
- test/dummy/test/fixtures/guests.yml
|
|
144
149
|
- test/dummy/test/fixtures/properties.yml
|
|
145
150
|
- test/dummy/test/fixtures/standalones.yml
|
|
151
|
+
- test/dummy/test/fixtures/things.yml
|
|
146
152
|
- test/dummy/test/fixtures/traits.yml
|
|
147
153
|
- test/test_helper.rb
|
|
148
154
|
- test/unit/dependency_maps/constant_map_test.rb
|
|
@@ -174,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
174
180
|
version: '0'
|
|
175
181
|
requirements: []
|
|
176
182
|
rubyforge_project:
|
|
177
|
-
rubygems_version: 2.4.
|
|
183
|
+
rubygems_version: 2.4.5
|
|
178
184
|
signing_key:
|
|
179
185
|
specification_version: 4
|
|
180
186
|
summary: depnendency tree update notifications
|
|
@@ -182,13 +188,16 @@ test_files:
|
|
|
182
188
|
- test/dummy/Rakefile
|
|
183
189
|
- test/dummy/app/models/.keep
|
|
184
190
|
- test/dummy/app/models/admin.rb
|
|
191
|
+
- test/dummy/app/models/admin_thing.rb
|
|
185
192
|
- test/dummy/app/models/admin_trait.rb
|
|
186
193
|
- test/dummy/app/models/admin_trait_modifier.rb
|
|
187
194
|
- test/dummy/app/models/guest.rb
|
|
195
|
+
- test/dummy/app/models/guest_thing.rb
|
|
188
196
|
- test/dummy/app/models/guest_trait.rb
|
|
189
197
|
- test/dummy/app/models/guest_trait_modifier.rb
|
|
190
198
|
- test/dummy/app/models/property.rb
|
|
191
199
|
- test/dummy/app/models/standalone.rb
|
|
200
|
+
- test/dummy/app/models/thing.rb
|
|
192
201
|
- test/dummy/app/models/trait.rb
|
|
193
202
|
- test/dummy/config.ru
|
|
194
203
|
- test/dummy/config/application.rb
|
|
@@ -217,7 +226,7 @@ test_files:
|
|
|
217
226
|
- test/dummy/db/development.sqlite3
|
|
218
227
|
- test/dummy/db/migrate/20150228015009_schema.rb
|
|
219
228
|
- test/dummy/db/schema.rb
|
|
220
|
-
- test/dummy/
|
|
229
|
+
- test/dummy/lib/clever_comm_object.rb
|
|
221
230
|
- test/dummy/lib/dummy_comm_object.rb
|
|
222
231
|
- test/dummy/lib/exploding_comm_object.rb
|
|
223
232
|
- test/dummy/lib/exploding_piston.rb
|
|
@@ -230,14 +239,17 @@ test_files:
|
|
|
230
239
|
- test/dummy/public/422.html
|
|
231
240
|
- test/dummy/public/500.html
|
|
232
241
|
- test/dummy/public/favicon.ico
|
|
242
|
+
- test/dummy/test/fixtures/admin_things.yml
|
|
233
243
|
- test/dummy/test/fixtures/admin_trait_modifiers.yml
|
|
234
244
|
- test/dummy/test/fixtures/admin_traits.yml
|
|
235
245
|
- test/dummy/test/fixtures/admins.yml
|
|
246
|
+
- test/dummy/test/fixtures/guest_things.yml
|
|
236
247
|
- test/dummy/test/fixtures/guest_trait_modifiers.yml
|
|
237
248
|
- test/dummy/test/fixtures/guest_traits.yml
|
|
238
249
|
- test/dummy/test/fixtures/guests.yml
|
|
239
250
|
- test/dummy/test/fixtures/properties.yml
|
|
240
251
|
- test/dummy/test/fixtures/standalones.yml
|
|
252
|
+
- test/dummy/test/fixtures/things.yml
|
|
241
253
|
- test/dummy/test/fixtures/traits.yml
|
|
242
254
|
- test/test_helper.rb
|
|
243
255
|
- test/unit/dependency_maps/constant_map_test.rb
|
data/test/dummy/db/test.sqlite3
DELETED
|
Binary file
|