card 1.15.7 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +3 -2
  4. data/config/initializers/inflections.rb +1 -1
  5. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +0 -1
  6. data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +12 -0
  7. data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +11 -0
  8. data/db/migrate_core_cards/20150611203506_rails_inflection_updates.rb +82 -0
  9. data/db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb +7 -0
  10. data/db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb +9 -0
  11. data/db/schema.rb +81 -81
  12. data/db/seed/new/card_actions.yml +12581 -1647
  13. data/db/seed/new/card_acts.yml +1 -1
  14. data/db/seed/new/card_changes.yml +39326 -7569
  15. data/db/seed/new/card_references.yml +518 -455
  16. data/db/seed/new/cards.yml +1547 -1291
  17. data/db/seed/test/fixtures/card_actions.yml +13700 -2717
  18. data/db/seed/test/fixtures/card_acts.yml +314 -272
  19. data/db/seed/test/fixtures/card_changes.yml +45409 -13573
  20. data/db/seed/test/fixtures/card_references.yml +1223 -1125
  21. data/db/seed/test/fixtures/cards.yml +2694 -2433
  22. data/db/seed/test/fixtures/file1.txt +1 -0
  23. data/db/seed/test/fixtures/file2.txt +1 -0
  24. data/db/version_core_cards.txt +1 -1
  25. data/lib/card.rb +23 -13
  26. data/lib/card/auth.rb +6 -6
  27. data/lib/card/cache.rb +24 -5
  28. data/lib/card/env.rb +10 -10
  29. data/lib/card/format.rb +29 -12
  30. data/lib/card/log.rb +5 -3
  31. data/lib/card/migration.rb +17 -41
  32. data/lib/card/name.rb +12 -0
  33. data/lib/card/reference.rb +11 -12
  34. data/lib/card/set.rb +59 -6
  35. data/lib/card/simplecov_helper.rb +6 -1
  36. data/lib/card/spec_helper.rb +3 -2
  37. data/lib/card/view_cache.rb +77 -0
  38. data/lib/cardio.rb +30 -22
  39. data/mod/01_core/format/html_format.rb +17 -9
  40. data/mod/01_core/layout/blank.html +1 -1
  41. data/mod/01_core/layout/default.html +6 -16
  42. data/mod/01_core/layout/modal.html +9 -0
  43. data/mod/01_core/layout/noside.html +5 -12
  44. data/mod/01_core/layout/simple.html +1 -1
  45. data/mod/01_core/set/all/collection.rb +57 -5
  46. data/mod/01_core/set/all/content.rb +5 -7
  47. data/mod/01_core/set/all/name.rb +8 -10
  48. data/mod/01_core/set/all/permissions.rb +1 -2
  49. data/mod/01_core/set/all/phases.rb +5 -13
  50. data/mod/01_core/set/all/references.rb +10 -10
  51. data/mod/01_core/set/all/rules.rb +2 -2
  52. data/mod/01_core/set/all/tracked_attributes.rb +5 -3
  53. data/mod/01_core/set/all/utils.rb +79 -9
  54. data/mod/01_core/set/all/view_cache.rb +9 -0
  55. data/mod/01_core/spec/format/html_format_spec.rb +2 -2
  56. data/mod/01_core/spec/set/all/collection_spec.rb +1 -1
  57. data/mod/01_history/lib/card/act.rb +3 -1
  58. data/mod/01_history/lib/card/action.rb +20 -12
  59. data/mod/01_history/lib/card/change.rb +12 -8
  60. data/mod/01_history/set/all/actions.rb +2 -2
  61. data/mod/01_history/set/all/content_history.rb +3 -2
  62. data/mod/01_history/set/all/history.rb +57 -19
  63. data/mod/02_basic_types/set/all/rss.rb +5 -6
  64. data/mod/{05_standard → 02_basic_types}/set/type/html.rb +4 -3
  65. data/mod/02_basic_types/set/type/plain_text.rb +1 -1
  66. data/mod/02_basic_types/set/type/pointer.rb +7 -4
  67. data/mod/02_basic_types/spec/set/type/pointer_spec.rb +21 -17
  68. data/mod/03_machines/lib/card/machine.rb +33 -31
  69. data/mod/03_machines/lib/javascript/script_card_menu.js.coffee +2 -10
  70. data/mod/03_machines/lib/javascript/wagn.js.coffee +10 -10
  71. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +87 -40
  72. data/mod/03_machines/lib/stylesheets/style_cards.scss +26 -28
  73. data/mod/03_machines/set/right/machine_output.rb +3 -3
  74. data/mod/03_machines/set/type/coffee_script.rb +6 -6
  75. data/mod/03_machines/set/type/css.rb +1 -1
  76. data/mod/03_machines/set/type/java_script.rb +5 -6
  77. data/mod/03_machines/spec/lib/shared_machine_examples.rb +3 -1
  78. data/mod/03_machines/spec/set/type/scss_spec.rb +9 -10
  79. data/mod/04_settings/lib/card/setting.rb +16 -14
  80. data/mod/04_settings/set/right/structure.rb +6 -0
  81. data/mod/04_settings/set/self/add_help.rb +1 -1
  82. data/mod/04_settings/set/self/autoname.rb +1 -1
  83. data/mod/04_settings/set/self/captcha.rb +1 -1
  84. data/mod/04_settings/set/self/default.rb +1 -1
  85. data/mod/04_settings/set/self/help.rb +1 -1
  86. data/mod/04_settings/set/self/input.rb +1 -1
  87. data/mod/04_settings/set/self/layout.rb +1 -1
  88. data/mod/04_settings/set/self/on_create.rb +1 -1
  89. data/mod/04_settings/set/self/on_delete.rb +1 -1
  90. data/mod/04_settings/set/self/on_update.rb +1 -1
  91. data/mod/04_settings/set/self/options.rb +1 -1
  92. data/mod/04_settings/set/self/options_label.rb +1 -1
  93. data/mod/04_settings/set/self/script.rb +1 -1
  94. data/mod/04_settings/set/self/structure.rb +1 -1
  95. data/mod/04_settings/set/self/style.rb +1 -1
  96. data/mod/04_settings/set/self/table_of_contents.rb +1 -1
  97. data/mod/04_settings/set/self/thanks.rb +1 -1
  98. data/mod/05_email/set/all/follow.rb +3 -21
  99. data/mod/05_email/set/all/notify.rb +20 -4
  100. data/mod/05_email/set/right/follow.rb +16 -18
  101. data/mod/05_email/set/self/follow.rb +1 -1
  102. data/mod/05_email/spec/set/all/follow_spec.rb +6 -13
  103. data/mod/05_standard/set/all/attach.rb +23 -9
  104. data/mod/05_standard/set/all/error.rb +5 -7
  105. data/mod/05_standard/set/all/event_viz.rb +10 -6
  106. data/mod/05_standard/set/all/links.rb +37 -13
  107. data/mod/05_standard/set/all/rich_html/content.rb +46 -18
  108. data/mod/05_standard/set/all/rich_html/editing.rb +29 -25
  109. data/mod/05_standard/set/all/rich_html/form.rb +17 -10
  110. data/mod/05_standard/set/all/rich_html/header.rb +26 -4
  111. data/mod/05_standard/set/all/rich_html/menu.rb +17 -34
  112. data/mod/05_standard/set/all/rich_html/modal.rb +50 -12
  113. data/mod/05_standard/set/all/rich_html/toolbar.rb +178 -186
  114. data/mod/05_standard/set/all/rich_html/wrapper.rb +44 -21
  115. data/mod/05_standard/set/rstar/rules.rb +43 -53
  116. data/mod/05_standard/set/self/all.rb +2 -1
  117. data/mod/05_standard/set/self/head.rb +2 -2
  118. data/mod/05_standard/set/self/signin.rb +18 -18
  119. data/mod/05_standard/set/self/stats.rb +14 -2
  120. data/mod/05_standard/set/type/search_type.rb +9 -4
  121. data/mod/05_standard/set/type/session.rb +12 -7
  122. data/mod/05_standard/set/type/set.rb +135 -18
  123. data/mod/05_standard/spec/chunk/include_spec.rb +15 -16
  124. data/mod/05_standard/spec/set/all/account_spec.rb +21 -21
  125. data/mod/05_standard/spec/set/all/event_viz_spec.rb +7 -7
  126. data/mod/05_standard/spec/set/all/history_spec.rb +54 -24
  127. data/mod/05_standard/spec/set/all/rich_html/editing_spec.rb +42 -40
  128. data/mod/05_standard/spec/set/rstar/rules_spec.rb +1 -1
  129. data/mod/05_standard/spec/set/type/search_type_spec.rb +9 -1
  130. data/mod/05_standard/spec/set/type/signup_spec.rb +42 -42
  131. data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +6 -0
  132. data/mod/06_bootstrap/set/all/bootstrap/form.rb +4 -5
  133. data/mod/06_bootstrap/set/all/bootstrap/helper.rb +145 -0
  134. data/mod/06_bootstrap/set/all/rich_bootstrap.rb +0 -59
  135. data/spec/lib/card/action_spec.rb +1 -1
  136. data/spec/lib/card/log_spec.rb +7 -7
  137. data/spec/models/card/cardtype_spec.rb +1 -1
  138. data/spec/spec_helper.rb +1 -1
  139. metadata +31 -6
  140. data/mod/04_settings/set/self/comment.rb +0 -2
@@ -1,13 +1,10 @@
1
+ include Pointer
2
+
1
3
  def history?
2
4
  false
3
5
  end
4
6
 
5
- event :store_in_session, :after=>:approve, :on=>:create do
6
- Env.session[key] = db_content
7
- self.db_content = ''
8
- end
9
-
10
- event :update_in_session, :after=>:approve, :on=>:update do
7
+ event :store_in_session, :before=>:standardize_items, :on=>:save do
11
8
  if db_content_changed?
12
9
  Env.session[key] = db_content
13
10
  self.db_content = ''
@@ -23,7 +20,15 @@ def content
23
20
  Env.session[key]
24
21
  end
25
22
 
23
+ format do
24
+ include Pointer::Format
25
+ end
26
+
26
27
  format :html do
27
- view :editor, :mod=>PlainText::HtmlFormat
28
+ include Pointer::HtmlFormat
29
+
30
+ def default_core_args args
31
+ args[:item] = :name
32
+ end
28
33
  end
29
34
 
@@ -2,18 +2,63 @@
2
2
  format :html do
3
3
 
4
4
  view :core do |args|
5
+ _render args[:rule_view], args
6
+ end
7
+ def default_core_args args
8
+ args[:rule_view] ||= :common_rules
9
+ args[:optional_set_label] ||= :show
10
+ args[:optional_rule_navbar] ||= :show
11
+ args[:optional_set_navbar] ||= :hide
12
+ end
13
+
14
+ def with_label_and_navbars args
5
15
  output [
6
- _optional_render(:set_label, args, :show),
7
- (content_tag(:div, :class=>'panel-group', :id=>'accordion', :role=>'tablist','aria-multiselectable'=>'true') do
16
+ _optional_render(:set_label, args, :show),
17
+ _optional_render(:rule_navbar, args, :hide),
18
+ _optional_render(:set_navbar, args, :hide),
19
+ yield
20
+ ]
21
+ end
22
+
23
+ view :all_rules do |args|
24
+ with_label_and_navbars args.merge(:selected_view =>:all_rules) do
25
+ rules_table (card.visible_setting_codenames.sort & card.visible_setting_codenames), args
26
+ end
27
+ end
28
+
29
+ view :grouped_rules do |args|
30
+ with_label_and_navbars args.merge(:selected_view =>:grouped_rules) do
31
+ content_tag(:div, :class=>'panel-group', :id=>'accordion', :role=>'tablist','aria-multiselectable'=>'true') do
8
32
  Card::Setting.groups.keys.map do |group_key|
9
33
  _optional_render(group_key, args, :show)
10
34
  end * "\n"
11
- end)
12
- ]
35
+ end
36
+ end
37
+ end
38
+
39
+ view :recent_rules do |args|
40
+ with_label_and_navbars args.merge(:selected_view =>:recent_rules) do
41
+ recent_settings = Card[:recent_settings].item_cards.map(&:codename)
42
+ rules_table (recent_settings.map(&:to_sym) & card.visible_setting_codenames), args
43
+ end
44
+ end
45
+
46
+ view :common_rules do |args|
47
+ with_label_and_navbars args.merge(:selected_view =>:common_rules) do
48
+ rules_table (card.visible_setting_codenames & [:create, :read, :update, :delete, :structure, :default, :style]), args
49
+ end
50
+ end
51
+
52
+ view :field_related_rules do |args|
53
+ with_label_and_navbars args.merge(:selected_view =>:field_related_rules) do
54
+ field_settings = [:default, :help, :structure]
55
+ field_settings += [:input, :options, :options_label] if card.type_id == PointerID
56
+ rules_table (card.visible_setting_codenames & field_settings), args
57
+ end
13
58
  end
14
59
 
15
60
  view :set_label do |args|
16
- content_tag :h2, card.label, :class=>'set-label'
61
+ content_tag :h3, card.label, :class=>'set-label'
17
62
  end
18
63
 
19
64
  Card::Setting.groups.keys.each do |group_key|
@@ -32,25 +77,29 @@ format :html do
32
77
  end
33
78
  end),
34
79
  (content_tag :div, :id=>collapse_id, :class=>'panel-collapse collapse', :role=>'tabpanel', 'aria-labelledby'=>heading_id do
35
- wrap_with :table, :class=>'set-rules table' do
36
- [
37
- (content_tag(:tr, :class=>"rule-group") do
38
- wrap_each_with :th, %w(Setting Content Set), :class=>'rule-heading'
39
- end),
40
- (settings.map do |setting|
41
- if show_view? setting.codename, args
42
- rule_card = card.fetch(:trait=>setting.codename, :new=>{})
43
- nest(rule_card, :view=>:closed_rule).html_safe
44
- end
45
- end * "\n")
46
- ]
47
- end
80
+ rules_table settings.map(&:codename), args
48
81
  end)
49
82
  ]
50
83
  end
51
84
  end
52
85
  end
53
86
 
87
+ def rules_table settings, args={}
88
+ wrap_with :table, :class=>'set-rules table' do
89
+ [
90
+ (content_tag(:tr, :class=>"rule-group") do
91
+ wrap_each_with :th, %w(Trait Content Set), :class=>'rule-heading'
92
+ end),
93
+ (settings.map do |setting|
94
+ if show_view? setting, args
95
+ rule_card = card.fetch(:trait=>setting, :new=>{})
96
+ nest(rule_card, :view=>:closed_rule).html_safe
97
+ end
98
+ end * "\n")
99
+ ]
100
+ end
101
+ end
102
+
54
103
  view :editor do |args|
55
104
  'Cannot currently edit Sets' #ENGLISH
56
105
  end
@@ -89,6 +138,58 @@ format :html do
89
138
  ''
90
139
  end
91
140
 
141
+
142
+ view :set_navbar do |args|
143
+ id = "rule-navbar-#{card.cardname.safe_key}-#{args[:home_view]}"
144
+ related_sets = card.related_sets(true)
145
+ return '' if related_sets.size <= 1
146
+ navbar id, :toggle=>'Rules<span class="caret"></span>', :toggle_align=>:left,
147
+ :class=>'slotter toolbar', :navbar_type=>'inverse', :collapsed_content=>close_link(:class=>'pull-right visible-xs') do
148
+ [
149
+ content_tag(:span, 'Set:', :class=>"navbar-text hidden-xs"),
150
+ (wrap_with :ul, :class=>'nav navbar-nav nav-pills' do
151
+ related_sets.map do |name, label|
152
+ link = card_link name, :text=>label, :remote=>true,
153
+ :path_opts => {
154
+ :view => @slot_view,
155
+ :slot => {:subheader=>showname(name), :subframe=>true, :hide=>'header set_label rule_navbar', :show=>'subheader set_navbar'}
156
+ }
157
+ li_pill link, name == card.name
158
+ end
159
+ end),
160
+ ]
161
+ end
162
+ end
163
+
164
+ def li_pill content, active
165
+ "<li role='presentation' #{"class='active'" if active}>#{content}</li>"
166
+ end
167
+
168
+ view :rule_navbar do |args|
169
+ id = "rule-navbar-#{card.cardname.safe_key}-#{args[:home_view]}"
170
+ args.merge!(:path_opts=>{:slot=>{:show=>:rule_navbar}})
171
+ navbar id, :toggle=>'Rules<span class="caret"></span>', :toggle_align=>:left,
172
+ :class=>'slotter toolbar', :navbar_type=>'inverse', :collapsed_content=>close_link(:class=>'pull-right visible-xs') do
173
+ [
174
+ content_tag(:span, 'Rules:', :class=>"navbar-text hidden-xs"),
175
+ (wrap_with :ul, :class=>'nav navbar-nav nav-pills' do
176
+ [
177
+ (view_link_pill( 'field', :field_related_rules, args) if card.junction?),
178
+ view_link_pill( 'common', :common_rules, args),
179
+ view_link_pill( 'by group', :grouped_rules, args),
180
+ view_link_pill( 'by name', :all_rules, args),
181
+ (view_link_pill( 'recent', :recent_rules, args) if recently_edited_settings?),
182
+ ]
183
+ end),
184
+ ]
185
+ end
186
+ end
187
+
188
+ def view_link_pill name, view, args
189
+ selected_view = args[:selected_view] || @slot_view || args[:home_view]
190
+ opts = {:class=>'slotter', :role=>'pill', :path_opts=>args[:path_opts]}
191
+ li_pill view_link(name, view, opts), selected_view == view
192
+ end
92
193
  end
93
194
 
94
195
 
@@ -184,6 +285,13 @@ def setting_codenames_by_group
184
285
  result
185
286
  end
186
287
 
288
+ def visible_setting_codenames
289
+ @visible_settings ||=
290
+ Card::Setting.groups.values.flatten.compact.reject do |setting|
291
+ !setting.applies_to_cardtype(prototype.type_id)
292
+ end.map(&:codename)
293
+ end
294
+
187
295
  def visible_settings group
188
296
  Card::Setting.groups[group].reject do |setting|
189
297
  !setting or !setting.applies_to_cardtype(prototype.type_id)
@@ -227,3 +335,12 @@ def prototype
227
335
  opts = subclass_for_set.prototype_args self.cardname.trunk_name
228
336
  Card.fetch opts[:name], :new=>opts
229
337
  end
338
+
339
+ def related_sets with_self = false
340
+ if subclass_for_set.anchorless?
341
+ prototype.related_sets with_self
342
+ else
343
+ left(:new=>{}).related_sets with_self
344
+ end
345
+ end
346
+
@@ -1,13 +1,12 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  describe Card::Chunk::Include, "Inclusion" do
4
- include ActionView::Helpers::TextHelper
5
4
 
6
5
  context "syntax parsing" do
7
6
  before do
8
7
  @class= Card::Chunk::Include
9
8
  end
10
-
9
+
11
10
  it "should ignore invisible comments" do
12
11
  expect(render_content("{{## now you see nothing}}")).to eq('')
13
12
  end
@@ -16,7 +15,7 @@ describe Card::Chunk::Include, "Inclusion" do
16
15
  expect(render_content("{{# now you see me}}")).to eq('<!-- # now you see me -->')
17
16
  expect(render_content("{{# -->}}")).to eq('<!-- # --&gt; -->')
18
17
  end
19
-
18
+
20
19
  it "should handle empty inclusions" do
21
20
  instance = @class.new( @class.full_match( '{{ }}' ) , nil )
22
21
  expect(instance.name).to eq('')
@@ -24,27 +23,27 @@ describe Card::Chunk::Include, "Inclusion" do
24
23
  instance1 = @class.new( @class.full_match( '{{|}}' ) , nil )
25
24
  expect(instance1.name).to eq('')
26
25
  expect(instance1.options[:inc_syntax]).to eq('|')
27
-
26
+
28
27
  end
29
-
28
+
30
29
  it "should handle no pipes" do
31
30
  instance = @class.new( @class.full_match( '{{toy}}') , nil )
32
31
  expect(instance.name).to eq('toy')
33
32
  expect(instance.options[:inc_name]).to eq('toy')
34
33
  expect(instance.options.key?(:view)).to eq(false)
35
34
  end
36
-
35
+
37
36
  it "should strip the name" do
38
37
  expect(@class.new( @class.full_match( '{{ toy }}') , nil ).name).to eq('toy')
39
38
  end
40
-
39
+
41
40
  it 'should strip html tags' do
42
41
  expect(@class.new( @class.full_match( '{{ <span>toy</span> }}') , nil ).name).to eq('toy')
43
42
  instance = @class.new( @class.full_match( '{{ <span>toy|open</span> }}') , nil )
44
43
  expect(instance.name).to eq('toy')
45
44
  expect(instance.options[:view]).to eq('open')
46
45
  end
47
-
46
+
48
47
  it "should handle single pipe" do
49
48
  options = @class.new( @class.full_match('{{toy|view:link;hide:me}}'), nil ).options
50
49
  expect(options[:inc_name]).to eq('toy')
@@ -52,13 +51,13 @@ describe Card::Chunk::Include, "Inclusion" do
52
51
  expect(options[:hide]).to eq('me')
53
52
  expect(options.key?(:items)).to eq(false)
54
53
  end
55
-
54
+
56
55
  it "should handle multiple pipes" do
57
56
  options = @class.new( @class.full_match('{{box|open|closed}}'), nil ).options
58
57
  expect(options[:inc_name]).to eq('box')
59
58
  expect(options[:view]).to eq('open')
60
59
  expect(options[:items][:view]).to eq('closed')
61
- expect(options[:items].key?(:items)).to eq(false)
60
+ expect(options[:items].key?(:items)).to eq(false)
62
61
  end
63
62
 
64
63
  it "should handle multiple pipes with blank lists" do
@@ -67,7 +66,7 @@ describe Card::Chunk::Include, "Inclusion" do
67
66
  expect(options[:view]).to eq(nil)
68
67
  expect(options[:items][:view]).to eq('closed')
69
68
  end
70
-
69
+
71
70
  it "should treat :item as view of next level" do
72
71
  options = @class.new( @class.full_match('{{toy|link;item:name}}'), nil ).options
73
72
  expect(options[:inc_name]).to eq('toy')
@@ -91,7 +90,7 @@ describe Card::Chunk::Include, "Inclusion" do
91
90
  alpha_beta = Card.create :name=>"#{alpha.name}#{Card::Name.joint}Beta", :content=>"Woot"
92
91
  assert_view_select alpha.format.render_core, 'div[class~=card-content]', "Woot"
93
92
  end
94
-
93
+
95
94
  it "should handle complex relative names" do
96
95
  bob_city = Card.create! :name=>'bob+city', :content=> "Sparta"
97
96
  Card::Auth.as_bot { address_tmpl = Card.create! :name=>'address+*right+*structure', :content =>"{{_left+city}}" }
@@ -115,11 +114,11 @@ describe Card::Chunk::Include, "Inclusion" do
115
114
  it "should handle options when nesting" do
116
115
  Card.create! :type=>'Pointer', :name=>'Livable', :content=>'[[Earth]]'
117
116
  Card.create! :name=>'Earth'
118
-
117
+
119
118
  expect(render_content('{{Livable|core;item:link}}')).to eq(render_content('{{Livable|core|link}}'))
120
119
  expect(render_content('{{Livable|core;item:name}}')).to eq(render_content('{{Livable|core|name}}'))
121
120
  end
122
-
121
+
123
122
  it "should prevent recursion" do
124
123
  oak = Card.create! :name=>'Oak', :content=>'{{Quentin}}'
125
124
  qnt = Card.create! :name=>'Quentin', :content=>'{{Admin}}'
@@ -139,12 +138,12 @@ describe Card::Chunk::Include, "Inclusion" do
139
138
  age = newcard('age')
140
139
  template = Card['*template']
141
140
  specialtype = Card.create :type_code=>'Cardtype', :name=>'SpecialType'
142
-
141
+
143
142
  specialtype_template = specialtype.fetch(:trait=>:type,:new=>{}).fetch(:trait=>:structure,:new=>{})
144
143
  specialtype_template.content = "{{#{Card::Name.joint}age}}"
145
144
  Card::Auth.as_bot { specialtype_template.save! }
146
145
  assert_equal "{{#{Card::Name.joint}age}}", specialtype_template.format.render_raw
147
-
146
+
148
147
  wooga = Card.create! :name=>'Wooga', :type=>'SpecialType'
149
148
  wooga_age = Card.create!( :name=>"#{wooga.name}#{Card::Name.joint}age", :content=> "39" )
150
149
  expect(wooga_age.format.render_core).to eq("39")
@@ -2,7 +2,7 @@
2
2
 
3
3
  describe Card::Set::All::Account do
4
4
  describe 'accountable?' do
5
-
5
+
6
6
  it 'should be false for cards with *accountable rule off' do
7
7
  expect(Card['A'].accountable?).to eq(false)
8
8
  end
@@ -14,16 +14,16 @@ describe Card::Set::All::Account do
14
14
  end
15
15
  expect(Card['A'].accountable?).to eq(true)
16
16
  end
17
-
17
+
18
18
  end
19
-
19
+
20
20
  describe "parties" do
21
-
21
+
22
22
  it "for Wagn Bot" do
23
23
  Card::Auth.current_id = Card::WagnBotID
24
24
  expect(Card::Auth.current.parties.sort).to eq([Card::WagnBotID, Card::AnyoneSignedInID, Card::AdministratorID])
25
25
  end
26
-
26
+
27
27
  it "for Anonymous" do
28
28
  Card::Auth.current_id = Card::AnonymousID
29
29
  expect(Card::Auth.current.parties.sort).to eq([Card::AnonymousID])
@@ -38,33 +38,33 @@ describe Card::Set::All::Account do
38
38
  it "should initially have only auth and self " do
39
39
  expect(@parties).to eq([Card::AnyoneSignedInID, @joe_user_card.id])
40
40
  end
41
-
41
+
42
42
  it 'should update when new roles are set' do
43
43
  roles_card = @joe_user_card.fetch :trait=>:roles, :new=>{}
44
44
  r1 = Card['r1']
45
45
 
46
- Card::Auth.as_bot { roles_card.items = [ r1.id ] }
47
- expect(Card['Joe User'].parties).to eq(@parties) # local cache still has old parties (permission does not change mid-request)
48
-
46
+ Card::Auth.as_bot { roles_card.items = [ r1.id ] }
47
+ expect(Card['Joe User'].parties).to eq(@parties) # local cache still has old parties (permission does not change mid-request)
48
+
49
49
  Card::Cache.restore # simulate new request -- clears local cache, where, eg, @parties would still be cached on card
50
50
  Card::Auth.current_id = Card::Auth.current_id # simulate new request -- current_id assignment clears several class variables
51
-
51
+
52
52
  new_parties = [ Card::AnyoneSignedInID, r1.id, @joe_user_card.id ]
53
53
  expect(Card['Joe User'].parties).to eq(new_parties) # @parties regenerated, now with correct values
54
54
  expect(Card::Auth.current. parties).to eq(new_parties)
55
-
55
+
56
56
  # @joe_user_card.refresh(force=true).parties.should == new_parties # should work, but now superfluous?
57
57
  end
58
58
  end
59
-
59
+
60
60
  end
61
-
61
+
62
62
  describe 'among?' do
63
63
  it 'should be true for self' do
64
64
  expect(Card::Auth.current.among?([Card::Auth.current_id])).to be_truthy
65
65
  end
66
66
  end
67
-
67
+
68
68
 
69
69
  describe "'+*email'" do
70
70
  it 'should create a card and account card' do
@@ -77,10 +77,10 @@ describe Card::Set::All::Account do
77
77
 
78
78
  c = Card['Joe New']
79
79
  u = Card::Auth[ 'joe@new.com' ]
80
-
80
+
81
81
  expect(c).to eq(u)
82
82
  expect(c.type_id).to eq(Card::UserID)
83
- =begin
83
+ =begin
84
84
  email = ActionMailer::Base.deliveries.last
85
85
  email.to.should == ['joe@new.com']
86
86
  email.subject.should == 'Hey Joe!'
@@ -88,7 +88,7 @@ describe Card::Set::All::Account do
88
88
  =end
89
89
  end
90
90
  end
91
-
91
+
92
92
  context 'updates' do
93
93
  before do
94
94
  @card = Card['Joe User']
@@ -97,15 +97,15 @@ describe Card::Set::All::Account do
97
97
  @card.update_attributes! '+*account'=>{ '+*email'=>'joe@user.co.uk' }
98
98
  expect(@card.account.email).to eq('joe@user.co.uk')
99
99
  end
100
-
100
+
101
101
  it "should let Wagn Bot block accounts" do
102
102
  Card::Auth.as_bot do
103
103
  @card.account.status_card.update_attributes! :content => 'blocked'
104
104
  expect(@card.account.blocked?).to be_truthy
105
105
  end
106
106
  end
107
-
108
-
107
+
108
+
109
109
  it "should not allow a user to block or unblock himself" do
110
110
  expect do
111
111
  @card.account.status_card.update_attributes! :content => 'blocked'
@@ -113,7 +113,7 @@ describe Card::Set::All::Account do
113
113
  expect(@card.account.blocked?).to be_falsey
114
114
  end
115
115
  end
116
-
116
+
117
117
  describe "#read_rules" do
118
118
  before(:all) do
119
119
  @read_rules = Card['joe_user'].read_rules