card 1.101.0 → 1.101.5
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/i18n-tasks.yml +0 -5
- data/config/initializers/01_core_extensions/array.rb +2 -1
- data/config/initializers/01_core_extensions/hash.rb +1 -0
- data/config/initializers/01_core_extensions/object.rb +15 -11
- data/config/initializers/02_patches/active_job.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +2 -4
- data/config/initializers/02_patches/better_errors.rb +1 -3
- data/config/initializers/02_patches/kaminari.rb +2 -2
- data/config/initializers/deck_config.rb +1 -1
- data/config/initializers/inflections.rb +1 -0
- data/config/initializers/internationalization.rb +23 -21
- data/config/initializers/mime_types.rb +1 -0
- data/config/initializers/notification.rb +1 -0
- data/config/initializers/patches.rb +6 -5
- data/config/locales/en.yml +137 -525
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -0
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -0
- data/db/migrate/20121118114000_split_link_type.rb +1 -0
- data/db/migrate/20121118115000_update_link_type.rb +1 -0
- data/db/migrate/20130106052640_table_cleanup.rb +2 -2
- data/db/migrate/20130109015336_trunk_left.rb +1 -0
- data/db/migrate/20130411210957_update_codenames.rb +1 -0
- data/db/migrate/20140822073704_create_new_revision_tables.rb +1 -0
- data/db/migrate/20141001105348_move_revisions_to_actions.rb +9 -3
- data/db/migrate/20141216053032_better_index_names.rb +9 -6
- data/db/migrate/20170908114442_create_delayed_jobs.rb +1 -1
- data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +1 -1
- data/db/migrate/20180514152037_add_card_virtuals_table.rb +1 -1
- data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +3 -2
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +9 -9
- data/db/migrate_core_cards/20130419215612_import_help_text.rb +3 -2
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +5 -5
- data/db/migrate_core_cards/20130910183318_move_styles_to_content.rb +3 -2
- data/db/migrate_core_cards/20130920291703_update_stylesheets.rb +2 -4
- data/db/migrate_core_cards/20131016172445_common_css_patch.rb +1 -3
- data/db/migrate_core_cards/20140110193325_reset_account_request_type.rb +1 -3
- data/db/migrate_core_cards/20140307231621_user_data_to_cards.rb +12 -8
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +2 -4
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +16 -9
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +19 -11
- data/db/migrate_core_cards/20140725180118_config_card_updates.rb +1 -1
- data/db/migrate_core_cards/20141115034214_config_descriptions_etc.rb +1 -1
- data/db/migrate_core_cards/20141119001955_make_symlinks_relative.rb +1 -1
- data/db/migrate_core_cards/20141204061304_watchers_to_following.rb +2 -0
- data/db/migrate_core_cards/20141216155251_add_more_following_cards.rb +4 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +2 -2
- data/db/migrate_core_cards/20150220134731_following_to_follow_rule.rb +3 -4
- data/db/migrate_core_cards/20150317162412_bootstrap_themes.rb +8 -4
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +14 -7
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +6 -4
- data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +4 -2
- data/db/migrate_core_cards/20150510031118_fix_skin_codenames.rb +2 -1
- data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +3 -3
- data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +2 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +4 -3
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +6 -2
- data/db/migrate_core_cards/20150807205221_create_references_for_search_cards.rb +1 -1
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +2 -0
- data/db/migrate_core_cards/20160804112510_reorganize_scripts.rb +1 -1
- data/db/migrate_core_cards/20160811115836_rename_stats_to_admin.rb +1 -0
- data/db/migrate_core_cards/20160914132636_fix_mod_files.rb +2 -0
- data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +6 -6
- data/db/migrate_core_cards/20161103154836_update_keys.rb +2 -1
- data/db/migrate_core_cards/20170209132834_email_test_context.rb +2 -0
- data/db/migrate_core_cards/20170314175313_add_notification_event_card.rb +3 -3
- data/db/migrate_core_cards/20170515101262_add_advanced_edit_cards.rb +1 -1
- data/db/migrate_core_cards/20170608200649_add_input_options_codename.rb +1 -1
- data/db/migrate_core_cards/20180712042655_head_rule.rb +3 -4
- data/db/migrate_core_cards/20180905061537_migrate_layouts.rb +4 -4
- data/db/migrate_core_cards/20181120200937_update_layout.rb +1 -1
- data/db/migrate_core_cards/20190320091257_upgrade_recaptcha_to_v3.rb +7 -7
- data/db/migrate_core_cards/20190424100531_update_credit_image.rb +1 -0
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +15 -14
- data/db/migrate_core_cards/20190503122739_update_pristine_data.rb +1 -1
- data/db/migrate_core_cards/20190625153616_pointer_overhaul.rb +9 -5
- data/db/migrate_core_cards/20190718140126_add_guides.rb +3 -3
- data/db/migrate_core_cards/20190822093633_move_help_text_to_code.rb +1 -2
- data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +1 -1
- data/db/migrate_core_cards/20190829093961_cardtype_grouping.rb +7 -7
- data/db/migrate_core_cards/20190902193208_input_type.rb +1 -3
- data/db/migrate_core_cards/20190909104250_add_cardtype_input_types.rb +2 -2
- data/db/migrate_core_cards/20191028135243_add_link_editor_to_tiny_mce_config.rb +1 -0
- data/db/migrate_core_cards/20191115160748_history_cleanup.rb +0 -1
- data/db/migrate_core_cards/20191118145629_codename_fixes.rb +1 -2
- data/db/migrate_core_cards/20200821231558_add_nest_list_type.rb +1 -1
- data/db/migrate_core_cards/data/decko_logo.svg +1 -59
- data/db/seed/new/card_actions.yml +2153 -2145
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +900 -858
- data/db/seed/new/cards.yml +4869 -4848
- data/db/seed/new/schema_migrations_deck_cards.yml +2 -0
- data/db/seed/test/fixtures/card_actions.yml +3563 -3547
- data/db/seed/test/fixtures/card_acts.yml +675 -675
- data/db/seed/test/fixtures/card_changes.yml +103 -103
- data/db/seed/test/fixtures/card_references.yml +2165 -2123
- data/db/seed/test/fixtures/cards.yml +7862 -7751
- data/db/seed/test/fixtures/rails.gif +0 -0
- data/db/seed/test/fixtures/schema_migrations_deck_cards.yml +2 -0
- data/db/test_seed.rb +33 -34
- data/lib/card.rb +18 -1
- data/lib/card/auth.rb +5 -2
- data/lib/card/auth/current.rb +39 -100
- data/lib/card/auth/proxy.rb +36 -16
- data/lib/card/auth/token.rb +8 -2
- data/lib/card/cache.rb +2 -1
- data/lib/card/cache/all.rb +88 -0
- data/lib/card/cache/card_class.rb +44 -0
- data/lib/card/cache/persistent.rb +3 -34
- data/lib/card/cache/persistent_class.rb +28 -0
- data/lib/card/codename.rb +3 -4
- data/lib/card/content.rb +20 -10
- data/lib/card/content/all.rb +59 -0
- data/lib/card/content/chunk.rb +1 -1
- data/lib/card/content/clean.rb +4 -3
- data/lib/card/content/diff.rb +3 -2
- data/lib/card/content/diff/l_c_s/processor.rb +1 -1
- data/lib/card/content/diff/result.rb +41 -29
- data/lib/card/content/parser.rb +2 -2
- data/lib/card/content/truncate.rb +6 -6
- data/lib/card/director.rb +1 -1
- data/lib/card/director/act_direction.rb +4 -0
- data/lib/card/director/all.rb +61 -0
- data/lib/card/director/card_class.rb +18 -0
- data/lib/card/director/card_methods.rb +1 -0
- data/lib/card/director/event_delay.rb +4 -6
- data/lib/card/director/phases.rb +0 -1
- data/lib/card/director/run.rb +2 -0
- data/lib/card/director/stages.rb +3 -2
- data/lib/card/dirty.rb +13 -3
- data/lib/card/env.rb +2 -2
- data/lib/card/env/location.rb +4 -3
- data/lib/card/env/success.rb +46 -103
- data/lib/card/env/success/target.rb +73 -0
- data/lib/card/error.rb +1 -2
- data/lib/card/fetch.rb +7 -4
- data/lib/card/fetch/all.rb +33 -0
- data/lib/card/fetch/card_class.rb +155 -0
- data/lib/card/fetch/results.rb +9 -0
- data/lib/card/fetch/retrieve.rb +2 -0
- data/lib/card/fetch/store.rb +1 -0
- data/lib/card/format.rb +1 -2
- data/lib/card/format/content.rb +1 -3
- data/lib/card/format/error.rb +8 -4
- data/lib/card/format/method_delegation.rb +10 -2
- data/lib/card/format/nest.rb +3 -2
- data/lib/card/format/nest/fetch.rb +3 -2
- data/lib/card/format/nesting/mode.rb +1 -1
- data/lib/card/format/nesting/subformat.rb +2 -1
- data/lib/card/format/render.rb +2 -2
- data/lib/card/format/wrapper.rb +1 -1
- data/lib/card/lexicon.rb +5 -4
- data/lib/card/mark.rb +17 -15
- data/lib/card/model/save_helper.rb +18 -184
- data/lib/card/model/save_helper/save_arguments.rb +94 -0
- data/lib/card/model/save_helper/save_helper_helper.rb +93 -0
- data/lib/card/name.rb +10 -9
- data/lib/card/name/all.rb +136 -0
- data/lib/card/name/all/descendants.rb +48 -0
- data/lib/card/name/all/parts.rb +67 -0
- data/lib/card/name/card_class.rb +28 -0
- data/lib/card/name/fields_and_traits.rb +4 -2
- data/lib/card/name/name_variants.rb +0 -1
- data/lib/card/query.rb +24 -19
- data/lib/card/query/card_query/interpretation.rb +3 -2
- data/lib/card/query/card_query/match_attributes.rb +2 -1
- data/lib/card/query/card_query/normalization.rb +1 -0
- data/lib/card/query/card_query/reference_attributes.rb +1 -1
- data/lib/card/query/card_query/sorting.rb +12 -4
- data/lib/card/query/join.rb +1 -1
- data/lib/card/query/sql_statement.rb +1 -1
- data/lib/card/query/value/match_value.rb +1 -0
- data/lib/card/reference/all.rb +136 -0
- data/lib/card/rule/all.rb +76 -0
- data/lib/card/rule/cache.rb +2 -0
- data/lib/card/set/advanced_api.rb +8 -4
- data/lib/card/set/event.rb +2 -2
- data/lib/card/set/event/all.rb +101 -0
- data/lib/card/set/event/delayed_event.rb +6 -6
- data/lib/card/set/event/options.rb +14 -5
- data/lib/card/set/event/skip_and_trigger.rb +89 -0
- data/lib/card/set/format.rb +16 -9
- data/lib/card/set/format/abstract_format/view_definition.rb +1 -0
- data/lib/card/set/format/abstract_format/view_opts.rb +1 -0
- data/lib/card/set/i18n_scope.rb +18 -13
- data/lib/card/set/inheritance.rb +8 -6
- data/lib/card/set/loader.rb +24 -13
- data/lib/card/set/pattern/all.rb +63 -0
- data/lib/card/set/pattern/base.rb +4 -74
- data/lib/card/set/pattern/class_methods.rb +75 -0
- data/lib/card/set/required_field.rb +4 -1
- data/lib/card/set/trait.rb +11 -8
- data/lib/card/setting.rb +13 -12
- data/lib/card/subcards.rb +3 -4
- data/lib/card/subcards/add.rb +3 -24
- data/lib/card/subcards/all.rb +103 -0
- data/lib/card/subcards/args.rb +42 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +1 -1
- data/lib/card/tasks/card/file_card_creator/output_helper.rb +17 -14
- data/lib/card/tasks/card/migrate.rake +2 -2
- data/lib/card/view/cache.rb +6 -8
- data/lib/card/view/cache/cache_action.rb +1 -2
- data/lib/card/view/cache/stub.rb +1 -1
- data/lib/card/view/options.rb +5 -4
- data/lib/card/view/permission.rb +15 -3
- data/lib/cardio.rb +10 -67
- data/lib/cardio/defaults.yml +70 -0
- data/lib/cardio/migration.rb +2 -2
- data/lib/cardio/migration/deck_structure.rb +2 -4
- data/lib/cardio/migration/import.rb +3 -3
- data/lib/cardio/migration/import/import_data.rb +1 -0
- data/lib/cardio/mod.rb +1 -0
- data/lib/cardio/mod/dirs.rb +2 -2
- data/lib/cardio/mod/load_strategy.rb +2 -4
- data/lib/cardio/mod/loader/set_loader.rb +2 -1
- data/lib/cardio/mod/loader/set_pattern_loader.rb +0 -1
- data/lib/cardio/mod/module_template.rb +1 -0
- data/lib/cardio/modfiles.rb +2 -4
- data/lib/cardio/schema.rb +2 -4
- data/lib/cardio/utils.rb +9 -0
- data/lib/generators/card/format/format_generator.rb +1 -1
- data/lib/generators/card/migration/migration_generator.rb +2 -1
- data/lib/generators/card/mod/mod_generator.rb +3 -2
- data/lib/generators/card/set/set_generator.rb +3 -3
- data/lib/generators/card/template/template_generator.rb +1 -1
- data/mod/admin/set/self/admin.rb +6 -3
- data/mod/admin/set/self/admin_info.rb +3 -8
- data/mod/admin/set/self/trash.rb +3 -2
- data/mod/admin/spec/set/self/admin_spec.rb +4 -4
- data/mod/core/set/all/abort.rb +5 -5
- data/mod/core/set/all/assign_attributes.rb +12 -28
- data/mod/core/set/all/autoname.rb +17 -0
- data/mod/core/set/all/codename.rb +3 -2
- data/mod/core/set/all/collection.rb +4 -6
- data/mod/core/set/all/content.rb +55 -99
- data/mod/core/set/all/contextual_content.rb +2 -4
- data/mod/core/set/all/initialize.rb +9 -9
- data/mod/core/set/all/name_events.rb +78 -58
- data/mod/core/set/all/reference_events.rb +69 -0
- data/mod/core/set/all/states.rb +5 -5
- data/mod/core/set/all/subcards.rb +1 -101
- data/mod/core/set/all/trash.rb +16 -14
- data/mod/core/set/all/type.rb +11 -11
- data/mod/core/set/all/utils.rb +4 -1
- data/mod/{settings → core}/set/right/autoname.rb +0 -0
- data/mod/{settings → core}/set/self/autoname.rb +0 -0
- data/mod/core/set/type/cardtype.rb +28 -0
- data/mod/core/set_pattern/06_rule.rb +1 -1
- data/mod/core/spec/set/all/assign_attributes_spec.rb +10 -9
- data/mod/core/spec/set/all/{rules2_spec.rb → clean_me_spec.rb} +19 -4
- data/mod/core/spec/set/all/collection_spec.rb +1 -1
- data/mod/core/spec/set/all/export_spec.rb +1 -0
- data/mod/core/spec/set/all/initialize_spec.rb +11 -11
- data/mod/core/spec/set/all/name_events_spec.rb +204 -0
- data/mod/{standard → core}/spec/set/type/cardtype_spec.rb +3 -24
- data/mod/standard/file/logo/image-original.svg +1 -59
- metadata +50 -61
- data/config/initializers/uuid_state_file.rb +0 -3
- data/lib/card/mod_inflector.rb +0 -16
- data/mod/Modfile +0 -4
- data/mod/core/set/all/actify.rb +0 -68
- data/mod/core/set/all/cache.rb +0 -109
- data/mod/core/set/all/event_conditions.rb +0 -172
- data/mod/core/set/all/fetch.rb +0 -122
- data/mod/core/set/all/fetch_helper.rb +0 -35
- data/mod/core/set/all/i18n.rb +0 -11
- data/mod/core/set/all/name.rb +0 -229
- data/mod/core/set/all/pattern.rb +0 -54
- data/mod/core/set/all/references.rb +0 -191
- data/mod/core/set/all/rename.rb +0 -33
- data/mod/core/set/all/rules.rb +0 -81
- data/mod/core/spec/set/all/actify_spec.rb +0 -58
- data/mod/core/spec/set/all/content_spec.rb +0 -15
- data/mod/core/spec/set/all/event_conditions_spec.rb +0 -217
- data/mod/core/spec/set/all/fetch_helper_spec.rb +0 -65
- data/mod/core/spec/set/all/fetch_spec.rb +0 -338
- data/mod/core/spec/set/all/i18n_spec.rb +0 -17
- data/mod/core/spec/set/all/name_spec.rb +0 -11
- data/mod/core/spec/set/all/pattern_spec.rb +0 -101
- data/mod/core/spec/set/all/permissions/reader_rules_spec.rb +0 -166
- data/mod/core/spec/set/all/references_spec.rb +0 -62
- data/mod/core/spec/set/all/rename_spec.rb +0 -189
- data/mod/core/spec/set/all/rules_spec.rb +0 -100
- data/mod/core/spec/set/all/subcards_spec.rb +0 -102
- data/mod/standard/set/all/rich_html/html_views/info.rb +0 -84
- data/mod/standard/set/type/cardtype.rb +0 -119
@@ -1,166 +0,0 @@
|
|
1
|
-
describe Card::Set::All::Permissions do
|
2
|
-
describe "reader rules" do
|
3
|
-
before do
|
4
|
-
@perm_card = Card.new name: "Home+*self+*read", type: "Pointer",
|
5
|
-
content: "[[Anyone Signed In]]"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "is *all+*read by default" do
|
9
|
-
card = Card.fetch("Home")
|
10
|
-
expect(card.read_rule_id).to eq(Card.fetch("*all+*read").id)
|
11
|
-
expect(card.who_can(:read)).to eq([Card::AnyoneID])
|
12
|
-
Card::Auth.as(:anonymous) { expect(card.ok?(:read)).to be_truthy }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "updates to role ('Anyone Signed In')" do
|
16
|
-
name = @perm_card.name
|
17
|
-
Card::Auth.as_bot { @perm_card.save! }
|
18
|
-
pc = Card[name]
|
19
|
-
card = Card["Home"]
|
20
|
-
# warn "card #{name}, #{card.inspect}, #{pc.inspect}"
|
21
|
-
expect(pc).to be
|
22
|
-
expect(card.read_rule_id).to eq(pc.id)
|
23
|
-
expect(card.who_can(:read)).to eq([Card::AnyoneSignedInID])
|
24
|
-
Card::Auth.as(:anonymous) { expect(card.ok?(:read)).to be_falsey }
|
25
|
-
end
|
26
|
-
|
27
|
-
it "updates to user ('Joe Admin')" do
|
28
|
-
@perm_card.db_content = "[[Joe Admin]]"
|
29
|
-
Card::Auth.as_bot { @perm_card.save! }
|
30
|
-
|
31
|
-
card = Card.fetch("Home")
|
32
|
-
expect(card.read_rule_id).to eq(@perm_card.id)
|
33
|
-
expect(card.who_can(:read)).to eq([Card["joe_admin"].id])
|
34
|
-
Card::Auth.as(:anonymous) { expect(card.ok?(:read)).to be_falsey }
|
35
|
-
Card::Auth.as("joe_user") { expect(card.ok?(:read)).to be_falsey }
|
36
|
-
Card::Auth.as("joe_admin") { expect(card.ok?(:read)).to be_truthy }
|
37
|
-
Card::Auth.as_bot { expect(card.ok?(:read)).to be_truthy }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when more specific (self) rule is deleted" do
|
41
|
-
it "reverts to more general rule" do
|
42
|
-
Card::Auth.as_bot do
|
43
|
-
@perm_card.save!
|
44
|
-
@perm_card.delete!
|
45
|
-
end
|
46
|
-
card = Card.fetch("Home")
|
47
|
-
expect(card.read_rule_id).to eq(Card.fetch("*all+*read").id)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when more specific (right) rule is deleted" do
|
52
|
-
it "reverts to more general rule" do
|
53
|
-
pc = nil
|
54
|
-
Card::Auth.as_bot do
|
55
|
-
pc = Card.create name: "B+*right+*read", type: "Pointer",
|
56
|
-
content: "[[Anyone Signed In]]"
|
57
|
-
end
|
58
|
-
expect(pc).to be
|
59
|
-
card = Card.fetch("A+B")
|
60
|
-
expect(card.read_rule_id).to eq(pc.id)
|
61
|
-
# important to re-fetch to catch issues
|
62
|
-
# with detecting change in trash status.
|
63
|
-
pc = Card.fetch(pc.name)
|
64
|
-
Card::Auth.as_bot { pc.delete }
|
65
|
-
card = Card.fetch("A+B")
|
66
|
-
expect(card.read_rule_id).to eq(Card.fetch("*all+*read").id)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when more specific rule is renamed" do
|
71
|
-
it "reverts to more general rule" do
|
72
|
-
Card::Auth.as_bot do
|
73
|
-
@perm_card.save!
|
74
|
-
@perm_card = Card[@perm_card.name]
|
75
|
-
@perm_card.name = "Something else+*self+*read"
|
76
|
-
@perm_card.save!
|
77
|
-
end
|
78
|
-
|
79
|
-
card = Card.fetch("Home")
|
80
|
-
expect(card.read_rule_id).to eq(Card.fetch("*all+*read").id)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
it "gets not overruled by a more general rule added later" do
|
85
|
-
Card::Auth.as_bot do
|
86
|
-
@perm_card.save!
|
87
|
-
c = Card.fetch("Home")
|
88
|
-
c.type_id = Card::PhraseID
|
89
|
-
c.save!
|
90
|
-
Card.create name: "Phrase+*type+*read", type: "Pointer",
|
91
|
-
content: "[[Joe User]]"
|
92
|
-
end
|
93
|
-
|
94
|
-
card = Card.fetch("Home")
|
95
|
-
expect(card.read_rule_id).to eq(@perm_card.id)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "gets updated when trunk type change makes " \
|
99
|
-
"type-plus-right apply / unapply" do
|
100
|
-
@perm_card.name = "Phrase+B+*type plus right+*read"
|
101
|
-
Card::Auth.as_bot { @perm_card.save! }
|
102
|
-
expect(Card.fetch("A+B").read_rule_id).to eq(Card.fetch("*all+*read").id)
|
103
|
-
c = Card.fetch("A")
|
104
|
-
c.type_id = Card::PhraseID
|
105
|
-
c.save!
|
106
|
-
expect(Card.fetch("A+B").read_rule_id).to eq(@perm_card.id)
|
107
|
-
end
|
108
|
-
|
109
|
-
it "works with relative settings" do
|
110
|
-
Card::Auth.as_bot do
|
111
|
-
@perm_card.save!
|
112
|
-
all_plus = Card.fetch "*all plus+*read", new: { content: "_left" }
|
113
|
-
all_plus.save
|
114
|
-
end
|
115
|
-
c = Card.new(name: "Home+Heart")
|
116
|
-
expect(c.who_can(:read)).to eq([Card::AnyoneSignedInID])
|
117
|
-
expect(c.permission_rule_id(:read)).to eq(@perm_card.id)
|
118
|
-
c.save
|
119
|
-
expect(c.read_rule_id).to eq(@perm_card.id)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "gets updated when relative settings change" do
|
123
|
-
Card::Auth.as_bot do
|
124
|
-
all_plus = Card.fetch "*all plus+*read", new: { content: "_left" }
|
125
|
-
all_plus.save
|
126
|
-
end
|
127
|
-
c = Card.new(name: "Home+Heart")
|
128
|
-
expect(c.who_can(:read)).to eq([Card::AnyoneID])
|
129
|
-
expect(c.permission_rule_id(:read)).to(
|
130
|
-
eq(Card.fetch("*all+*read").id)
|
131
|
-
)
|
132
|
-
c.save
|
133
|
-
expect(c.read_rule_id).to eq(Card.fetch("*all+*read").id)
|
134
|
-
Card::Auth.as_bot { @perm_card.save! }
|
135
|
-
c2 = Card.fetch("Home+Heart")
|
136
|
-
expect(c2.who_can(:read)).to eq([Card::AnyoneSignedInID])
|
137
|
-
expect(c2.read_rule_id).to eq(@perm_card.id)
|
138
|
-
expect(Card.fetch("Home+Heart").read_rule_id).to(
|
139
|
-
eq(@perm_card.id)
|
140
|
-
)
|
141
|
-
Card::Auth.as_bot { @perm_card.delete }
|
142
|
-
expect(Card.fetch("Home").read_rule_id).to eq(Card.fetch("*all+*read").id)
|
143
|
-
expect(Card.fetch("Home+Heart").read_rule_id).to(
|
144
|
-
eq(Card.fetch("*all+*read").id)
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
it "insures that class overrides work with relative settings" do
|
149
|
-
Card::Auth.as_bot do
|
150
|
-
all_plus = Card.fetch "*all plus+*read", new: { content: "_left" }
|
151
|
-
all_plus.save
|
152
|
-
Card::Auth.as_bot { @perm_card.save! }
|
153
|
-
c = Card.create(name: "Home+Heart")
|
154
|
-
expect(c.read_rule_id).to eq(@perm_card.id)
|
155
|
-
r = Card.create name: "Heart+*right+*read", type: "Pointer",
|
156
|
-
content: "[[Administrator]]"
|
157
|
-
expect(Card.fetch("Home+Heart").read_rule_id).to eq(r.id)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
it "works on virtual+virtual cards" do
|
162
|
-
c = Card.fetch("Number+*type+by name")
|
163
|
-
expect(c.ok?(:read)).to be_truthy
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
RSpec.describe Card::Set::All::References do
|
4
|
-
it "replaces references should work on nests inside links" do
|
5
|
-
card = Card.create! name: "ref test", content: "[[test_card|test{{test}}]]"
|
6
|
-
assert_equal "[[test_card|test{{best}}]]",
|
7
|
-
card.replace_reference_syntax("test", "best")
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#referers" do
|
11
|
-
it "returns all cards that refer to card" do
|
12
|
-
expect(Card["Blue"].referers.map(&:name))
|
13
|
-
.to contain_exactly(
|
14
|
-
"blue includer 1", "blue includer 2", "blue linker 1", "blue linker 2"
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#nesters" do
|
20
|
-
it "returns all cards that nest card" do
|
21
|
-
expect(Card["Blue"].nesters.map(&:name))
|
22
|
-
.to contain_exactly("blue includer 1", "blue includer 2")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#referee" do
|
27
|
-
it "returns all cards that card nests" do
|
28
|
-
expect(Card["Y"].referees.map(&:name)).to contain_exactly("A", "A+B", "B", "T")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns all cards that card links to and their ancestors" do
|
32
|
-
# NOTE: B is not directly referred to; the reference is implied by the link to A+B
|
33
|
-
expect(Card["X"].referees.map(&:name)).to contain_exactly("A", "A+B", "B", "T")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#nestee" do
|
38
|
-
it "returns all cards that card nests" do
|
39
|
-
expect(Card["Y"].nestees.map(&:name)).to contain_exactly("A", "A+B", "B", "T")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns all cards that card links to" do
|
43
|
-
expect(Card["X"].nestees.map(&:name)).to eq([])
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "event :update_referer_content" do
|
48
|
-
it "handles self references" do
|
49
|
-
Card["A"].update! name: "AAA", update_referers: true
|
50
|
-
expect(Card["X"].content).to eq("[[AAA]] [[AAA+B]] [[T]]")
|
51
|
-
end
|
52
|
-
|
53
|
-
# FIXME: following should pass!
|
54
|
-
xit "handles reference loops" do
|
55
|
-
Card["A"].update! content: "[[A+B]] refers to me"
|
56
|
-
Card["A+B"].update! content: "[[A]] refers to me, too"
|
57
|
-
Card["A"].update! name: "AAA", update_referers: true
|
58
|
-
expect(Card["AAA+B"].content).to eq("[[AAA]] refers to me, too")
|
59
|
-
expect(Card["AAA"].content).to eq("[[AAA+B]] refers to me")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
module RenameMethods
|
4
|
-
def name_invariant_attributes card
|
5
|
-
descendant_ids = []
|
6
|
-
card.each_descendant { |d| descendant_ids << d.id }
|
7
|
-
{
|
8
|
-
content: card.db_content,
|
9
|
-
# updater_id: card.updater_id,
|
10
|
-
# revisions: card.actions.count,
|
11
|
-
referers: card.referers.map(&:name).sort,
|
12
|
-
referees: card.referees.map(&:name).sort,
|
13
|
-
descendants: descendant_ids.sort
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
def assert_rename card, new_name
|
18
|
-
if card.is_a? String
|
19
|
-
card = Card[card].refresh || raise("Couldn't find card named #{card}")
|
20
|
-
end
|
21
|
-
attrs_before = name_invariant_attributes(card)
|
22
|
-
actions_count_before = card.actions.count
|
23
|
-
update! card.name, name: new_name, update_referers: true
|
24
|
-
expect(card.actions.count).to eq(actions_count_before + 1)
|
25
|
-
assert_equal attrs_before, name_invariant_attributes(card)
|
26
|
-
assert_equal new_name, card.name
|
27
|
-
assert Card[new_name]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
RSpec.describe Card::Set::All::Rename do
|
32
|
-
include RenameMethods
|
33
|
-
include CardExpectations
|
34
|
-
|
35
|
-
it "renames simple card to its own child" do
|
36
|
-
assert_rename "F", "F+M"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "disallows renaming simple to compound when simple is used as tag" do
|
40
|
-
expect { Card["A"].update! name: "A+M" }.to raise_error(/illegal name change/)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "renames plus card to its own child" do
|
44
|
-
assert_rename "A+B", "A+B+T"
|
45
|
-
end
|
46
|
-
|
47
|
-
it "clears cache for old name" do
|
48
|
-
assert_rename "Menu", "manure"
|
49
|
-
expect(Card["Menu"]).to be_nil
|
50
|
-
end
|
51
|
-
|
52
|
-
it "wipes old references by default" do
|
53
|
-
update "Menu", name: "manure"
|
54
|
-
expect(Card["manure"].references_in.size).to eq(0)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "picks up new references" do
|
58
|
-
expect(Card["Z"].references_in.size).to eq(2)
|
59
|
-
assert_rename "Z", "Mister X"
|
60
|
-
expect(Card["Mister X"].references_in.size).to eq(3)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "handles name variants" do
|
64
|
-
assert_rename "B", "b"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "handles plus cards renamed to simple" do
|
68
|
-
assert_rename "A+B", "K"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "handles flipped parts" do
|
72
|
-
assert_rename "A+B", "B+A"
|
73
|
-
end
|
74
|
-
|
75
|
-
it "fails if card exists" do
|
76
|
-
expect { update "T", name: "A+B" }.to raise_error(/Name must be unique/)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "fails if used as tag" do
|
80
|
-
expect { update "B", name: "A+D" }.to raise_error(/Name must be unique/)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "updates descendants" do
|
84
|
-
old_names = %w[One+Two One+Two+Three Four+One Four+One+Five]
|
85
|
-
new_names = %w[Uno+Two Uno+Two+Three Four+Uno Four+Uno+Five]
|
86
|
-
card_list = old_names.map {|name| Card[name]}
|
87
|
-
|
88
|
-
expect(card_list.map(&:name)).to eq old_names
|
89
|
-
update "One", name: "Uno"
|
90
|
-
expect(card_list.map(&:id).map(&:cardname)).to eq new_names
|
91
|
-
end
|
92
|
-
|
93
|
-
it "fails if name is invalid" do
|
94
|
-
expect { update "T", name: "" }
|
95
|
-
.to raise_error(/Name can't be blank/)
|
96
|
-
end
|
97
|
-
|
98
|
-
example "simple to simple" do
|
99
|
-
assert_rename "A", "Alephant"
|
100
|
-
end
|
101
|
-
|
102
|
-
example "simple to junction with create" do
|
103
|
-
assert_rename "T", "C+J"
|
104
|
-
end
|
105
|
-
|
106
|
-
example "reset key" do
|
107
|
-
c = Card["basicname"]
|
108
|
-
update "basicname", name: "banana card"
|
109
|
-
expect(c.key).to eq("banana_card")
|
110
|
-
expect(Card["Banana Card"]).not_to be_nil
|
111
|
-
end
|
112
|
-
|
113
|
-
it "does not fail when updating inaccessible referer" do
|
114
|
-
Card.create! name: "Joe Card", content: "Whattup"
|
115
|
-
Card::Auth.as "joe_admin" do
|
116
|
-
Card.create! name: "Admin Card", content: "[[Joe Card]]"
|
117
|
-
end
|
118
|
-
|
119
|
-
c = Card["Joe Card"]
|
120
|
-
c.update! name: "Card of Joe", update_referers: true
|
121
|
-
assert_equal "[[Card of Joe]]", Card["Admin Card"].content
|
122
|
-
end
|
123
|
-
|
124
|
-
it "test_rename_should_update_structured_referer" do
|
125
|
-
Card::Auth.as_bot do
|
126
|
-
c = Card.create! name: "Pit"
|
127
|
-
Card.create! name: "Orange", type: "Fruit", content: "[[Pit]]"
|
128
|
-
Card.create! name: "Fruit+*type+*structure", content: "this [[Pit]]"
|
129
|
-
|
130
|
-
assert_equal "this [[Pit]]", Card["Orange"].content
|
131
|
-
c.update! name: "Seed", update_referers: true
|
132
|
-
assert_equal "this [[Seed]]", Card["Orange"].content
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
it "handles plus cards that have children" do
|
137
|
-
assert_rename Card["a+b"], "e+f"
|
138
|
-
end
|
139
|
-
|
140
|
-
context "self references" do
|
141
|
-
example "renaming card with self link should nothang" do
|
142
|
-
pre_content = Card["self_aware"].content
|
143
|
-
update "self aware", name: "buttah", update_referers: true
|
144
|
-
expect_card("Buttah").to have_content(pre_content)
|
145
|
-
end
|
146
|
-
|
147
|
-
it "renames card without updating references" do
|
148
|
-
pre_content = Card["self_aware"].content
|
149
|
-
update "self aware", name: "Newt", update_referers: false
|
150
|
-
expect_card("Newt").to have_content(pre_content)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context "references" do
|
155
|
-
it "updates nests" do
|
156
|
-
update "Blue", name: "Red", update_referers: true
|
157
|
-
expect_card("blue includer 1").to have_content("{{Red}}")
|
158
|
-
expect_card("blue includer 2").to have_content("{{Red|closed;other:stuff}}")
|
159
|
-
end
|
160
|
-
|
161
|
-
it "updates nests when renaming to plus" do
|
162
|
-
update "Blue", name: "blue includer 1+color", update_referers: true
|
163
|
-
expect_card("blue includer 1").to have_content("{{blue includer 1+color}}")
|
164
|
-
end
|
165
|
-
|
166
|
-
it "reference updates on case variants" do
|
167
|
-
update "Blue", name: "Red", update_referers: true
|
168
|
-
expect_card("blue linker 1").to have_content("[[Red]]")
|
169
|
-
expect_card("blue linker 2").to have_content("[[Red]]")
|
170
|
-
end
|
171
|
-
|
172
|
-
it "handles link to and nest of same card" do
|
173
|
-
update "blue linker 1", content: "[[Blue]] is {{Blue|name}}"
|
174
|
-
update "Blue", name: "Red", update_referers: true
|
175
|
-
expect_card("blue linker 1").to have_content("[[Red]] is {{Red|name}}")
|
176
|
-
end
|
177
|
-
|
178
|
-
example "reference updates plus to simple" do
|
179
|
-
assert_rename Card["A+B"], "schmuck"
|
180
|
-
expect_card("X").to have_content("[[A]] [[schmuck]] [[T]]")
|
181
|
-
end
|
182
|
-
|
183
|
-
it "substitutes name part" do
|
184
|
-
c1 = Card["A+B"]
|
185
|
-
assert_rename Card["B"], "buck"
|
186
|
-
expect(Card.find(c1.id).name).to eq "A+buck"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
@@ -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
|