card 1.101.3 → 1.101.4

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/02_patches/active_record.rb +1 -1
  4. data/config/locales/en.yml +155 -378
  5. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
  6. data/lib/card.rb +15 -2
  7. data/lib/card/auth.rb +5 -2
  8. data/lib/card/auth/current.rb +39 -100
  9. data/lib/card/auth/proxy.rb +36 -16
  10. data/lib/card/auth/token.rb +6 -0
  11. data/lib/card/cache/all.rb +83 -0
  12. data/lib/card/cache/card_class.rb +41 -0
  13. data/lib/card/cache/persistent.rb +3 -34
  14. data/lib/card/cache/persistent_class.rb +28 -0
  15. data/lib/card/codename.rb +1 -1
  16. data/lib/card/content.rb +16 -2
  17. data/lib/card/content/all.rb +59 -0
  18. data/lib/card/director/act_direction.rb +4 -0
  19. data/lib/card/director/all.rb +61 -0
  20. data/lib/card/director/card_class.rb +18 -0
  21. data/lib/card/director/phases.rb +0 -1
  22. data/lib/card/dirty.rb +13 -3
  23. data/lib/card/env/success.rb +14 -14
  24. data/lib/card/env/success/target.rb +9 -11
  25. data/lib/card/error.rb +1 -1
  26. data/lib/card/fetch/all.rb +32 -0
  27. data/lib/card/fetch/card_class.rb +147 -0
  28. data/lib/card/format.rb +1 -1
  29. data/lib/card/format/error.rb +3 -3
  30. data/lib/card/format/nest.rb +1 -1
  31. data/lib/card/format/nest/fetch.rb +1 -1
  32. data/lib/card/lexicon.rb +2 -2
  33. data/lib/card/name/all.rb +8 -0
  34. data/lib/card/name/all/descendants.rb +6 -3
  35. data/lib/card/name/card_class.rb +26 -0
  36. data/lib/card/reference/all.rb +131 -0
  37. data/lib/card/rule/all.rb +75 -0
  38. data/lib/card/set/event/all.rb +95 -0
  39. data/lib/card/set/event/skip_and_trigger.rb +89 -0
  40. data/lib/card/set/pattern/all.rb +63 -0
  41. data/lib/card/subcards/all.rb +103 -0
  42. data/lib/cardio/migration/import.rb +1 -1
  43. data/lib/cardio/utils.rb +5 -3
  44. data/mod/admin/set/self/admin_info.rb +3 -5
  45. data/mod/admin/set/self/trash.rb +2 -2
  46. data/mod/core/set/all/autoname.rb +17 -0
  47. data/mod/core/set/all/codename.rb +2 -2
  48. data/mod/core/set/all/content.rb +52 -97
  49. data/mod/core/set/all/name_events.rb +69 -58
  50. data/mod/core/set/all/reference_events.rb +67 -0
  51. data/mod/core/set/all/states.rb +2 -2
  52. data/mod/core/set/all/subcards.rb +0 -100
  53. data/mod/core/set/all/trash.rb +11 -13
  54. data/mod/core/set/all/type.rb +7 -9
  55. data/mod/core/set/all/utils.rb +3 -0
  56. data/mod/core/set/type/cardtype.rb +3 -3
  57. data/mod/core/set_pattern/06_rule.rb +1 -1
  58. data/mod/core/spec/set/all/{rules2_spec.rb → clean_me_spec.rb} +0 -0
  59. data/mod/core/spec/set/all/name_events_spec.rb +204 -0
  60. metadata +30 -37
  61. data/lib/card/mod_inflector.rb +0 -16
  62. data/lib/card/name/all/class_methods.rb +0 -28
  63. data/mod/core/set/all/actify.rb +0 -68
  64. data/mod/core/set/all/cache.rb +0 -109
  65. data/mod/core/set/all/event_conditions.rb +0 -172
  66. data/mod/core/set/all/fetch.rb +0 -122
  67. data/mod/core/set/all/fetch_helper.rb +0 -35
  68. data/mod/core/set/all/i18n.rb +0 -9
  69. data/mod/core/set/all/pattern.rb +0 -54
  70. data/mod/core/set/all/references.rb +0 -191
  71. data/mod/core/set/all/rename.rb +0 -33
  72. data/mod/core/set/all/rules.rb +0 -81
  73. data/mod/core/spec/set/all/actify_spec.rb +0 -58
  74. data/mod/core/spec/set/all/content_spec.rb +0 -15
  75. data/mod/core/spec/set/all/event_conditions_spec.rb +0 -217
  76. data/mod/core/spec/set/all/fetch_helper_spec.rb +0 -65
  77. data/mod/core/spec/set/all/fetch_spec.rb +0 -338
  78. data/mod/core/spec/set/all/i18n_spec.rb +0 -17
  79. data/mod/core/spec/set/all/pattern_spec.rb +0 -101
  80. data/mod/core/spec/set/all/permissions/reader_rules_spec.rb +0 -166
  81. data/mod/core/spec/set/all/references_spec.rb +0 -62
  82. data/mod/core/spec/set/all/rename_spec.rb +0 -189
  83. data/mod/core/spec/set/all/rules_spec.rb +0 -100
  84. data/mod/core/spec/set/all/subcards_spec.rb +0 -102
@@ -1,100 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- RSpec.describe Card::Set::All::Rules do
4
- before do
5
- Card::Auth.signin Card::WagnBotID
6
- end
7
-
8
- describe "setting data setup" do
9
- it "makes Set of +*type" do
10
- Card.create! name: "SpeciForm", type: "Cardtype"
11
- expect(Card.create!(name: "SpeciForm+*type").type_code).to eq(:set)
12
- end
13
- end
14
-
15
- describe "#rule" do
16
- it "retrieves Set based value" do
17
- Card.create name: "Book+*type+*help", content: "authorize"
18
- help_rule = Card.new(type: "Book").rule(:help)
19
- expect(help_rule).to eq("authorize")
20
- end
21
-
22
- it "retrieves single values" do
23
- Card.create! name: "banana+*self+*help", content: "pebbles"
24
- expect(Card["banana"].rule(:help)).to eq("pebbles")
25
- end
26
- end
27
-
28
- describe "#setting_codenames_by_group" do
29
- before do
30
- @pointer_settings = %i[options options_label input]
31
- end
32
- it "doesn't fail on nonexistent trunks" do
33
- codenames = Card.new(name: "foob+*right").setting_codenames_by_group
34
- expect(codenames.class).to eq(Hash)
35
- end
36
-
37
- it "returns universal setting names for non-pointer set" do
38
- skip "Different api, we should just put the tests in a new spec for that"
39
- snbg = Card.fetch("*star").setting_codenames_by_group
40
- # warn "snbg #{snbg.class} #{snbg.inspect}"
41
- expect(snbg.keys.length).to eq(4)
42
- expect(snbg.keys.first).to be_a Symbol
43
- expect(snbg.keys.member?(:pointer)).not_to be_truthy
44
- end
45
- end
46
-
47
- describe "user specific rules" do
48
- before do
49
- Card::Auth.signin "Joe User"
50
- end
51
-
52
- it "user rule is recognized as rule" do
53
- Card::Auth.as_bot do
54
- card = Card.create name: "Book+*type+Joe User+*follow",
55
- content: "[[*always]]"
56
- expect(card.is_rule?).to be_truthy
57
- end
58
- end
59
-
60
- it "retrieves Set based value" do
61
- Card::Auth.as_bot do
62
- Card.create name: "Book+*type+Joe User+*follow", content: "[[*always]]"
63
- end
64
- expect(Card.new(type: "Book").preference(:follow)).to eq("[[*always]]")
65
- end
66
-
67
- it "retrieves user independent Set based value" do
68
- Card::Auth.as_bot do
69
- Card.create name: "Book+*type+*all+*follow", content: "[[Home]]"
70
- end
71
- expect(Card.new(type: "Book").preference(:follow)).to eq("[[Home]]")
72
- end
73
-
74
- it "uses *all user rule when no super.s"
75
-
76
- it "user-specific value overwrites user-independent value" do
77
- Card::Auth.as_bot do
78
- Card.create name: "Book+*type+Joe User+*follow", content: "[[*never]]"
79
- Card.create name: "Book+*type+*all+*follow", content: "[[*always]]"
80
- end
81
- expect(Card.new(type: "Book").preference(:follow)).to eq("[[*never]]")
82
- end
83
-
84
- describe "#all_user_ids_with_rule_for" do
85
- it "returns all user with values for the given Set and rule" do
86
- Card::Auth.as_bot do
87
- Card.create(name: "Book+*type+Joe User+*follow", content: "[[Home]]")
88
- Card::Auth.signin "Joe Admin"
89
- Card.create(name: "Book+*type+Joe Admin+*follow", content: "[[Home]]")
90
- user_ids = Card::Rule.all_user_ids_with_rule_for(
91
- Card.fetch("Book+*type"), :follow
92
- )
93
- expect(user_ids.sort).to eq(
94
- [Card["Joe User"].id, Card["Joe Admin"].id].sort
95
- )
96
- end
97
- end
98
- end
99
- end
100
- end
@@ -1,102 +0,0 @@
1
- RSpec.describe Card::Set::All::Subcards do
2
- let(:create_card) { Card.create!(name: "main card") }
3
- let(:create_card_with_subcards) do
4
- Card.create name: "main card",
5
- subcards: { "11" => { subcards: { "111" => "A" } },
6
- "12" => { subcards: { "121" => "A" } } }
7
- end
8
-
9
- class Card
10
- def __current_trans
11
- @current_trans = ActiveRecord::Base.connection.current_transaction
12
- end
13
-
14
- def __record_names reset=false
15
- trans = @current_trans && !reset ? @current_trans : __current_trans
16
- trans.records&.map { |r| r.try :name }&.compact
17
- end
18
- end
19
-
20
- describe "add subcards" do
21
- context "when in integrate stage" do
22
- context "with default subcard handling" do
23
- it "processes all cards in one transaction" do
24
- with_test_events do
25
- test_event :validate, on: :create, for: "main card" do
26
- add_subcard("sub card")
27
- end
28
-
29
- test_event :finalize, on: :create, for: "main card" do
30
- expect(__record_names).to eq ["main card", "sub card"]
31
- end
32
-
33
- create_card
34
- end
35
- end
36
- end
37
-
38
- context "with delayed jobs" do
39
- before { Cardio.delaying! }
40
- after { Cardio.delaying! :off }
41
-
42
- context "with serial subcard handling" do
43
- it "director.delay! processes subcards in separate transaction" do
44
- with_test_events do
45
- test_event :validate, on: :create, for: "main card" do
46
- sc = add_subcard("sub card")
47
- sc.director.delay!
48
- end
49
-
50
- test_event :finalize, on: :create, for: "main card" do
51
- expect(__record_names(true)).to eq ["main card"]
52
- expect(subcard("sub card").director.stage).to eq nil
53
- end
54
-
55
- test_event :integrate, on: :create, for: "main card" do
56
- expect(__record_names(true)).to eq(nil)
57
- expect(subcard("sub card").director.stage).to eq nil
58
- end
59
-
60
- test_event :finalize, on: :create, for: "sub card" do
61
- expect(__record_names(true)).to eq ["sub card"]
62
- end
63
-
64
- test_event :integrate_with_delay, on: :create do
65
- expect(__record_names(true)).to eq(nil)
66
- end
67
- create_card
68
- expect(Delayed::Worker.new.work_off).to eq [2, 0]
69
- expect(Card["sub card"]).to be_instance_of(Card)
70
- end
71
- end
72
- end
73
- end
74
-
75
- describe "in integrate_with_delay stage" do
76
- it "processes cards not in the same transaction" do
77
- with_test_events do
78
- test_event :integrate_with_delay, on: :create, for: "main card" do
79
- Card.create! name: "sub create card"
80
- add_subcard("sub card")
81
- end
82
-
83
- test_event :finalize, on: :create, for: "main card" do
84
- __current_trans
85
- end
86
-
87
- main_card = create_card
88
- Delayed::Worker.new.work_off
89
-
90
- expect(main_card.__record_names).to eq ["main card"]
91
- expect(Card["sub card"]).to exist
92
- expect(Card["sub create card"]).to exist
93
-
94
- act_of_main = main_card.acts.last
95
- expect(act_of_main).to eq Card["sub create card"].actions.last.act
96
- expect(act_of_main).to eq Card["sub card"].actions.last.act
97
- end
98
- end
99
- end
100
- end
101
- end
102
- end