card 1.93.3 → 1.93.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +9 -0
  4. data/db/migrate_core_cards/data/cards/*header +2 -2
  5. data/lib/card/format/nest.rb +12 -5
  6. data/lib/card/format/nest/fetch.rb +1 -2
  7. data/lib/card/format/render.rb +2 -2
  8. data/lib/card/model/save_helper.rb +1 -1
  9. data/lib/card/set/format/haml_views.rb +7 -3
  10. data/lib/card/subcards.rb +27 -228
  11. data/lib/card/subcards/add.rb +121 -0
  12. data/lib/card/subcards/relate.rb +27 -0
  13. data/lib/card/subcards/remove.rb +42 -0
  14. data/lib/card/tasks/card/create.rake +35 -132
  15. data/lib/card/tasks/card/file_card_creator.rb +25 -0
  16. data/lib/card/tasks/card/file_card_creator/abstract_file_card.rb +44 -0
  17. data/lib/card/tasks/card/file_card_creator/abstract_file_card/migration_file.rb +49 -0
  18. data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +30 -0
  19. data/lib/card/tasks/card/file_card_creator/abstract_file_card/source_file.rb +36 -0
  20. data/lib/card/tasks/card/file_card_creator/haml_card.rb +42 -0
  21. data/lib/card/tasks/card/file_card_creator/output_helper.rb +50 -0
  22. data/lib/card/tasks/card/file_card_creator/script_card.rb +33 -0
  23. data/lib/card/tasks/card/file_card_creator/style_card.rb +25 -0
  24. data/lib/generators/card/template/template_generator.rb +1 -1
  25. data/mod/account/set/self/account_links.rb +1 -1
  26. data/mod/basic_formats/set/all/all_csv.rb +63 -0
  27. data/mod/basic_formats/set/all/json.rb +4 -1
  28. data/mod/bootstrap/db/migrate_cards/20170719163733_update_bootswatch_themes_to_4_beta.rb +5 -2
  29. data/mod/carrierwave/set/abstract/attachment.rb +1 -2
  30. data/mod/core/set/abstract/haml_file.rb +20 -0
  31. data/mod/core/set/all/chunk.rb +125 -0
  32. data/mod/core/set/all/collection.rb +2 -351
  33. data/mod/core/set/all/content.rb +26 -7
  34. data/mod/core/set/all/extended.rb +45 -0
  35. data/mod/core/set/all/haml.rb +3 -7
  36. data/mod/core/set/all/item.rb +92 -0
  37. data/mod/core/set/all/name.rb +36 -0
  38. data/mod/core/set/all/subcards.rb +21 -12
  39. data/mod/core/set/all/tabs.rb +50 -0
  40. data/mod/core/set/all/trash.rb +4 -0
  41. data/mod/core/spec/set/all/chunk_spec.rb +45 -0
  42. data/mod/core/spec/set/all/collection_spec.rb +6 -6
  43. data/mod/history/set/all/action_view.rb +1 -1
  44. data/mod/machines/lib/javascript/decko.js.coffee +3 -0
  45. data/mod/pointer/set/abstract/02_pointer/edit.rb +0 -2
  46. data/mod/search/set/abstract/search.rb +1 -1
  47. data/mod/search/set/all/filter.rb +0 -2
  48. data/mod/search/template/all/filter/_filter_input.haml +1 -1
  49. data/mod/search/template/all/filter/filter_form.haml +1 -1
  50. data/mod/standard/set/all/rich_html/editing.rb +1 -1
  51. data/mod/standard/set/all/rich_html/form.rb +6 -7
  52. data/mod/standard/set/all/rich_html/menu.rb +2 -3
  53. data/mod/standard/set/all/rich_html/toolbar.rb +3 -4
  54. data/mod/standard/set/type/cardtype.rb +1 -1
  55. data/mod/standard/spec/set/all/rich_html/editing_spec.rb +15 -4
  56. data/mod/tinymce_editor/db/migrate_cards/{20171113233150_update_tinymce_config.rb → 20171113233151_update_tinymce_config.rb} +1 -0
  57. metadata +25 -161
  58. data/.rspec +0 -4
  59. data/card.gemspec +0 -87
  60. data/db/seed/test/fixtures/.gitkeep +0 -0
  61. data/mod/bootstrap/vendor/bootstrap/.babelrc.js +0 -16
  62. data/mod/bootstrap/vendor/bootstrap/.editorconfig +0 -17
  63. data/mod/bootstrap/vendor/bootstrap/.eslintignore +0 -3
  64. data/mod/bootstrap/vendor/bootstrap/.gitattributes +0 -16
  65. data/mod/bootstrap/vendor/bootstrap/.github/CONTRIBUTING.md +0 -252
  66. data/mod/bootstrap/vendor/bootstrap/.github/ISSUE_TEMPLATE.md +0 -22
  67. data/mod/bootstrap/vendor/bootstrap/.gitignore +0 -46
  68. data/mod/bootstrap/vendor/bootstrap/.hound.yml +0 -19
  69. data/mod/bootstrap/vendor/bootstrap/.houndignore +0 -4
  70. data/mod/bootstrap/vendor/bootstrap/.travis.yml +0 -32
  71. data/mod/bootstrap/vendor/bootstrap/build/.htmllintrc +0 -19
  72. data/mod/bootstrap/vendor/bootstrap/build/.stylelintrc +0 -248
  73. data/mod/bootstrap/vendor/bootstrap/docs/4.0/examples/.stylelintrc +0 -12
  74. data/mod/bootstrap/vendor/bootstrap/js/.eslintrc.json +0 -240
  75. data/mod/bootstrap/vendor/bootstrap/js/tests/.eslintrc.json +0 -46
  76. data/mod/bootstrap/vendor/bootswatch/.gitignore +0 -7
  77. data/mod/bootstrap/vendor/bootswatch/.npmignore +0 -12
  78. data/mod/bootstrap/vendor/bootswatch/.travis.yml +0 -21
  79. data/mod/bootstrap/vendor/bootswatch/docs/.nojekyll +0 -0
  80. data/mod/bootstrap/vendor/bootswatch/docs/2/.travis.yml +0 -15
  81. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.bower.json +0 -20
  82. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.gitignore +0 -37
  83. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.travis.yml +0 -3
  84. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/js/.jshintrc +0 -12
  85. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.bower.json +0 -20
  86. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.gitignore +0 -1
  87. data/mod/bootstrap/vendor/bootswatch/docs/2/swatchmaker/.gitignore +0 -1
  88. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap-sass-official/.bower.json +0 -45
  89. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/.bower.json +0 -44
  90. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/grunt/.jshintrc +0 -7
  91. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jscsrc +0 -42
  92. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jshintrc +0 -15
  93. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csscomb.json +0 -304
  94. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csslintrc +0 -19
  95. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.bower.json +0 -14
  96. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.gitignore +0 -32
  97. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/html5shiv/.bower.json +0 -25
  98. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/jquery/.bower.json +0 -38
  99. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/respond/.bower.json +0 -20
  100. data/mod/bootstrap/vendor/select2/.editorconfig +0 -6
  101. data/mod/bootstrap/vendor/select2/.github/CONTRIBUTING.md +0 -204
  102. data/mod/bootstrap/vendor/select2/.github/ISSUE_TEMPLATE.md +0 -46
  103. data/mod/bootstrap/vendor/select2/.github/PULL_REQUEST_TEMPLATE.md +0 -13
  104. data/mod/bootstrap/vendor/select2/.gitignore +0 -3
  105. data/mod/bootstrap/vendor/select2/.jshintignore +0 -4
  106. data/mod/bootstrap/vendor/select2/.jshintrc +0 -25
  107. data/mod/bootstrap/vendor/select2/.travis.yml +0 -22
  108. data/script/fetch_bootswatch_themes.rb +0 -38
  109. data/spec/config/initializers/core_extensions_spec.rb +0 -47
  110. data/spec/config/initializers/patches/active_job_spec.rb +0 -7
  111. data/spec/lib/card/action_spec.rb +0 -15
  112. data/spec/lib/card/auth_spec.rb +0 -58
  113. data/spec/lib/card/cache_spec.rb +0 -116
  114. data/spec/lib/card/chunk_spec.rb +0 -18
  115. data/spec/lib/card/codename_spec.rb +0 -66
  116. data/spec/lib/card/content_spec.rb +0 -428
  117. data/spec/lib/card/diff_spec.rb +0 -208
  118. data/spec/lib/card/format/nest_spec.rb +0 -13
  119. data/spec/lib/card/format/render_spec.rb +0 -26
  120. data/spec/lib/card/format_spec.rb +0 -117
  121. data/spec/lib/card/i18n_spec.rb +0 -24
  122. data/spec/lib/card/loader/Modfile +0 -2
  123. data/spec/lib/card/loader_spec.rb +0 -98
  124. data/spec/lib/card/migration/import_spec.rb +0 -80
  125. data/spec/lib/card/mod/loader/mod_dirs.rb +0 -8
  126. data/spec/lib/card/mod/loader/set_loader_spec.rb +0 -19
  127. data/spec/lib/card/mod/loader/set_pattern_loader_spec.rb +0 -19
  128. data/spec/lib/card/name/fields_and_traits_spec.rb +0 -18
  129. data/spec/lib/card/name_spec.rb +0 -70
  130. data/spec/lib/card/query/sorting_spec.rb +0 -68
  131. data/spec/lib/card/query_spec.rb +0 -574
  132. data/spec/lib/card/reference_spec.rb +0 -212
  133. data/spec/lib/card/set/event_spec.rb +0 -22
  134. data/spec/lib/card/set/trait_spec.rb +0 -80
  135. data/spec/lib/card/set_pattern_spec.rb +0 -59
  136. data/spec/lib/card/set_spec.rb +0 -89
  137. data/spec/lib/card/stage_director_spec.rb +0 -482
  138. data/spec/lib/card/subcards_spec.rb +0 -177
  139. data/spec/lib/card/success_spec.rb +0 -148
  140. data/spec/lib/card/view_cache_spec.rb +0 -27
  141. data/spec/mailers/mailer_spec.rb +0 -62
  142. data/spec/models/card/create_spec.rb +0 -119
  143. data/spec/models/card/trash_spec.rb +0 -189
  144. data/spec/models/card_spec.rb +0 -136
  145. data/spec/spec_helper.rb +0 -45
  146. data/spec/support/card_spec_helper.rb +0 -74
  147. data/spec/support/card_spec_loader.rb +0 -112
  148. data/spec/support/helper/card_helper.rb +0 -58
  149. data/spec/support/helper/event_helper.rb +0 -94
  150. data/spec/support/helper/render_helper.rb +0 -44
  151. data/spec/support/helper/save_helper.rb +0 -30
  152. data/spec/support/helper/set_helper.rb +0 -80
  153. data/spec/support/matchers/card_matchers.rb +0 -160
  154. data/spec/support/matchers/expectations.rb +0 -5
  155. data/spec/support/matchers/file_matchers.rb +0 -71
  156. data/spec/support/matchers/html_matchers.rb +0 -29
  157. data/spec/support/matchers/negated_matchers.rb +0 -2
  158. data/spec/support/simplecov_helper.rb +0 -70
  159. data/spec/support/test_mods/mod1/set/all/test_set.rb +0 -3
  160. data/spec/support/test_mods/mod2/set_pattern/test_pattern.rb +0 -0
@@ -1,482 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- RSpec.describe Card::ActManager::StageDirector do
4
- describe "abortion" do
5
- let(:create_card) { Card.create name: "a card" }
6
- let(:create_card_with_subcard) do
7
- Card.create name: "a card",
8
- subcards: { "a subcard" => "content" }
9
- end
10
- subject { Card.fetch "a card" }
11
- context "when error added" do
12
- it "stops act in validation phase" do
13
- in_stage :validate,
14
- on: :save,
15
- trigger: -> { create_card } do
16
- errors.add :stop, "don't do this"
17
- end
18
- is_expected.to be_falsey
19
- end
20
-
21
- it "does not stop act in storage phase" do
22
- in_stage :store, on: :save,
23
- trigger: -> { create_card } do
24
- errors.add :stop, "don't do this"
25
- end
26
- is_expected.to be_truthy
27
- end
28
- end
29
-
30
- context "when exception raised" do
31
- it "rollbacks in finalize stage" do
32
- begin
33
- in_stage :finalize,
34
- on: :save,
35
- trigger: -> { create_card } do
36
- raise Card::Error, "rollback"
37
- end
38
- rescue Card::Error => e
39
- ensure
40
- is_expected.to be_falsey
41
- end
42
- end
43
-
44
- it "does not rollback in integrate stage" do
45
- begin
46
- Card::Auth.as_bot do
47
- in_stage :integrate,
48
- on: :save,
49
- trigger: -> { create_card } do
50
- raise Card::Error::Abort, "rollback"
51
- end
52
- end
53
- rescue Card::Error::Abort => e
54
- ensure
55
- is_expected.to be_truthy
56
- end
57
- end
58
- end
59
-
60
- context "when abort :success called" do
61
- it "aborts storage in validation stage" do
62
- in_stage :validate,
63
- on: :create,
64
- trigger: -> { create_card } do
65
- abort :success
66
- end
67
- is_expected.to be_falsey
68
- end
69
-
70
- it "does not execute subcard stages on create" do
71
- @called_events = []
72
-
73
- def event_called ev
74
- @called_events << ev
75
- end
76
-
77
- with_test_events do
78
- test_event :validate,
79
- on: :create,
80
- for: "a card" do
81
- abort :success
82
- end
83
- test_event :prepare_to_validate,
84
- on: :create, for: "a subcard" do
85
- event_called "ptv"
86
- end
87
- test_event :validate,
88
- on: :create, for: "a subcard" do
89
- event_called "v"
90
- end
91
- test_event :prepare_to_store,
92
- on: :create, for: "a subcard" do
93
- event_called "pts"
94
- end
95
- test_event :integrate,
96
- on: :create, for: "a subcard" do
97
- event_called "i"
98
- end
99
- create_card_with_subcard
100
- expect(@called_events).to eq ["ptv"]
101
- end
102
- end
103
-
104
- it "does not delete children" do
105
- @called_events = []
106
-
107
- def event_called ev
108
- @called_events << ev
109
- end
110
-
111
- with_test_events do
112
- test_event :validate,
113
- on: :delete,
114
- for: "A" do
115
- abort :success
116
- end
117
- test_event :prepare_to_validate,
118
- on: :delete, for: "A+B" do
119
- event_called "ptv"
120
- end
121
- test_event :validate,
122
- on: :delete, for: "A+B" do
123
- event_called "v"
124
- end
125
- test_event :prepare_to_store,
126
- on: :delete, for: "A+B" do
127
- event_called "pts"
128
- end
129
- test_event :integrate,
130
- on: :delete, for: "A+B" do
131
- event_called "i"
132
- end
133
- Card["A"].delete!
134
- expect(@called_events).to eq []
135
- end
136
- end
137
-
138
- it "aborts storage in store stage" do
139
- in_stage :store,
140
- on: :create,
141
- trigger: -> { create_card } do
142
- abort :success
143
- end
144
- is_expected.to be_falsey
145
- end
146
-
147
- it "aborts storage in finalize stage" do
148
- in_stage :store,
149
- on: :create,
150
- trigger: -> { create_card } do
151
- abort :success
152
- end
153
- is_expected.to be_falsey
154
- end
155
-
156
- it "does not abort storage in integrate stage" do
157
- in_stage :integrate,
158
- on: :create,
159
- trigger: -> { create_card } do
160
- abort :success
161
- end
162
- is_expected.to be_truthy
163
- end
164
- end
165
- end
166
-
167
- describe "stage order" do
168
- let(:create_card_with_subcards) do
169
- Card.create name: "1",
170
- subcards: {
171
- "11" => { subcards: { "111" => "A" } },
172
- "12" => { subcards: { "121" => "A" } }
173
- }
174
- end
175
- let(:create_card_with_junction) do
176
- Card.create name: "1+2",
177
- subcards: { "11" => "A" }
178
- end
179
- let(:preorder) { %w(1 11 111 12 121) }
180
- let(:postorder) { %w(111 11 121 12 1) }
181
- describe "validate" do
182
- it "is pre-order depth-first" do
183
- order = []
184
- in_stage :validate, on: :create,
185
- trigger: -> { create_card_with_subcards } do
186
- order << name
187
- end
188
- expect(order).to eq(preorder)
189
- end
190
-
191
- it "executes all validate stages before next stage" do
192
- order = []
193
- with_test_events do
194
- test_event :validate, on: :create do
195
- order << "v:#{name}"
196
- end
197
- test_event :prepare_to_store, on: :create do
198
- order << "pts:#{name}"
199
- end
200
- create_card_with_subcards
201
- end
202
- expect(order).to eq(
203
- %w(v:1 v:11 v:111 v:12 v:121 pts:1 pts:11 pts:111 pts:12 pts:121)
204
- )
205
- end
206
- end
207
-
208
- describe "finalize" do
209
- it "is post-order depth-first" do
210
- order = []
211
- in_stage :finalize, on: :create,
212
- trigger: -> { create_card_with_subcards } do
213
- order << name
214
- end
215
- expect(order).to eq(postorder)
216
- end
217
- end
218
-
219
- describe "store" do
220
- it "is pre-order depth-first" do
221
- order = []
222
- in_stage :store, on: :create,
223
- trigger: -> { create_card_with_subcards } do
224
- order << name
225
- end
226
- expect(order).to eq(preorder)
227
- end
228
- end
229
-
230
- describe "store and finalize" do
231
- it "executes finalize when all subcards are stored and finalized" do
232
- order = []
233
- with_test_events do
234
- test_event :store, on: :create do
235
- order << "store:#{name}"
236
- end
237
- test_event :finalize, on: :create do
238
- order << "finalize:#{name}"
239
- end
240
- create_card_with_subcards
241
- end
242
- expect(order).to eq(
243
- %w(store:1 store:11 store:111 finalize:111 finalize:11
244
- store:12 store:121 finalize:121 finalize:12 finalize:1)
245
- )
246
- end
247
- end
248
-
249
- describe "complete run" do
250
- it "is in correct order" do
251
- order = []
252
- with_test_events do
253
- test_event :initialize, on: :create do
254
- order << "i:#{name}"
255
- end
256
- test_event :prepare_to_validate, on: :create do
257
- order << "ptv:#{name}"
258
- end
259
- test_event :validate, on: :create do
260
- order << "v:#{name}"
261
- add_subcard "112v" if name == "11"
262
- end
263
- test_event :prepare_to_store, on: :create do
264
- order << "pts:#{name}"
265
- end
266
- test_event :store, on: :create do
267
- order << "s:#{name}"
268
- end
269
- test_event :finalize, on: :create do
270
- order << "f:#{name}"
271
- end
272
- test_event :integrate, on: :create do
273
- order << "ig:#{name}"
274
- end
275
- test_event :integrate_with_delay, on: :create do
276
- order << "igwd:#{name}"
277
- end
278
- create_card_with_subcards
279
- end
280
- # Delayed::Worker.new.work_off
281
- expect(order).to eq(
282
- %w(
283
- i:1 i:11 i:111 i:12 i:121
284
- ptv:1 ptv:11 ptv:111 ptv:12 ptv:121
285
- v:1 v:11 v:111
286
- i:112v ptv:112v v:112v
287
- v:12 v:121
288
- pts:1 pts:11 pts:111 pts:112v pts:12 pts:121
289
- s:1
290
- s:11
291
- s:111 f:111
292
- s:112v f:112v
293
- f:11
294
- s:12
295
- s:121 f:121
296
- f:12
297
- f:1
298
- ig:1 ig:11 ig:111 ig:112v ig:12 ig:121
299
- igwd:1 igwd:11 igwd:111 igwd:112v igwd:12 igwd:121
300
- )
301
- )
302
- end
303
-
304
- it "with junction" do
305
- order = []
306
- with_test_events do
307
- test_event :initialize, on: :create do
308
- order << "i:#{name}"
309
- end
310
- test_event :prepare_to_validate, on: :create do
311
- order << "ptv:#{name}"
312
- end
313
- test_event :validate, on: :create do
314
- order << "v:#{name}"
315
- end
316
- test_event :prepare_to_store, on: :create do
317
- order << "pts:#{name}"
318
- end
319
- test_event :store, on: :create do
320
- order << "s:#{name}"
321
- end
322
- test_event :finalize, on: :create do
323
- order << "f:#{name}"
324
- end
325
- test_event :integrate, on: :create do
326
- order << "ig:#{name}"
327
- end
328
- test_event :integrate_with_delay, on: :create do
329
- order << "igwd:#{name}"
330
- end
331
- create_card_with_junction
332
- end
333
- # Delayed::Worker.new.work_off
334
- expect(order).to eq(
335
- %w(
336
- i:1+2 i:11
337
- ptv:1+2 ptv:11
338
- v:1+2 v:11
339
- pts:1+2 pts:11
340
- s:1+2
341
- i:1 ptv:1 v:1 pts:1 s:1 f:1
342
- i:2 ptv:2 v:2 pts:2 s:2 f:2
343
- s:11 f:11
344
- f:1+2
345
- ig:1+2 ig:11 ig:1 ig:2
346
- igwd:1+2 igwd:11 igwd:1 igwd:2
347
- )
348
- )
349
- end
350
- end
351
- end
352
-
353
- describe "subcards" do
354
- def create_subcards
355
- Card.create! name: "", subcards: {
356
- "+sub1" => "some content",
357
- "+sub2" => { "+sub3" => "content" }
358
- }
359
- end
360
-
361
- def create_single_card
362
- Card.create! name: "single card"
363
- end
364
-
365
- it "has correct name if supercard's name get changed" do
366
- Card::Auth.as_bot do
367
- changed = false
368
- in_stage :prepare_to_validate,
369
- on: :create,
370
- trigger: :create_subcards do
371
- self.name = "main" if name.empty? && !changed
372
- end
373
- expect(Card["main+sub1"].class).to eq(Card)
374
- expect(Card["main+sub2+sub3"].class).to eq(Card)
375
- end
376
- end
377
- it "has correct name if supercard's name get changed to a junction card" do
378
- Card::Auth.as_bot do
379
- changed = false
380
- in_stage :prepare_to_validate,
381
- on: :create,
382
- trigger: :create_subcards do
383
- if name.empty? && !changed
384
- self.name = "main1+main2"
385
- expect(subfield("sub1")).to be
386
- expect(subfield("sub1").content).to eq("some content")
387
- end
388
- end
389
- expect(Card["main1+main2+sub1"].class).to eq(Card)
390
- expect(Card["main1+main2+sub1"].content).to eq("some content")
391
- expect(Card["main1+main2+sub2+sub3"].class).to eq(Card)
392
- expect(Card["main1+main2+sub2+sub3"].content).to eq("content")
393
- end
394
- end
395
-
396
- it "load type_plus_right set module" do
397
- Card::Auth.as_bot do
398
- in_stage :prepare_to_validate,
399
- on: :create,
400
- for: "single card",
401
- trigger: :create_single_card do
402
-
403
- u_card = attach_subfield "a user", type_id: Card::UserID
404
- f_card = u_card.attach_subfield "*follow"
405
- expect(f_card.set_modules)
406
- .to include(Card::Set::TypePlusRight::User::Follow)
407
- end
408
- end
409
- end
410
-
411
- it "adds subsubcard to correct subdirector" do
412
- Card::Auth.as_bot do
413
- in_stage :prepare_to_store,
414
- on: :create,
415
- trigger: -> { Card.create! name: "main" } do
416
- case name
417
- when "main"
418
- add_subcard "subby", "+sub2" => {
419
- subcards: { "AARGH" => { "+sub4" => "more content" } }
420
- }
421
- in_subdirectors = director.subdirectors.any? do |subdir|
422
- subdir.card.name == "AARGH"
423
- end
424
- expect(in_subdirectors).to be_falsey
425
- when "subby+sub2"
426
- in_subsubdirectors = director.subdirectors.any? do |subdir|
427
- subdir.card.name == "AARGH"
428
- end
429
- expect(in_subsubdirectors).to be_truthy
430
- end
431
- end
432
- end
433
- end
434
- end
435
-
436
- describe "creating and updating cards in stages" do
437
- it "update_attributes works in integrate stage" do
438
- act_cnt = Card["A"].acts.size
439
- in_stage :integrate,
440
- on: :create,
441
- trigger: -> { Card.create! name: "act card" } do
442
- Card["A"].update_attributes content: "changed content"
443
- end
444
- expect(Card["A"].content).to eq "changed content"
445
- expect(Card["A"].acts.size).to eq(act_cnt), "no act added to A"
446
- expect(Card["act card"].acts.size).to eq(1), "new act for 'act card'"
447
- expect(Card["A"].actions.last.act).to eq Card["act card"].acts.last
448
- end
449
-
450
- it "update_attributes works integrate_with_delay stage" do
451
- act_cnt = Card["A"].acts.size
452
- with_delayed_jobs 1 do
453
- in_stage :integrate_with_delay,
454
- on: :create, for: "act card",
455
- trigger: -> { Card.create! name: "act card" } do
456
- Card["A"].update_attributes content: "changed content"
457
- end
458
- end
459
- expect(Card["A"].content).to eq "changed content"
460
- expect(Card["A"].acts.size).to eq(act_cnt), "expected no new act on A"
461
- expect(Card["act card"].acts.size).to eq(1), "new act for 'act card'"
462
- expect(Card["A"].actions.last.act).to eq Card["act card"].acts.last
463
-
464
- Delayed::Worker.delay_jobs = false
465
- end
466
-
467
- it "create works in integrate_with_delay stage" do
468
- with_delayed_jobs 1 do
469
- in_stage :integrate_with_delay,
470
- on: :create, for: "act card",
471
- trigger: -> { Card.create! name: "act card" } do
472
- Card.create! name: "iwd created card", content: "new content"
473
- end
474
- end
475
- expect(Card["iwd created card"]).to exist.and have_db_content "new content"
476
- expect(Card["act card"].acts.size).to eq(1), "new act for 'act card'"
477
- expect(Card["iwd created card"].actions.last.act).to eq Card["act card"].acts.last
478
- expect(Card["iwd created card"].acts.size).to eq(0), "no act added"
479
-
480
- end
481
- end
482
- end