card 1.16.8 → 1.16.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/db/migrate_core_cards/{20150611203506_rails_inflection_updates.rb → 20120611203506_rails_inflection_updates.rb} +0 -0
  4. data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +0 -1
  5. data/db/migrate_core_cards/20150429090551_search_card_context.rb +1 -1
  6. data/db/migrate_core_cards/20150708224756_add_list_cards.rb +22 -0
  7. data/db/seed/new/card_actions.yml +789 -509
  8. data/db/seed/new/card_acts.yml +1 -1
  9. data/db/seed/new/card_changes.yml +2618 -1920
  10. data/db/seed/new/card_references.yml +1034 -901
  11. data/db/seed/new/cards.yml +2303 -1675
  12. data/db/seed/test/fixtures/card_actions.yml +1926 -1606
  13. data/db/seed/test/fixtures/card_acts.yml +354 -324
  14. data/db/seed/test/fixtures/card_changes.yml +5950 -5175
  15. data/db/seed/test/fixtures/card_references.yml +1861 -1630
  16. data/db/seed/test/fixtures/cards.yml +3768 -3048
  17. data/db/seed/test/seed.rb +121 -107
  18. data/lib/card.rb +2 -3
  19. data/lib/card/active_record_helper.rb +44 -0
  20. data/lib/card/auth.rb +51 -47
  21. data/lib/card/cache.rb +7 -3
  22. data/lib/card/codename.rb +7 -7
  23. data/lib/card/format.rb +2 -1
  24. data/lib/card/migration.rb +17 -16
  25. data/lib/card/name.rb +71 -20
  26. data/lib/card/set.rb +202 -166
  27. data/lib/card/simplecov_helper.rb +11 -7
  28. data/lib/card/subcards.rb +249 -0
  29. data/mod/01_core/set/all/collection.rb +1 -2
  30. data/mod/01_core/set/all/fetch.rb +167 -92
  31. data/mod/01_core/set/all/initialize.rb +8 -22
  32. data/mod/01_core/set/all/name.rb +128 -79
  33. data/mod/01_core/set/all/phases.rb +93 -95
  34. data/mod/01_core/set/all/subcards.rb +70 -0
  35. data/mod/01_core/set/all/tracked_attributes.rb +83 -59
  36. data/mod/01_core/set/all/trash.rb +14 -12
  37. data/mod/01_core/set/all/type.rb +3 -24
  38. data/mod/01_core/spec/set/all/initialize_spec.rb +44 -14
  39. data/mod/01_core/spec/set/all/permissions_spec.rb +206 -185
  40. data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +0 -10
  41. data/mod/01_core/spec/set/all/trash_spec.rb +38 -13
  42. data/mod/01_core/spec/set/all/type_spec.rb +0 -19
  43. data/mod/01_history/set/all/content_history.rb +5 -3
  44. data/mod/01_history/set/all/history.rb +117 -82
  45. data/mod/02_basic_types/set/all/base.rb +50 -49
  46. data/mod/03_machines/lib/card/machine.rb +2 -1
  47. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +55 -17
  48. data/mod/03_machines/spec/set/type/javascript_spec.rb +18 -12
  49. data/mod/05_email/set/right/followers.rb +5 -5
  50. data/mod/05_email/set/right/following.rb +1 -1
  51. data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
  52. data/mod/05_standard/lib/carrier_wave/cardmount.rb +19 -11
  53. data/mod/05_standard/lib/file_uploader.rb +1 -1
  54. data/mod/05_standard/set/abstract/attachment.rb +20 -8
  55. data/mod/05_standard/set/all/list_changes.rb +43 -0
  56. data/mod/05_standard/set/all/rich_html/form.rb +21 -11
  57. data/mod/05_standard/set/all/rich_html/menu.rb +1 -1
  58. data/mod/05_standard/set/right/account.rb +5 -5
  59. data/mod/05_standard/set/self/head.rb +0 -1
  60. data/mod/05_standard/set/self/signin.rb +43 -35
  61. data/mod/05_standard/set/type/file.rb +9 -2
  62. data/mod/05_standard/set/type/list.rb +134 -0
  63. data/mod/05_standard/set/type/listed_by.rb +94 -0
  64. data/mod/05_standard/set/type/search_type.rb +62 -61
  65. data/mod/05_standard/set/type/signup.rb +94 -63
  66. data/mod/05_standard/set/type/user.rb +48 -39
  67. data/mod/05_standard/spec/set/all/account_spec.rb +1 -1
  68. data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +2 -2
  69. data/mod/05_standard/spec/set/self/signin_spec.rb +23 -27
  70. data/mod/05_standard/spec/set/type/email_template_spec.rb +0 -2
  71. data/mod/05_standard/spec/set/type/list_spec.rb +140 -0
  72. data/mod/05_standard/spec/set/type/listed_by_spec.rb +157 -0
  73. data/mod/05_standard/spec/set/type/signup_spec.rb +38 -32
  74. data/spec/lib/card/subcards_spec.rb +126 -0
  75. metadata +14 -3
@@ -1,92 +1,94 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  describe Card::Set::Type::Signup do
4
-
5
4
  before do
6
5
  Card::Auth.current_id = Card::AnonymousID
7
6
  end
8
7
 
9
-
10
8
  context 'signup form form' do
11
9
  before do
12
10
  card = Card.new type_id: Card::SignupID
13
11
  @form = card.format.render_new
14
12
  end
15
13
 
16
- it 'should prompt to signup' do
14
+ it 'prompts to signup' do
17
15
  Card::Auth.as :anonymous do
18
- expect(@form.match( /Sign up/ )).to be_truthy
16
+ expect(@form.match(/Sign up/)).to be_truthy
19
17
  end
20
18
  end
21
19
  end
22
20
 
23
-
24
-
25
21
  context 'signup (without approval)' do
26
22
  before do
27
- ActionMailer::Base.deliveries = [] #needed?
23
+ ActionMailer::Base.deliveries = [] # needed?
28
24
 
29
25
  Card::Auth.as_bot do
30
26
  Card.create! name: 'User+*type+*create', content: '[[Anyone]]'
31
27
  end
32
28
 
33
29
  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'}
30
+ @signup = Card.create!(
31
+ name: 'Big Bad Wolf', type_id: Card::SignupID,
32
+ '+*account' => { '+*email' => 'wolf@wagn.org', '+*password' => 'wolf' }
33
+ )
36
34
 
37
35
  @account = @signup.account
38
36
  @token = @account.token
39
37
  end
40
38
 
41
- it 'should create all the necessary cards' do
39
+ it 'creates all the necessary cards' do
42
40
  expect(@signup.type_id).to eq(Card::SignupID)
43
41
  expect(@account.email).to eq('wolf@wagn.org')
44
42
  expect(@account.status).to eq('pending')
45
43
  expect(@account.salt).not_to eq('')
46
- expect(@account.password.length).to be > 10 #encrypted
44
+ expect(@account.password.length).to be > 10 # encrypted
47
45
  expect(@account.token).to be_present
48
46
  end
49
47
 
50
- it 'should send email with an appropriate link' do
48
+ it 'sends email with an appropriate link' do
51
49
  @mail = ActionMailer::Base.deliveries.last
52
- expect( @mail.parts[0].body.raw_source ).to match(Card.setting( :title ))
50
+ expect(@mail.parts[0].body.raw_source).to match(Card.setting(:title))
53
51
  end
54
52
 
55
- it 'should create an authenticable token' do
53
+ it 'creates an authenticable token' do
56
54
  expect(@account.token).to eq(@token)
57
55
  expect(@account.authenticate_by_token(@token)).to eq(@signup.id)
58
56
  expect(@account.fetch(trait: :token)).not_to be_present
59
57
  end
60
58
 
61
- it 'should notify someone' do
59
+ it 'notifies someone' do
62
60
  expect(ActionMailer::Base.deliveries.last.to).to eq(['signups@wagn.org'])
63
61
  end
64
62
 
65
- it 'should be activated by an update' do
63
+ it 'is activated by an update' do
66
64
  Card::Env.params[:token] = @token
65
+ @signup = Card.fetch 'big bad wolf'
67
66
  @signup.update_attributes({})
68
- #puts @signup.errors.full_messages * "\n"
67
+ # puts @signup.errors.full_messages * "\n"
69
68
  expect(@signup.errors).to be_empty
70
69
  expect(@signup.type_id).to eq(Card::UserID)
71
70
  expect(@account.status).to eq('active')
72
- expect(Card[ @account.name ].active?).to be_truthy
71
+ expect(Card[@account.name].active?).to be_truthy
73
72
  end
74
73
 
75
- it 'should reject expired token and create new token' do
76
- @account.token_card.update_column :updated_at, 8.days.ago.strftime("%F %T")
74
+ it 'rejects expired token and creates new token' do
75
+ @account.token_card.update_column :updated_at,
76
+ 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
- expect(result).to eq(true) # successfully completes save
81
+ # successfully completes save
82
+ expect(result).to eq(true)
82
83
  @account.reload
83
- expect(@account.token).not_to eq(@token) # token gets updated
84
+ # token gets updated
85
+ expect(@account.token).not_to eq(@token)
84
86
  success = Card::Env.params[:success]
85
- expect(success[:message]).to match(/expired/) # user notified of expired token
87
+ # user notified of expired token
88
+ expect(success[:message]).to match(/expired/)
86
89
  end
87
90
  end
88
91
 
89
-
90
92
  context 'signup (with approval)' do
91
93
  before do
92
94
  # NOTE: by default Anonymous does not have permission to create User cards.
@@ -167,24 +169,28 @@ describe Card::Set::Type::Signup do
167
169
 
168
170
  end
169
171
  it 'sends welcome email when account is activated' do
170
- @signup.activate_account
171
- @mail = ActionMailer::Base.deliveries.find{ |a| a.subject == 'welcome' }
172
+ @signup.run_phase :approve do
173
+ @signup.activate_account
174
+ end
175
+ @mail = ActionMailer::Base.deliveries.find { |a| a.subject == 'welcome' }
172
176
  Mail::TestMailer.deliveries.clear
173
177
 
174
178
  expect(@mail).to be_truthy
175
- expect(@mail.body.raw_source ).to include('Welcome Big Bad Sheep')
179
+ expect(@mail.body.raw_source).to include('Welcome Big Bad Sheep')
176
180
  end
177
181
  end
178
182
 
179
183
  context 'invitation' do
180
184
  before do
181
- # NOTE: by default Anonymous does not have permission to create User cards.
185
+ # NOTE:
186
+ # by default Anonymous does not have permission to create User cards.
182
187
  Card::Auth.current_id = Card::WagnBotID
183
- @signup = Card.create! name: 'Big Bad Wolf', type_id: Card::SignupID, '+*account'=>{ '+*email'=>'wolf@wagn.org'}
188
+ @signup = Card.create! name: 'Big Bad Wolf', type_id: Card::SignupID,
189
+ '+*account' => { '+*email' => 'wolf@wagn.org' }
184
190
  @account = @signup.account
185
191
  end
186
192
 
187
- it 'should create all the necessary cards, but no password' do
193
+ it 'creates all the necessary cards, but no password' do
188
194
  expect(@signup.type_id).to eq(Card::SignupID)
189
195
  expect(@account.email).to eq('wolf@wagn.org')
190
196
  expect(@account.status).to eq('pending')
@@ -192,7 +198,6 @@ describe Card::Set::Type::Signup do
192
198
  expect(@account.token).to be_present
193
199
  expect(@account.password).not_to be_present
194
200
  end
195
-
196
201
  end
197
202
 
198
203
  # describe '#signup_notifications' do
@@ -202,7 +207,8 @@ describe Card::Set::Type::Signup do
202
207
  # end
203
208
  # @user_name = 'Big Bad Wolf'
204
209
  # @user_email = 'wolf@wagn.org'
205
- # @signup = Card.create! name: @user_name, type_id: Card::SignupID, '+*account'=>{
210
+ # @signup = Card.create! name: @user_name, type_id: Card::SignupID,
211
+ # '+*account'=>{
206
212
  # '+*email'=>@user_email, '+*password'=>'wolf'}
207
213
  # ActionMailer::Base.deliveries = []
208
214
  # @signup.signup_notifications
@@ -0,0 +1,126 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Subcards do
4
+ describe 'creating card with subcards' do
5
+ it 'works with subcard hash' do
6
+ Card::Auth.as_bot do
7
+ @card = Card.create!(
8
+ name: 'card with subs',
9
+ subcards: { '+sub1' => { content: 'this is sub1' } }
10
+ )
11
+ end
12
+ expect(Card['card with subs+sub1'].content).to eq 'this is sub1'
13
+ end
14
+
15
+ it 'works with content string' do
16
+ Card::Auth.as_bot do
17
+ @card = Card.create!(
18
+ name: 'card with subs', subcards: { '+sub1' => 'this is sub1' }
19
+ )
20
+ end
21
+ expect(Card['card with subs+sub1'].content).to eq 'this is sub1'
22
+ end
23
+
24
+ it 'works with +name key in args' do
25
+ Card::Auth.as_bot do
26
+ @card = Card.create!(
27
+ name: 'card with subs', '+sub1' => { content: 'this is sub1' }
28
+ )
29
+ end
30
+ expect(Card['card with subs+sub1'].content).to eq 'this is sub1'
31
+ end
32
+
33
+ it 'handles more than one level' do
34
+ Card::Auth.as_bot do
35
+ @card = Card.create!(
36
+ name: 'card with subs', '+sub1' => { '+sub2' => 'this is sub2' }
37
+ )
38
+ end
39
+ expect(Card['card with subs+sub1+sub2'].content).to eq 'this is sub2'
40
+ end
41
+
42
+ it 'handles compound names' do
43
+ Card::Auth.as_bot do
44
+ @card = Card.create! name: 'superman', '+sub1+sub2' => 'this is sub2'
45
+ end
46
+ expect(Card['superman+sub1']).to be_truthy
47
+ expect(Card['superman+sub1+sub2'].content).to eq 'this is sub2'
48
+ end
49
+
50
+ it 'keeps plural of left part' do
51
+ Card::Auth.as_bot do
52
+ @card = Card.create!(
53
+ name: 'supermen', content: 'something',
54
+ subcards: { '+pseudonym' => 'clark' }
55
+ )
56
+ end
57
+ expect(Card['supermen+pseudonym'].name).to eq 'supermen+pseudonym'
58
+ end
59
+
60
+ it "cleans the cache for autonaming case" do
61
+ Card::Auth.as_bot do
62
+ Card.create!(
63
+ name: 'Book+*type+*autoname', content: 'Book_1',
64
+ type_id: Card::PhraseID
65
+ )
66
+ card = Card.create!(
67
+ type: "Book",
68
+ subcards: { '+editable' => 'yes'}
69
+ )
70
+ expect(card.errors).to be_empty
71
+ expect(Card["#{card.name}+editable"]).to be_truthy
72
+
73
+ @card = Card.create!(
74
+ type: "Book",
75
+ subcards: { '+editable' => 'sure'}
76
+ )
77
+ end
78
+
79
+ expect(@card.errors).to be_empty
80
+ expect(Card["#{@card.name}+editable"]).to be_truthy
81
+ end
82
+ end
83
+
84
+ describe '#add_subfield' do
85
+ before do
86
+ @card = Card['A']
87
+ end
88
+ subject { Card.fetch("#{@card.name}+sub", new: {}, local_only: true).content }
89
+ it 'works with string' do
90
+ @card._add_subfield 'sub', content: 'this is a sub'
91
+ is_expected.to eq 'this is a sub'
92
+ end
93
+ it 'works with codename' do
94
+ @card._add_subfield :phrase, content: 'this is a sub'
95
+ subcard = Card.fetch('A+phrase', new: {}, local_only: true)
96
+ expect(subcard.content).to eq 'this is a sub'
97
+ end
98
+ end
99
+
100
+ describe '#subfield' do
101
+ before do
102
+ @card = Card['A']
103
+ end
104
+ subject { Card.fetch("#{@card.name}+sub", new: {}, local_only: true).content }
105
+ it 'works with string' do
106
+ @card._add_subfield 'sub', content: 'this is a sub'
107
+ expect(@card.subfield('sub').content).to eq 'this is a sub'
108
+ end
109
+
110
+ it 'works with codename' do
111
+ @card._add_subfield :phrase, content: 'this is a sub'
112
+ expect(@card.subfield(':phrase').content).to eq 'this is a sub'
113
+ end
114
+ end
115
+
116
+ describe '#add' do
117
+ before do
118
+ @card = Card['A']
119
+ end
120
+ it 'adds a subcard' do
121
+ @card._add_subcard 'sub', content: 'sub content'
122
+ @card.save!
123
+ expect(Card['sub'].content).to eq 'sub content'
124
+ end
125
+ end
126
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.8
4
+ version: 1.16.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-10-06 00:00:00.000000000 Z
14
+ date: 2015-10-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: smartname
@@ -262,6 +262,7 @@ files:
262
262
  - db/migrate/20141208132159_remove_present_from_reference_table.rb
263
263
  - db/migrate/20141216053032_better_index_names.rb
264
264
  - db/migrate/20150724210803_add_comment_to_actions.rb
265
+ - db/migrate_core_cards/20120611203506_rails_inflection_updates.rb
265
266
  - db/migrate_core_cards/20130411191151_renaming_for_menu.rb
266
267
  - db/migrate_core_cards/20130411211600_delete_old_related_tab_cards.rb
267
268
  - db/migrate_core_cards/20130419215612_import_help_text.rb
@@ -298,9 +299,9 @@ files:
298
299
  - db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb
299
300
  - db/migrate_core_cards/20150605115802_add_performance_log_card.rb
300
301
  - db/migrate_core_cards/20150610171702_add_debugger_session_card.rb
301
- - db/migrate_core_cards/20150611203506_rails_inflection_updates.rb
302
302
  - db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb
303
303
  - db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb
304
+ - db/migrate_core_cards/20150708224756_add_list_cards.rb
304
305
  - db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb
305
306
  - db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb
306
307
  - db/migrate_core_cards/20150824135418_update_file_history.rb
@@ -380,6 +381,7 @@ files:
380
381
  - db/version_core_cards.txt
381
382
  - lib/card.rb
382
383
  - lib/card/active_record_ext.rb
384
+ - lib/card/active_record_helper.rb
383
385
  - lib/card/auth.rb
384
386
  - lib/card/cache.rb
385
387
  - lib/card/chunk.rb
@@ -408,6 +410,7 @@ files:
408
410
  - lib/card/set_pattern.rb
409
411
  - lib/card/simplecov_helper.rb
410
412
  - lib/card/spec_helper.rb
413
+ - lib/card/subcards.rb
411
414
  - lib/card/success.rb
412
415
  - lib/card/version.rb
413
416
  - lib/card/view_cache.rb
@@ -455,6 +458,7 @@ files:
455
458
  - mod/01_core/set/all/references.rb
456
459
  - mod/01_core/set/all/rules.rb
457
460
  - mod/01_core/set/all/states.rb
461
+ - mod/01_core/set/all/subcards.rb
458
462
  - mod/01_core/set/all/templating.rb
459
463
  - mod/01_core/set/all/tracked_attributes.rb
460
464
  - mod/01_core/set/all/trash.rb
@@ -681,6 +685,7 @@ files:
681
685
  - mod/05_standard/set/all/error.rb
682
686
  - mod/05_standard/set/all/event_viz.rb
683
687
  - mod/05_standard/set/all/links.rb
688
+ - mod/05_standard/set/all/list_changes.rb
684
689
  - mod/05_standard/set/all/rich_html/content.rb
685
690
  - mod/05_standard/set/all/rich_html/editing.rb
686
691
  - mod/05_standard/set/all/rich_html/form.rb
@@ -718,6 +723,8 @@ files:
718
723
  - mod/05_standard/set/type/file.rb
719
724
  - mod/05_standard/set/type/image.rb
720
725
  - mod/05_standard/set/type/layout_type.rb
726
+ - mod/05_standard/set/type/list.rb
727
+ - mod/05_standard/set/type/listed_by.rb
721
728
  - mod/05_standard/set/type/number.rb
722
729
  - mod/05_standard/set/type/phrase.rb
723
730
  - mod/05_standard/set/type/search_type.rb
@@ -778,6 +785,8 @@ files:
778
785
  - mod/05_standard/spec/set/type/html_spec.rb
779
786
  - mod/05_standard/spec/set/type/image_spec.rb
780
787
  - mod/05_standard/spec/set/type/layout_type_spec.rb
788
+ - mod/05_standard/spec/set/type/list_spec.rb
789
+ - mod/05_standard/spec/set/type/listed_by_spec.rb
781
790
  - mod/05_standard/spec/set/type/number_spec.rb
782
791
  - mod/05_standard/spec/set/type/phrase_spec.rb
783
792
  - mod/05_standard/spec/set/type/search_type_spec.rb
@@ -965,6 +974,7 @@ files:
965
974
  - spec/lib/card/reference_spec.rb
966
975
  - spec/lib/card/set_pattern_spec.rb
967
976
  - spec/lib/card/set_spec.rb
977
+ - spec/lib/card/subcards_spec.rb
968
978
  - spec/lib/card/success_spec.rb
969
979
  - spec/mailers/mailer_spec.rb
970
980
  - spec/models/card/cardtype_spec.rb
@@ -1193,6 +1203,7 @@ test_files:
1193
1203
  - spec/lib/card/reference_spec.rb
1194
1204
  - spec/lib/card/set_pattern_spec.rb
1195
1205
  - spec/lib/card/set_spec.rb
1206
+ - spec/lib/card/subcards_spec.rb
1196
1207
  - spec/lib/card/success_spec.rb
1197
1208
  - spec/mailers/mailer_spec.rb
1198
1209
  - spec/models/card/cardtype_spec.rb