la_maquina 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +20 -1
  5. data/README.md +7 -7
  6. data/lib/la_maquina/dependency_map/base.rb +19 -0
  7. data/lib/la_maquina/dependency_map/constant_map.rb +13 -0
  8. data/lib/la_maquina/dependency_map/yaml_map.rb +15 -0
  9. data/lib/la_maquina/dependency_map.rb +7 -0
  10. data/lib/la_maquina/engine.rb +39 -0
  11. data/lib/la_maquina/error_notifier/base.rb +1 -1
  12. data/lib/la_maquina/{volante.rb → notifier.rb} +10 -8
  13. data/lib/la_maquina/piston/base.rb +2 -2
  14. data/lib/la_maquina/piston/cache_piston.rb +18 -15
  15. data/lib/la_maquina/piston/sunspot_piston.rb +22 -0
  16. data/lib/la_maquina/piston.rb +3 -2
  17. data/lib/la_maquina/version.rb +1 -1
  18. data/lib/la_maquina.rb +3 -2
  19. data/test/dummy/app/models/admin.rb +7 -3
  20. data/test/dummy/app/models/admin_trait.rb +3 -3
  21. data/test/dummy/app/models/admin_trait_modifier.rb +3 -3
  22. data/test/dummy/app/models/guest.rb +2 -2
  23. data/test/dummy/app/models/guest_trait.rb +3 -3
  24. data/test/dummy/app/models/guest_trait_modifier.rb +2 -3
  25. data/test/dummy/app/models/property.rb +2 -3
  26. data/test/dummy/app/models/standalone.rb +2 -2
  27. data/test/dummy/config/database.yml +6 -4
  28. data/test/dummy/config/initializers/la_maquina.rb +8 -2
  29. data/test/dummy/config/la_maquina/dependency_maps/bad_map.yml +1 -0
  30. data/test/dummy/config/la_maquina/dependency_maps/sunspot_piston.yml +1 -0
  31. data/test/dummy/config/sunspot.yml +5 -0
  32. data/test/dummy/db/schema.rb +0 -1
  33. data/test/dummy/db/test.sqlite3 +0 -0
  34. data/test/dummy/lib/dummy_comm_object.rb +1 -1
  35. data/test/dummy/lib/exploding_comm_object.rb +1 -1
  36. data/test/dummy/lib/exploding_piston.rb +5 -0
  37. data/test/dummy/lib/extended_sunspot_piston.rb +13 -0
  38. data/test/dummy/lib/primitive_piston.rb +5 -0
  39. data/test/dummy/lib/test_notifier.rb +2 -2
  40. data/test/dummy/log/development.log +34 -0
  41. data/test/unit/dependency_maps/yamp_map_test.rb +26 -0
  42. data/test/unit/engine_test.rb +32 -0
  43. data/test/unit/error_notifier_test.rb +21 -0
  44. data/test/{la_maquina_test.rb → unit/la_maquina_test.rb} +12 -0
  45. data/test/unit/notifier_test.rb +123 -0
  46. data/test/unit/piston_test.rb +10 -0
  47. data/test/unit/pistons/cache_piston_test.rb +26 -0
  48. data/test/unit/pistons/sunspot_piston_test.rb +25 -0
  49. metadata +39 -12
  50. data/lib/la_maquina/ciguenal.rb +0 -27
  51. data/test/ciguenal_test.rb +0 -30
  52. data/test/dummy/lib/test_piston.rb +0 -5
  53. data/test/volante_test.rb +0 -136
@@ -14,3 +14,37 @@ Migrating to Schema (20150228015009)
14
14
  SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150228015009"]]
15
15
   (143.3ms) commit transaction
16
16
  ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
17
+ SOLR Request (132.0ms) [ path=update parameters={} ]
18
+ Admin Load (0.1ms) SELECT "admins".* FROM "admins" ORDER BY "admins"."id" ASC LIMIT 50
19
+ SQLite3::SQLException: no such table: admins: SELECT "admins".* FROM "admins" ORDER BY "admins"."id" ASC LIMIT 50
20
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
21
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
22
+  (0.2ms) CREATE TABLE "admin" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar) 
23
+  (0.1ms) CREATE TABLE "admin_attribute" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "admin_id" integer, "attribute_id" integer, "value" varchar)
24
+  (0.1ms) CREATE TABLE "attribute" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar) 
25
+  (0.1ms) CREATE TABLE "guest" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar)
26
+  (0.1ms) CREATE TABLE "guest_attribute" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "guest_id" integer, "attribute_id" integer, "value" varchar) 
27
+  (0.1ms) CREATE TABLE "property" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "user_type" varchar, "value" varchar)
28
+  (0.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
29
+  (0.0ms) select sqlite_version(*)
30
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
31
+  (0.0ms) SELECT version FROM "schema_migrations"
32
+  (0.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150228015009')
33
+  (0.2ms) CREATE TABLE "admin" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar) 
34
+  (0.1ms) CREATE TABLE "admin_attribute" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "admin_id" integer, "attribute_id" integer, "value" varchar)
35
+  (0.1ms) CREATE TABLE "attribute" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar) 
36
+  (0.1ms) CREATE TABLE "guest" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar)
37
+  (0.1ms) CREATE TABLE "guest_attribute" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "guest_id" integer, "attribute_id" integer, "value" varchar) 
38
+  (0.1ms) CREATE TABLE "property" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "user_type" varchar, "value" varchar)
39
+  (0.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
40
+  (0.1ms) select sqlite_version(*)
41
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
42
+  (0.0ms) SELECT version FROM "schema_migrations"
43
+  (0.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150228015009')
44
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
45
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
46
+  (13.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
47
+  (0.1ms) select sqlite_version(*)
48
+  (13.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
49
+  (0.1ms) SELECT version FROM "schema_migrations"
50
+  (11.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class YamlMapTest < ActiveSupport::TestCase
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ @admin.index!
8
+ @map = LaMaquina::DependencyMap::YamlMap.new( Rails.root + 'config/la_maquina/dependency_maps/sunspot_piston.yml' )
9
+ end
10
+
11
+ def test_can_load_map
12
+ assert 'admin', @map.mapping_for(:admin)
13
+ end
14
+
15
+ def test_catches_mapless_lookup
16
+ map = LaMaquina::DependencyMap::YamlMap.new
17
+ map.mapping_for :admin
18
+
19
+ assert_equal NoMethodError, $error.class
20
+ end
21
+
22
+ def test_is_with_indifferent_access
23
+ assert 'admin', @map.mapping_for(:admin)
24
+ assert :admin, @map.mapping_for(:admin)
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ class EngineTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ end
8
+
9
+ def test_can_install_pistons
10
+ # the dummy app installs stuff into the Engine
11
+ assert LaMaquina::Engine.send(:pistons).include? PrimitivePiston
12
+ end
13
+
14
+ def test_can_fire_pistons
15
+ LaMaquina::Engine.notify!("admin", @admin.id)
16
+ end
17
+
18
+ def test_bad_piston_doesnt_block
19
+ LaMaquina::Engine.install ExplodingPiston
20
+
21
+ $error = nil
22
+ $deets = nil
23
+
24
+ LaMaquina::Engine.notify! "admin", @admin.id
25
+
26
+ assert_equal RuntimeError, $error.class
27
+ assert_equal "NOPE! LOL", $error.to_s
28
+ assert_equal ExplodingPiston, $deets[:misfiring_piston]
29
+
30
+ assert_equal "admin/#{@admin.id}", $fire_message
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class ErroNotifierTest < ActiveSupport::TestCase
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ LaMaquina.error_notifier = LaMaquina::ErrorNotifier::Base
8
+ end
9
+
10
+ def test_base_notifier_raises_exception
11
+ assert_raises RuntimeError do
12
+ thing = standalones(:thing)
13
+ thing.value = "something new"
14
+ thing.save
15
+ end
16
+ end
17
+
18
+ def teardown
19
+ LaMaquina.error_notifier = TestNotifier
20
+ end
21
+ end
@@ -2,6 +2,10 @@ require 'test_helper'
2
2
 
3
3
  class LaMaquinaTest < ActiveSupport::TestCase
4
4
 
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ end
8
+
5
9
  def test_object_name_formatting
6
10
  assert_equal "admin", LaMaquina.format_object_name(admins(:su))
7
11
  assert_equal "admin_trait", LaMaquina.format_object_name(admin_traits(:wheels_something_else))
@@ -12,4 +16,12 @@ class LaMaquinaTest < ActiveSupport::TestCase
12
16
  assert_equal "admin", LaMaquina.format_class_name(Admin)
13
17
  assert_equal "admin_trait", LaMaquina.format_class_name(AdminTrait)
14
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
15
27
  end
@@ -0,0 +1,123 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class NotifierTest < ActiveSupport::TestCase
5
+
6
+ def setup
7
+ keys = LaMaquina::Piston::CachePiston.redis.keys "*"
8
+ Redis.current.del keys
9
+ end
10
+
11
+ def test_notifier_suports_explicit_class_and_class_name
12
+ admin_attr = admin_traits(:wheels_something_else)
13
+ admin_key = LaMaquina::Piston::CachePiston.cache_key :admin, admin_attr.user.id
14
+ trait_key = LaMaquina::Piston::CachePiston.cache_key :trait, admin_attr.thing.id
15
+
16
+ admin_attr.value = "lol"
17
+ admin_attr.save!
18
+
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.thing.id)
21
+ end
22
+
23
+ def test_notifier_can_update_self
24
+ wheel = admins(:wheel)
25
+ key = LaMaquina::Piston::CachePiston.cache_key :admin, wheel.id
26
+
27
+ wheel.name = "WHEEL!"
28
+ wheel.save!
29
+
30
+ assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:admin, wheel.id)
31
+ end
32
+
33
+
34
+ def test_notifier_supports_implict_class
35
+
36
+ guest_attr = guest_traits(:gregs_something)
37
+ guest_key = LaMaquina::Piston::CachePiston.cache_key :guest, guest_attr.guest.id
38
+ trait_key = LaMaquina::Piston::CachePiston.cache_key :trait, guest_attr.trait.id
39
+
40
+ guest_attr.value = "who cares"
41
+ guest_attr.save!
42
+
43
+ assert_not_equal guest_key, LaMaquina::Piston::CachePiston.cache_key(:guest, guest_attr.guest.id)
44
+ assert_not_equal trait_key, LaMaquina::Piston::CachePiston.cache_key(:trait, guest_attr.trait.id)
45
+ end
46
+
47
+ def test_notifier_supports_polymorphism
48
+ su_whatever = properties(:su_whatever)
49
+ gregs_thing = properties(:gregs_thing)
50
+
51
+ su_key = LaMaquina::Piston::CachePiston.cache_key :admin, su_whatever.user.id
52
+ gt_key = LaMaquina::Piston::CachePiston.cache_key :guest, gregs_thing.user.id
53
+
54
+ su_whatever.value = "blah"
55
+ gregs_thing.value = "blah blah"
56
+
57
+ su_whatever.save!
58
+ gregs_thing.save!
59
+
60
+ assert_not_equal su_key, LaMaquina::Piston::CachePiston.cache_key(:admin, su_whatever.user.id)
61
+ assert_not_equal gt_key, LaMaquina::Piston::CachePiston.cache_key(:guest, gregs_thing.user.id)
62
+ end
63
+
64
+ def test_object_creation_notifies_listener
65
+ greg = guests(:greg)
66
+ key = LaMaquina::Piston::CachePiston.cache_key :guest, greg.id
67
+
68
+ greg.guest_traits.create!(:value => "some bullshit")
69
+
70
+ assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:guest, greg.id)
71
+ end
72
+
73
+ def test_object_destruction_notifies_listener
74
+ wheel = admins(:wheel)
75
+ wheel_attr = admin_traits(:wheels_something_else)
76
+
77
+ key = LaMaquina::Piston::CachePiston.cache_key :admin, wheel.id
78
+
79
+ wheel_attr.destroy
80
+
81
+ assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:admin, wheel.id)
82
+ end
83
+
84
+ def test_notifications_can_use_through_associations
85
+ modifier = guest_trait_modifiers(:gregs_something_modifier)
86
+ key = LaMaquina::Piston::CachePiston.cache_key(:guest, modifier.guest_trait.guest.id)
87
+
88
+ modifier.modifier = "something something darkside"
89
+ modifier.save!
90
+
91
+ assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:guest, modifier.guest_trait.guest.id)
92
+ end
93
+
94
+ def test_notifier_can_update_through_with_explicit_target_class
95
+ modifier = admin_trait_modifiers(:wheels_something_else_modifier)
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.thing.id
98
+
99
+ modifier.modifier = "something something darkside"
100
+ modifier.save!
101
+
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.thing.id)
104
+ end
105
+
106
+ def test_notify_through_intermediate_object
107
+ admin = admins(:su)
108
+ admin.update_attribute(:name, "lol")
109
+
110
+ assert $dummy_params, "comm_object wasn't called"
111
+ assert_equal "admin", $dummy_params[:notified_class]
112
+ end
113
+
114
+ def test_notifier_can_handle_comm_object_failures
115
+ thing = standalones(:thing)
116
+ thing.value = "something new"
117
+ thing.save
118
+
119
+ assert_equal RuntimeError, $error.class
120
+ assert_equal "oh noes!", $error.to_s
121
+ assert_equal "standalone", $deets[:notified_class]
122
+ end
123
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class PistonTest < ActiveSupport::TestCase
5
+ def test_base_piston_raises_exception
6
+ assert_raises RuntimeError do
7
+ LaMaquina::Piston::Base.fire!("class", 1, "other_class")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class CachePistonTest < ActiveSupport::TestCase
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ end
8
+
9
+ def test_fire_updates_cache_key
10
+ key = LaMaquina::Piston::CachePiston.cache_key :admin, @admin.id
11
+
12
+ sleep(1)
13
+ LaMaquina::Piston::CachePiston.fire! :admin, @admin.id
14
+
15
+ assert_not_equal key, LaMaquina::Piston::CachePiston.cache_key(:admin, @admin.id)
16
+ end
17
+
18
+ def test_cache_key_generates_new_key
19
+ redis = LaMaquina::Piston::CachePiston.redis
20
+ key = LaMaquina::Piston::CachePiston.send :redis_key, :admin, @admin.id
21
+
22
+ redis.del key
23
+
24
+ assert_not_nil LaMaquina::Piston::CachePiston.cache_key(:admin, @admin.id)
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class SunspotPistonTest < ActiveSupport::TestCase
5
+ def setup
6
+ @admin = admins(:wheel)
7
+ @admin.index!
8
+ end
9
+
10
+ def test_indexer_fires
11
+ search = Admin.search{ fulltext "wheel" }
12
+ assert_not_empty search.results, "there's no results to start with"
13
+
14
+ @admin.update_attributes name: "OMGLOL"
15
+
16
+ search = Admin.search{ fulltext "OMGLOL" }.results
17
+ assert_not_empty search
18
+ end
19
+
20
+ def test_indexer_does_not_fire_for_unmapped_objects
21
+ admin_traits(:wheels_something_else).update_attributes value: "whatever"
22
+ assert_not_equal "admin_traits", $last_reindexed
23
+ end
24
+
25
+ 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.0.3
4
+ version: 0.1.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-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,17 +69,21 @@ files:
69
69
  - Rakefile
70
70
  - la_maquina.gemspec
71
71
  - lib/la_maquina.rb
72
- - lib/la_maquina/ciguenal.rb
72
+ - lib/la_maquina/dependency_map.rb
73
+ - lib/la_maquina/dependency_map/base.rb
74
+ - lib/la_maquina/dependency_map/constant_map.rb
75
+ - lib/la_maquina/dependency_map/yaml_map.rb
76
+ - lib/la_maquina/engine.rb
73
77
  - lib/la_maquina/error_notifier.rb
74
78
  - lib/la_maquina/error_notifier/base.rb
75
79
  - lib/la_maquina/error_notifier/honeybadger_notifier.rb
76
80
  - lib/la_maquina/error_notifier/silent_notifier.rb
81
+ - lib/la_maquina/notifier.rb
77
82
  - lib/la_maquina/piston.rb
78
83
  - lib/la_maquina/piston/base.rb
79
84
  - lib/la_maquina/piston/cache_piston.rb
85
+ - lib/la_maquina/piston/sunspot_piston.rb
80
86
  - lib/la_maquina/version.rb
81
- - lib/la_maquina/volante.rb
82
- - test/ciguenal_test.rb
83
87
  - test/dummy/Rakefile
84
88
  - test/dummy/app/models/.keep
85
89
  - test/dummy/app/models/admin.rb
@@ -108,16 +112,22 @@ files:
108
112
  - test/dummy/config/initializers/mime_types.rb
109
113
  - test/dummy/config/initializers/session_store.rb
110
114
  - test/dummy/config/initializers/wrap_parameters.rb
115
+ - test/dummy/config/la_maquina/dependency_maps/bad_map.yml
116
+ - test/dummy/config/la_maquina/dependency_maps/sunspot_piston.yml
111
117
  - test/dummy/config/locales/en.yml
112
118
  - test/dummy/config/routes.rb
113
119
  - test/dummy/config/secrets.yml
120
+ - test/dummy/config/sunspot.yml
114
121
  - test/dummy/db/development.sqlite3
115
122
  - test/dummy/db/migrate/20150228015009_schema.rb
116
123
  - test/dummy/db/schema.rb
124
+ - test/dummy/db/test.sqlite3
117
125
  - test/dummy/lib/dummy_comm_object.rb
118
126
  - test/dummy/lib/exploding_comm_object.rb
127
+ - test/dummy/lib/exploding_piston.rb
128
+ - test/dummy/lib/extended_sunspot_piston.rb
129
+ - test/dummy/lib/primitive_piston.rb
119
130
  - test/dummy/lib/test_notifier.rb
120
- - test/dummy/lib/test_piston.rb
121
131
  - test/dummy/log/.keep
122
132
  - test/dummy/log/development.log
123
133
  - test/dummy/public/404.html
@@ -133,9 +143,15 @@ files:
133
143
  - test/dummy/test/fixtures/properties.yml
134
144
  - test/dummy/test/fixtures/standalones.yml
135
145
  - test/dummy/test/fixtures/traits.yml
136
- - test/la_maquina_test.rb
137
146
  - test/test_helper.rb
138
- - test/volante_test.rb
147
+ - test/unit/dependency_maps/yamp_map_test.rb
148
+ - test/unit/engine_test.rb
149
+ - test/unit/error_notifier_test.rb
150
+ - test/unit/la_maquina_test.rb
151
+ - test/unit/notifier_test.rb
152
+ - test/unit/piston_test.rb
153
+ - test/unit/pistons/cache_piston_test.rb
154
+ - test/unit/pistons/sunspot_piston_test.rb
139
155
  homepage: https://github.com/gaorlov/la_maquina
140
156
  licenses:
141
157
  - MIT
@@ -161,7 +177,6 @@ signing_key:
161
177
  specification_version: 4
162
178
  summary: depnendency tree update notifications
163
179
  test_files:
164
- - test/ciguenal_test.rb
165
180
  - test/dummy/Rakefile
166
181
  - test/dummy/app/models/.keep
167
182
  - test/dummy/app/models/admin.rb
@@ -190,16 +205,22 @@ test_files:
190
205
  - test/dummy/config/initializers/mime_types.rb
191
206
  - test/dummy/config/initializers/session_store.rb
192
207
  - test/dummy/config/initializers/wrap_parameters.rb
208
+ - test/dummy/config/la_maquina/dependency_maps/bad_map.yml
209
+ - test/dummy/config/la_maquina/dependency_maps/sunspot_piston.yml
193
210
  - test/dummy/config/locales/en.yml
194
211
  - test/dummy/config/routes.rb
195
212
  - test/dummy/config/secrets.yml
213
+ - test/dummy/config/sunspot.yml
196
214
  - test/dummy/db/development.sqlite3
197
215
  - test/dummy/db/migrate/20150228015009_schema.rb
198
216
  - test/dummy/db/schema.rb
217
+ - test/dummy/db/test.sqlite3
199
218
  - test/dummy/lib/dummy_comm_object.rb
200
219
  - test/dummy/lib/exploding_comm_object.rb
220
+ - test/dummy/lib/exploding_piston.rb
221
+ - test/dummy/lib/extended_sunspot_piston.rb
222
+ - test/dummy/lib/primitive_piston.rb
201
223
  - test/dummy/lib/test_notifier.rb
202
- - test/dummy/lib/test_piston.rb
203
224
  - test/dummy/log/.keep
204
225
  - test/dummy/log/development.log
205
226
  - test/dummy/public/404.html
@@ -215,7 +236,13 @@ test_files:
215
236
  - test/dummy/test/fixtures/properties.yml
216
237
  - test/dummy/test/fixtures/standalones.yml
217
238
  - test/dummy/test/fixtures/traits.yml
218
- - test/la_maquina_test.rb
219
239
  - test/test_helper.rb
220
- - test/volante_test.rb
240
+ - test/unit/dependency_maps/yamp_map_test.rb
241
+ - test/unit/engine_test.rb
242
+ - test/unit/error_notifier_test.rb
243
+ - test/unit/la_maquina_test.rb
244
+ - test/unit/notifier_test.rb
245
+ - test/unit/piston_test.rb
246
+ - test/unit/pistons/cache_piston_test.rb
247
+ - test/unit/pistons/sunspot_piston_test.rb
221
248
  has_rdoc:
@@ -1,27 +0,0 @@
1
- module LaMaquina
2
- class Ciguenal
3
-
4
- class << self
5
- protected
6
-
7
- attr_accessor :pistons
8
- end
9
- self.pistons = []
10
-
11
- class << self
12
-
13
- def notify!(klass = "", id = nil)
14
- pistons.each do |piston|
15
- piston.fire! klass, id
16
- end
17
- end
18
-
19
- def install(*attrs)
20
- attrs.each do |piston|
21
- self.pistons << piston
22
- end
23
- end
24
-
25
- end
26
- end
27
- end
@@ -1,30 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- class TestPiston < LaMaquina::Piston::Base
2
- def self.fire!(klass = "", id = nil)
3
- $fire_message = "#{klass}/#{id}"
4
- end
5
- end
data/test/volante_test.rb DELETED
@@ -1,136 +0,0 @@
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