card 1.15.7 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,9 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- describe Card::Set::All::EventViz do
4
- describe '#events' do
5
- it "should have at least twenty events" do
6
- expect(Card['A'].events( :update ).split("\n").length).to be > 20
7
- end
8
- end
9
- end
3
+ # describe Card::Set::All::EventViz do
4
+ # describe '#events' do
5
+ # it "should have at least twenty events" do
6
+ # expect(Card['A'].events( :update ).split("\n").length).to be > 20
7
+ # end
8
+ # end
9
+ # end
@@ -8,34 +8,34 @@ describe Card::Set::All::History do
8
8
  history = render_card :history, :name=>"A"
9
9
  assert_view_select history, 'div[class~="card-frame"]'
10
10
  end
11
-
12
-
11
+
12
+
13
13
  describe '#action_summary' do
14
- subject do
14
+ subject do
15
15
  first = Card.fetch('First')
16
16
  first.format.render_action_summary
17
17
  end
18
18
  it 'should have a summary' do
19
- assert_view_select subject, 'del[class="diffdel diff-red"]', :text=>'chicken'
20
- assert_view_select subject, 'ins[class="diffins diff-green"]', :text=>'chick'
19
+ assert_view_select subject, 'del[class="diffdel diff-red"]', :text=>'chicken'
20
+ assert_view_select subject, 'ins[class="diffins diff-green"]', :text=>'chick'
21
21
  end
22
22
  end
23
23
  end
24
-
25
-
24
+
25
+
26
26
  describe '#create_act_and_action' do
27
27
  let!(:act_start_cnt) {Card::Act.count}
28
28
  let(:content) {"Nobody expects the Spanish inquisition"}
29
29
  let(:act) {@card.acts.last}
30
30
  let(:action) {act.actions.last}
31
-
31
+
32
32
  context 'for single card' do
33
33
  before do
34
34
  @card = Card::Auth.as_bot do
35
35
  Card.create :name=>"single card", :content=>content
36
36
  end
37
37
  end
38
-
38
+
39
39
  context 'when created' do
40
40
  it 'adds new act' do
41
41
  expect(Card::Act.count).to eq(act_start_cnt+1)
@@ -45,7 +45,7 @@ describe Card::Set::All::History do
45
45
  expect(action.action_type).to eq(:create)
46
46
  end
47
47
  end
48
-
48
+
49
49
  context 'when updated' do
50
50
  it 'adds no act if nothing changed' do
51
51
  @card.update_attributes :name=>"single card", :content=>content
@@ -56,7 +56,7 @@ describe Card::Set::All::History do
56
56
  expect(Card::Act.count).to eq(act_start_cnt+2)
57
57
  end
58
58
  end
59
-
59
+
60
60
  context 'when deleted' do
61
61
  before do
62
62
  Card::Auth.as_bot do
@@ -68,11 +68,41 @@ describe Card::Set::All::History do
68
68
  end
69
69
  it 'adds delete action' do
70
70
  expect(action.action_type).to eq(:delete)
71
- end
72
- it 'adds trash change' do
73
- expect(action.changes.last.field).to eq('trash')
74
- expect(action.changes.last.value).to be_truthy
75
71
  end
72
+ it 'adds trash change' do
73
+ expect(action.card_changes.last.field).to eq('trash')
74
+ expect(action.card_changes.last.value).to be_truthy
75
+ end
76
+ end
77
+
78
+ context 'when creation fails' do
79
+ it "doesn't create an act" do
80
+ Card::Auth.as(:anonymous) do
81
+ act_count = Card::Act.count
82
+ Card.create :name=>"create fail"
83
+ expect(Card::Act.count).to eq act_count
84
+ end
85
+ end
86
+
87
+ it "doesn't create an action" do
88
+ Card::Auth.as(:anonymous) do
89
+ action_count = Card::Action.count
90
+ Card.create :name=>"create fail"
91
+ expect(Card::Action.count).to eq action_count
92
+ end
93
+ end
94
+
95
+ it "doesn't create act and actions if subcard fails" do
96
+ Card::Auth.as(:joe_user) do
97
+ act_count = Card::Act.count
98
+ action_count = Card::Action.count
99
+ Card.create :name=>"crete fail", :subcards=>{'*all+*create'=>''}
100
+ expect(Card::Action.count).to eq action_count
101
+ expect(Card::Act.count).to eq act_count
102
+ end
103
+ end
104
+
105
+
76
106
  end
77
107
  end
78
108
 
@@ -85,13 +115,13 @@ describe Card::Set::All::History do
85
115
  @plus_action = act.actions[1]
86
116
  end
87
117
  end
88
-
118
+
89
119
  context 'when created' do
90
120
  it 'adds only a act for left card' do
91
121
  expect(Card::Act.count).to eq(act_start_cnt+1)
92
122
  expect(act.card).to eq(@card)
93
123
  end
94
-
124
+
95
125
  it 'adds three actions' do
96
126
  expect(act.actions.size).to eq(3)
97
127
  end
@@ -108,13 +138,13 @@ describe Card::Set::All::History do
108
138
  expect(@plus_action.action_type).to eq(:create)
109
139
  end
110
140
  it 'adds content change' do
111
- expect(@plus_action.changes.find_by_field(:db_content).value).to eq(content)
141
+ expect(@plus_action.card_changes.find_by_field_name(:db_content).value).to eq(content)
112
142
  end
113
143
  it 'adds superaction for plus card' do
114
144
  expect(@plus_action.super_action_id).to eq(@left_action.id)
115
145
  end
116
146
  end
117
-
147
+
118
148
  context 'when updated' do
119
149
  it 'adds act for left card' do
120
150
  @card.update_attributes :subcards=>{"+right"=>{:content=>"New content", :db_content=>"New Content"}}
@@ -130,7 +160,7 @@ describe Card::Set::All::History do
130
160
  end
131
161
  end
132
162
  end
133
-
163
+
134
164
  context 'for plus card' do
135
165
  before do
136
166
  Card::Auth.as_bot do
@@ -140,7 +170,7 @@ describe Card::Set::All::History do
140
170
  @right_action = act.actions[2]
141
171
  end
142
172
  end
143
-
173
+
144
174
  context 'adds' do
145
175
  it 'only a act for plus card' do
146
176
  expect(Card::Act.count).to eq(act_start_cnt+1)
@@ -148,7 +178,7 @@ describe Card::Set::All::History do
148
178
  end
149
179
  it 'three actions' do
150
180
  expect(act.actions.size).to eq(3)
151
- end
181
+ end
152
182
  it 'action for left part of type create' do
153
183
  expect(@left_action.card.name).to eq("left")
154
184
  expect(@left_action.action_type).to eq(:create)
@@ -163,9 +193,9 @@ describe Card::Set::All::History do
163
193
  it 'action for plus card of type create' do
164
194
  expect(@plus_action.card.name).to eq("left+right")
165
195
  expect(@plus_action.action_type).to eq(:create)
166
- end
196
+ end
167
197
  it 'content change' do
168
- expect(@plus_action.changes.find_by_field(:db_content).value).to eq(content)
198
+ expect(@plus_action.card_changes(true).find_by_field_name(:db_content).value).to eq(content)
169
199
  end
170
200
  end
171
201
  end
@@ -17,44 +17,46 @@ describe Card::Set::All::RichHtml::Editing do
17
17
  end
18
18
  end
19
19
 
20
- describe "edit view" do
21
- it "has toolbar with active 'content' pill" do
22
- assert_active_toolbar_pill :edit, 'content'
23
- end
24
- end
25
-
26
- describe 'edit_type view' do
27
- it "has toolbar with active 'type' pill" do
28
- assert_active_toolbar_pill :edit_type, 'type'
29
- end
30
- end
31
-
32
- describe 'edit_name view' do
33
- it "has toolbar with active 'name' pill" do
34
- assert_active_toolbar_pill :edit_name, 'name'
35
- end
36
- end
37
-
38
- describe 'edit_structure view' do
39
- before do
40
- @mycard = Card["Iliad"].format
41
- end
42
- it "has toolbar with active 'rules' pill" do
43
- Card::Auth.as_bot do
44
- assert_active_toolbar_pill :edit_structure, 'rules', true
45
- end
46
- end
47
- end
48
-
49
- describe 'edit_nests view' do
50
- before do
51
- Card::Auth.as_bot do
52
- Card.create! :name=>'Iliad+author', :content=>'Homer'
53
- end
54
- @mycard = Card["Iliad"].format
55
- end
56
- it "has toolbar with active 'nests' pill" do
57
- assert_active_toolbar_pill :edit_nests, 'nests'
58
- end
59
- end
20
+ # outdated
21
+ # TODO: write tests for new toolbar
22
+ # describe "edit view" do
23
+ # it "has toolbar with active 'content' pill" do
24
+ # assert_active_toolbar_pill :edit, 'content'
25
+ # end
26
+ # end
27
+ #
28
+ # describe 'edit_type view' do
29
+ # it "has toolbar with active 'type' pill" do
30
+ # assert_active_toolbar_pill :edit_type, 'type'
31
+ # end
32
+ # end
33
+ #
34
+ # describe 'edit_name view' do
35
+ # it "has toolbar with active 'name' pill" do
36
+ # assert_active_toolbar_pill :edit_name, 'name'
37
+ # end
38
+ # end
39
+ #
40
+ # describe 'edit_structure view' do
41
+ # before do
42
+ # @mycard = Card["Iliad"].format
43
+ # end
44
+ # it "has toolbar with active 'rules' pill" do
45
+ # Card::Auth.as_bot do
46
+ # assert_active_toolbar_pill :edit_structure, 'rules', true
47
+ # end
48
+ # end
49
+ # end
50
+ #
51
+ # describe 'edit_nests view' do
52
+ # before do
53
+ # Card::Auth.as_bot do
54
+ # Card.create! :name=>'Iliad+author', :content=>'Homer'
55
+ # end
56
+ # @mycard = Card["Iliad"].format
57
+ # end
58
+ # it "has toolbar with active 'nests' pill" do
59
+ # assert_active_toolbar_pill :edit_nests, 'nests'
60
+ # end
61
+ # end
60
62
  end
@@ -7,7 +7,7 @@ describe Card::Set::Rstar::Rules do
7
7
  expect(r).not_to match('No Card!')
8
8
  #warn "r = #{r}"
9
9
  assert_view_select r, 'table[class="set-rules table"]' do
10
- assert_select 'a[href~="/*read+*right+*input?view=open_rule"]', :text => 'input'
10
+ assert_select 'a[href~="/*read+*right+*read?view=open_rule"]', :text => 'read'
11
11
  end
12
12
  end
13
13
 
@@ -25,5 +25,13 @@ describe Card::Set::Type::SearchType do
25
25
  expect(r.scan('item-closed').size).to eq(2) #there are two of each
26
26
  end
27
27
 
28
- it ''
28
+ it 'handles type update from pointer' do
29
+ pointer_card = Card.create!(
30
+ :name=>"PointerToSearches",
31
+ :type_id=>Card::PointerID,
32
+ )
33
+
34
+ pointer_card.update_attributes! :type_id=>Card::SearchTypeID,:content=>%{{"type":"User"}}
35
+ expect(pointer_card.content).to eq(%{{"type":"User"}})
36
+ end
29
37
  end
@@ -1,27 +1,27 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  describe Card::Set::Type::Signup do
4
-
4
+
5
5
  before do
6
6
  Card::Auth.current_id = Card::AnonymousID
7
7
  end
8
-
9
-
8
+
9
+
10
10
  context 'signup form form' do
11
11
  before do
12
12
  card = Card.new :type_id=>Card::SignupID
13
13
  @form = card.format.render_new
14
14
  end
15
-
15
+
16
16
  it 'should prompt to signup' do
17
17
  Card::Auth.as :anonymous do
18
18
  expect(@form.match( /Sign up/ )).to be_truthy
19
19
  end
20
20
  end
21
21
  end
22
-
23
22
 
24
-
23
+
24
+
25
25
  context 'signup (without approval)' do
26
26
  before do
27
27
  ActionMailer::Base.deliveries = [] #needed?
@@ -29,15 +29,15 @@ describe Card::Set::Type::Signup do
29
29
  Card::Auth.as_bot do
30
30
  Card.create! :name=>'User+*type+*create', :content=>'[[Anyone]]'
31
31
  end
32
-
32
+
33
33
  Card::Auth.current_id = Card::AnonymousID
34
- @signup = Card.create! :name=>'Big Bad Wolf', :type_id=>Card::SignupID,
35
- '+*account'=>{'+*email'=>'wolf@wagn.org', '+*password'=>'wolf'}
36
-
34
+ @signup = Card.create! :name=>'Big Bad Wolf', :type_id=>Card::SignupID,
35
+ '+*account'=>{'+*email'=>'wolf@wagn.org', '+*password'=>'wolf'}
36
+
37
37
  @account = @signup.account
38
38
  @token = @account.token
39
39
  end
40
-
40
+
41
41
  it 'should create all the necessary cards' do
42
42
  expect(@signup.type_id).to eq(Card::SignupID)
43
43
  expect(@account.email).to eq('wolf@wagn.org')
@@ -46,22 +46,22 @@ describe Card::Set::Type::Signup do
46
46
  expect(@account.password.length).to be > 10 #encrypted
47
47
  expect(@account.token).to be_present
48
48
  end
49
-
49
+
50
50
  it 'should send email with an appropriate link' do
51
51
  @mail = ActionMailer::Base.deliveries.last
52
52
  expect( @mail.parts[0].body.raw_source ).to match(Card.setting( :title ))
53
53
  end
54
-
54
+
55
55
  it 'should create an authenticable token' do
56
56
  expect(@account.token).to eq(@token)
57
57
  expect(@account.authenticate_by_token(@token)).to eq(@signup.id)
58
58
  expect(@account.fetch(:trait=> :token)).not_to be_present
59
59
  end
60
-
60
+
61
61
  it 'should notify someone' do
62
62
  expect(ActionMailer::Base.deliveries.last.to).to eq(['signups@wagn.org'])
63
63
  end
64
-
64
+
65
65
  it 'should be activated by an update' do
66
66
  Card::Env.params[:token] = @token
67
67
  @signup.update_attributes({})
@@ -71,12 +71,12 @@ describe Card::Set::Type::Signup do
71
71
  expect(@account.status).to eq('active')
72
72
  expect(Card[ @account.name ].active?).to be_truthy
73
73
  end
74
-
74
+
75
75
  it 'should reject expired token and create new token' do
76
76
  @account.token_card.update_column :updated_at, 8.days.ago.strftime("%F %T")
77
77
  @account.token_card.expire
78
78
  Card::Env.params[:token] = @token
79
-
79
+
80
80
  result = @signup.update_attributes!({})
81
81
  expect(result).to eq(true) # successfully completes save
82
82
  @account.reload
@@ -96,8 +96,8 @@ describe Card::Set::Type::Signup do
96
96
  '+*account'=>{ '+*email'=>'wolf@wagn.org', '+*password'=>'wolf' }
97
97
  @account = @signup.account
98
98
  end
99
-
100
-
99
+
100
+
101
101
  it 'should create all the necessary cards, but no token' do
102
102
  expect(@signup.type_id).to eq(Card::SignupID)
103
103
  expect(@account.email).to eq('wolf@wagn.org')
@@ -105,11 +105,11 @@ describe Card::Set::Type::Signup do
105
105
  expect(@account.salt).not_to eq('')
106
106
  expect(@account.password.length).to be > 10 #encrypted
107
107
  end
108
-
108
+
109
109
  it 'should not create a token' do
110
110
  expect(@account.token).not_to be_present
111
111
  end
112
-
112
+
113
113
  it 'sends signup alert email' do
114
114
  signup_alert = ActionMailer::Base.deliveries.last
115
115
  expect(signup_alert.to).to eq(['signups@wagn.org'])
@@ -118,33 +118,33 @@ describe Card::Set::Type::Signup do
118
118
  expect(body).to include(@signup.name)
119
119
  expect(body).to include('wolf@wagn.org')
120
120
  end
121
-
121
+
122
122
  end
123
-
123
+
124
124
  it 'does not send verification email' do
125
125
  expect(Mail::TestMailer.deliveries[-2]).to be_nil
126
126
  end
127
-
128
-
127
+
128
+
129
129
  context 'approval with token' do
130
-
130
+
131
131
  it 'should create token' do
132
132
  Card::Env.params[:approve_with_token] = true
133
133
  Card::Auth.as :joe_admin
134
-
134
+
135
135
  @signup = Card.fetch @signup.id
136
136
  @signup.save!
137
137
  expect(@signup.account.token).to be_present
138
138
  end
139
-
139
+
140
140
  end
141
-
141
+
142
142
  context 'approval without token' do
143
-
143
+
144
144
  it 'should create token' do
145
145
  Card::Env.params[:approve_without_token] = true
146
146
  Card::Auth.as :joe_admin
147
-
147
+
148
148
  @signup = Card.fetch @signup.id
149
149
  @signup.save!
150
150
  expect(@signup.account.token).not_to be_present
@@ -154,36 +154,36 @@ describe Card::Set::Type::Signup do
154
154
  end
155
155
 
156
156
  end
157
-
157
+
158
158
  context 'a welcome email card exists' do
159
159
  before do
160
- Card::Auth.as_bot do
161
- Card.create! :name=>'welcome email', :subcards=>{'+*subject'=>'welcome',
160
+ Card::Auth.as_bot do
161
+ Card.create! :name=>'welcome email', :subcards=>{'+*subject'=>'welcome',
162
162
  '+*html_message'=>'Welcome {{_self|name}}'}, :type_id=>Card::EmailTemplateID
163
163
  end
164
164
  Mail::TestMailer.deliveries.clear
165
- @signup = Card.create! :name=>'Big Bad Sheep', :type_id=>Card::SignupID,
166
- '+*account'=>{'+*email'=>'sheep@wagn.org', '+*password'=>'sheep'}
167
-
165
+ @signup = Card.create! :name=>'Big Bad Sheep', :type_id=>Card::SignupID,
166
+ '+*account'=>{'+*email'=>'sheep@wagn.org', '+*password'=>'sheep'}
167
+
168
168
  end
169
169
  it 'sends welcome email when account is activated' do
170
170
  @signup.activate_account
171
171
  @mail = ActionMailer::Base.deliveries.find{ |a| a.subject == 'welcome' }
172
172
  Mail::TestMailer.deliveries.clear
173
-
173
+
174
174
  expect(@mail).to be_truthy
175
175
  expect(@mail.body.raw_source ).to include('Welcome Big Bad Sheep')
176
176
  end
177
177
  end
178
-
178
+
179
179
  context 'invitation' do
180
180
  before do
181
181
  # NOTE: by default Anonymous does not have permission to create User cards.
182
- Card::Auth.current_id = Card::WagnBotID
182
+ Card::Auth.current_id = Card::WagnBotID
183
183
  @signup = Card.create! :name=>'Big Bad Wolf', :type_id=>Card::SignupID, '+*account'=>{ '+*email'=>'wolf@wagn.org'}
184
184
  @account = @signup.account
185
185
  end
186
-
186
+
187
187
  it 'should create all the necessary cards, but no password' do
188
188
  expect(@signup.type_id).to eq(Card::SignupID)
189
189
  expect(@account.email).to eq('wolf@wagn.org')
@@ -192,7 +192,7 @@ describe Card::Set::Type::Signup do
192
192
  expect(@account.token).to be_present
193
193
  expect(@account.password).not_to be_present
194
194
  end
195
-
195
+
196
196
  end
197
197
 
198
198
  # describe '#signup_notifications' do