card 1.20.4 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +9 -9
  4. data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +20 -0
  5. data/db/migrate_core_cards/20170608083819_add_full_width_layout_card.rb +23 -0
  6. data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +8 -0
  7. data/db/seed/new/card_actions.yml +783 -791
  8. data/db/seed/new/card_acts.yml +65 -47
  9. data/db/seed/new/card_changes.yml +3198 -3177
  10. data/db/seed/new/card_references.yml +604 -534
  11. data/db/seed/new/cards.yml +2355 -2256
  12. data/db/seed/test/fixtures/card_actions.yml +1795 -1803
  13. data/db/seed/test/fixtures/card_acts.yml +264 -246
  14. data/db/seed/test/fixtures/card_changes.yml +6275 -6184
  15. data/db/seed/test/fixtures/card_references.yml +1305 -1263
  16. data/db/seed/test/fixtures/cards.yml +3393 -3298
  17. data/db/seed/test/seed.rb +2 -2
  18. data/db/version_core_cards.txt +1 -1
  19. data/lib/card.rb +4 -0
  20. data/lib/card/act_manager/subdirector_array.rb +1 -0
  21. data/lib/card/auth/current.rb +7 -3
  22. data/lib/card/env.rb +5 -0
  23. data/lib/card/env/success.rb +1 -1
  24. data/lib/card/format/names.rb +3 -13
  25. data/lib/card/model/save_helper.rb +4 -6
  26. data/lib/card/query.rb +2 -1
  27. data/lib/card/query/attributes.rb +34 -14
  28. data/lib/card/query/value.rb +3 -4
  29. data/lib/card/set/format.rb +29 -4
  30. data/lib/card/set/format/haml_views.rb +25 -13
  31. data/lib/card/set/trait.rb +1 -0
  32. data/lib/card/set_pattern.rb +17 -1
  33. data/lib/card/subcards.rb +3 -2
  34. data/lib/generators/card/format/format_generator.rb +2 -0
  35. data/lib/generators/card/set/set_generator.rb +2 -0
  36. data/lib/generators/card/template/USAGE +10 -0
  37. data/lib/generators/card/template/template_generator.rb +46 -0
  38. data/lib/generators/card/template/templates/haml_template.erb +1 -0
  39. data/mod/Modfile +1 -1
  40. data/mod/account/set/all/account.rb +9 -5
  41. data/mod/account/set/right/account.rb +17 -5
  42. data/mod/account/set/self/account_links.rb +1 -2
  43. data/mod/account/set/type/signup.rb +4 -5
  44. data/mod/account/set/type/user.rb +1 -1
  45. data/mod/account/spec/set/all/account_spec.rb +2 -2
  46. data/mod/account/spec/set/right/account_spec.rb +2 -2
  47. data/mod/account/spec/set/right/email_spec.rb +1 -1
  48. data/mod/account/spec/set/right/password_spec.rb +1 -1
  49. data/mod/account/spec/set/self/signin_spec.rb +2 -2
  50. data/mod/account/spec/set/type/signup_spec.rb +4 -0
  51. data/mod/ace_editor/set/abstract/ace_editor.rb +6 -3
  52. data/mod/ace_editor/set/self/script_ace.rb +1 -0
  53. data/mod/admin/set/self/admin.rb +1 -1
  54. data/mod/admin/set/self/version.rb +1 -0
  55. data/mod/basic_formats/format/css_format.rb +1 -0
  56. data/mod/basic_formats/format/csv_format.rb +1 -0
  57. data/mod/basic_formats/format/file_format.rb +1 -0
  58. data/mod/basic_formats/format/js_format.rb +1 -0
  59. data/mod/basic_formats/format/json_format.rb +1 -0
  60. data/mod/basic_formats/format/rss_format.rb +1 -0
  61. data/mod/basic_formats/format/xml_format.rb +1 -0
  62. data/mod/basic_formats/set/all/all_csv.rb +1 -1
  63. data/mod/basic_formats/set/all/base.rb +11 -3
  64. data/mod/basic_formats/set/all/json.rb +50 -8
  65. data/mod/basic_formats/set/all/rss.rb +21 -7
  66. data/mod/basic_formats/set/self/01_head/javascript.rb +1 -1
  67. data/mod/basic_formats/set/self/head.rb +1 -1
  68. data/mod/basic_formats/spec/set/all/base_spec.rb +13 -0
  69. data/mod/basic_types/set/type/html.rb +6 -2
  70. data/mod/basic_types/set/type/plain_text.rb +2 -3
  71. data/mod/bootstrap/lib/bootstrap.rb +2 -2
  72. data/mod/bootstrap/lib/bootstrap/basic_tags.rb +1 -1
  73. data/mod/bootstrap/lib/bootstrap/component.rb +2 -3
  74. data/mod/bootstrap/lib/bootstrap/component/form.rb +6 -5
  75. data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +1 -1
  76. data/mod/bootstrap/lib/bootstrap/component/layout.rb +3 -3
  77. data/mod/bootstrap/lib/bootstrap/component_loader.rb +0 -2
  78. data/mod/bootstrap/lib/bootstrap/delegate.rb +2 -2
  79. data/mod/bootstrap/lib/bootstrapper.rb +1 -1
  80. data/mod/bootstrap/set/all/bootstrap/accordion.rb +1 -1
  81. data/mod/bootstrap/set/all/bootstrap/form.rb +2 -2
  82. data/mod/bootstrap/set/all/bootstrap/helper.rb +1 -0
  83. data/mod/bootstrap/set/all/bootstrap/wrapper.rb +1 -1
  84. data/mod/bootstrap/set/self/bootstrap_js.rb +1 -1
  85. data/mod/bootstrap/set/self/bootswatch_shared.rb +6 -6
  86. data/mod/bootstrap/set/self/script_mods.rb +1 -1
  87. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +7 -6
  88. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +2 -1
  89. data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +6 -3
  90. data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +3 -2
  91. data/mod/carrierwave/set/abstract/attachment.rb +1 -3
  92. data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
  93. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +11 -1
  94. data/mod/carrierwave/set/type/file.rb +3 -3
  95. data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +3 -0
  96. data/mod/carrierwave/spec/set/type/file_spec.rb +24 -6
  97. data/mod/carrierwave/spec/set/type/image_spec.rb +3 -0
  98. data/mod/core/chunk/link.rb +1 -1
  99. data/mod/core/chunk/nest.rb +2 -1
  100. data/mod/core/chunk/query_reference.rb +1 -1
  101. data/mod/core/chunk/reference.rb +1 -0
  102. data/mod/core/chunk/uri.rb +4 -3
  103. data/mod/core/set/abstract/lock.rb +26 -0
  104. data/mod/core/set/all/assign_attributes.rb +8 -4
  105. data/mod/core/set/all/collection.rb +16 -7
  106. data/mod/core/set/all/content.rb +6 -0
  107. data/mod/core/set/all/event.rb +1 -1
  108. data/mod/core/set/all/fetch.rb +2 -2
  109. data/mod/core/set/all/haml.rb +5 -15
  110. data/mod/core/set/all/initialize.rb +2 -2
  111. data/mod/core/set/all/name.rb +1 -1
  112. data/mod/core/set/all/permissions.rb +28 -16
  113. data/mod/core/set/all/rules.rb +1 -2
  114. data/mod/core/set/all/subcards.rb +3 -3
  115. data/mod/core/set/all/templating.rb +5 -1
  116. data/mod/core/set/all/trash.rb +1 -1
  117. data/mod/core/set/all/utils.rb +1 -1
  118. data/mod/core/spec/set/all/actify_spec.rb +1 -1
  119. data/mod/core/spec/set/all/assign_attributes_spec.rb +2 -2
  120. data/mod/core/spec/set/all/collection_spec.rb +6 -3
  121. data/mod/core/spec/set/all/export_spec.rb +40 -112
  122. data/mod/core/spec/set/all/name_spec.rb +1 -1
  123. data/mod/core/spec/set/all/permissions_spec.rb +7 -7
  124. data/mod/core/spec/set/all/rules2_spec.rb +25 -25
  125. data/mod/core/spec/set/all/rules_spec.rb +2 -7
  126. data/mod/developer/set/all/event_viz.rb +1 -1
  127. data/mod/developer/set/right/debug.rb +1 -1
  128. data/mod/history/lib/card/act.rb +1 -0
  129. data/mod/history/lib/card/act/act_renderer.rb +23 -20
  130. data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +0 -1
  131. data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +1 -0
  132. data/mod/history/lib/card/action.rb +1 -1
  133. data/mod/history/lib/card/action/action_renderer.rb +2 -2
  134. data/mod/history/lib/card/change.rb +2 -1
  135. data/mod/history/set/all/action_view.rb +1 -1
  136. data/mod/history/set/all/content_history.rb +7 -4
  137. data/mod/history/set/all/history.rb +6 -6
  138. data/mod/machines/file/all_script_machine_output/file.js +50 -34
  139. data/mod/machines/file/all_style_machine_output/file.css +1 -1
  140. data/mod/machines/lib/javascript/wagn.js.coffee +29 -18
  141. data/mod/machines/lib/javascript/wagn_layout.js.coffee +7 -3
  142. data/mod/machines/lib/stylesheets/style_cards.scss +10 -10
  143. data/mod/machines/set/abstract/machine.rb +5 -28
  144. data/mod/machines/set/abstract/script.rb +7 -4
  145. data/mod/machines/set/all/reset_machines.rb +1 -1
  146. data/mod/machines/set/self/script_jquery_helper.rb +2 -2
  147. data/mod/machines/set/self/script_slot.rb +1 -1
  148. data/mod/machines/set/type/coffee_script.rb +3 -2
  149. data/mod/machines/set/type/css.rb +7 -3
  150. data/mod/machines/set/type/scss.rb +7 -1
  151. data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
  152. data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
  153. data/mod/machines/spec/set/type/scss_spec.rb +3 -2
  154. data/mod/machines/spec/set/type/skin_spec.rb +1 -1
  155. data/mod/machines/spec/shared_examples/machine.rb +5 -3
  156. data/mod/machines/spec/shared_examples/machine_input.rb +1 -0
  157. data/mod/notifications/format/email_html_format.rb +1 -0
  158. data/mod/notifications/set/all/follow.rb +1 -1
  159. data/mod/notifications/set/all/observer.rb +1 -1
  160. data/mod/notifications/set/all/send_notifications.rb +2 -2
  161. data/mod/notifications/set/self/follow_defaults.rb +3 -8
  162. data/mod/notifications/set/type/email_template/email_config.rb +2 -2
  163. data/mod/notifications/set/type_plus_right/user/follow.rb +2 -2
  164. data/mod/notifications/spec/set/all/follow_spec.rb +7 -0
  165. data/mod/notifications/spec/set/all/notify_spec.rb +3 -0
  166. data/mod/notifications/spec/set/all/observer_spec.rb +1 -1
  167. data/mod/notifications/spec/set/right/followers_spec.rb +1 -0
  168. data/mod/pointer/set/abstract/00_paging_params.rb +11 -0
  169. data/mod/pointer/set/abstract/{00_paging.rb → 01_paging.rb} +10 -6
  170. data/mod/pointer/set/abstract/{00_paging → 01_paging}/paging_links.rb +0 -0
  171. data/mod/pointer/set/abstract/{01_pointer.rb → 02_pointer.rb} +26 -5
  172. data/mod/pointer/set/abstract/{01_pointer → 02_pointer}/edit.rb +3 -5
  173. data/mod/pointer/set/self/input_options.rb +12 -0
  174. data/mod/pointer/spec/set/self/input_options_spec.rb +8 -0
  175. data/mod/pointer/spec/set/type/pointer_spec.rb +3 -2
  176. data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +1 -1
  177. data/mod/prosemirror_editor/set/self/script_prosemirror.rb +1 -0
  178. data/mod/settings/lib/card/setting.rb +1 -2
  179. data/mod/settings/set/abstract/permission.rb +1 -1
  180. data/mod/settings/set/self/add_help.rb +1 -1
  181. data/mod/settings/set/self/autoname.rb +1 -1
  182. data/mod/settings/set/self/csv_structure.rb +2 -0
  183. data/mod/settings/set/self/help.rb +1 -1
  184. data/mod/settings/set/self/input.rb +1 -2
  185. data/mod/settings/set/self/options.rb +2 -2
  186. data/mod/settings/set/self/options_label.rb +2 -2
  187. data/mod/settings/set/type/setting.rb +1 -1
  188. data/mod/settings/spec/set/right/script_spec.rb +1 -1
  189. data/mod/settings/spec/set/right/style_spec.rb +1 -1
  190. data/mod/solid_cache/set/abstract/solid_cache.rb +5 -3
  191. data/mod/solid_cache/spec/set/abstract/solid_cache_spec.rb +4 -3
  192. data/mod/standard/set/abstract/01_search_params.rb +4 -3
  193. data/mod/standard/set/abstract/search.rb +2 -1
  194. data/mod/standard/set/abstract/toolbar_split_button.rb +22 -0
  195. data/mod/standard/set/all/links.rb +3 -3
  196. data/mod/standard/set/all/rich_html/classy.rb +37 -0
  197. data/mod/standard/set/all/rich_html/editing.rb +6 -2
  198. data/mod/standard/set/all/rich_html/editor.rb +50 -0
  199. data/mod/standard/set/all/rich_html/form.rb +19 -12
  200. data/mod/standard/set/all/rich_html/form_elements.rb +2 -2
  201. data/mod/standard/set/all/rich_html/formgroup.rb +2 -1
  202. data/mod/standard/set/all/rich_html/header.rb +2 -27
  203. data/mod/standard/set/all/rich_html/menu.rb +1 -1
  204. data/mod/standard/set/all/rich_html/new.rb +5 -1
  205. data/mod/standard/set/all/rich_html/toolbar.rb +15 -60
  206. data/mod/standard/set/all/rich_html/wrapper.rb +6 -3
  207. data/mod/standard/set/right/when_created.rb +2 -2
  208. data/mod/standard/set/rstar/rules_editor.rb +10 -7
  209. data/mod/standard/set/self/activity_toolbar_button.rb +14 -0
  210. data/mod/standard/set/self/recent.rb +7 -2
  211. data/mod/standard/set/self/rules_toolbar_button.rb +42 -0
  212. data/mod/standard/set/self/search.rb +19 -6
  213. data/mod/standard/set/type/basic.rb +6 -6
  214. data/mod/standard/set/type/cardtype.rb +7 -3
  215. data/mod/standard/set/type/date.rb +2 -4
  216. data/mod/standard/set/type/layout_type.rb +1 -0
  217. data/mod/standard/set/type/list.rb +1 -1
  218. data/mod/standard/set/type/listed_by.rb +1 -2
  219. data/mod/standard/set/type/number.rb +4 -2
  220. data/mod/standard/set/type/phrase.rb +4 -2
  221. data/mod/standard/set/type/search_type.rb +11 -3
  222. data/mod/standard/set/type/set.rb +8 -8
  223. data/mod/standard/set/type/toggle.rb +1 -3
  224. data/mod/standard/set/type/uri.rb +6 -2
  225. data/mod/standard/spec/chunk/include_spec.rb +3 -2
  226. data/mod/standard/spec/chunk/query_reference_spec.rb +2 -2
  227. data/mod/standard/spec/set/all/history_spec.rb +1 -0
  228. data/mod/standard/spec/set/all/links_spec.rb +1 -0
  229. data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +2 -0
  230. data/mod/standard/spec/set/self/activity_toolbar_button_spec.rb +22 -0
  231. data/mod/standard/spec/set/type/email_template/email_config_spec.rb +10 -8
  232. data/mod/standard/spec/set/type/email_template_spec.rb +1 -0
  233. data/mod/standard/spec/set/type/list_spec.rb +2 -0
  234. data/mod/standard/spec/set/type/listed_by_spec.rb +5 -0
  235. data/mod/standard/spec/set/type/search_type_spec.rb +1 -1
  236. data/mod/standard/spec/set/type/toggle_spec.rb +1 -2
  237. data/mod/standard/spec/set/type/uri_spec.rb +0 -1
  238. data/mod/tinymce_editor/db/migrate_cards/20160804112560_add_tinymce_cards.rb +3 -1
  239. data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
  240. data/mod/tinymce_editor/set/self/script_tinymce.rb +1 -0
  241. data/mod/twitter/db/migrate_cards/20170305112346_add_twitter_cards.rb +1 -1
  242. data/mod/twitter/set/type/twitter_template.rb +1 -1
  243. data/spec/lib/card/format_spec.rb +26 -7
  244. data/spec/lib/card/loader_spec.rb +96 -35
  245. data/spec/lib/card/query_spec.rb +0 -1
  246. data/spec/support/card_spec_loader.rb +1 -0
  247. data/spec/support/helper/card_helper.rb +0 -36
  248. data/spec/support/helper/set_helper.rb +80 -0
  249. data/spec/support/matchers.rb +74 -0
  250. data/tmpsets/set/mod001-core/all/actify.rb +5 -6
  251. data/tmpsets/set/mod001-core/all/fetch.rb +14 -12
  252. data/tmpsets/set/mod001-core/all/name.rb +1 -1
  253. data/tmpsets/set/mod001-core/all/permissions.rb +12 -22
  254. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +76 -0
  255. data/tmpsets/set/mod001-core/all/utils.rb +40 -3
  256. data/tmpsets/set/mod002-history/all/history.rb +1 -2
  257. data/tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb +1 -1
  258. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +282 -0
  259. data/tmpsets/set/mod013-carrierwave/type/file.rb +155 -0
  260. data/tmpsets/set/mod013-carrierwave/type/image.rb +96 -0
  261. data/tmpsets/set/mod014-admin/self/admin.rb +113 -0
  262. data/tmpsets/set/mod014-admin/self/admin_info.rb +110 -0
  263. data/tmpsets/set/mod014-admin/self/version.rb +15 -0
  264. data/tmpsets/set/mod015-developer/all/event_viz.rb +59 -0
  265. data/tmpsets/set/mod015-developer/all/view_viz.rb +30 -0
  266. data/tmpsets/set/mod015-developer/right/debug.rb +96 -0
  267. metadata +52 -22
@@ -1,3 +1,4 @@
1
1
  include_set Abstract::CodeFile
2
2
 
3
3
  Self::ScriptMods.add_to_basket :item_codenames, :script_tinymce
4
+ Self::InputOptions.add_to_basket :options, "tinymce editor"
@@ -17,7 +17,7 @@ class AddTwitterCards < Card::Migration
17
17
 
18
18
  Card::Cache.reset_all
19
19
 
20
- ensure_card name: [:twitter_template, :type, :structure],
20
+ ensure_card name: %i[twitter_template type structure],
21
21
  content: structure
22
22
  end
23
23
 
@@ -5,7 +5,7 @@ card_reader :access_secret
5
5
 
6
6
  card_reader :message
7
7
 
8
- require 'twitter'
8
+ require "twitter"
9
9
 
10
10
  def deliver args={}
11
11
  client.update message_card.contextual_content(args[:context])
@@ -10,6 +10,7 @@ describe Card::Format do
10
10
  format.show_view?(:menu, default_viz)
11
11
  end
12
12
  end
13
+
13
14
  it "respects defaults" do
14
15
  expect(show_menu?({}, :show)).to be_truthy
15
16
  expect(show_menu?({}, :hide)).to be_falsey
@@ -42,9 +43,7 @@ describe Card::Format do
42
43
  let(:url_text1) do
43
44
  "with external free link http://localhost:2020/path?cgi=foo&bar=baz"
44
45
  end
45
- let(:url_text2) do
46
- "with external in link syntax: [[http://brain.org/Home|extra]]"
47
- end
46
+ let(:url_text2) { "with external in link syntax: [[http://brain.org/Home|extra]]" }
48
47
  let(:url_text3) { "with internal lik [[A]]" }
49
48
  let(:url_text4) { "with internal lik [[Home|display text]]" }
50
49
  let(:url_text5) do
@@ -67,18 +66,18 @@ describe Card::Format do
67
66
  it "formats html links" do
68
67
  cobj = Card::Content.new url_text1, html_format
69
68
  expect(cobj.to_s).to eq(
70
- 'with external free link <a target="_blank" class="external-link" ' \
69
+ 'with external free link <a target="_blank" class="external-link" ' \
71
70
  'href="http://localhost:2020/path?cgi=foo&amp;bar=baz">' \
72
71
  "http://localhost:2020/path?cgi=foo&bar=baz</a>"
73
- )
72
+ )
74
73
  cobj = Card::Content.new url_text2 + url_text3 + url_text4, html_format
75
74
  expect(cobj.to_s).to eq url_text2 + url_text3 + url_text4
76
75
  cobj = Card::Content.new url_text5, html_format
77
76
  expect(cobj.to_s).to eq(
78
- 'external with port: <a target="_blank" class="external-link" ' \
77
+ 'external with port: <a target="_blank" class="external-link" ' \
79
78
  'href="http://localhost:2020/path?cgi=foo+bar=baz">' \
80
79
  "http://localhost:2020/path?cgi=foo+bar=baz</a> after "
81
- )
80
+ )
82
81
  end
83
82
 
84
83
  it "formats page_path" do
@@ -95,4 +94,24 @@ describe Card::Format do
95
94
  .to eq "http://test.host/#{card.name}"
96
95
  end
97
96
  end
97
+
98
+ describe "async view" do
99
+ let(:format) do
100
+ Card["A"].format_with do
101
+ view :lazy_view, async: true do
102
+ "content"
103
+ end
104
+ end
105
+ end
106
+
107
+ it "renders placeholder" do
108
+ expect(format.render(:lazy_view))
109
+ .to eq "<card-view-placeholder data-url=/A?view=lazy_view_async_content/>"
110
+ end
111
+
112
+ it "renders content in _async_content view" do
113
+ expect(format.render(:lazy_view_async_content))
114
+ .to eq "content"
115
+ end
116
+ end
98
117
  end
@@ -1,37 +1,98 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- # describe Card::Mod::Loader do
4
- # # let(:card_double) { double "Card" }
5
- # # let(:pat_all_double) { proxy Card::Set::All }
6
- # # let(:format_double) { proxy Card::Format }
7
- # # let(:html_format_double) { proxy Card::Format::HtmlFormat }
8
- # # it "autos-load Card class methods from lib/card and mods" do
9
- # # #xpect(Card).to receive(:load_mods)
10
- # # #
11
- # # card = Card[:all]
12
- # # expect(card_double).to receive(:load_formats)
13
- # # #expect(Card).to receive(:load_sets)
14
- # # #expect(Card).to receive(:tracks).with(:any_args) # so Card still loads without core in failure testing
15
- # # Card[:all]
16
- # # #expect(Card.instance_method(:version)).to be
17
- # # # allow(Card).to receive(:version)
18
- # # # expect(Card.instance_method(:type_card)).to be
19
- # # # allow(Card).to receive(:file_path_sdfs)
20
- # # #expect(Card.instance_method(:file_path)).to be
21
- # # end
22
- # # it "defines Card methods from modules" do
23
- # # expect(Card.instance_method(:set_modules)).to be
24
- # # end
25
- # # it "defines Formatter methods from modules" do
26
- # # #expect(Card.instance_method(:render_core)).to be
27
- # # expect(Card.instance_method(:_render_raw)).to be
28
- # # expect(Card.instance_method(:render_core)).to be
29
- # # expect(Card.instance_method(:_render_raw)).to be
30
- # # end
31
- # # it "defines Formatter methods from modules" do
32
- # # expect(html_format_double.method(:render_core)).to be
33
- # # expect(html_format_double.method(:_render_raw)).to be
34
- # # expect(html_format_double.method(:render_core)).to be
35
- # # expect(html_format_double.method(:_render_raw)).to be
36
- # # end
37
- # end
3
+ describe Card::Mod::Loader do
4
+ # let(:card_double) { double "Card" }
5
+ # let(:pat_all_double) { proxy Card::Set::All }
6
+ # let(:format_double) { proxy Card::Format }
7
+ # let(:html_format_double) { proxy Card::Format::HtmlFormat }
8
+ # it "autos-load Card class methods from lib/card and mods" do
9
+ # #xpect(Card).to receive(:load_mods)
10
+ # #
11
+ # allow(Card::Mod::Loader).to receive(:load_mods)
12
+ # #card = Card[:all]
13
+ # #expect(card_double).to receive(:load_formats)
14
+ # #expect(Card).to receive(:load_sets)
15
+ # #expect(Card).to receive(:tracks).with(:any_args) # so Card still loads without core in failure testing
16
+ # Card[:all]
17
+ # expect(Card::Mod::Loader).to have_received(:load_mods)
18
+ # #expect(Card.instance_method(:version)).to be
19
+ # # allow(Card).to receive(:version)
20
+ # # expect(Card.instance_method(:type_card)).to be
21
+ # # allow(Card).to receive(:file_path_sdfs)
22
+ # #expect(Card.instance_method(:file_path)).to be
23
+ # end
24
+ # it "defines Card methods from modules" do
25
+ # expect(Card.instance_method(:set_modules)).to be
26
+ # end
27
+ # it "defines Formatter methods from modules" do
28
+ # #expect(Card.instance_method(:render_core)).to be
29
+ # expect(Card.instance_method(:_render_raw)).to be
30
+ # expect(Card.instance_method(:render_core)).to be
31
+ # expect(Card.instance_method(:_render_raw)).to be
32
+ # end
33
+ # it "defines Formatter methods from modules" do
34
+ # expect(html_format_double.method(:render_core)).to be
35
+ # expect(html_format_double.method(:_render_raw)).to be
36
+ # expect(html_format_double.method(:render_core)).to be
37
+ # expect(html_format_double.method(:_render_raw)).to be
38
+ # end
39
+
40
+ it "loads self set" do
41
+ create_card "set test load", codename: "set_test_load"
42
+ Card::Cache.reset_all
43
+ class ::Card::Set::Self
44
+ module SetTestLoad
45
+ extend Card::Set
46
+ def hello
47
+ "hello"
48
+ end
49
+ end
50
+ end
51
+
52
+ expect(Card["set_test_load"]).to respond_to :hello
53
+ end
54
+
55
+ it "loads self set for junction card" do
56
+ create_card "set+test+load", codename: "set_test_load"
57
+ Card::Cache.reset_all
58
+ class ::Card::Set::Self
59
+ module SetTestLoad
60
+ extend Card::Set
61
+ def hello
62
+ "hello"
63
+ end
64
+ end
65
+ end
66
+
67
+ expect(Card["set+test+load"]).to respond_to :hello
68
+ end
69
+
70
+ it "loads type set" do
71
+ create_card "set test load", codename: "set_test_load", type_id: Card::CardtypeID
72
+ Card::Cache.reset_all
73
+ class ::Card::Set::Type
74
+ module SetTestLoad
75
+ extend Card::Set
76
+ def hello
77
+ "hello"
78
+ end
79
+ end
80
+ end
81
+ expect(Card.new(name: "test load", type: "set test load")).to respond_to :hello
82
+ end
83
+
84
+ it "loads type set for a junction cardtyp" do
85
+ create_card "set+test load", codename: "set_test_load", type_id: Card::CardtypeID
86
+ Card::Cache.reset_all
87
+ class ::Card::Set::Type
88
+ module SetTestLoad
89
+ extend Card::Set
90
+ def hi
91
+ "hello"
92
+ end
93
+ end
94
+ end
95
+ expect(Card.new(name: "test load", type: "set+test load")).to respond_to :hi
96
+ end
97
+
98
+ end
@@ -1,6 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
-
4
3
  RSpec.describe Card::Query do
5
4
  A_JOINEES = %w(B C D E F).freeze
6
5
  CARDS_MATCHING_TWO = ["Joe User", "One+Two", "One+Two+Three",
@@ -71,6 +71,7 @@ class CardSpecLoader
71
71
  require File.expand_path "../card_spec_helper.rb", __FILE__
72
72
  RSpec::Core::ExampleGroup.send :include, Card::SpecHelper
73
73
  Card.send :include, Card::SpecHelper::CardHelper
74
+ Card.send :include, Card::SpecHelper::SetHelper
74
75
  Card.send :extend, Card::SpecHelper::CardHelper::ClassMethods
75
76
  end
76
77
 
@@ -53,42 +53,6 @@ class Card
53
53
  yield
54
54
  rescue NameError
55
55
  end
56
-
57
- def with_set set
58
- set = include_set_in_test_set(set) if set.abstract_set?
59
- singleton_class.send :include, set
60
- yield set if block_given?
61
- self
62
- end
63
-
64
- def format_with_set set, format_type=:base
65
- format = format format_type
66
- with_set set do |extended_set|
67
- format_class = set_format_class(extended_set, format_type)
68
- format.singleton_class.send :include, format_class
69
- end
70
- block_given? ? yield(format) : format
71
- end
72
-
73
- def set_format_class set, format_type
74
- format_class = Card::Format.format_class_name format_type
75
- set.const_get format_class
76
- end
77
-
78
- def include_set_in_test_set set
79
- # rubocop:disable Lint/Eval
80
- ::Card::Set::Self.const_remove_if_defined :TestSet
81
- eval <<-RUBY
82
- class ::Card::Set::Self
83
- module TestSet
84
- extend Card::Set
85
- include_set #{set}
86
- end
87
- end
88
- RUBY
89
- ::Card::Set::Self::TestSet
90
- # rubocop:enable Lint/Eval
91
- end
92
56
  end
93
57
  end
94
58
  end
@@ -0,0 +1,80 @@
1
+ class Card
2
+ module SpecHelper
3
+ # To be included in Card.
4
+ # Defines helper to change card sets and formats
5
+ module SetHelper
6
+ # define dynamically views (or other things) on format objects
7
+ # @return format object
8
+ # @example add a view to a card's html format
9
+ # format =
10
+ # Card["A"].attach_to_format(:html) do
11
+ # view :my_test_view do
12
+ # card.name
13
+ # end
14
+ # end
15
+ # format.render :my_test_view # => "A"
16
+ def format_with format_type=:html, &block
17
+ dynamic_set =
18
+ create_dynamic_set do
19
+ format(format_type, &block)
20
+ end
21
+ format_with_set dynamic_set, format_type
22
+ #::Card::Set::Self::DynamicSet, :html
23
+ end
24
+
25
+ # define dynamically sets on card objects
26
+ # @return card object
27
+ def set_with &block
28
+ with_set create_dynamic_set(&block)
29
+ end
30
+
31
+ # load set into card object
32
+ def with_set set
33
+ set = include_set_in_test_set(set) if set.abstract_set?
34
+ singleton_class.send :include, set
35
+ yield set if block_given?
36
+ self
37
+ end
38
+
39
+ # load set into a card's format object
40
+ def format_with_set set, format_type=:base
41
+ format = format format_type
42
+ with_set set do |extended_set|
43
+ format_class = set_format_class(extended_set, format_type)
44
+ format.singleton_class.send :include, format_class
45
+ end
46
+ block_given? ? yield(format) : format
47
+ end
48
+
49
+ def set_format_class set, format_type
50
+ format_class = Card::Format.format_class_name format_type
51
+ set.const_get format_class
52
+ end
53
+
54
+ def include_set_in_test_set set
55
+ # rubocop:disable Lint/Eval
56
+ ::Card::Set::Self.const_remove_if_defined :TestSet
57
+ eval <<-RUBY
58
+ class ::Card::Set::Self
59
+ module TestSet
60
+ extend Card::Set
61
+ include_set #{set}
62
+ end
63
+ end
64
+ RUBY
65
+ ::Card::Set::Self::TestSet
66
+ # rubocop:enable Lint/Eval
67
+ end
68
+
69
+ private
70
+
71
+ def create_dynamic_set &block
72
+ ::Card::Set::Self.const_remove_if_defined :DynamicSet
73
+ ::Card::Set::Self.const_set :DynamicSet, Module.new
74
+ ::Card::Set::Self::DynamicSet.extend Card::Set
75
+ ::Card::Set::Self::DynamicSet.module_eval &block
76
+ ::Card::Set::Self::DynamicSet
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,74 @@
1
+ RSpec::Matchers.define :be_valid do
2
+ match do |card|
3
+ value_match?(true, card.errors.empty?)
4
+ end
5
+ end
6
+
7
+ RSpec::Matchers.define :be_invalid do
8
+ match do |card|
9
+ # valid? clears errors
10
+ # For a new card we have to call valid? to create the errors.
11
+ # For a updated card we have to check errors because with valid? we would
12
+ # loose the errors.
13
+ @valid = card.errors.empty? && card.valid?
14
+ # card.errors returns an array, hence we need an extra include matcher
15
+ values_match?(false, @valid) &&
16
+ values_match?(include(@error_msg), card.errors[@error_key])
17
+ end
18
+
19
+ description do
20
+ "be invalid #{"because of #{@error_key} #{@error_msg}" if @error_key}"
21
+ end
22
+
23
+ chain(:because_of) do |reason|
24
+ @error_key, @error_msg = reason.to_a.first
25
+ end
26
+
27
+ failure_message do |actual|
28
+ super() + fail_reason(actual)
29
+ end
30
+
31
+ def fail_reason actual
32
+ if @valid
33
+ "but file is valid"
34
+ else
35
+ "but it is invalid because of #{actual.errors.messages}"
36
+ end
37
+ end
38
+ end
39
+
40
+ RSpec::Matchers.define :have_file do |trait|
41
+ match do |card|
42
+ trait ||= :file
43
+ (@file = card.fetch(trait: trait)) && file_size_matches
44
+ end
45
+
46
+ description do
47
+ "have a file attached #{"of size #{@size}" if @size}"
48
+ end
49
+
50
+ chain(:of_size) { |size| @size = size }
51
+
52
+ failure_message do |_actual|
53
+ if @size
54
+ "#{super()} but file size is #{@file.file.size}"
55
+ else
56
+ "#{super()} but found no file"
57
+ end
58
+ end
59
+
60
+ failure_message_when_negated do |_actual|
61
+ if @size
62
+ "#{super()} but file size is #{@file.file.size}"
63
+ else
64
+ "#{super()} but found a file"
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def file_size_matches
71
+ return true unless @size
72
+ @size === @file.file.size
73
+ end
74
+ end
@@ -52,12 +52,12 @@ def valid?(*)
52
52
  act { super }
53
53
  end
54
54
 
55
- def update_attributes *args
56
- act(*args) { super }
55
+ def update_attributes(*)
56
+ act { super }
57
57
  end
58
58
 
59
- def update_attributes! *args
60
- act(*args) { super }
59
+ def update_attributes!(*)
60
+ act { super }
61
61
  end
62
62
 
63
63
  def abortable
@@ -88,8 +88,7 @@ def with_transaction_returning_status
88
88
  end
89
89
 
90
90
  event :notable_exception_raised do
91
- error = Card::Error.current
92
- Rails.logger.debug "#{error.message}\n#{error.backtrace * "\n "}"
91
+ Rails.logger.debug "BT: #{Card::Error.current.backtrace * "\n "}"
93
92
  end
94
93
 
95
94
  def success