card 1.16.15 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/initializers/recaptcha.rb +21 -4
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +1 -1
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +2 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
- data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +1 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +63 -0
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +1 -1
- data/db/schema.rb +1 -1
- data/db/seed/new/card_actions.yml +602 -394
- data/db/seed/new/card_acts.yml +595 -1
- data/db/seed/new/card_changes.yml +26282 -10262
- data/db/seed/new/card_references.yml +1252 -1084
- data/db/seed/new/cards.yml +1899 -1423
- data/db/seed/test/fixtures/card_actions.yml +1653 -1413
- data/db/seed/test/fixtures/card_acts.yml +1063 -445
- data/db/seed/test/fixtures/card_changes.yml +29674 -13637
- data/db/seed/test/fixtures/card_references.yml +1976 -1815
- data/db/seed/test/fixtures/cards.yml +3194 -2719
- data/lib/card.rb +14 -13
- data/lib/card/auth.rb +10 -6
- data/lib/card/cache.rb +58 -120
- data/lib/card/cache/persistent.rb +50 -0
- data/lib/card/cache/temporary.rb +38 -0
- data/lib/card/chunk.rb +34 -25
- data/lib/card/content.rb +3 -3
- data/lib/card/env.rb +3 -0
- data/lib/card/format.rb +56 -53
- data/lib/card/migration.rb +6 -2
- data/lib/card/name.rb +9 -1
- data/lib/card/query.rb +1 -1
- data/lib/card/reference.rb +17 -11
- data/lib/card/set.rb +1 -1
- data/lib/card/subcards.rb +6 -6
- data/lib/card/view_cache.rb +45 -28
- data/lib/generators/card/migration/templates/card_migration.erb +1 -2
- data/mod/01_core/chunk/include.rb +71 -48
- data/mod/01_core/chunk/link.rb +6 -3
- data/mod/01_core/chunk/query_reference.rb +38 -29
- data/mod/01_core/chunk/reference.rb +23 -24
- data/mod/01_core/set/all/collection.rb +1 -1
- data/mod/01_core/set/all/fetch.rb +39 -12
- data/mod/01_core/set/all/permissions.rb +2 -4
- data/mod/01_core/set/all/references.rb +50 -75
- data/mod/01_core/set/all/rules.rb +19 -18
- data/mod/01_core/set/all/subcards.rb +1 -1
- data/mod/01_core/set/all/templating.rb +31 -88
- data/mod/01_core/set/all/tracked_attributes.rb +7 -14
- data/mod/01_core/set/all/utils.rb +77 -66
- data/mod/01_core/set_pattern/07_type_plus_right.rb +6 -3
- data/mod/01_core/spec/set/all/fetch_spec.rb +148 -96
- data/mod/01_core/spec/set/all/templating_spec.rb +49 -40
- data/mod/01_core/spec/set/all/trash_spec.rb +1 -1
- data/mod/01_history/set/all/actions.rb +1 -1
- data/mod/02_basic_types/set/all/base.rb +13 -7
- data/mod/02_basic_types/set/all/rss.rb +17 -22
- data/mod/02_basic_types/set/type/plain_text.rb +5 -2
- data/mod/02_basic_types/spec/set/all/base_spec.rb +1 -0
- data/mod/02_basic_types/spec/set/all/rss_spec.rb +7 -6
- data/mod/03_machines/lib/javascript/wagn.js.coffee +22 -9
- data/mod/03_machines/set/right/machine_output.rb +1 -1
- data/mod/04_settings/lib/card/setting.rb +45 -31
- data/mod/04_settings/set/right/structure.rb +47 -1
- data/mod/04_settings/set/self/default_html_view.rb +2 -0
- data/mod/04_settings/set/self/follow_fields.rb +2 -0
- data/mod/04_settings/set/self/recent_settings.rb +1 -1
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/05_standard/set/all/links.rb +27 -26
- data/mod/05_standard/set/all/rich_html/editing.rb +1 -1
- data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
- data/mod/05_standard/set/rstar/rules.rb +20 -325
- data/mod/05_standard/set/rstar/rules_editor.rb +362 -0
- data/mod/05_standard/set/self/admin_info.rb +82 -0
- data/mod/05_standard/set/self/all.rb +16 -10
- data/mod/05_standard/set/self/head.rb +20 -19
- data/mod/05_standard/set/type/signup.rb +0 -1
- data/mod/05_standard/spec/set/all/account_spec.rb +44 -43
- data/mod/05_standard/spec/set/right/account_spec.rb +4 -2
- data/mod/05_standard/spec/set/type/search_type_spec.rb +8 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +24 -17
- data/mod/06_bootstrap/set/all/bootstrap/helper.rb +1 -1
- data/spec/lib/card/cache_spec.rb +64 -70
- data/spec/lib/card/content_spec.rb +236 -150
- data/spec/lib/card/reference_spec.rb +22 -38
- data/spec/lib/card/subcards_spec.rb +38 -0
- data/spec/lib/card/view_cache_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/collection.rb +77 -74
- data/tmpsets/set/mod001-01_core/all/content.rb +14 -16
- data/tmpsets/set/mod001-01_core/all/fetch.rb +137 -110
- data/tmpsets/set/mod001-01_core/all/name.rb +58 -40
- data/tmpsets/set/mod001-01_core/all/pattern.rb +12 -11
- data/tmpsets/set/mod001-01_core/all/permissions.rb +125 -117
- data/tmpsets/set/mod001-01_core/all/phases.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/references.rb +52 -77
- data/tmpsets/set/mod001-01_core/all/rules.rb +47 -53
- data/tmpsets/set/mod001-01_core/all/templating.rb +31 -87
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +12 -21
- data/tmpsets/set/mod001-01_core/all/trash.rb +4 -1
- data/tmpsets/set/mod001-01_core/all/type.rb +23 -21
- data/tmpsets/set/mod001-01_core/all/utils.rb +80 -64
- data/tmpsets/set/mod002-01_history/all/actions.rb +20 -16
- data/tmpsets/set/mod002-01_history/all/history.rb +18 -13
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +37 -10
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +17 -22
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +5 -2
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +51 -39
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +10 -6
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +10 -5
- data/tmpsets/set/mod005-04_settings/right/structure.rb +47 -1
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +1 -0
- data/tmpsets/set/mod005-04_settings/type/setting.rb +4 -1
- data/tmpsets/set/mod006-05_email/all/follow.rb +45 -54
- data/tmpsets/set/mod006-05_email/all/notify.rb +88 -73
- data/tmpsets/set/mod006-05_email/right/followers.rb +17 -14
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +22 -18
- data/tmpsets/set/mod006-05_email/type/email_template.rb +1 -1
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +94 -67
- data/tmpsets/set/mod007-05_standard/all/account.rb +18 -20
- data/tmpsets/set/mod007-05_standard/all/comment.rb +51 -29
- data/tmpsets/set/mod007-05_standard/all/error.rb +129 -99
- data/tmpsets/set/mod007-05_standard/all/links.rb +27 -26
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +115 -103
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +112 -78
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +123 -81
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +15 -58
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/account.rb +71 -75
- data/tmpsets/set/mod007-05_standard/right/email.rb +16 -13
- data/tmpsets/set/mod007-05_standard/right/password.rb +20 -12
- data/tmpsets/set/mod007-05_standard/right/status.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/token.rb +49 -2
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +20 -325
- data/tmpsets/set/mod007-05_standard/self/all.rb +16 -10
- data/tmpsets/set/mod007-05_standard/self/head.rb +76 -62
- data/tmpsets/set/mod007-05_standard/self/search.rb +45 -22
- data/tmpsets/set/mod007-05_standard/self/signin.rb +14 -12
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +13 -11
- data/tmpsets/set/mod007-05_standard/type/file.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +3 -2
- data/tmpsets/set/mod007-05_standard/type/set.rb +20 -16
- data/tmpsets/set/mod007-05_standard/type/signup.rb +19 -25
- data/tmpsets/set/mod007-05_standard/type/user.rb +1 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +1 -1
- data/tmpsets/set_pattern/106-type_plus_right.rb +6 -3
- metadata +11 -2
@@ -21,8 +21,8 @@ format :html do
|
|
21
21
|
def head_title
|
22
22
|
title = root.card && root.card.name
|
23
23
|
title = nil if title.blank?
|
24
|
-
title = params[:action] if title
|
25
|
-
%(<title>#{title ? "#{title} - " : ''}#{ Card.
|
24
|
+
title = params[:action] if title=='*placeholder'
|
25
|
+
%(<title>#{title ? "#{title} - " : ''}#{ Card.global_setting :title }</title>)
|
26
26
|
end
|
27
27
|
|
28
28
|
def head_buttons
|
@@ -101,7 +101,7 @@ format :html do
|
|
101
101
|
#{ javascript_tag do varvals * ';' end }
|
102
102
|
#{ @js_tag if @js_tag }
|
103
103
|
<!--[if lt IE 9]>#{ javascript_include_tag ie9_card.machine_output_url if ie9_card }<![endif]-->
|
104
|
-
#{ javascript_tag { "wagn.setTinyMCEConfig('#{ escape_javascript Card.
|
104
|
+
#{ javascript_tag { "wagn.setTinyMCEConfig('#{ escape_javascript Card.global_setting(:tiny_mce).to_s }')" } }
|
105
105
|
#{ google_analytics_head_javascript }
|
106
106
|
<script type="text/javascript">
|
107
107
|
$('document').ready(function() {
|
@@ -111,22 +111,23 @@ format :html do
|
|
111
111
|
HTML
|
112
112
|
end
|
113
113
|
|
114
|
+
|
114
115
|
def google_analytics_head_javascript
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
116
|
+
return unless (ga_key = Card.global_setting(:google_analytics_key))
|
117
|
+
<<-JAVASCRIPT
|
118
|
+
<script type="text/javascript">
|
119
|
+
var _gaq = _gaq || [];
|
120
|
+
_gaq.push(['_setAccount', '#{ga_key}']);
|
121
|
+
_gaq.push(['_trackPageview']);
|
122
|
+
(function() {
|
123
|
+
var ga = document.createElement('script');
|
124
|
+
ga.type = 'text/javascript'; ga.async = true;
|
125
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
126
|
+
var s = document.getElementsByTagName('script')[0];
|
127
|
+
s.parentNode.insertBefore(ga, s);
|
128
|
+
s.parentNode.insertBefore(ga, s);
|
129
|
+
})();
|
130
|
+
</script>
|
131
|
+
JAVASCRIPT
|
131
132
|
end
|
132
133
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
describe Card::Set::All::Account do
|
4
4
|
describe 'accountable?' do
|
5
|
-
|
6
5
|
it 'should be false for cards with *accountable rule off' do
|
7
6
|
expect(Card['A'].accountable?).to eq(false)
|
8
7
|
end
|
@@ -10,21 +9,22 @@ describe Card::Set::All::Account do
|
|
10
9
|
it 'should be true for cards with *accountable rule on' do
|
11
10
|
Card::Auth.as_bot do
|
12
11
|
Card.create name: 'A+*self+*accountable', content: '1'
|
13
|
-
Card.create name: '*account+*right+*create',
|
12
|
+
Card.create name: '*account+*right+*create',
|
13
|
+
content: '[[Anyone Signed In]]'
|
14
14
|
end
|
15
15
|
expect(Card['A'].accountable?).to eq(true)
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
19
18
|
|
20
|
-
describe
|
21
|
-
|
22
|
-
it "for Wagn Bot" do
|
19
|
+
describe 'parties' do
|
20
|
+
it 'for Wagn Bot' do
|
23
21
|
Card::Auth.current_id = Card::WagnBotID
|
24
|
-
expect(Card::Auth.current.parties.sort).to eq(
|
22
|
+
expect(Card::Auth.current.parties.sort).to eq(
|
23
|
+
[Card::WagnBotID, Card::AnyoneSignedInID, Card::AdministratorID]
|
24
|
+
)
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
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])
|
30
30
|
end
|
@@ -35,7 +35,7 @@ describe Card::Set::All::Account do
|
|
35
35
|
@parties = @joe_user_card.parties # note: must be called to test resets
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
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
|
|
@@ -43,20 +43,28 @@ describe Card::Set::All::Account 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 = [
|
47
|
-
expect(Card['Joe User'].parties).to eq(@parties)
|
46
|
+
Card::Auth.as_bot { roles_card.items = [r1.id] }
|
47
|
+
expect(Card['Joe User'].parties).to eq(@parties)
|
48
|
+
# local cache still has old parties
|
49
|
+
# (permission does not change mid-request)
|
48
50
|
|
49
|
-
Card::Cache.restore
|
50
|
-
|
51
|
+
Card::Cache.restore
|
52
|
+
# simulate new request
|
53
|
+
# clears local cache, where, eg, @parties would still be cached on card
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
Card::Auth.current_id = Card::Auth.current_id
|
56
|
+
# simulate new request
|
57
|
+
# current_id assignment clears several class variables
|
55
58
|
|
56
|
-
|
59
|
+
new_parties = [Card::AnyoneSignedInID, r1.id, @joe_user_card.id]
|
60
|
+
expect(Card['Joe User'].parties).to eq(new_parties)
|
61
|
+
# @parties regenerated, now with correct values
|
62
|
+
|
63
|
+
expect(Card::Auth.current. parties).to eq(new_parties)
|
64
|
+
# @joe_user_card.refresh(force=true).parties.should == new_parties
|
65
|
+
# should work, but now superfluous?
|
57
66
|
end
|
58
67
|
end
|
59
|
-
|
60
68
|
end
|
61
69
|
|
62
70
|
describe 'among?' do
|
@@ -65,27 +73,23 @@ describe Card::Set::All::Account do
|
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
68
|
-
|
69
|
-
describe "'+*email'" do
|
76
|
+
describe '+*email' do
|
70
77
|
it 'should create a card and account card' do
|
71
78
|
jadmin = Card['joe admin']
|
72
|
-
Card::Auth.current_id = jadmin.id
|
73
|
-
|
79
|
+
Card::Auth.current_id = jadmin.id
|
80
|
+
# simulate login to get correct from address
|
74
81
|
|
75
|
-
Card::Env[:params] = { email: {subject: 'Hey Joe!',
|
76
|
-
|
82
|
+
Card::Env[:params] = { email: { subject: 'Hey Joe!',
|
83
|
+
message: 'Come on in.' } }
|
84
|
+
Card.create! name: 'Joe New',
|
85
|
+
type_id: Card::UserID,
|
86
|
+
'+*account' => { '+*email' => 'joe@new.com' }
|
77
87
|
|
78
88
|
c = Card['Joe New']
|
79
|
-
u = Card::Auth[
|
89
|
+
u = Card::Auth['joe@new.com']
|
80
90
|
|
81
91
|
expect(c.account).to eq(u)
|
82
92
|
expect(c.type_id).to eq(Card::UserID)
|
83
|
-
=begin
|
84
|
-
email = ActionMailer::Base.deliveries.last
|
85
|
-
email.to.should == ['joe@new.com']
|
86
|
-
email.subject.should == 'Hey Joe!'
|
87
|
-
email.from.should == [ ja_email ]
|
88
|
-
=end
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
@@ -93,20 +97,20 @@ describe Card::Set::All::Account do
|
|
93
97
|
before do
|
94
98
|
@card = Card['Joe User']
|
95
99
|
end
|
96
|
-
|
97
|
-
|
100
|
+
|
101
|
+
it 'should handle email updates' do
|
102
|
+
@card.update_attributes! '+*account' => { '+*email' => 'joe@user.co.uk' }
|
98
103
|
expect(@card.account.email).to eq('joe@user.co.uk')
|
99
104
|
end
|
100
105
|
|
101
|
-
it
|
106
|
+
it 'should let Wagn Bot block accounts' do
|
102
107
|
Card::Auth.as_bot do
|
103
108
|
@card.account.status_card.update_attributes! content: 'blocked'
|
104
109
|
expect(@card.account.blocked?).to be_truthy
|
105
110
|
end
|
106
111
|
end
|
107
112
|
|
108
|
-
|
109
|
-
it "should not allow a user to block or unblock himself" do
|
113
|
+
it 'should not allow a user to block or unblock himself' do
|
110
114
|
expect do
|
111
115
|
@card.account.status_card.update_attributes! content: 'blocked'
|
112
116
|
end.to raise_error
|
@@ -114,24 +118,21 @@ describe Card::Set::All::Account do
|
|
114
118
|
end
|
115
119
|
end
|
116
120
|
|
117
|
-
describe
|
121
|
+
describe '#read_rules' do
|
118
122
|
before(:all) do
|
119
123
|
@read_rules = Card['joe_user'].read_rules
|
120
124
|
end
|
121
125
|
|
122
|
-
|
123
|
-
it "*all+*read should apply to Joe User" do
|
126
|
+
it '*all+*read should apply to Joe User' do
|
124
127
|
expect(@read_rules.member?(Card.fetch('*all+*read').id)).to be_truthy
|
125
128
|
end
|
126
129
|
|
127
|
-
it
|
130
|
+
it '13 more should apply to Joe Admin' do
|
128
131
|
# includes lots of account rules...
|
129
132
|
Card::Auth.as('joe_admin') do
|
130
133
|
ids = Card::Auth.as_card.read_rules
|
131
|
-
expect(ids.length).to eq(@read_rules.size +
|
134
|
+
expect(ids.length).to eq(@read_rules.size + 13)
|
132
135
|
end
|
133
136
|
end
|
134
|
-
|
135
137
|
end
|
136
|
-
|
137
138
|
end
|
@@ -58,7 +58,8 @@ describe Card::Set::Right::Account do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'contains deck title' do
|
61
|
-
|
61
|
+
body = @mail.parts[0].body.raw_source
|
62
|
+
expect(body).to match(Card.global_setting(:title))
|
62
63
|
end
|
63
64
|
|
64
65
|
it 'contains link to verify account' do
|
@@ -82,7 +83,8 @@ describe Card::Set::Right::Account do
|
|
82
83
|
end
|
83
84
|
|
84
85
|
it 'contains deck title' do
|
85
|
-
|
86
|
+
body = @mail.parts[0].body.raw_source
|
87
|
+
expect(body).to match(Card.global_setting(:title))
|
86
88
|
end
|
87
89
|
|
88
90
|
it 'contains password resset link' do
|
@@ -49,4 +49,12 @@ describe Card::Set::Type::SearchType do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
52
|
+
context 'rss format' do
|
53
|
+
it 'render rss without errors' do
|
54
|
+
search_card = Card.create type: 'Search', name: 'Asearch',
|
55
|
+
content: %{{"id":"1"}}
|
56
|
+
rss = search_card.format(:rss).render_feed
|
57
|
+
expect(rss).to have_tag('title', text: 'Wagn Bot')
|
58
|
+
end
|
59
|
+
end
|
52
60
|
end
|
@@ -47,7 +47,8 @@ describe Card::Set::Type::Signup do
|
|
47
47
|
|
48
48
|
it 'sends email with an appropriate link' do
|
49
49
|
@mail = ActionMailer::Base.deliveries.last
|
50
|
-
|
50
|
+
body = @mail.parts[0].body.raw_source
|
51
|
+
expect(body).to match(Card.global_setting(:title))
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'creates an authenticable token' do
|
@@ -90,21 +91,25 @@ describe Card::Set::Type::Signup do
|
|
90
91
|
|
91
92
|
context 'signup (with approval)' do
|
92
93
|
before do
|
93
|
-
# NOTE: by default Anonymous does not have permission
|
94
|
+
# NOTE: by default Anonymous does not have permission
|
95
|
+
# to create User cards.
|
94
96
|
Mail::TestMailer.deliveries.clear
|
95
97
|
Card::Auth.current_id = Card::AnonymousID
|
96
|
-
@signup = Card.create! name: 'Big Bad Wolf',
|
97
|
-
|
98
|
+
@signup = Card.create! name: 'Big Bad Wolf',
|
99
|
+
type_id: Card::SignupID,
|
100
|
+
'+*account' => {
|
101
|
+
'+*email' => 'wolf@wagn.org',
|
102
|
+
'+*password' => 'wolf'
|
103
|
+
}
|
98
104
|
@account = @signup.account
|
99
105
|
end
|
100
106
|
|
101
|
-
|
102
107
|
it 'should create all the necessary cards, but no token' do
|
103
108
|
expect(@signup.type_id).to eq(Card::SignupID)
|
104
109
|
expect(@account.email).to eq('wolf@wagn.org')
|
105
110
|
expect(@account.status).to eq('pending')
|
106
111
|
expect(@account.salt).not_to eq('')
|
107
|
-
expect(@account.password.length).to be > 10 #encrypted
|
112
|
+
expect(@account.password.length).to be > 10 # encrypted
|
108
113
|
end
|
109
114
|
|
110
115
|
it 'should not create a token' do
|
@@ -119,16 +124,13 @@ describe Card::Set::Type::Signup do
|
|
119
124
|
expect(body).to include(@signup.name)
|
120
125
|
expect(body).to include('wolf@wagn.org')
|
121
126
|
end
|
122
|
-
|
123
127
|
end
|
124
128
|
|
125
129
|
it 'does not send verification email' do
|
126
130
|
expect(Mail::TestMailer.deliveries[-2]).to be_nil
|
127
131
|
end
|
128
132
|
|
129
|
-
|
130
133
|
context 'approval with token' do
|
131
|
-
|
132
134
|
it 'should create token' do
|
133
135
|
Card::Env.params[:approve_with_token] = true
|
134
136
|
Card::Auth.as 'joe_admin'
|
@@ -137,11 +139,9 @@ describe Card::Set::Type::Signup do
|
|
137
139
|
@signup.save!
|
138
140
|
expect(@signup.account.token).to be_present
|
139
141
|
end
|
140
|
-
|
141
142
|
end
|
142
143
|
|
143
144
|
context 'approval without token' do
|
144
|
-
|
145
145
|
it 'should create token' do
|
146
146
|
Card::Env.params[:approve_without_token] = true
|
147
147
|
Card::Auth.as 'joe_admin'
|
@@ -153,20 +153,27 @@ describe Card::Set::Type::Signup do
|
|
153
153
|
expect(@signup.account.status).to eq('active')
|
154
154
|
end
|
155
155
|
end
|
156
|
-
|
157
156
|
end
|
158
157
|
|
159
158
|
context 'a welcome email card exists' do
|
160
159
|
before do
|
161
160
|
Card::Auth.as_bot do
|
162
|
-
Card.create! name: 'welcome email',
|
163
|
-
|
161
|
+
Card.create! name: 'welcome email',
|
162
|
+
type_id: Card::EmailTemplateID,
|
163
|
+
subcards: {
|
164
|
+
'+*subject' => 'welcome',
|
165
|
+
'+*html_message' => 'Welcome {{_self|name}}'
|
166
|
+
}
|
164
167
|
end
|
165
168
|
Mail::TestMailer.deliveries.clear
|
166
|
-
@signup = Card.create! name: 'Big Bad Sheep',
|
167
|
-
|
168
|
-
|
169
|
+
@signup = Card.create! name: 'Big Bad Sheep',
|
170
|
+
type_id: Card::SignupID,
|
171
|
+
'+*account' => {
|
172
|
+
'+*email' => 'sheep@wagn.org',
|
173
|
+
'+*password' => 'sheep'
|
174
|
+
}
|
169
175
|
end
|
176
|
+
|
170
177
|
it 'sends welcome email when account is activated' do
|
171
178
|
@signup.run_phase :approve do
|
172
179
|
@signup.activate_account
|
data/spec/lib/card/cache_spec.rb
CHANGED
@@ -1,121 +1,115 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
describe Card::Cache do
|
4
|
-
describe
|
4
|
+
describe 'with nil store' do
|
5
5
|
before do
|
6
|
-
|
7
|
-
@cache = Card::Cache.new prefix: "prefix"
|
6
|
+
@cache = Card::Cache.new prefix: 'prefix'
|
8
7
|
end
|
9
8
|
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
@cache.write(
|
13
|
-
expect(@cache.read(
|
14
|
-
@cache.fetch(
|
15
|
-
expect(@cache.read(
|
9
|
+
describe '#basic operations' do
|
10
|
+
it 'should work' do
|
11
|
+
@cache.write('a', 'foo')
|
12
|
+
expect(@cache.read('a')).to eq('foo')
|
13
|
+
@cache.fetch('b') { 'bar' }
|
14
|
+
expect(@cache.read('b')).to eq('bar')
|
16
15
|
@cache.reset
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
describe
|
20
|
+
describe 'with same cache_id' do
|
22
21
|
before :each do
|
23
|
-
@
|
24
|
-
|
25
|
-
@cache = Card::Cache.new store: @store, prefix: "prefix"
|
22
|
+
@hard = ActiveSupport::Cache::MemoryStore.new
|
23
|
+
@cache = Card::Cache.new store: @hard, prefix: 'prefix'
|
26
24
|
end
|
27
25
|
|
28
|
-
it
|
29
|
-
expect(@
|
30
|
-
@cache.read(
|
26
|
+
it '#read' do
|
27
|
+
expect(@hard).to receive(:read).with('prefix/foo')
|
28
|
+
@cache.read('foo')
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
34
|
-
expect(@
|
35
|
-
@cache.write(
|
36
|
-
expect(@cache.read('foo')).to eq(
|
31
|
+
it '#write' do
|
32
|
+
expect(@hard).to receive(:write).with('prefix/foo', 'val')
|
33
|
+
@cache.write('foo', 'val')
|
34
|
+
expect(@cache.read('foo')).to eq('val')
|
37
35
|
end
|
38
36
|
|
39
|
-
it
|
40
|
-
block = Proc.new {
|
41
|
-
expect(@
|
42
|
-
@cache.fetch(
|
37
|
+
it '#fetch' do
|
38
|
+
block = Proc.new { 'hi' }
|
39
|
+
expect(@hard).to receive(:fetch).with('prefix/foo', &block)
|
40
|
+
@cache.fetch('foo', &block)
|
43
41
|
end
|
44
42
|
|
45
|
-
it
|
46
|
-
expect(@
|
47
|
-
@cache.delete
|
43
|
+
it '#delete' do
|
44
|
+
expect(@hard).to receive(:delete).with('prefix/foo')
|
45
|
+
@cache.delete 'foo'
|
48
46
|
end
|
49
47
|
|
50
|
-
it
|
51
|
-
@cache.
|
52
|
-
expect(@cache.read(
|
53
|
-
expect(@
|
54
|
-
expect(@cache.
|
48
|
+
it '#soft.write' do
|
49
|
+
@cache.soft.write('a', 'foo')
|
50
|
+
expect(@cache.read('a')).to eq('foo')
|
51
|
+
expect(@hard).not_to receive(:write)
|
52
|
+
expect(@cache.hard.read('a')).to eq(nil)
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
|
-
it
|
59
|
-
|
60
|
-
@
|
61
|
-
@cache
|
62
|
-
|
63
|
-
@cache.
|
64
|
-
expect(@cache.read("foo")).to eq("bar")
|
56
|
+
it '#reset' do
|
57
|
+
@hard = ActiveSupport::Cache::MemoryStore.new
|
58
|
+
@cache = Card::Cache.new store: @hard, prefix: 'prefix'
|
59
|
+
expect(@cache.hard.prefix).to eq('prefix/')
|
60
|
+
@cache.write('foo','bar')
|
61
|
+
expect(@cache.read('foo')).to eq('bar')
|
65
62
|
|
66
63
|
# reset
|
67
|
-
expect(Card::Cache).to receive(:generate_cache_id).and_return("cache_id2")
|
68
64
|
@cache.reset
|
69
|
-
expect(@cache.prefix).to eq(
|
70
|
-
expect(@cache.
|
71
|
-
expect(@cache.read("foo")).to be_nil
|
65
|
+
expect(@cache.hard.prefix).to eq('prefix/')
|
66
|
+
expect(@cache.read('foo')).to be_nil
|
72
67
|
|
73
|
-
cache2 = Card::Cache.new store: @
|
74
|
-
expect(cache2.prefix).to eq(
|
68
|
+
cache2 = Card::Cache.new store: @hard, prefix: 'prefix'
|
69
|
+
expect(cache2.hard.prefix).to eq('prefix/')
|
75
70
|
end
|
76
71
|
|
77
|
-
describe
|
72
|
+
describe 'with file store' do
|
78
73
|
before do
|
79
74
|
cache_path = "#{Wagn.root}/tmp/cache"
|
80
75
|
unless File.directory?(cache_path)
|
81
76
|
FileUtils.mkdir_p(cache_path)
|
82
77
|
end
|
83
|
-
@
|
78
|
+
@hard = ActiveSupport::Cache::FileStore.new cache_path
|
84
79
|
|
85
|
-
@
|
86
|
-
#cache_path = cache_path +
|
87
|
-
#p = Pathname.new(cache_path)
|
88
|
-
#p.mkdir if !p.exist?
|
80
|
+
@hard.clear
|
81
|
+
# cache_path = cache_path + '/prefix'
|
82
|
+
# p = Pathname.new(cache_path)
|
83
|
+
# p.mkdir if !p.exist?
|
89
84
|
#
|
90
|
-
#root_dirs = Dir.entries(cache_path).reject{|f| ['.', '..'].include?(f)}
|
91
|
-
#files_to_remove = root_dirs.collect{|f| File.join(cache_path, f)}
|
92
|
-
#FileUtils.rm_r(files_to_remove)
|
93
|
-
|
94
|
-
expect(Card::Cache).to receive(:generate_cache_id).exactly(2).times.and_return("cache_id1")
|
95
|
-
@cache = Card::Cache.new store: @store, prefix: "prefix"
|
85
|
+
# root_dirs = Dir.entries(cache_path).reject{|f| ['.', '..'].include?(f)}
|
86
|
+
# files_to_remove = root_dirs.collect{|f| File.join(cache_path, f)}
|
87
|
+
# FileUtils.rm_r(files_to_remove)
|
88
|
+
@cache = Card::Cache.new store: @hard, prefix: 'prefix'
|
96
89
|
end
|
97
90
|
|
98
|
-
describe
|
99
|
-
it
|
100
|
-
@cache.write('%\\/*:?"<>|',
|
101
|
-
cache2 = Card::Cache.new store: @
|
102
|
-
expect(cache2.read('%\\/*:?"<>|')).to eq(
|
91
|
+
describe '#basic operations with special symbols' do
|
92
|
+
it 'should work' do
|
93
|
+
@cache.write('%\\/*:?"<>|', 'foo')
|
94
|
+
cache2 = Card::Cache.new store: @hard, prefix: 'prefix'
|
95
|
+
expect(cache2.read('%\\/*:?"<>|')).to eq('foo')
|
103
96
|
@cache.reset
|
104
97
|
end
|
105
98
|
end
|
106
99
|
|
107
|
-
describe
|
108
|
-
it
|
109
|
-
@cache.write('(汉语漢語 Hànyǔ; 华语華語 Huáyǔ; 中文 Zhōngwén',
|
110
|
-
@cache.write('русский',
|
111
|
-
cache3 = Card::Cache.new store: @
|
112
|
-
|
113
|
-
expect(
|
100
|
+
describe '#basic operations with non-latin symbols' do
|
101
|
+
it 'should work' do
|
102
|
+
@cache.write('(汉语漢語 Hànyǔ; 华语華語 Huáyǔ; 中文 Zhōngwén', 'foo')
|
103
|
+
@cache.write('русский', 'foo')
|
104
|
+
cache3 = Card::Cache.new store: @hard, prefix: 'prefix'
|
105
|
+
cached = cache3.read '(汉语漢語 Hànyǔ; 华语華語 Huáyǔ; 中文 Zhōngwén'
|
106
|
+
expect(cached).to eq('foo')
|
107
|
+
expect(cache3.read('русский')).to eq('foo')
|
114
108
|
@cache.reset
|
115
109
|
end
|
116
110
|
end
|
117
111
|
|
118
|
-
describe
|
112
|
+
describe '#tempfile' do
|
119
113
|
# TODO
|
120
114
|
end
|
121
115
|
end
|