card 1.19.6 → 1.20.0
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/card.gemspec +8 -7
- data/config/initializers/01_core_extensions/array.rb +4 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +12 -0
- data/config/initializers/02_patches/better_errors.rb +56 -0
- data/config/initializers/core_extensions.rb +13 -18
- data/config/initializers/patches.rb +8 -0
- data/config/locales/de.yml +0 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +22 -12
- data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +17 -0
- data/db/migrate_core_cards/20161103154836_update_keys.rb +46 -0
- data/lib/card.rb +1 -8
- data/lib/card/act_manager.rb +4 -0
- data/lib/card/auth/permissions.rb +5 -3
- data/lib/card/cache.rb +1 -20
- data/lib/card/cache/persistent.rb +6 -0
- data/lib/card/content/chunk.rb +4 -3
- data/lib/card/content/diff.rb +2 -2
- data/lib/card/content/diff/result.rb +11 -0
- data/lib/card/env/success.rb +4 -0
- data/lib/card/error.rb +2 -0
- data/lib/card/format.rb +14 -17
- data/lib/card/format/content.rb +16 -8
- data/lib/card/format/error.rb +3 -5
- data/lib/card/format/names.rb +22 -16
- data/lib/card/format/nest.rb +67 -61
- data/lib/card/format/nest/fetch.rb +40 -33
- data/lib/card/format/nest/main.rb +39 -19
- data/lib/card/format/nest/subformat.rb +3 -16
- data/lib/card/format/nest/view.rb +23 -32
- data/lib/card/format/permission.rb +49 -34
- data/lib/card/format/registration.rb +12 -6
- data/lib/card/format/render.rb +62 -73
- data/lib/card/migration.rb +14 -10
- data/lib/card/migration/import.rb +20 -19
- data/lib/card/migration/import/import_data.rb +50 -59
- data/lib/card/migration/import/import_data/card_attributes.rb +56 -0
- data/lib/card/migration/import/import_data/card_content.rb +33 -0
- data/lib/card/migration/import/merger.rb +47 -0
- data/lib/card/mod/loader.rb +4 -4
- data/lib/card/model/save_helper.rb +49 -10
- data/lib/card/name.rb +16 -52
- data/lib/card/name/fields_and_traits.rb +67 -0
- data/lib/card/name/variants.rb +17 -0
- data/lib/card/query.rb +6 -2
- data/lib/card/query/attributes.rb +1 -1
- data/lib/card/query/interpretation.rb +3 -3
- data/lib/card/set/event.rb +2 -1
- data/lib/card/set/format.rb +18 -7
- data/lib/card/set_pattern.rb +17 -13
- data/lib/card/tasks/card.rake +1 -1
- data/lib/card/view.rb +55 -0
- data/lib/card/view/cache.rb +90 -0
- data/lib/card/view/fetch.rb +109 -0
- data/lib/card/view/options.rb +164 -0
- data/lib/card/view/stub.rb +30 -0
- data/lib/card/view/visibility.rb +95 -0
- data/lib/cardio.rb +3 -2
- data/lib/cardio/schema.rb +21 -8
- data/lib/generators/card.rb +16 -2
- data/lib/generators/card/format/format_generator.rb +10 -9
- data/lib/generators/card/migration/migration_generator.rb +10 -5
- data/lib/generators/card/set/USAGE +1 -1
- data/lib/generators/card/set/set_generator.rb +11 -9
- data/mod/account/set/right/account.rb +38 -40
- data/mod/account/set/right/token.rb +2 -1
- data/mod/account/set/self/account_links.rb +34 -54
- data/mod/account/set/self/signin.rb +107 -93
- data/mod/account/set/type/signup.rb +33 -32
- data/mod/account/set/type/user.rb +28 -21
- data/mod/account/spec/set/all/account_spec.rb +9 -9
- data/mod/account/spec/set/right/account_spec.rb +23 -14
- data/mod/account/spec/set/right/email_spec.rb +6 -6
- data/mod/account/spec/set/right/password_spec.rb +4 -4
- data/mod/account/spec/set/right/token_spec.rb +3 -3
- data/mod/account/spec/set/self/account_links_spec.rb +3 -3
- data/mod/account/spec/set/self/signin_spec.rb +2 -2
- data/mod/account/spec/set/type/signup_spec.rb +7 -8
- data/mod/ace_editor/set/abstract/ace_editor.rb +1 -4
- data/mod/admin/set/self/admin.rb +2 -2
- data/mod/admin/set/self/admin_info.rb +1 -1
- data/mod/admin/set/self/recaptcha_private_key.rb +3 -0
- data/mod/admin/set/self/recaptcha_proxy.rb +3 -0
- data/mod/admin/set/self/recaptcha_public_key.rb +3 -0
- data/mod/admin/set/self/trash.rb +4 -4
- data/mod/admin/spec/set/self/admin_spec.rb +4 -4
- data/mod/admin/spec/set/self/version_spec.rb +1 -1
- data/mod/basic_formats/set/all/all_css.rb +3 -3
- data/mod/basic_formats/set/all/all_csv.rb +6 -6
- data/mod/basic_formats/set/all/all_js.rb +4 -0
- data/mod/basic_formats/set/all/base.rb +40 -62
- data/mod/basic_formats/set/all/json.rb +34 -39
- data/mod/basic_formats/set/all/rss.rb +6 -6
- data/mod/basic_formats/set/all/text.rb +3 -2
- data/mod/basic_formats/set/self/01_head/javascript.rb +2 -2
- data/mod/basic_formats/set/self/head.rb +6 -10
- data/mod/basic_formats/spec/set/all/all_css_spec.rb +1 -1
- data/mod/basic_formats/spec/set/all/all_csv_spec.rb +1 -1
- data/mod/basic_formats/spec/set/all/base_spec.rb +8 -5
- data/mod/basic_formats/spec/set/all/json_spec.rb +2 -2
- data/mod/basic_formats/spec/set/all/rss_spec.rb +4 -4
- data/mod/basic_types/set/type/plain_text.rb +3 -5
- data/mod/basic_types/spec/set/type/plain_text_spec.rb +2 -2
- data/mod/bootstrap/lib/bootstrap.rb +16 -0
- data/mod/bootstrap/lib/bootstrap/basic_tags.rb +26 -0
- data/mod/bootstrap/lib/bootstrap/component.rb +133 -0
- data/mod/bootstrap/lib/bootstrap/component/form.rb +31 -0
- data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +38 -0
- data/mod/bootstrap/lib/bootstrap/component/layout.rb +83 -0
- data/mod/bootstrap/lib/bootstrap/component/panel.rb +9 -0
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +30 -0
- data/mod/bootstrap/lib/bootstrap/delegate.rb +16 -0
- data/mod/bootstrap/lib/bootstrapper.rb +16 -0
- data/mod/bootstrap/lib/stylesheets/bootstrap/_tables.scss +55 -52
- data/mod/bootstrap/lib/stylesheets/bootstrap/mixins/_table-row.scss +12 -12
- data/mod/bootstrap/lib/stylesheets/bootstrap_cards.scss +12 -0
- data/mod/bootstrap/set/all/bootstrap/accordion.rb +63 -0
- data/mod/bootstrap/set/all/bootstrap/helper.rb +7 -140
- data/mod/bootstrap/set/all/bootstrap/navbar.rb +74 -0
- data/mod/bootstrap/set/all/bootstrap/table.rb +76 -46
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +58 -23
- data/mod/bootstrap/set/all/bootstrap/wrapper.rb +14 -8
- data/mod/bootstrap/set/all/rich_bootstrap.rb +5 -3
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +31 -0
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +20 -0
- data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +59 -1
- data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +104 -15
- data/mod/carrierwave/set/abstract/attachment.rb +4 -3
- data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
- data/mod/carrierwave/set/abstract/attachment/storage_type.rb +5 -11
- data/mod/carrierwave/set/type/file.rb +39 -32
- data/mod/carrierwave/set/type/image.rb +59 -34
- data/mod/carrierwave/spec/set/type/image_spec.rb +3 -3
- data/mod/core/chunk/link.rb +5 -0
- data/mod/core/chunk/{include.rb → nest.rb} +8 -29
- data/mod/core/chunk/reference.rb +5 -6
- data/mod/core/chunk/view_stub.rb +42 -0
- data/mod/core/format/html_format.rb +23 -26
- data/mod/core/set/abstract/code_file.rb +1 -1
- data/mod/core/set/all/actify.rb +1 -1
- data/mod/core/set/all/active_card.rb +0 -1
- data/mod/core/set/all/{tracked_attributes.rb → assign_attributes.rb} +55 -24
- data/mod/core/set/all/collection.rb +136 -122
- data/mod/core/set/all/content.rb +8 -0
- data/mod/core/set/all/event.rb +5 -2
- data/mod/core/set/all/export.rb +7 -7
- data/mod/core/set/all/fetch.rb +90 -26
- data/mod/core/set/all/initialize.rb +17 -6
- data/mod/core/set/all/name.rb +2 -3
- data/mod/core/set/all/permissions.rb +19 -11
- data/mod/core/set/all/states.rb +12 -2
- data/mod/core/set/all/trash.rb +1 -1
- data/mod/core/set/all/type.rb +2 -0
- data/mod/core/set/all/utils.rb +4 -3
- data/mod/core/spec/chunk/literal_spec.rb +2 -2
- data/mod/core/spec/chunk/uri_spec.rb +17 -17
- data/mod/core/spec/format/html_format_spec.rb +11 -13
- data/mod/core/spec/set/all/attribute_tracking_spec.rb +2 -2
- data/mod/core/spec/set/all/collection_spec.rb +21 -24
- data/mod/core/spec/set/all/content_spec.rb +1 -1
- data/mod/core/spec/set/all/export_spec.rb +3 -3
- data/mod/core/spec/set/all/fetch_spec.rb +5 -5
- data/mod/core/spec/set/all/initialize_spec.rb +4 -4
- data/mod/core/spec/set/all/name_spec.rb +6 -6
- data/mod/core/spec/set/all/permissions_spec.rb +10 -10
- data/mod/core/spec/set/all/references_spec.rb +1 -1
- data/mod/core/spec/set/all/rules2_spec.rb +24 -24
- data/mod/core/spec/set/all/rules_spec.rb +1 -1
- data/mod/core/spec/set/all/templating_spec.rb +8 -8
- data/mod/core/spec/set/all/tracked_attributes_spec.rb +6 -6
- data/mod/core/spec/set/all/type_spec.rb +5 -5
- data/mod/developer/spec/set/all/event_viz_spec.rb +1 -1
- data/mod/developer/spec/set/right/debug_spec.rb +1 -1
- data/mod/email/set/all/email_html.rb +2 -2
- data/mod/email/set/all/notify.rb +8 -3
- data/mod/email/set/right/bcc.rb +3 -3
- data/mod/email/set/right/follow.rb +5 -5
- data/mod/email/set/right/following.rb +1 -1
- data/mod/email/set/self/follow_defaults.rb +27 -16
- data/mod/email/set/type/email_template.rb +1 -1
- data/mod/email/set/type_plus_right/user/follow.rb +10 -9
- data/mod/history/lib/card/act.rb +4 -0
- data/mod/history/lib/card/act/act_renderer.rb +194 -0
- data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +25 -0
- data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +41 -0
- data/mod/history/lib/card/action.rb +1 -0
- data/mod/history/lib/card/action/action_renderer.rb +92 -0
- data/mod/history/lib/card/action/differ.rb +6 -1
- data/mod/history/set/all/act_view.rb +64 -0
- data/mod/history/set/all/action_view.rb +65 -0
- data/mod/history/set/all/content_history.rb +44 -37
- data/mod/history/set/all/history.rb +49 -263
- data/mod/machines/lib/stylesheets/style_cards.scss +30 -115
- data/mod/machines/set/abstract/script.rb +42 -7
- data/mod/machines/set/right/machine_input.rb +4 -0
- data/mod/machines/set/type/coffee_script.rb +8 -22
- data/mod/machines/set/type/css.rb +2 -2
- data/mod/machines/set/type/java_script.rb +4 -24
- data/mod/machines/set/type/scss.rb +1 -1
- data/mod/machines/spec/set/type/css_spec.rb +1 -1
- data/mod/machines/spec/set/type/scss_spec.rb +3 -3
- data/mod/machines/spec/set/type/skin_spec.rb +7 -7
- data/mod/pointer/set/abstract/01_pointer.rb +44 -46
- data/mod/pointer/set/abstract/01_pointer/edit.rb +13 -13
- data/mod/pointer/set/right/options.rb +4 -0
- data/mod/pointer/spec/set/type/pointer_spec.rb +7 -7
- data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +3 -3
- data/mod/settings/set/abstract/permission.rb +25 -18
- data/mod/settings/set/right/add_help.rb +3 -3
- data/mod/settings/set/right/structure.rb +10 -16
- data/mod/settings/spec/set/right/comment_spec.rb +3 -3
- data/mod/settings/spec/set/right/create_spec.rb +1 -1
- data/mod/settings/spec/set/right/style_spec.rb +1 -1
- data/mod/settings/spec/set/type/setting_spec.rb +1 -1
- data/mod/solid_cache/set/abstract/solid_cache.rb +4 -4
- data/mod/solid_cache/set/right/solid_cache.rb +9 -10
- data/mod/standard/set/abstract/01_search_params.rb +41 -0
- data/mod/standard/set/abstract/search.rb +132 -0
- data/mod/standard/set/abstract/search/paging.rb +81 -0
- data/mod/standard/set/abstract/search/paging/paging_links.rb +90 -0
- data/mod/standard/set/abstract/wql_search.rb +67 -0
- data/mod/standard/set/all/error.rb +89 -82
- data/mod/standard/set/all/links.rb +1 -1
- data/mod/standard/set/all/rich_html/content.rb +125 -141
- data/mod/standard/set/all/rich_html/editing.rb +115 -178
- data/mod/standard/set/all/rich_html/form.rb +111 -131
- data/mod/standard/set/all/rich_html/header.rb +57 -39
- data/mod/standard/set/all/rich_html/menu.rb +94 -94
- data/mod/standard/set/all/rich_html/modal.rb +5 -10
- data/mod/standard/set/all/rich_html/new.rb +103 -0
- data/mod/standard/set/all/rich_html/toolbar.rb +54 -74
- data/mod/standard/set/all/rich_html/wrapper.rb +111 -138
- data/mod/standard/set/rstar/rules.rb +27 -38
- data/mod/standard/set/rstar/rules_editor.rb +298 -277
- data/mod/standard/set/self/navbox.rb +20 -15
- data/mod/standard/set/self/recent.rb +25 -17
- data/mod/standard/set/self/search.rb +25 -4
- data/mod/standard/set/type/cardtype.rb +11 -9
- data/mod/standard/set/type/date.rb +1 -1
- data/mod/standard/set/type/number.rb +1 -1
- data/mod/standard/set/type/phrase.rb +1 -1
- data/mod/standard/set/type/search_type.rb +17 -282
- data/mod/standard/set/type/session.rb +1 -1
- data/mod/standard/set/type/set.rb +155 -131
- data/mod/standard/set/type/toggle.rb +1 -1
- data/mod/standard/set/type/uri.rb +4 -4
- data/mod/standard/spec/chunk/include_spec.rb +13 -31
- data/mod/standard/spec/chunk/link_spec.rb +1 -1
- data/mod/standard/spec/set/all/error_spec.rb +1 -1
- data/mod/standard/spec/set/all/history_spec.rb +2 -2
- data/mod/standard/spec/set/all/rich_html/form_spec.rb +4 -4
- data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +22 -0
- data/mod/standard/spec/set/all/rich_html/wrapper_spec.rb +3 -2
- data/mod/standard/spec/set/right/when_created_spec.rb +1 -1
- data/mod/standard/spec/set/right/when_last_edited_spec.rb +1 -1
- data/mod/standard/spec/set/rstar/rules_spec.rb +2 -3
- data/mod/standard/spec/set/self/head_spec.rb +2 -2
- data/mod/standard/spec/set/self/navbox_spec.rb +1 -1
- data/mod/standard/spec/set/self/now_spec.rb +1 -1
- data/mod/standard/spec/set/type/date_spec.rb +1 -1
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -1
- data/mod/standard/spec/set/type/layout_type_spec.rb +1 -1
- data/mod/standard/spec/set/type/number_spec.rb +1 -1
- data/mod/standard/spec/set/type/phrase_spec.rb +1 -1
- data/mod/standard/spec/set/type/search_type_spec.rb +2 -2
- data/mod/standard/spec/set/type/set_spec.rb +2 -2
- data/mod/standard/spec/set/type/toggle_spec.rb +2 -2
- data/mod/standard/spec/set/type/uri_spec.rb +3 -1
- data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
- data/spec/config/initializers/core_extensions_spec.rb +40 -10
- data/spec/lib/card/auth_spec.rb +8 -8
- data/spec/lib/card/cache_spec.rb +3 -3
- data/spec/lib/card/chunk_spec.rb +4 -4
- data/spec/lib/card/codename_spec.rb +2 -2
- data/spec/lib/card/content_spec.rb +23 -23
- data/spec/lib/card/diff_spec.rb +1 -1
- data/spec/lib/card/format_spec.rb +19 -24
- data/spec/lib/card/loader_spec.rb +4 -4
- data/spec/lib/card/name_spec.rb +16 -16
- data/spec/lib/card/query_spec.rb +80 -80
- data/spec/lib/card/reference_spec.rb +5 -5
- data/spec/lib/card/set_spec.rb +6 -6
- data/spec/lib/card/subcards_spec.rb +14 -0
- data/spec/lib/card/view_cache_spec.rb +5 -5
- data/spec/models/card/cardtype_spec.rb +15 -15
- data/spec/models/card/create_spec.rb +2 -2
- data/spec/models/card/trash_spec.rb +24 -24
- data/spec/models/card/type_transition_spec.rb +8 -8
- data/spec/models/card/validation_spec.rb +5 -5
- data/spec/models/card_spec.rb +14 -14
- data/spec/spec_helper.rb +6 -2
- data/spec/support/card_spec_helper.rb +21 -11
- data/spec/support/helper/card_helper.rb +11 -4
- metadata +73 -15
- data/lib/card/cache/view_cache.rb +0 -103
- data/mod/bootstrap/set/all/bootstrap/layout.rb +0 -58
- data/mod/core/set/all/view_cache.rb +0 -9
data/spec/lib/card/chunk_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require "card/content/chunk"
|
|
3
3
|
|
4
4
|
describe Card::Content::Chunk, "Chunk" do
|
5
5
|
context "Class" do
|
6
|
-
it "
|
6
|
+
it "populates prefix map on load" do
|
7
7
|
expect(Card::Content::Chunk.prefix_map_by_list[:default].keys.size)
|
8
8
|
.to be > 0
|
9
9
|
expect(Card::Content::Chunk.prefix_map_by_list[:default]["{"][:class])
|
10
|
-
.to eq(Card::Content::Chunk::
|
10
|
+
.to eq(Card::Content::Chunk::Nest)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "finds Chunk classes using matched prefix" do
|
14
14
|
expect(Card::Content::Chunk.find_class_by_prefix("{{"))
|
15
|
-
.to eq(Card::Content::Chunk::
|
15
|
+
.to eq(Card::Content::Chunk::Nest)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -5,14 +5,14 @@ describe Card::Codename, "Codename" do
|
|
5
5
|
@codename = :default
|
6
6
|
end
|
7
7
|
|
8
|
-
it "
|
8
|
+
it "is sane" do
|
9
9
|
expect(Card[@codename].codename).to eq(@codename.to_s) # would prefer Symbol eventually
|
10
10
|
card_id = Card::Codename[@codename]
|
11
11
|
expect(card_id).to be_a_kind_of Integer
|
12
12
|
expect(Card::Codename[card_id]).to eq(@codename)
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "makes cards indestructable" do
|
16
16
|
Card::Auth.as_bot do
|
17
17
|
card = Card[@codename]
|
18
18
|
card.delete
|
@@ -5,42 +5,42 @@ describe Card::Content do
|
|
5
5
|
EXAMPLES = {
|
6
6
|
nests: {
|
7
7
|
content: "Some Literals: \\[{I'm not| a link]}, and " \
|
8
|
-
'\\{{This Card|Is not
|
8
|
+
'\\{{This Card|Is not Nestd}}' \
|
9
9
|
", but " \
|
10
10
|
"{{this is}}" \
|
11
11
|
", and some tail",
|
12
12
|
rendered: ["Some Literals: \\[{I'm not| a link]}, and ",
|
13
|
-
"<span>{</span>{This Card|Is not
|
13
|
+
"<span>{</span>{This Card|Is not Nestd}}",
|
14
14
|
", but ",
|
15
|
-
{ options: {
|
16
|
-
|
15
|
+
{ options: { nest_name: "this is",
|
16
|
+
nest_syntax: "this is" } },
|
17
17
|
", and some tail"],
|
18
|
-
classes: [String, :EscapedLiteral, String, :
|
18
|
+
classes: [String, :EscapedLiteral, String, :Nest, String]
|
19
19
|
},
|
20
20
|
|
21
21
|
links_and_nests: {
|
22
22
|
content: "Some Links and includes: [[the card|the text]], " \
|
23
|
-
"and {{This Card|Is
|
23
|
+
"and {{This Card|Is Nestd}}{{this too}} " \
|
24
24
|
"and [[http://external.wagn.org/path|link text]]" \
|
25
|
-
"{{
|
25
|
+
"{{Nestd|open}}",
|
26
26
|
rendered: ["Some Links and includes: ",
|
27
27
|
'<a class="wanted-card" ' \
|
28
28
|
'href="/the_card">' \
|
29
29
|
"the text</a>",
|
30
30
|
", and ",
|
31
|
-
{ options: { view: "Is
|
32
|
-
|
33
|
-
|
34
|
-
{ options: {
|
35
|
-
|
31
|
+
{ options: { view: "Is Nestd",
|
32
|
+
nest_name: "This Card",
|
33
|
+
nest_syntax: "This Card|Is Nestd" } },
|
34
|
+
{ options: { nest_name: "this too",
|
35
|
+
nest_syntax: "this too" } },
|
36
36
|
" and ",
|
37
37
|
'<a target="_blank" class="external-link" ' \
|
38
38
|
'href="http://external.wagn.org/path">link text</a>',
|
39
39
|
{ options: { view: "open",
|
40
|
-
|
41
|
-
|
40
|
+
nest_name: "Nestd",
|
41
|
+
nest_syntax: "Nestd|open" } }],
|
42
42
|
classes: [
|
43
|
-
String, :Link, String, :
|
43
|
+
String, :Link, String, :Nest, :Nest, String, :Link, :Nest
|
44
44
|
]
|
45
45
|
},
|
46
46
|
|
@@ -134,7 +134,7 @@ describe Card::Content do
|
|
134
134
|
|
135
135
|
single_nest: {
|
136
136
|
content: "{{one nest|size;large}}",
|
137
|
-
classes: [:
|
137
|
+
classes: [:Nest]
|
138
138
|
},
|
139
139
|
|
140
140
|
css: {
|
@@ -324,13 +324,13 @@ describe Card::Content do
|
|
324
324
|
|
325
325
|
context "class" do
|
326
326
|
describe "#clean!" do
|
327
|
-
it "
|
327
|
+
it "does not alter untagged content" do
|
328
328
|
UNTAGGED_CASES.each do |test_case|
|
329
329
|
assert_equal test_case, Card::Content.clean!(test_case)
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
333
|
-
it "
|
333
|
+
it "strips disallowed html class attributes" do
|
334
334
|
assert_equal "<p>html<div>with</div> funky tags</p>",
|
335
335
|
Card::Content.clean!(
|
336
336
|
'<p>html<div class="boo">with</div>' \
|
@@ -340,7 +340,7 @@ describe Card::Content do
|
|
340
340
|
Card::Content.clean!('<span class="banana">foo</span>')
|
341
341
|
end
|
342
342
|
|
343
|
-
it "
|
343
|
+
it "does not strip permitted_classes" do
|
344
344
|
has_stripped1 = '<span class="w-spotlight">foo</span>'
|
345
345
|
assert_equal has_stripped1,
|
346
346
|
Card::Content.clean!(has_stripped1)
|
@@ -349,7 +349,7 @@ describe Card::Content do
|
|
349
349
|
Card::Content.clean!(has_stripped2)
|
350
350
|
end
|
351
351
|
|
352
|
-
it "
|
352
|
+
it "strips permitted_classes " \
|
353
353
|
"but not permitted ones when both are present" do
|
354
354
|
assert_equal '<span class="w-spotlight w-ok">foo</span>',
|
355
355
|
Card::Content.clean!(
|
@@ -365,7 +365,7 @@ describe Card::Content do
|
|
365
365
|
)
|
366
366
|
end
|
367
367
|
|
368
|
-
it "
|
368
|
+
it "allows permitted attributes" do
|
369
369
|
assert_equal '<img src="foo">', Card::Content.clean!('<img src="foo">')
|
370
370
|
assert_equal "<img alt='foo'>", Card::Content.clean!("<img alt='foo'>")
|
371
371
|
assert_equal '<img title="foo">',
|
@@ -377,12 +377,12 @@ describe Card::Content do
|
|
377
377
|
Card::Content.clean!('<blockquote cite="foo">')
|
378
378
|
end
|
379
379
|
|
380
|
-
it "
|
380
|
+
it "does not allow nonpermitted attributes" do
|
381
381
|
assert_equal "<img>", Card::Content.clean!('<img size="25">')
|
382
382
|
assert_equal "<p>", Card::Content.clean!('<p font="blah">')
|
383
383
|
end
|
384
384
|
|
385
|
-
it "
|
385
|
+
it "removes comments" do
|
386
386
|
assert_equal "yo", Card::Content.clean!("<!-- not me -->yo")
|
387
387
|
assert_equal "joe",
|
388
388
|
Card::Content.clean!("<!-- not me -->joe<!-- not me -->")
|
data/spec/lib/card/diff_spec.rb
CHANGED
@@ -202,7 +202,7 @@ describe Card::Content::Diff do
|
|
202
202
|
end
|
203
203
|
|
204
204
|
it "removes square brackets" do
|
205
|
-
expect(diff "[[Hello]]", "[[Hi]]").to eq(del("Hello") + ins("Hi"))
|
205
|
+
expect(diff "[[Hello]]", "[[Hi]]").to eq(del("Hello<br>") + ins("Hi<br>"))
|
206
206
|
end
|
207
207
|
end
|
208
208
|
end
|
@@ -1,36 +1,31 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
describe Card::Format do
|
4
|
-
describe "#
|
4
|
+
describe "#show_view?" do
|
5
5
|
let(:format) { described_class.new Card.new }
|
6
6
|
|
7
|
-
def show_menu? args
|
8
|
-
|
7
|
+
def show_menu? args, default_viz=:show
|
8
|
+
args.merge! optional: true
|
9
|
+
format.with_voo(Card::View.new format, :nonview, args) do
|
10
|
+
format.show_view?(:menu, default_viz)
|
11
|
+
end
|
9
12
|
end
|
10
|
-
it "
|
11
|
-
expect(show_menu?(
|
12
|
-
expect(show_menu?(
|
13
|
+
it "respects defaults" do
|
14
|
+
expect(show_menu?({}, :show)).to be_truthy
|
15
|
+
expect(show_menu?({}, :hide)).to be_falsey
|
13
16
|
expect(show_menu?({})).to be_truthy
|
14
17
|
end
|
15
18
|
|
16
|
-
it "
|
17
|
-
expect(show_menu?(
|
18
|
-
|
19
|
-
expect(show_menu?(
|
20
|
-
.to be_falsey
|
21
|
-
expect(show_menu?(optional_menu: :hide)).to be_falsey
|
19
|
+
it "respects developer defaults" do
|
20
|
+
expect(show_menu?({ show: "menu" }, :hide)).to be_truthy
|
21
|
+
expect(show_menu?({ hide: "menu" }, :show)).to be_falsey
|
22
|
+
expect(show_menu?(hide: "menu")).to be_falsey
|
22
23
|
end
|
23
24
|
|
24
|
-
it "
|
25
|
-
expect(show_menu?(show: "menu",
|
26
|
-
expect(show_menu?(hide: "menu, paging",
|
27
|
-
|
28
|
-
expect(show_menu?(show: "menu", optional_menu: :hide)).to be_truthy
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should handle hard developer overrides" do
|
32
|
-
expect(show_menu?(optional_menu: :always, hide: "menu")).to be_truthy
|
33
|
-
expect(show_menu?(optional_menu: :never, show: "menu")).to be_falsey
|
25
|
+
it "handles args from nests" do
|
26
|
+
expect(show_menu?({ show: "menu" }, :hide)).to be_truthy
|
27
|
+
expect(show_menu?({ hide: "menu, paging" }, :show)).to be_falsey
|
28
|
+
expect(show_menu?({ show: "menu" }, :hide)).to be_truthy
|
34
29
|
end
|
35
30
|
end
|
36
31
|
|
@@ -56,7 +51,7 @@ describe Card::Format do
|
|
56
51
|
"external with port: http://localhost:2020/path?cgi=foo+bar=baz after "
|
57
52
|
end
|
58
53
|
|
59
|
-
it "
|
54
|
+
it "formats links" do
|
60
55
|
cobj = Card::Content.new url_text1, text_format
|
61
56
|
expect(cobj.to_s).to eq url_text1
|
62
57
|
cobj = Card::Content.new url_text2, text_format
|
@@ -69,7 +64,7 @@ describe Card::Format do
|
|
69
64
|
expect(cobj.to_s).to eq url_text5
|
70
65
|
end
|
71
66
|
|
72
|
-
it "
|
67
|
+
it "formats html links" do
|
73
68
|
cobj = Card::Content.new url_text1, html_format
|
74
69
|
expect(cobj.to_s).to eq(
|
75
70
|
'with external free link <a target="_blank" class="external-link" ' \
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# # let(:pat_all_double) { proxy Card::Set::All }
|
6
6
|
# # let(:format_double) { proxy Card::Format }
|
7
7
|
# # let(:html_format_double) { proxy Card::Format::HtmlFormat }
|
8
|
-
# # it "
|
8
|
+
# # it "autos-load Card class methods from lib/card and mods" do
|
9
9
|
# # #xpect(Card).to receive(:load_mods)
|
10
10
|
# # #
|
11
11
|
# # card = Card[:all]
|
@@ -19,16 +19,16 @@
|
|
19
19
|
# # # allow(Card).to receive(:file_path_sdfs)
|
20
20
|
# # #expect(Card.instance_method(:file_path)).to be
|
21
21
|
# # end
|
22
|
-
# # it "
|
22
|
+
# # it "defines Card methods from modules" do
|
23
23
|
# # expect(Card.instance_method(:set_modules)).to be
|
24
24
|
# # end
|
25
|
-
# # it "
|
25
|
+
# # it "defines Formatter methods from modules" do
|
26
26
|
# # #expect(Card.instance_method(:render_core)).to be
|
27
27
|
# # expect(Card.instance_method(:_render_raw)).to be
|
28
28
|
# # expect(Card.instance_method(:render_core)).to be
|
29
29
|
# # expect(Card.instance_method(:_render_raw)).to be
|
30
30
|
# # end
|
31
|
-
# # it "
|
31
|
+
# # it "defines Formatter methods from modules" do
|
32
32
|
# # expect(html_format_double.method(:render_core)).to be
|
33
33
|
# # expect(html_format_double.method(:_render_raw)).to be
|
34
34
|
# # expect(html_format_double.method(:render_core)).to be
|
data/spec/lib/card/name_spec.rb
CHANGED
@@ -2,64 +2,64 @@
|
|
2
2
|
|
3
3
|
describe Card::Name do
|
4
4
|
describe "#key" do
|
5
|
-
it "
|
5
|
+
it "lowercases and underscores" do
|
6
6
|
expect("This Name".to_name.key).to eq("this_name")
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "removes spaces" do
|
10
10
|
expect("this Name".to_name.key).to eq("this_name")
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "underscores" do
|
14
|
-
it "
|
14
|
+
it "is treated like spaces" do
|
15
15
|
expect("weird_ combo".to_name.key).to eq("weird combo".to_name.key)
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
18
|
+
it "does not impede pluralization checks" do
|
19
19
|
expect("Mamas_and_Papas".to_name.key).to(
|
20
20
|
eq("Mamas and Papas".to_name.key)
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "is removed when before first word character" do
|
25
25
|
expect("_This Name".to_name.key).to eq("this_name")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "singularizes" do
|
30
30
|
expect("ethans".to_name.key).to eq("ethan")
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "changes CamelCase to snake case" do
|
34
34
|
expect("ThisThing".to_name.key).to eq("this_thing")
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "handles plus cards" do
|
38
38
|
expect("ThisThing+Ethans".to_name.key).to eq("this_thing+ethan")
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "retains * for star cards" do
|
42
42
|
expect("*right".to_name.key).to eq("*right")
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "does not singularize double s's" do
|
46
46
|
expect("grass".to_name.key).to eq("grass")
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "does not singularize letter 'S'" do
|
50
50
|
expect("S".to_name.key).to eq("s")
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "handles unicode characters" do
|
54
54
|
expect("Mañana".to_name.key).to eq("mañana")
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "handles weird initial characters" do
|
58
58
|
expect("__you motha @\#$".to_name.key).to eq("you_motha")
|
59
59
|
expect("?!_you motha @\#$".to_name.key).to eq("you_motha")
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "allows numbers" do
|
63
63
|
expect("3way".to_name.key).to eq("3way")
|
64
64
|
end
|
65
65
|
|
@@ -67,7 +67,7 @@ describe Card::Name do
|
|
67
67
|
expect("cards hooks label foos".to_name.key).to eq("card_hook_label_foo")
|
68
68
|
end
|
69
69
|
|
70
|
-
it "
|
70
|
+
it "handles html entities" do
|
71
71
|
# This no longer takes off the s, is singularize broken now?
|
72
72
|
expect("Jean-françois Noubel".to_name.key).to(
|
73
73
|
eq("jean_françoi_noubel")
|
@@ -80,7 +80,7 @@ describe Card::Name do
|
|
80
80
|
"PB & J", "Mañana"].map(&:to_name)
|
81
81
|
|
82
82
|
cardnames.each do |cardname|
|
83
|
-
it "
|
83
|
+
it "has the same key as the name" do
|
84
84
|
k = cardname.key
|
85
85
|
k2 = cardname.url_key
|
86
86
|
# warn "cn tok #{cardname.inspect}, #{k.inspect}, #{k2.inspect}"
|
data/spec/lib/card/query_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Card::Query do
|
|
10
10
|
Card::Query.run @query.reverse_merge return: :name, sort: :name
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "does not alter original statement" do
|
14
14
|
@query = { right_plus: { name: %w(in tag source) } }
|
15
15
|
query_clone = @query.deep_clone
|
16
16
|
subject # runs query
|
@@ -18,7 +18,7 @@ describe Card::Query do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "append" do
|
21
|
-
it "
|
21
|
+
it "finds real cards" do
|
22
22
|
@query = {
|
23
23
|
name: [:in, "C", "D", "F"],
|
24
24
|
append: "A"
|
@@ -26,7 +26,7 @@ describe Card::Query do
|
|
26
26
|
is_expected.to eq(%w(C+A D+A F+A))
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "absolutizes names" do
|
30
30
|
@query = {
|
31
31
|
name: [:in, "C", "D", "F"],
|
32
32
|
append: "_right",
|
@@ -35,7 +35,7 @@ describe Card::Query do
|
|
35
35
|
is_expected.to eq(%w(C+A D+A F+A))
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "finds virtual cards" do
|
39
39
|
@query = {
|
40
40
|
name: [:in, "C", "D"],
|
41
41
|
append: "*plus cards"
|
@@ -45,17 +45,17 @@ describe Card::Query do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "in" do
|
48
|
-
it "
|
48
|
+
it "works for content options" do
|
49
49
|
@query = { in: %w(AlphaBeta Theta) }
|
50
50
|
is_expected.to eq(%w(A+B T))
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "finds the same thing in full syntax" do
|
54
54
|
@query = { content: [:in, "Theta", "AlphaBeta"] }
|
55
55
|
is_expected.to eq(%w(A+B T))
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "works on types" do
|
59
59
|
@query = { type: [:in, "Cardtype E", "Cardtype F"] }
|
60
60
|
is_expected.to eq(%w(type-e-card type-f-card))
|
61
61
|
end
|
@@ -74,7 +74,7 @@ describe Card::Query do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "not" do
|
77
|
-
it "
|
77
|
+
it "excludes cards matching not criteria" do
|
78
78
|
Card::Auth.as_bot
|
79
79
|
@query = { plus: "A", not: { plus: "A+B" } }
|
80
80
|
is_expected.to eq(%w(B D E F))
|
@@ -82,64 +82,64 @@ describe Card::Query do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
describe "multiple values" do
|
85
|
-
it "
|
85
|
+
it "handles :all as the first element of an Array" do
|
86
86
|
@query = { member_of: [:all, { name: "r1" }, { key: "r2" }] }
|
87
87
|
is_expected.to eq(%w(u1 u2))
|
88
88
|
end
|
89
89
|
|
90
|
-
it "
|
90
|
+
it "handles act like :all by default" do
|
91
91
|
@query = { member_of: [{ name: "r1" }, { key: "r2" }] }
|
92
92
|
is_expected.to eq(%w(u1 u2))
|
93
93
|
end
|
94
94
|
|
95
|
-
it "
|
95
|
+
it "handles :any as the first element of an Array" do
|
96
96
|
@query = { member_of: [:any, { name: "r1" }, { key: "r2" }] }
|
97
97
|
is_expected.to eq(%w(u1 u2 u3))
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
100
|
+
it "handles :any as a relationship" do
|
101
101
|
@query = { member_of: { any: [{ name: "r1" }, { key: "r2" }] } }
|
102
102
|
is_expected.to eq(%w(u1 u2 u3))
|
103
103
|
end
|
104
104
|
|
105
|
-
it "
|
105
|
+
it "handles explicit conjunctions in plus_relational keys" do
|
106
106
|
@query = { right_plus: [:all, "e", "c"] }
|
107
107
|
is_expected.to eq(%w(A))
|
108
108
|
end
|
109
109
|
|
110
|
-
it "
|
110
|
+
it "handles multiple values for right_part in compound relations" do
|
111
111
|
@query = { right_plus: [["e", {}], "c"] }
|
112
112
|
is_expected.to eq(%w(A)) # first element is array
|
113
113
|
end
|
114
114
|
|
115
|
-
it "
|
115
|
+
it "does not interpret simple arrays as multi values for plus" do
|
116
116
|
@query = { right_plus: %w(e c) }
|
117
117
|
is_expected.to eq([]) # NOT interpreted as multi-value
|
118
118
|
end
|
119
119
|
|
120
|
-
it "
|
120
|
+
it "handles :and for references" do
|
121
121
|
@query = { refer_to: [:and, "a", "b"] }
|
122
122
|
is_expected.to eq(%w(Y))
|
123
123
|
end
|
124
124
|
|
125
|
-
it "
|
125
|
+
it "handles :or for references" do
|
126
126
|
@query = { refer_to: [:or, "b", "z"] }
|
127
127
|
is_expected.to eq(%w(A B Y))
|
128
128
|
end
|
129
129
|
|
130
|
-
it "
|
130
|
+
it "handles treat simple arrays like :all for references" do
|
131
131
|
@query = { refer_to: %w(A T) }
|
132
132
|
is_expected.to eq(%w(X Y))
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe "edited_by/editor_of" do
|
137
|
-
it "
|
137
|
+
it "finds card edited by joe using subquery" do
|
138
138
|
@query = { edited_by: { match: "Joe User" } }
|
139
139
|
is_expected.to eq(%w(JoeLater JoeNow))
|
140
140
|
end
|
141
141
|
|
142
|
-
it "
|
142
|
+
it "finds card edited by Wagn Bot" do
|
143
143
|
# this is a weak test, since it gives the name, but different sorting
|
144
144
|
# mechanisms in other db setups
|
145
145
|
# was having it return *account in some cases and 'A' in others
|
@@ -147,12 +147,12 @@ describe Card::Query do
|
|
147
147
|
is_expected.to eq(%w(A))
|
148
148
|
end
|
149
149
|
|
150
|
-
it
|
150
|
+
it "fails gracefully if user isn't there" do
|
151
151
|
@query = { edited_by: "Joe LUser" }
|
152
152
|
is_expected.to eq([])
|
153
153
|
end
|
154
154
|
|
155
|
-
it "
|
155
|
+
it "does not give duplicate results for multiple edits" do
|
156
156
|
c = Card["JoeNow"]
|
157
157
|
c.content = "testagagin"
|
158
158
|
c.save
|
@@ -162,7 +162,7 @@ describe Card::Query do
|
|
162
162
|
is_expected.to eq(%w(JoeLater JoeNow))
|
163
163
|
end
|
164
164
|
|
165
|
-
it
|
165
|
+
it "finds joe user among card's editors" do
|
166
166
|
@query = { editor_of: "JoeLater" }
|
167
167
|
is_expected.to eq(["Joe User"])
|
168
168
|
end
|
@@ -173,12 +173,12 @@ describe Card::Query do
|
|
173
173
|
Card.create name: "Create Test", content: "sufficiently distinctive"
|
174
174
|
end
|
175
175
|
|
176
|
-
it "
|
176
|
+
it "finds Joe User as the card's creator" do
|
177
177
|
@query = { creator_of: "Create Test" }
|
178
178
|
is_expected.to eq(["Joe User"])
|
179
179
|
end
|
180
180
|
|
181
|
-
it "
|
181
|
+
it "finds card created by Joe User" do
|
182
182
|
@query = { created_by: "Joe User", eq: "sufficiently distinctive" }
|
183
183
|
is_expected.to eq(["Create Test"])
|
184
184
|
end
|
@@ -191,26 +191,26 @@ describe Card::Query do
|
|
191
191
|
c.save!
|
192
192
|
end
|
193
193
|
|
194
|
-
it "
|
194
|
+
it "finds Joe User as the card's last editor" do
|
195
195
|
@query = { last_editor_of: "A" }
|
196
196
|
is_expected.to eq(["Joe User"])
|
197
197
|
end
|
198
198
|
|
199
|
-
it "
|
199
|
+
it "finds card created by Joe User" do
|
200
200
|
@query = { last_edited_by: "Joe User", eq: "peculicious" }
|
201
201
|
is_expected.to eq(["A"])
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
205
|
describe "keyword" do
|
206
|
-
it "
|
206
|
+
it "escapes nonword characters" do
|
207
207
|
@query = { match: "two :(!" }
|
208
208
|
is_expected.to eq(CARDS_MATCHING_TWO)
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
212
|
describe "search count" do
|
213
|
-
it "
|
213
|
+
it "returns integer" do
|
214
214
|
search = Card.create!(
|
215
215
|
name: "tmpsearch",
|
216
216
|
type: "Search",
|
@@ -221,51 +221,51 @@ describe Card::Query do
|
|
221
221
|
end
|
222
222
|
|
223
223
|
describe "cgi_params" do
|
224
|
-
it "
|
224
|
+
it "matchs content from cgi" do
|
225
225
|
@query = { match: "$keyword", vars: { keyword: "two" } }
|
226
226
|
is_expected.to eq(CARDS_MATCHING_TWO)
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
230
|
describe "content equality" do
|
231
|
-
it "
|
231
|
+
it "matchs content explicitly" do
|
232
232
|
@query = { content: ["=", "I'm number two"] }
|
233
233
|
is_expected.to eq(["Joe User"])
|
234
234
|
end
|
235
235
|
|
236
|
-
it "
|
236
|
+
it "matchs via shortcut" do
|
237
237
|
@query = { "=" => "I'm number two" }
|
238
238
|
is_expected.to eq(["Joe User"])
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
242
|
describe "links" do
|
243
|
-
it "
|
243
|
+
it "handles refer_to" do
|
244
244
|
@query = { refer_to: "Z" }
|
245
245
|
is_expected.to eq(%w(A B))
|
246
246
|
end
|
247
247
|
|
248
|
-
it "
|
248
|
+
it "handles link_to" do
|
249
249
|
@query = { link_to: "Z" }
|
250
250
|
is_expected.to eq(%w(A))
|
251
251
|
end
|
252
252
|
|
253
|
-
it "
|
253
|
+
it "handles include" do
|
254
254
|
@query = { include: "Z" }
|
255
255
|
is_expected.to eq(%w(B))
|
256
256
|
end
|
257
257
|
|
258
|
-
it "
|
258
|
+
it "handles linked_to_by" do
|
259
259
|
@query = { linked_to_by: "A" }
|
260
260
|
is_expected.to eq(%w(Z))
|
261
261
|
end
|
262
262
|
|
263
|
-
it "
|
263
|
+
it "handles included_by" do
|
264
264
|
@query = { included_by: "B" }
|
265
265
|
is_expected.to eq(%w(Z))
|
266
266
|
end
|
267
267
|
|
268
|
-
it "
|
268
|
+
it "handles referred_to_by" do
|
269
269
|
@query = { referred_to_by: "X" }
|
270
270
|
is_expected.to eq(%w(A A+B T))
|
271
271
|
end
|
@@ -284,14 +284,14 @@ describe Card::Query do
|
|
284
284
|
end
|
285
285
|
|
286
286
|
describe "relative links" do
|
287
|
-
it "
|
287
|
+
it "handles relative refer_to" do
|
288
288
|
@query = { refer_to: "_self", context: "Z" }
|
289
289
|
is_expected.to eq(%w(A B))
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
293
293
|
describe "permissions" do
|
294
|
-
it "
|
294
|
+
it "does not find cards not in group" do
|
295
295
|
Card::Auth.as_bot do
|
296
296
|
Card.create name: "C+*self+*read", type: "Pointer", content: "[[R1]]"
|
297
297
|
end
|
@@ -301,53 +301,53 @@ describe Card::Query do
|
|
301
301
|
end
|
302
302
|
|
303
303
|
describe "basics" do
|
304
|
-
it "
|
304
|
+
it "is case insensitive for name" do
|
305
305
|
@query = { name: "a" }
|
306
306
|
is_expected.to eq(["A"])
|
307
307
|
end
|
308
308
|
|
309
|
-
it "
|
309
|
+
it "finds plus cards" do
|
310
310
|
@query = { plus: "A" }
|
311
311
|
is_expected.to eq(A_JOINEES)
|
312
312
|
end
|
313
313
|
|
314
|
-
it "
|
314
|
+
it "finds connection cards" do
|
315
315
|
@query = { part: "A" }
|
316
316
|
is_expected.to eq(%w(A+B A+C A+D A+E C+A D+A F+A))
|
317
317
|
end
|
318
318
|
|
319
|
-
it "
|
319
|
+
it "finds left connection cards" do
|
320
320
|
@query = { left: "A" }
|
321
321
|
is_expected.to eq(%w(A+B A+C A+D A+E))
|
322
322
|
end
|
323
323
|
|
324
|
-
it "
|
324
|
+
it "finds right connection cards based on name" do
|
325
325
|
@query = { right: "A" }
|
326
326
|
is_expected.to eq(%w(C+A D+A F+A))
|
327
327
|
end
|
328
328
|
|
329
|
-
it "
|
329
|
+
it "finds right connection cards based on content" do
|
330
330
|
@query = { right: { content: "Alpha [[Z]]" } }
|
331
331
|
is_expected.to eq(%w(C+A D+A F+A))
|
332
332
|
end
|
333
333
|
|
334
|
-
it "
|
334
|
+
it "returns count" do
|
335
335
|
expect(Card.count_by_wql part: "A").to eq(7)
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
339
|
describe "limit and offset" do
|
340
|
-
it "
|
340
|
+
it "returns limit" do
|
341
341
|
@query = { part: "A", limit: 5 }
|
342
342
|
expect(subject.size).to eq(5)
|
343
343
|
end
|
344
344
|
|
345
|
-
it "
|
345
|
+
it "does not break if offset but no limit" do
|
346
346
|
@query = { part: "A", offset: 5 }
|
347
347
|
expect(subject.size).not_to eq(0)
|
348
348
|
end
|
349
349
|
|
350
|
-
it "
|
350
|
+
it "does not break count" do
|
351
351
|
query = { match: "two", offset: 1 }
|
352
352
|
expect(Card.count_by_wql(query)).to eq(CARDS_MATCHING_TWO.length)
|
353
353
|
end
|
@@ -360,24 +360,24 @@ describe Card::Query do
|
|
360
360
|
"Sunglasses fan", "u1", "u2", "u3"
|
361
361
|
].sort
|
362
362
|
|
363
|
-
it "
|
363
|
+
it "finds cards of this type" do
|
364
364
|
@query = { type: "_self", context: "User" }
|
365
365
|
is_expected.to eq(user_cards)
|
366
366
|
end
|
367
367
|
|
368
|
-
it "
|
368
|
+
it "finds User cards " do
|
369
369
|
@query = { type: "User" }
|
370
370
|
is_expected.to eq(user_cards)
|
371
371
|
end
|
372
372
|
|
373
|
-
it "
|
373
|
+
it "handles casespace variants" do
|
374
374
|
@query = { type: "users" }
|
375
375
|
is_expected.to eq(user_cards)
|
376
376
|
end
|
377
377
|
end
|
378
378
|
|
379
379
|
describe "trash handling" do
|
380
|
-
it "
|
380
|
+
it "does not find cards in the trash" do
|
381
381
|
Card["A+B"].delete!
|
382
382
|
@query = { left: "A" }
|
383
383
|
is_expected.to eq(["A+C", "A+D", "A+E"])
|
@@ -385,7 +385,7 @@ describe Card::Query do
|
|
385
385
|
end
|
386
386
|
|
387
387
|
describe "order" do
|
388
|
-
it "
|
388
|
+
it "sorts by create" do
|
389
389
|
Card.create! name: "classic bootstrap skin head"
|
390
390
|
# classic skin head is created more recently than classic skin,
|
391
391
|
# which is in the seed data
|
@@ -395,22 +395,22 @@ describe Card::Query do
|
|
395
395
|
)
|
396
396
|
end
|
397
397
|
|
398
|
-
it "
|
398
|
+
it "sorts by name" do
|
399
399
|
@query = { name: %w(in B Z A Y C X), sort: "name", dir: "desc" }
|
400
400
|
is_expected.to eq(%w(Z Y X C B A))
|
401
401
|
end
|
402
402
|
|
403
|
-
it "
|
403
|
+
it "sorts by content" do
|
404
404
|
@query = { name: %w(in Z T A), sort: "content" }
|
405
405
|
is_expected.to eq(%w(A Z T))
|
406
406
|
end
|
407
407
|
|
408
|
-
it "
|
408
|
+
it "plays nice with match" do
|
409
409
|
@query = { match: "Z", type: "Basic", sort: "content" }
|
410
410
|
is_expected.to eq(%w(A B Z))
|
411
411
|
end
|
412
412
|
|
413
|
-
it "
|
413
|
+
it "sorts by plus card content" do
|
414
414
|
Card::Auth.as_bot do
|
415
415
|
c = Card.fetch("Setting+*self+*table of contents")
|
416
416
|
c.content = "10"
|
@@ -426,7 +426,7 @@ describe Card::Query do
|
|
426
426
|
end
|
427
427
|
end
|
428
428
|
|
429
|
-
it "
|
429
|
+
it "sorts by count" do
|
430
430
|
Card::Auth.as_bot do
|
431
431
|
@query = {
|
432
432
|
name: [:in, "*always", "*never", "*edited"],
|
@@ -436,7 +436,7 @@ describe Card::Query do
|
|
436
436
|
end
|
437
437
|
end
|
438
438
|
|
439
|
-
# it '
|
439
|
+
# it 'sorts by update' do
|
440
440
|
# # do this on a restricted set so it won't change every time we
|
441
441
|
# # add a card..
|
442
442
|
# Card::Query.run(
|
@@ -450,47 +450,47 @@ describe Card::Query do
|
|
450
450
|
end
|
451
451
|
|
452
452
|
describe "match" do
|
453
|
-
it "
|
453
|
+
it "reachs content and name via shortcut" do
|
454
454
|
@query = { match: "two" }
|
455
455
|
is_expected.to eq(CARDS_MATCHING_TWO)
|
456
456
|
end
|
457
457
|
|
458
|
-
it "
|
458
|
+
it "gets only content when content is explicit" do
|
459
459
|
@query = { content: [:match, "two"] }
|
460
460
|
is_expected.to eq(["Joe User", "script: ace+*all+*script+*machine cache",
|
461
461
|
"script: slot+*all+*script+*machine cache"])
|
462
462
|
end
|
463
463
|
|
464
|
-
it "
|
464
|
+
it "gets only name when name is explicit" do
|
465
465
|
@query = { name: [:match, "two"] }
|
466
466
|
is_expected.to eq(["One+Two", "One+Two+Three", "Two"])
|
467
467
|
end
|
468
468
|
end
|
469
469
|
|
470
470
|
describe "and" do
|
471
|
-
it "
|
471
|
+
it "acts as a simple passthrough with operators" do
|
472
472
|
@query = { and: { match: "two" } }
|
473
473
|
is_expected.to eq(CARDS_MATCHING_TWO)
|
474
474
|
end
|
475
475
|
|
476
|
-
it "
|
476
|
+
it "acts as a simple passthrough with relationships" do
|
477
477
|
@query = { and: {}, type: "Cardtype E" }
|
478
478
|
is_expected.to eq(["type-e-card"])
|
479
479
|
end
|
480
480
|
|
481
|
-
it '
|
481
|
+
it 'works within "or"' do
|
482
482
|
@query = { or: { name: "Z", and: { left: "A", right: "C" } } }
|
483
483
|
is_expected.to eq(["A+C", "Z"])
|
484
484
|
end
|
485
485
|
end
|
486
486
|
|
487
487
|
describe "any" do
|
488
|
-
it "
|
488
|
+
it "works with :plus" do
|
489
489
|
@query = { plus: "A", any: { name: "B", match: "K" } }
|
490
490
|
is_expected.to eq(["B"])
|
491
491
|
end
|
492
492
|
|
493
|
-
it "
|
493
|
+
it "works with multiple plusses" do
|
494
494
|
@query = { or: { right_plus: "A", plus: "B" } }
|
495
495
|
is_expected.to eq(%w(A C D F))
|
496
496
|
end
|
@@ -504,29 +504,29 @@ describe Card::Query do
|
|
504
504
|
)
|
505
505
|
end
|
506
506
|
|
507
|
-
it "
|
507
|
+
it "finds cards returned by search of given name" do
|
508
508
|
@query = { found_by: "Simple Search" }
|
509
509
|
is_expected.to eq(["A"])
|
510
510
|
end
|
511
511
|
|
512
|
-
it "
|
512
|
+
it "finds cards returned by virtual cards" do
|
513
513
|
image_cards = Card.search type: "Image", return: :name, sort: :name
|
514
514
|
@query = { found_by: "Image+*type+by name" }
|
515
515
|
is_expected.to eq(image_cards)
|
516
516
|
end
|
517
517
|
|
518
|
-
it "
|
518
|
+
it "plays nicely with other properties and relationships" do
|
519
519
|
explicit_query = { plus: { name: "A" }, return: :name, sort: :name }
|
520
520
|
@query = { plus: { found_by: "Simple Search" } }
|
521
521
|
is_expected.to eq(Card::Query.run(explicit_query))
|
522
522
|
end
|
523
523
|
|
524
|
-
it "
|
524
|
+
it "plays work with virtual cards" do
|
525
525
|
@query = { found_by: "A+*self", plus: "C" }
|
526
526
|
is_expected.to eq(["A"])
|
527
527
|
end
|
528
528
|
|
529
|
-
it "
|
529
|
+
it "is able to handle _self" do
|
530
530
|
@query = {
|
531
531
|
context: "Simple Search",
|
532
532
|
left: { found_by: "_self" },
|
@@ -538,33 +538,33 @@ describe Card::Query do
|
|
538
538
|
end
|
539
539
|
|
540
540
|
describe "relative" do
|
541
|
-
it "
|
541
|
+
it "cleans wql" do
|
542
542
|
query = Card::Query.new(part: "_self", context: "A")
|
543
543
|
expect(query.statement[:part]).to eq("A")
|
544
544
|
end
|
545
545
|
|
546
|
-
it "
|
546
|
+
it "finds connection cards" do
|
547
547
|
@query = { part: "_self", context: "A" }
|
548
548
|
is_expected.to eq(%w(A+B A+C A+D A+E C+A D+A F+A))
|
549
549
|
end
|
550
550
|
|
551
|
-
it "
|
551
|
+
it "is able to use parts of nonexistent cards in search" do
|
552
552
|
expect(Card["B+A"]).to be_nil
|
553
553
|
@query = { left: "_right", right: "_left", context: "B+A" }
|
554
554
|
is_expected.to eq(["A+B"])
|
555
555
|
end
|
556
556
|
|
557
|
-
it "
|
557
|
+
it "finds plus cards for _self" do
|
558
558
|
@query = { plus: "_self", context: "A" }
|
559
559
|
is_expected.to eq(A_JOINEES)
|
560
560
|
end
|
561
561
|
|
562
|
-
it "
|
562
|
+
it "finds plus cards for _left" do
|
563
563
|
@query = { plus: "_left", context: "A+B" }
|
564
564
|
is_expected.to eq(A_JOINEES)
|
565
565
|
end
|
566
566
|
|
567
|
-
it "
|
567
|
+
it "finds plus cards for _right" do
|
568
568
|
@query = { plus: "_right", context: "C+A" }
|
569
569
|
is_expected.to eq(A_JOINEES)
|
570
570
|
end
|