card 1.16.8 → 1.16.9
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/db/migrate_core_cards/{20150611203506_rails_inflection_updates.rb → 20120611203506_rails_inflection_updates.rb} +0 -0
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +0 -1
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +1 -1
- data/db/migrate_core_cards/20150708224756_add_list_cards.rb +22 -0
- data/db/seed/new/card_actions.yml +789 -509
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +2618 -1920
- data/db/seed/new/card_references.yml +1034 -901
- data/db/seed/new/cards.yml +2303 -1675
- data/db/seed/test/fixtures/card_actions.yml +1926 -1606
- data/db/seed/test/fixtures/card_acts.yml +354 -324
- data/db/seed/test/fixtures/card_changes.yml +5950 -5175
- data/db/seed/test/fixtures/card_references.yml +1861 -1630
- data/db/seed/test/fixtures/cards.yml +3768 -3048
- data/db/seed/test/seed.rb +121 -107
- data/lib/card.rb +2 -3
- data/lib/card/active_record_helper.rb +44 -0
- data/lib/card/auth.rb +51 -47
- data/lib/card/cache.rb +7 -3
- data/lib/card/codename.rb +7 -7
- data/lib/card/format.rb +2 -1
- data/lib/card/migration.rb +17 -16
- data/lib/card/name.rb +71 -20
- data/lib/card/set.rb +202 -166
- data/lib/card/simplecov_helper.rb +11 -7
- data/lib/card/subcards.rb +249 -0
- data/mod/01_core/set/all/collection.rb +1 -2
- data/mod/01_core/set/all/fetch.rb +167 -92
- data/mod/01_core/set/all/initialize.rb +8 -22
- data/mod/01_core/set/all/name.rb +128 -79
- data/mod/01_core/set/all/phases.rb +93 -95
- data/mod/01_core/set/all/subcards.rb +70 -0
- data/mod/01_core/set/all/tracked_attributes.rb +83 -59
- data/mod/01_core/set/all/trash.rb +14 -12
- data/mod/01_core/set/all/type.rb +3 -24
- data/mod/01_core/spec/set/all/initialize_spec.rb +44 -14
- data/mod/01_core/spec/set/all/permissions_spec.rb +206 -185
- data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +0 -10
- data/mod/01_core/spec/set/all/trash_spec.rb +38 -13
- data/mod/01_core/spec/set/all/type_spec.rb +0 -19
- data/mod/01_history/set/all/content_history.rb +5 -3
- data/mod/01_history/set/all/history.rb +117 -82
- data/mod/02_basic_types/set/all/base.rb +50 -49
- data/mod/03_machines/lib/card/machine.rb +2 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +55 -17
- data/mod/03_machines/spec/set/type/javascript_spec.rb +18 -12
- data/mod/05_email/set/right/followers.rb +5 -5
- data/mod/05_email/set/right/following.rb +1 -1
- data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +19 -11
- data/mod/05_standard/lib/file_uploader.rb +1 -1
- data/mod/05_standard/set/abstract/attachment.rb +20 -8
- data/mod/05_standard/set/all/list_changes.rb +43 -0
- data/mod/05_standard/set/all/rich_html/form.rb +21 -11
- data/mod/05_standard/set/all/rich_html/menu.rb +1 -1
- data/mod/05_standard/set/right/account.rb +5 -5
- data/mod/05_standard/set/self/head.rb +0 -1
- data/mod/05_standard/set/self/signin.rb +43 -35
- data/mod/05_standard/set/type/file.rb +9 -2
- data/mod/05_standard/set/type/list.rb +134 -0
- data/mod/05_standard/set/type/listed_by.rb +94 -0
- data/mod/05_standard/set/type/search_type.rb +62 -61
- data/mod/05_standard/set/type/signup.rb +94 -63
- data/mod/05_standard/set/type/user.rb +48 -39
- data/mod/05_standard/spec/set/all/account_spec.rb +1 -1
- data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +2 -2
- data/mod/05_standard/spec/set/self/signin_spec.rb +23 -27
- data/mod/05_standard/spec/set/type/email_template_spec.rb +0 -2
- data/mod/05_standard/spec/set/type/list_spec.rb +140 -0
- data/mod/05_standard/spec/set/type/listed_by_spec.rb +157 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +38 -32
- data/spec/lib/card/subcards_spec.rb +126 -0
- metadata +14 -3
@@ -4,41 +4,53 @@ include Basic
|
|
4
4
|
attr_accessor :email
|
5
5
|
|
6
6
|
format :html do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
view :setup, tags: :unknown_ok,
|
8
|
+
perms: lambda { |_r| Auth.needs_setup? } do |args|
|
9
|
+
account = card.fetch trait: :account, new: {}
|
10
|
+
Auth.as_bot do
|
11
|
+
frame_and_form :create, args do
|
12
|
+
[
|
13
|
+
_render_name_formgroup(help: 'usually first and last name'),
|
14
|
+
subformat(account)._render(:content_formgroup, structure: true),
|
15
|
+
_render_button_formgroup(args)
|
16
|
+
]
|
17
|
+
end
|
12
18
|
end
|
13
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_setup_args args
|
22
|
+
args.merge!(
|
14
23
|
title: 'Welcome, Wagneer!',
|
15
24
|
optional_help: :show,
|
16
25
|
optional_menu: :never,
|
17
26
|
help_text: help_text,
|
18
|
-
buttons:
|
27
|
+
buttons: setup_button,
|
19
28
|
hidden: {
|
20
29
|
success: "REDIRECT: #{ Card.path_setting '/' }",
|
21
30
|
'card[type_id]' => Card.default_accounted_type_id,
|
22
|
-
'setup'=>true
|
31
|
+
'setup' => true
|
23
32
|
}
|
24
|
-
|
25
|
-
|
26
|
-
account = card.fetch trait: :account, new: {}
|
33
|
+
)
|
34
|
+
end
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
+
def help_text
|
37
|
+
text = '<h3>To get started, set up an account.</h3>'
|
38
|
+
if Card.config.action_mailer.perform_deliveries == false
|
39
|
+
text += <<-HTML
|
40
|
+
<br>WARNING: Email delivery is turned off.
|
41
|
+
Change settings in config/application.rb to send sign up notifications.'
|
42
|
+
HTML
|
36
43
|
end
|
44
|
+
text
|
37
45
|
end
|
38
|
-
end
|
39
46
|
|
47
|
+
def setup_button
|
48
|
+
button_tag 'Set up', disable_with: 'Setting up', situation: 'primary'
|
49
|
+
end
|
50
|
+
end
|
40
51
|
|
41
|
-
event :setup_as_bot, before: :check_permissions, on: :create,
|
52
|
+
event :setup_as_bot, before: :check_permissions, on: :create,
|
53
|
+
when: proc { Card::Env.params[:setup] } do
|
42
54
|
abort :failure unless Auth.needs_setup?
|
43
55
|
Auth.as_bot
|
44
56
|
# we need bot authority to set the initial administrator roles
|
@@ -46,27 +58,24 @@ event :setup_as_bot, before: :check_permissions, on: :create, when: proc{ |c| Ca
|
|
46
58
|
# flexibility and security when configuring initial setups
|
47
59
|
end
|
48
60
|
|
49
|
-
event :setup_first_user, before: :process_subcards, on: :create,
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
email, password = subcards.delete('+*account+*email'), subcards.delete('+*account+*password')
|
54
|
-
subcards['+*account'] = { '+*email'=>email, '+*password'=>password }
|
61
|
+
event :setup_first_user, before: :process_subcards, on: :create,
|
62
|
+
when: proc { Card::Env.params[:setup] } do
|
63
|
+
add_subcard 'signup alert email+*to', content: name
|
64
|
+
add_subfield :roles, content: Card[:administrator].name
|
55
65
|
end
|
56
66
|
|
57
|
-
event :signin_after_setup, before: :extend, on: :create,
|
58
|
-
|
67
|
+
event :signin_after_setup, before: :extend, on: :create,
|
68
|
+
when: proc { Card::Env.params[:setup] } do
|
59
69
|
Auth.signin id
|
60
70
|
end
|
61
71
|
|
62
|
-
def follow follow_name, option
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
72
|
+
def follow follow_name, option='*always'
|
73
|
+
return unless
|
74
|
+
(card = Card.fetch follow_name) &&
|
75
|
+
(set_card = card.default_follow_set_card) &&
|
76
|
+
(follow_rule_name = set_card.follow_rule_name(name)) &&
|
77
|
+
(follow_rule = Card.fetch follow_rule_name, new: {})
|
78
|
+
follow_rule.drop_item '*never'
|
79
|
+
follow_rule.add_item option
|
80
|
+
follow_rule.save!
|
70
81
|
end
|
71
|
-
|
72
|
-
|
@@ -73,7 +73,7 @@ describe Card::Set::All::Account do
|
|
73
73
|
ja_email = jadmin.account.email
|
74
74
|
|
75
75
|
Card::Env[:params] = { email: {subject: 'Hey Joe!', message: 'Come on in.'} }
|
76
|
-
Card.create name: 'Joe New', type_id: Card::UserID, '+*account'=>{ '+*email'=> 'joe@new.com' }
|
76
|
+
Card.create! name: 'Joe New', type_id: Card::UserID, '+*account'=>{ '+*email'=> 'joe@new.com' }
|
77
77
|
|
78
78
|
c = Card['Joe New']
|
79
79
|
u = Card::Auth[ 'joe@new.com' ]
|
@@ -10,10 +10,10 @@ describe Card::Set::All::RichHtml::Form do
|
|
10
10
|
expect(@card.format.type_field).to match(/<option [^>]*selected/)
|
11
11
|
tf=@card.format.type_field(no_current_type: true)
|
12
12
|
expect(tf).not_to match(/<option [^>]*selected/)
|
13
|
-
expect(tf.scan(/<option /).length).to eq(
|
13
|
+
expect(tf.scan(/<option /).length).to eq(29)
|
14
14
|
tf=@card.format.type_field
|
15
15
|
expect(tf).to match(/<option [^>]*selected/)
|
16
|
-
expect(tf.scan(/<option /).length).to eq(
|
16
|
+
expect(tf.scan(/<option /).length).to eq(29)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should get type list" do
|
@@ -1,73 +1,69 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
#FIXME need more specific assertions
|
3
|
+
# FIXME: need more specific assertions
|
4
4
|
|
5
5
|
describe Card::Set::Self::Signin do
|
6
|
-
|
7
6
|
before :each do
|
8
7
|
@card = Card[:signin]
|
9
8
|
end
|
10
|
-
|
9
|
+
|
11
10
|
it 'open view should have email and password fields' do
|
12
11
|
open_view = @card.format.render_open
|
13
12
|
expect(open_view).to match(/email/)
|
14
13
|
expect(open_view).to match(/password/)
|
15
|
-
|
16
14
|
end
|
17
|
-
|
15
|
+
|
18
16
|
it 'edit view should prompt for forgot password' do
|
19
17
|
edit_view = @card.format.render_edit
|
20
18
|
expect(edit_view).to match(/email/)
|
21
19
|
expect(edit_view).to match(/reset_password/)
|
22
20
|
end
|
23
|
-
|
21
|
+
|
24
22
|
it 'password reset success view should prompt to check email' do
|
25
23
|
rps_view = @card.format.render_reset_password_success
|
26
24
|
expect(rps_view).to match(/Check your email/)
|
27
25
|
end
|
28
|
-
|
26
|
+
|
29
27
|
it 'delete action should sign out account' do
|
30
28
|
expect(Card::Auth.current_id).to eq(Card['joe_user'].id)
|
31
29
|
@card.delete
|
32
30
|
expect(Card::Auth.current_id).to eq(Card::AnonymousID)
|
33
31
|
end
|
34
|
-
|
35
|
-
context
|
36
|
-
it '
|
37
|
-
@card.update_attributes! '+*email'=>'joe@admin.com',
|
32
|
+
|
33
|
+
context '#update' do
|
34
|
+
it 'triggerk signin with valid credentials' do
|
35
|
+
@card.update_attributes! '+*email' => 'joe@admin.com',
|
36
|
+
'+*password' => 'joe_pass'
|
38
37
|
expect(Card::Auth.current).to eq(Card['joe admin'])
|
39
38
|
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
it 'does not trigger signin with bad email' do
|
41
|
+
@card.update_attributes! '+*email' => 'schmoe@admin.com',
|
42
|
+
'+*password' => 'joe_pass'
|
44
43
|
expect(@card.errors[:signin].first).to match(/Unrecognized email/)
|
45
44
|
end
|
46
|
-
|
47
|
-
it '
|
48
|
-
@card.update_attributes! '+*email'=>'joe@admin.com',
|
45
|
+
|
46
|
+
it 'does not trigger signin with bad password' do
|
47
|
+
@card.update_attributes! '+*email' => 'joe@admin.com',
|
48
|
+
'+*password' => 'joe_fail'
|
49
49
|
expect(@card.errors[:signin].first).to match(/Wrong password/)
|
50
50
|
end
|
51
|
-
|
52
|
-
|
53
51
|
end
|
54
|
-
|
52
|
+
|
55
53
|
context '#reset password' do
|
56
54
|
before :each do
|
57
55
|
Card::Env.params[:reset_password] = true
|
58
56
|
end
|
59
|
-
|
57
|
+
|
60
58
|
it 'should be triggered by an update' do
|
61
|
-
#Card['joe admin'].account.token.should be_nil FIXME - this should be t
|
62
|
-
@card.update_attributes! '+*email'=>'joe@admin.com'
|
59
|
+
# Card['joe admin'].account.token.should be_nil FIXME - this should be t
|
60
|
+
@card.update_attributes! '+*email' => 'joe@admin.com'
|
63
61
|
expect(Card['joe admin'].account.token).not_to be_nil
|
64
62
|
end
|
65
|
-
|
63
|
+
|
66
64
|
it 'should return an error if email is not found' do
|
67
|
-
@card.update_attributes '+*email'=>'schmoe@admin.com'
|
65
|
+
@card.update_attributes '+*email' => 'schmoe@admin.com'
|
68
66
|
expect(@card.errors[:email].first).to match(/not recognized/)
|
69
67
|
end
|
70
68
|
end
|
71
|
-
|
72
69
|
end
|
73
|
-
|
@@ -172,8 +172,6 @@ describe Card::Set::Type::EmailTemplate do
|
|
172
172
|
|
173
173
|
it 'handles contextual name in address search' do
|
174
174
|
update_field '*from', content: '{"left":"_self", "right":"email"}', type: 'Search'
|
175
|
-
update_field '*from', content: '{"left":"_self", "right":"email"}' #FIXME: have to do this twice to get the right content.
|
176
|
-
# After the first update the content is empty
|
177
175
|
expect(subject[:from]).to eq "gary@gary.com"
|
178
176
|
end
|
179
177
|
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
describe Card::Set::Type::List do
|
4
|
+
subject { Card.fetch('Parry Hotter+authors').item_names.sort }
|
5
|
+
before do
|
6
|
+
Card::Auth.as_bot do
|
7
|
+
Card.create! name: 'Stam Broker+books', type: 'listed by'
|
8
|
+
Card.create!(
|
9
|
+
name: 'Parry Hotter+authors',
|
10
|
+
content: "[[Darles Chickens]]\n[[Stam Broker]]",
|
11
|
+
type: 'list'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
describe 'Parry Hotter+authors' do
|
16
|
+
context "when 'Parry Hotter' is added to Joe-Ann Rolwings's books" do
|
17
|
+
before do
|
18
|
+
Card.create! name: 'Joe-Ann Rolwing', type: 'author'
|
19
|
+
Card.create!(
|
20
|
+
name: 'Joe-Ann Rolwing+books', type: 'listed by',
|
21
|
+
content: '[[Parry Hotter]]'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
it do
|
25
|
+
is_expected.to eq(
|
26
|
+
['Darles Chickens', 'Joe-Ann Rolwing', 'Stam Broker']
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when 'Parry Hotter' is dropped from Stam Brokers's books" do
|
32
|
+
before do
|
33
|
+
Card::Auth.as_bot do
|
34
|
+
Card['Stam Brokers+books'].update_attributes!(
|
35
|
+
content: '[[50 grades of shy]]'
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
it { is_expected.to eq ['Darles Chickens'] }
|
40
|
+
end
|
41
|
+
context 'when Stam Broker is deleted' do
|
42
|
+
before do
|
43
|
+
Card['Stam Broker'].delete
|
44
|
+
end
|
45
|
+
it { is_expected.to eq ['Darles Chickens', 'Stam Broker'] }
|
46
|
+
end
|
47
|
+
context 'when the cardtype of Stam Broker changed' do
|
48
|
+
it 'raises an error' do
|
49
|
+
@card = Card['Stam Broker']
|
50
|
+
@card.update_attributes type_id: Card::BasicID
|
51
|
+
expect(@card.errors[:type].first).to match(
|
52
|
+
/can't be changed because .+ is referenced by list/
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
context 'when the name of Parry Hotter changed to Parry Moppins' do
|
57
|
+
before do
|
58
|
+
Card['Parry Hotter'].update_attributes! name: 'Parry Moppins'
|
59
|
+
end
|
60
|
+
subject do
|
61
|
+
Card.fetch('Parry Moppins+authors').item_names.sort
|
62
|
+
end
|
63
|
+
it { is_expected.to eq ['Darles Chickens', 'Stam Broker'] }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when the name of Stam Broker changed to Stam Trader' do
|
67
|
+
before do
|
68
|
+
Card['Stam Broker'].update_attributes!(
|
69
|
+
name: 'Stam Trader', update_referencers: true
|
70
|
+
)
|
71
|
+
end
|
72
|
+
it { is_expected.to eq ['Darles Chickens', 'Stam Trader'] }
|
73
|
+
end
|
74
|
+
|
75
|
+
# if content is invalid then fail
|
76
|
+
context 'when Stam Broker+books changes to Stam Broker+poems' do
|
77
|
+
it 'raises error because content is invalid' do
|
78
|
+
expect do
|
79
|
+
Card['Stam Broker+books'].update_attributes! name: 'Stam Broker+poems'
|
80
|
+
end.to raise_error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
context 'when Stam Broker+books changes to Stam Broker+not a type' do
|
84
|
+
it 'raises error because name needs cardtype name as right part' do
|
85
|
+
expect do
|
86
|
+
Card['Stam Broker+books'].update_attributes!(
|
87
|
+
name: 'Stam Broker+not a type'
|
88
|
+
)
|
89
|
+
end.to raise_error
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when the cartype of Parry Hotter changed' do
|
94
|
+
before do
|
95
|
+
Card['Parry Hotter'].update_attributes! type_id: Card::BasicID
|
96
|
+
end
|
97
|
+
it { is_expected.to eq ['Darles Chickens', 'Stam Broker'] }
|
98
|
+
end
|
99
|
+
context 'when Parry Hotter+authors to Parry Hotter+basics' do
|
100
|
+
it 'raises error because content is invalid' do
|
101
|
+
expect do
|
102
|
+
Card['Parry Hotter+authors'].update_attributes!(
|
103
|
+
name: 'Parry Hotter+basics'
|
104
|
+
)
|
105
|
+
end.to raise_error
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "'listed by' entry added that doesn't have a list" do
|
111
|
+
context "when '50 grades of shy is added to Stam Broker's books" do
|
112
|
+
before do
|
113
|
+
Card['Stam Broker+books'].add_item! '50 grades of shy'
|
114
|
+
end
|
115
|
+
it "creates '50 grades of shy+authors" do
|
116
|
+
authors = Card['50 grades of shy+authors']
|
117
|
+
expect(authors).to be_truthy
|
118
|
+
expect(authors.item_names).to eq ['Stam Broker']
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'when the name of the cardtype books changed' do
|
124
|
+
before do
|
125
|
+
Card['book'].update_attributes!(
|
126
|
+
type_id: Card::BasicID, update_referencers: true
|
127
|
+
)
|
128
|
+
end
|
129
|
+
it { is_expected.to eq ['Darles Chickens', 'Stam Broker'] }
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'when the name of the cardtype authors changed' do
|
133
|
+
before do
|
134
|
+
Card['author'].update_attributes!(
|
135
|
+
type_id: Card::BasicID, update_referencers: true
|
136
|
+
)
|
137
|
+
end
|
138
|
+
it { is_expected.to eq ['Darles Chickens', 'Stam Broker'] }
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
describe Card::Set::Type::ListedBy do
|
4
|
+
let(:listed_by) { Card.fetch('Darles Chickens+books').item_names.sort }
|
5
|
+
before do
|
6
|
+
Card::Auth.as_bot do
|
7
|
+
Card.create!(
|
8
|
+
name: 'Parry Hotter+authors',
|
9
|
+
content: '[[Darles Chickens]]',
|
10
|
+
type: 'list'
|
11
|
+
)
|
12
|
+
Card.create!(
|
13
|
+
name: '50 grades of shy+authors',
|
14
|
+
content: "[[Darles Chickens]]\n[[Stam Broker]]",
|
15
|
+
type: 'list'
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
it "doesn't allow non-cardtype as right part" do
|
20
|
+
expect do
|
21
|
+
Card['Parry Hotter+authors'].update_attributes!(
|
22
|
+
name: 'Parry Hotter+hidden'
|
23
|
+
)
|
24
|
+
end.to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when Darles Chickens is in the author list of \
|
28
|
+
"Parry Hotter" and "50 grades of shy"' do
|
29
|
+
describe 'Darles Chickens+books' do
|
30
|
+
subject { listed_by }
|
31
|
+
it { is_expected.to eq ['50 grades of shy', 'Parry Hotter'] }
|
32
|
+
|
33
|
+
it 'is recorded in the reference table' do
|
34
|
+
search_result = Card.search(
|
35
|
+
right_plus: ['books', link_to: '50 grades of shy'],
|
36
|
+
return: :name
|
37
|
+
)
|
38
|
+
expect(search_result.sort).to eq ['Darles Chickens', 'Stam Broker']
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when Darles Chickens is removed from Parry Hotter's list" do
|
42
|
+
before do
|
43
|
+
Card['Parry Hotter+authors'].update_attributes!(
|
44
|
+
content: '[[Stam Broker]]'
|
45
|
+
)
|
46
|
+
end
|
47
|
+
it { is_expected.to eq ['50 grades of shy'] }
|
48
|
+
end
|
49
|
+
context 'when Parry Hotter is deleted' do
|
50
|
+
before do
|
51
|
+
Card['Parry Hotter'].delete
|
52
|
+
end
|
53
|
+
it { is_expected.to eq ['50 grades of shy'] }
|
54
|
+
end
|
55
|
+
context 'when a new book is created that lists Darles Chickens' do
|
56
|
+
before do
|
57
|
+
Card::Auth.as_bot do
|
58
|
+
Card.create!(
|
59
|
+
name: 'Adventures of Buckleharry Finn',
|
60
|
+
type: 'book',
|
61
|
+
subcards: {
|
62
|
+
'+authors' => { content: '[[Darles Chickens]]', type: 'list' }
|
63
|
+
}
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
it do
|
68
|
+
is_expected.to eq(
|
69
|
+
['50 grades of shy', 'Adventures of Buckleharry Finn', 'Parry Hotter']
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
context "when Darles Chickens is added to a book's list" do
|
74
|
+
before do
|
75
|
+
Card::Auth.as_bot do
|
76
|
+
Card.create!(
|
77
|
+
name: 'Adventures of Buckleharry Finn',
|
78
|
+
type: 'book',
|
79
|
+
subcards: {
|
80
|
+
'+authors' => { content: '[[Stam Broker]]', type: 'list' }
|
81
|
+
}
|
82
|
+
)
|
83
|
+
Card.fetch('Adventures of Buckleharry Finn+authors')
|
84
|
+
.update_attributes!(content: '[[Darles Chickens]]')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
it do
|
88
|
+
is_expected.to eq(
|
89
|
+
[
|
90
|
+
'50 grades of shy',
|
91
|
+
'Adventures of Buckleharry Finn',
|
92
|
+
'Parry Hotter'
|
93
|
+
]
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when the cardtype of Parry Hotter changed' do
|
99
|
+
before do
|
100
|
+
Card['Parry Hotter'].update_attributes! type_id: Card::BasicID
|
101
|
+
end
|
102
|
+
it { is_expected.to eq ['50 grades of shy'] }
|
103
|
+
end
|
104
|
+
context 'when the name of Parry Hotter changed to Parry Moppins' do
|
105
|
+
before do
|
106
|
+
Card::Auth.as_bot do
|
107
|
+
Card['Parry Hotter'].update_attributes!(
|
108
|
+
name: 'Parry Moppins',
|
109
|
+
update_referencers: true
|
110
|
+
)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
it { is_expected.to eq ['50 grades of shy','Parry Moppins'] }
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'when the name of Darles Chickens changed' do
|
117
|
+
before do
|
118
|
+
Card['Darles Chickens'].update_attributes!(
|
119
|
+
name: 'Darles Eggs',
|
120
|
+
update_referencers: true
|
121
|
+
)
|
122
|
+
end
|
123
|
+
subject { Card.fetch('Darles Eggs+books').item_names.sort }
|
124
|
+
it { is_expected.to eq ['50 grades of shy', 'Parry Hotter'] }
|
125
|
+
end
|
126
|
+
context 'when the cartype of Darles Chickens changed' do
|
127
|
+
it 'raises error' do
|
128
|
+
expect do
|
129
|
+
Card['Darles Chickens'].update_attributes! type_id: Card::BasicID
|
130
|
+
end.to raise_error
|
131
|
+
end
|
132
|
+
end
|
133
|
+
context 'when the name of Darles Chickens+books changed' do
|
134
|
+
subject { Card.fetch('Darles Chickens+authors').item_names.sort }
|
135
|
+
before do
|
136
|
+
Card['Darles Chickens+books'].update_attributes!(
|
137
|
+
name: 'Darles Chickens+authors'
|
138
|
+
)
|
139
|
+
end
|
140
|
+
it { is_expected.to eq [] }
|
141
|
+
end
|
142
|
+
context 'when the name of the cardtype books changed' do
|
143
|
+
before do
|
144
|
+
Card['book'].update_attributes! name: 'literature'
|
145
|
+
end
|
146
|
+
subject { Card.fetch('Darles Chickens+literature').item_names.sort }
|
147
|
+
it { is_expected.to eq ['50 grades of shy', 'Parry Hotter'] }
|
148
|
+
end
|
149
|
+
context 'when the name of the cardtype authors changed' do
|
150
|
+
before do
|
151
|
+
Card['author'].update_attributes! type_id: Card::BasicID
|
152
|
+
end
|
153
|
+
it { is_expected.to eq ['50 grades of shy', 'Parry Hotter'] }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|