card 1.17.1 → 1.17.2
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/initializers/recaptcha.rb +27 -19
- data/db/migrate/20160122153608_new_indeces.rb +10 -0
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +2 -2
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +2 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +4 -2
- data/db/schema.rb +5 -1
- data/db/version.txt +1 -1
- data/lib/card.rb +3 -3
- data/lib/card/reference.rb +68 -52
- data/mod/01_core/chunk/query_reference.rb +1 -1
- data/mod/01_core/set/all/collection.rb +1 -1
- data/mod/01_core/set/all/name.rb +27 -65
- data/mod/01_core/set/all/pattern.rb +6 -3
- data/mod/01_core/set/all/references.rb +135 -62
- data/mod/01_core/set/all/tracked_attributes.rb +1 -1
- data/mod/01_core/set/all/utils.rb +2 -2
- data/mod/01_core/spec/set/all/references_spec.rb +4 -3
- data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +16 -22
- data/mod/01_history/lib/card/act.rb +32 -30
- data/mod/01_history/lib/card/change.rb +26 -18
- data/mod/01_history/set/all/history.rb +1 -1
- data/mod/04_settings/set/right/structure.rb +1 -1
- data/mod/05_email/set/all/notify.rb +1 -1
- data/mod/05_email/spec/set/right/followers_spec.rb +1 -1
- data/mod/05_standard/set/all/rich_html/editing.rb +42 -45
- data/mod/05_standard/set/type/list.rb +2 -2
- data/mod/05_standard/spec/set/self/all_spec.rb +3 -3
- data/mod/05_standard/spec/set/type/list_spec.rb +3 -3
- data/mod/05_standard/spec/set/type/listed_by_spec.rb +2 -2
- data/mod/05_standard/spec/set/type/search_type_spec.rb +1 -1
- data/spec/lib/card/reference_spec.rb +30 -28
- data/spec/models/card/trash_spec.rb +63 -63
- data/spec/models/card/type_transition_spec.rb +34 -35
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d772d98ac5c860f29c6c27e3e6d0a259f6c8e7a7
|
4
|
+
data.tar.gz: a7e78fc4a0d9c36fafd07efd6d90183df1b707aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136c7897642c4e96cd070a08d474f2b7b199175495dce04dbcdc65b5768b49fb8a897844117167c49e68a766117fc122afefb73b95c5c15adf01534241c03ce8
|
7
|
+
data.tar.gz: 1c1c8077a10fc53451bbfa5890367f6ee27a6e7a25a9461abdc1cffb002aef0c7e7ef85c59ae82a764f0fef28989a2fb7a2edf231a3b69ce4c723f01c16f3fd8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.17.
|
1
|
+
1.17.2
|
@@ -1,24 +1,32 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
|
3
|
+
# card config overrides application.rb config overrides default
|
4
|
+
def load_recaptcha_config setting
|
5
|
+
setting = "recaptcha_#{setting}".to_sym
|
6
|
+
Cardio.config.send("#{setting}=",
|
7
|
+
load_recaptcha_card_config(setting) || # card content
|
8
|
+
Cardio.config.send(setting) || # application.rb
|
9
|
+
Card::Auth::DEFAULT_RECAPTCHA_SETTINGS[setting])
|
10
|
+
end
|
11
|
+
|
12
|
+
def card_table_ready?
|
13
|
+
# FIXME: this test should be more generally usable
|
14
|
+
ActiveRecord::Base.connection.table_exists?('cards') &&
|
15
|
+
Card.ancestors.include?(ActiveRecord::Base)
|
16
|
+
end
|
17
|
+
|
18
|
+
# use if card with value is present
|
19
|
+
def load_recaptcha_card_config setting
|
20
|
+
card = Card.find_by_codename setting
|
21
|
+
card && card.db_content.present? && card.db_content
|
11
22
|
end
|
12
23
|
|
13
24
|
Recaptcha.configure do |config|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
config.private_key = Cardio.config.recaptcha_private_key
|
22
|
-
# config.api_version = 'v1' if config.respond_to?(:api_version=)
|
23
|
-
config.proxy = Cardio.config.recaptcha_proxy
|
25
|
+
# the seed task runs initializers so we have to check
|
26
|
+
# if the cards table is ready before we use it here
|
27
|
+
if card_table_ready?
|
28
|
+
[:public_key, :private_key, :proxy].each do |setting|
|
29
|
+
config.send "#{setting}=", load_recaptcha_config(setting)
|
30
|
+
end
|
31
|
+
end
|
24
32
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# add new indeces for datetime and ref_type fields
|
2
|
+
class NewIndeces < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
add_index 'card_references', ['ref_type'],
|
5
|
+
name: 'card_references_ref_type_index' # using: :btree
|
6
|
+
add_index 'cards', ['created_at'], name: 'cards_created_at_index'
|
7
|
+
add_index 'cards', ['updated_at'], name: 'cards_updated_at_index'
|
8
|
+
add_index 'card_acts', ['acted_at'], name: 'acts_acted_at_index'
|
9
|
+
end
|
10
|
+
end
|
@@ -16,11 +16,11 @@ class RenamingForMenu < Card::CoreMigration
|
|
16
16
|
renames.each do |oldname, newname|
|
17
17
|
puts "updating: #{oldname}"
|
18
18
|
c = Card[oldname]
|
19
|
-
c.
|
19
|
+
c.update_referers = true
|
20
20
|
c.name = newname
|
21
21
|
c.save!
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
codenames = %w{
|
25
25
|
by_name
|
26
26
|
by_update
|
@@ -17,7 +17,7 @@ class AccountRequestsToSignups < Card::CoreMigration
|
|
17
17
|
# rename Account Request to "Sign up"
|
18
18
|
new_signup = Card[:account_request]
|
19
19
|
new_signup.name = newname
|
20
|
-
new_signup.
|
20
|
+
new_signup.update_referers = true
|
21
21
|
new_signup.codename = :signup
|
22
22
|
new_signup.save!
|
23
23
|
|
@@ -27,7 +27,7 @@ class AccountRequestsToSignups < Card::CoreMigration
|
|
27
27
|
thanks = Card[:thanks]
|
28
28
|
if (signup_thanks = Card["#{old_signup.name}+#{thanks.name}"])
|
29
29
|
signup_thanks.name = "#{new_signup.name}+#{Card[:type].name}+#{thanks.name}"
|
30
|
-
signup_thanks.
|
30
|
+
signup_thanks.update_referers = true
|
31
31
|
signup_thanks.save!
|
32
32
|
end
|
33
33
|
|
@@ -5,7 +5,7 @@ class ImportBootstrapLayout < Card::CoreMigration
|
|
5
5
|
layout = Card.fetch "Default Layout"
|
6
6
|
if layout
|
7
7
|
layout.name = "Classic Layout"
|
8
|
-
layout.
|
8
|
+
layout.update_referers = true
|
9
9
|
layout.save!
|
10
10
|
end
|
11
11
|
|
@@ -32,7 +32,7 @@ class ImportBootstrapLayout < Card::CoreMigration
|
|
32
32
|
old_func = Card[:style_functional]
|
33
33
|
old_func.name = 'style: cards'
|
34
34
|
old_func.codename = 'style_cards'
|
35
|
-
old_func.
|
35
|
+
old_func.update_referers = true
|
36
36
|
old_func.save!
|
37
37
|
|
38
38
|
old_stand = Card[:style_standard]
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
class CreateReferencesForSearchCards < Card::CoreMigration
|
4
4
|
def up
|
5
|
-
Card.where(
|
6
|
-
|
5
|
+
Card.where(
|
6
|
+
type_id: Card::SearchTypeID
|
7
|
+
).find_each.with_index do |card, index|
|
8
|
+
card.update_references_out
|
7
9
|
puts "completed #{index} search cards" if index % 100 == 0
|
8
10
|
end
|
9
11
|
end
|
data/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160122153608) do
|
15
15
|
|
16
16
|
create_table "card_actions", force: :cascade do |t|
|
17
17
|
t.integer "card_id", limit: 4
|
@@ -32,6 +32,7 @@ ActiveRecord::Schema.define(version: 20151105225559) do
|
|
32
32
|
t.string "ip_address", limit: 255
|
33
33
|
end
|
34
34
|
|
35
|
+
add_index "card_acts", ["acted_at"], name: "acts_acted_at_index", using: :btree
|
35
36
|
add_index "card_acts", ["actor_id"], name: "card_acts_actor_id_index", using: :btree
|
36
37
|
add_index "card_acts", ["card_id"], name: "card_acts_card_id_index", using: :btree
|
37
38
|
|
@@ -51,6 +52,7 @@ ActiveRecord::Schema.define(version: 20151105225559) do
|
|
51
52
|
t.integer "present", limit: 4
|
52
53
|
end
|
53
54
|
|
55
|
+
add_index "card_references", ["ref_type"], name: "card_references_ref_type_index", using: :btree
|
54
56
|
add_index "card_references", ["referee_id"], name: "card_references_referee_id_index", using: :btree
|
55
57
|
add_index "card_references", ["referee_key"], name: "card_references_referee_key_index", using: :btree
|
56
58
|
add_index "card_references", ["referer_id"], name: "card_references_referer_id_index", using: :btree
|
@@ -84,12 +86,14 @@ ActiveRecord::Schema.define(version: 20151105225559) do
|
|
84
86
|
t.text "db_content", limit: 16777215
|
85
87
|
end
|
86
88
|
|
89
|
+
add_index "cards", ["created_at"], name: "cards_created_at_index", using: :btree
|
87
90
|
add_index "cards", ["key"], name: "cards_key_index", unique: true, using: :btree
|
88
91
|
add_index "cards", ["left_id"], name: "cards_left_id_index", using: :btree
|
89
92
|
add_index "cards", ["name"], name: "cards_name_index", using: :btree
|
90
93
|
add_index "cards", ["read_rule_id"], name: "cards_read_rule_id_index", using: :btree
|
91
94
|
add_index "cards", ["right_id"], name: "cards_right_id_index", using: :btree
|
92
95
|
add_index "cards", ["type_id"], name: "cards_type_id_index", using: :btree
|
96
|
+
add_index "cards", ["updated_at"], name: "cards_updated_at_index", using: :btree
|
93
97
|
|
94
98
|
create_table "schema_migrations_core_cards", id: false, force: :cascade do |t|
|
95
99
|
t.string "version", limit: 255, null: false
|
data/db/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
20160122153608
|
data/lib/card.rb
CHANGED
@@ -33,8 +33,8 @@ class Card < ActiveRecord::Base
|
|
33
33
|
require_dependency 'card/subcards'
|
34
34
|
require_dependency 'card/view_cache'
|
35
35
|
|
36
|
-
has_many :
|
37
|
-
has_many :
|
36
|
+
has_many :references_in, class_name: :Reference, foreign_key: :referee_id
|
37
|
+
has_many :references_out, class_name: :Reference, foreign_key: :referer_id
|
38
38
|
has_many :acts, -> { order :id }
|
39
39
|
has_many :actions, -> { where(draft: [nil, false]).order :id }
|
40
40
|
has_many :drafts, -> { where(draft: true).order :id }, class_name: :Action
|
@@ -48,7 +48,7 @@ class Card < ActiveRecord::Base
|
|
48
48
|
:action, :supercard, :superleft,
|
49
49
|
:current_act, :current_action,
|
50
50
|
:comment, :comment_author, # obviated soon
|
51
|
-
:
|
51
|
+
:update_referers, # wrong mechanism for this
|
52
52
|
:update_all_users, # if the above is wrong then this one too
|
53
53
|
:silent_change, # and this probably too
|
54
54
|
:remove_rule_stash,
|
data/lib/card/reference.rb
CHANGED
@@ -1,68 +1,84 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
class Card
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
class Card
|
4
|
+
# a Reference is a directional relationship from one card (the referer)
|
5
|
+
# to another (the referee).
|
6
|
+
class Reference < ActiveRecord::Base
|
7
|
+
class << self
|
8
|
+
# bulk insert improves performance considerably
|
9
|
+
# array takes form [ [referer_id, referee_id, referee_key, ref_type], ...]
|
10
|
+
def mass_insert array
|
11
|
+
return if array.empty?
|
12
|
+
value_statements = array.map { |values| "\n(#{values.join ', '})" }
|
13
|
+
sql = 'INSERT into card_references '\
|
14
|
+
'(referer_id, referee_id, referee_key, ref_type) '\
|
15
|
+
"VALUES #{value_statements.join ', '}"
|
16
|
+
Card.connection.execute sql
|
17
|
+
end
|
11
18
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
# map existing reference to name to card via id
|
20
|
+
def map_referees referee_key, referee_id
|
21
|
+
where(referee_key: referee_key).update_all referee_id: referee_id
|
22
|
+
end
|
16
23
|
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
# references no longer refer to card, so remove id
|
25
|
+
def unmap_referees referee_id
|
26
|
+
where(referee_id: referee_id).update_all referee_id: nil
|
27
|
+
end
|
20
28
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
29
|
+
# find all references to missing (eg deleted) cards and reset them
|
30
|
+
def unmap_if_referee_missing
|
31
|
+
joins(
|
32
|
+
'LEFT JOIN cards ON card_references.referee_id = cards.id'
|
33
|
+
).where(
|
34
|
+
'(cards.id IS NULL OR cards.trash IS TRUE) AND referee_id IS NOT NULL'
|
35
|
+
).update_all referee_id: nil
|
36
|
+
end
|
25
37
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
38
|
+
# remove all references from missing (eg deleted) cards
|
39
|
+
def delete_if_referer_missing
|
40
|
+
joins(
|
41
|
+
'LEFT JOIN cards ON card_references.referer_id = cards.id'
|
42
|
+
).where(
|
43
|
+
'cards.id IS NULL'
|
44
|
+
).find_in_batches do |group|
|
45
|
+
# used to be .delete_all here, but that was failing on large dbs
|
46
|
+
puts 'deleting batch of references'
|
47
|
+
where("id in (#{group.map(&:id).join ','})").delete_all
|
48
|
+
end
|
33
49
|
end
|
34
|
-
update_existing_key card, newname
|
35
|
-
end
|
36
50
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
51
|
+
# repair references one by one (delete, create, delete, create...)
|
52
|
+
# slower, but better than #repair_all for use on running sites
|
53
|
+
def repair_all
|
54
|
+
delete_if_referer_missing
|
55
|
+
Card.where(trash: false).find_each do |card|
|
56
|
+
Rails.logger.info "updating references from #{card}"
|
57
|
+
card.include_set_modules
|
58
|
+
card.update_references_out
|
59
|
+
end
|
60
|
+
end
|
41
61
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
62
|
+
# delete all references, then recreate them one by one
|
63
|
+
# faster than #repair_all, but not recommended for use on running sites
|
64
|
+
def recreate_all
|
65
|
+
delete_all
|
66
|
+
Card.where(trash: false).find_each do |card|
|
67
|
+
Rails.logger.info "updating references from #{card}"
|
68
|
+
card.include_set_modules
|
69
|
+
card.create_references_out
|
70
|
+
end
|
71
|
+
end
|
48
72
|
end
|
49
73
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
).where(
|
54
|
-
'cards.id IS NULL'
|
55
|
-
).delete_all
|
74
|
+
# card that refers
|
75
|
+
def referer
|
76
|
+
Card[referer_id]
|
56
77
|
end
|
57
78
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
Card.where(trash: false).find_each do |card|
|
62
|
-
Rails.logger.info "Repairing references for '#{card.name}'" \
|
63
|
-
"(id: #{card.id}) ... "
|
64
|
-
card.update_references
|
65
|
-
end
|
79
|
+
# card that is referred to
|
80
|
+
def referee
|
81
|
+
Card[referee_id]
|
66
82
|
end
|
67
83
|
end
|
68
84
|
end
|
data/mod/01_core/set/all/name.rb
CHANGED
@@ -10,7 +10,7 @@ module ClassMethods
|
|
10
10
|
if rename == :old
|
11
11
|
# name conflict resolved; original name can be used
|
12
12
|
Card[name].update_attributes! name: uniq_name,
|
13
|
-
|
13
|
+
update_referers: true
|
14
14
|
name
|
15
15
|
else
|
16
16
|
uniq_name
|
@@ -71,39 +71,35 @@ def contextual_name
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def relative_name context_name=nil
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
cardname.relative_name(context_name)
|
74
|
+
context_name ||= @supercard.cardname if @supercard
|
75
|
+
cardname.relative_name context_name
|
78
76
|
end
|
79
77
|
|
80
78
|
def absolute_name context_name=nil
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
cardname.absolute_name(context_name)
|
79
|
+
context_name ||= @supercard.cardname if @supercard
|
80
|
+
cardname.absolute_name context_name
|
85
81
|
end
|
86
82
|
|
87
83
|
def left *args
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
84
|
+
case
|
85
|
+
when simple? then nil
|
86
|
+
when @superleft then @superleft
|
87
|
+
when name_changed? && name.to_name.trunk_name.key == name_was.to_name.key
|
88
|
+
nil # prevent recursion when, eg, renaming A+B to A+B+C
|
89
|
+
else
|
90
|
+
Card.fetch cardname.left, *args
|
95
91
|
end
|
96
92
|
end
|
97
93
|
|
98
94
|
def right *args
|
99
|
-
Card.fetch(cardname.right, *args)
|
95
|
+
Card.fetch(cardname.right, *args) unless simple?
|
100
96
|
end
|
101
97
|
|
102
98
|
def [] *args
|
103
99
|
case args[0]
|
104
100
|
when Fixnum, Range
|
105
101
|
fetch_name = Array.wrap(cardname.parts[args[0]]).compact.join '+'
|
106
|
-
Card.fetch(fetch_name, args[1] || {})
|
102
|
+
Card.fetch(fetch_name, args[1] || {}) unless simple?
|
107
103
|
else
|
108
104
|
super
|
109
105
|
end
|
@@ -141,22 +137,22 @@ def child_names parent_name=nil, side=nil
|
|
141
137
|
"(#{side}) children of #{parent_name}")
|
142
138
|
end
|
143
139
|
|
144
|
-
|
140
|
+
# ids of children and children's children
|
141
|
+
def descendant_ids parent_id=nil
|
145
142
|
return [] if new_card?
|
146
|
-
|
143
|
+
parent_id ||= id
|
147
144
|
Auth.as_bot do
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
145
|
+
child_ids = Card.search part: parent_id, return: :id
|
146
|
+
child_descendant_ids = child_ids.map { |cid| descendant_ids cid }
|
147
|
+
(child_ids + child_descendant_ids).flatten.uniq
|
152
148
|
end
|
153
149
|
end
|
154
150
|
|
151
|
+
# children and children's children
|
152
|
+
# NOTE - set modules are not loaded
|
153
|
+
# -- should only be used for name manipulations
|
155
154
|
def descendants
|
156
|
-
|
157
|
-
# NOTE - set modules are not loaded
|
158
|
-
# -- should only be used for name manipulations
|
159
|
-
@descendants ||= descendant_names.map { |name| Card.quick_fetch name }
|
155
|
+
@descendants ||= descendant_ids.map { |id| Card.quick_fetch id }
|
160
156
|
end
|
161
157
|
|
162
158
|
def repair_key
|
@@ -208,7 +204,7 @@ event :validate_name, before: :approve, on: :save do
|
|
208
204
|
|
209
205
|
unless cdname.valid?
|
210
206
|
errors.add :name, 'may not contain any of the following characters: ' \
|
211
|
-
"#{
|
207
|
+
"#{Card::Name.banned_array * ' '}"
|
212
208
|
end
|
213
209
|
# this is to protect against using a plus card as a tag
|
214
210
|
if cdname.junction? && simple? && id &&
|
@@ -290,12 +286,6 @@ def suspend_name name
|
|
290
286
|
end
|
291
287
|
|
292
288
|
event :cascade_name_changes, after: :store, on: :update, changed: :name do
|
293
|
-
# Rails.logger.info "------------------- #{name_was} CASCADE #{self.name} " \
|
294
|
-
# " -------------------------------------"
|
295
|
-
# handle strings from cgi
|
296
|
-
self.update_referencers = false if update_referencers == 'false'
|
297
|
-
Card::Reference.update_on_rename self, name, self.update_referencers
|
298
|
-
|
299
289
|
des = descendants
|
300
290
|
@descendants = nil # reset
|
301
291
|
|
@@ -306,36 +296,8 @@ event :cascade_name_changes, after: :store, on: :update, changed: :name do
|
|
306
296
|
Card.expire de.name # old name
|
307
297
|
newname = de.cardname.replace_part name_was, name
|
308
298
|
Card.where(id: de.id).update_all name: newname.to_s, key: newname.key
|
309
|
-
|
299
|
+
de.update_referers = update_referers
|
300
|
+
de.refresh_references_in
|
310
301
|
Card.expire newname
|
311
302
|
end
|
312
|
-
execute_referencers_update(des) if update_referencers
|
313
|
-
end
|
314
|
-
|
315
|
-
def execute_referencers_update descendants
|
316
|
-
Auth.as_bot do
|
317
|
-
[name_referencers(name_was) + descendants.map(&:referencers)]
|
318
|
-
.flatten.uniq.each do |card|
|
319
|
-
# FIXME: using 'name_referencers' instead of plain 'referencers' for self
|
320
|
-
# because there are cases where trunk and tag
|
321
|
-
# have already been saved via association by this point and therefore
|
322
|
-
# referencers misses things
|
323
|
-
# eg. X includes Y, and Y is renamed to X+Z. When X+Z is saved, X is
|
324
|
-
# first updated as a trunk before X+Z gets to this point.
|
325
|
-
# so at this time X is still including Y, which does not exist.
|
326
|
-
# therefore #referencers doesn't find it, but name_referencers(old_name)
|
327
|
-
# does.
|
328
|
-
# some even more complicated scenario probably breaks on the descendants,
|
329
|
-
# so this probably needs a more thoughtful refactor
|
330
|
-
# aligning the dependent saving with the name cascading
|
331
|
-
|
332
|
-
Rails.logger.debug "------------------ UPDATE REFERER #{card.name} " \
|
333
|
-
'------------------------'
|
334
|
-
unless card == self || card.structure
|
335
|
-
card = card.refresh
|
336
|
-
card.db_content = card.replace_references name_was, name
|
337
|
-
card.save!
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
303
|
end
|