card 1.19.0 → 1.19.1
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/card.gemspec +3 -3
- data/config/initializers/{02_extensions → 02_patches}/kaminari.rb +16 -5
- data/config/initializers/patches.rb +7 -0
- data/config/locales/en.yml +15 -6
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +11 -11
- data/db/migrate_core_cards/data/themes/bootstrap_default/_variables.scss +2 -1
- data/db/seed/new/card_actions.yml +915 -443
- data/db/seed/new/card_acts.yml +348 -186
- data/db/seed/new/card_changes.yml +4409 -3329
- data/db/seed/new/card_references.yml +220 -3
- data/db/seed/new/cards.yml +6687 -3445
- data/db/seed/test/fixtures/card_actions.yml +1953 -1513
- data/db/seed/test/fixtures/card_acts.yml +615 -453
- data/db/seed/test/fixtures/card_changes.yml +7596 -6516
- data/db/seed/test/fixtures/card_references.yml +892 -675
- data/db/seed/test/fixtures/cards.yml +8803 -5561
- data/db/seeds.rb +8 -0
- data/lib/card.rb +10 -0
- data/lib/card/auth/setup.rb +6 -6
- data/lib/card/mod/dirs.rb +13 -3
- data/lib/card/set/advanced_api.rb +5 -4
- data/lib/cardio.rb +7 -3
- data/mod/Modfile +2 -2
- data/mod/admin/set/self/admin.rb +47 -30
- data/mod/admin/set/self/admin_info.rb +11 -11
- data/mod/basic_formats/set/self/head.rb +1 -1
- data/mod/{basic_types → basic_formats}/spec/set/all/all_css_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/all_csv_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/base_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/file_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/json_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/rss_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/text_spec.rb +0 -0
- data/mod/bootstrap/lib/stylesheets/bootstrap/_variables.scss +1 -1
- data/mod/bootstrap/set/all/bootstrap/table.rb +1 -1
- data/mod/bootstrap/set/self/bootswatch_shared.rb +1 -1
- data/mod/carrierwave/Gemfile +4 -0
- data/mod/carrierwave/lib/carrier_wave/cardmount.rb +24 -13
- data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +189 -57
- data/mod/carrierwave/lib/carrier_wave/image_card_uploader.rb +5 -0
- data/mod/carrierwave/set/abstract/attachment.rb +26 -190
- data/mod/carrierwave/set/abstract/attachment/paths.rb +50 -0
- data/mod/carrierwave/set/abstract/attachment/storage_type.rb +319 -0
- data/mod/carrierwave/set/abstract/attachment/upload_cache.rb +77 -0
- data/mod/carrierwave/set/all/file_utils.rb +28 -0
- data/mod/carrierwave/set/self/admin.rb +23 -0
- data/mod/carrierwave/set/type/file.rb +26 -23
- data/mod/carrierwave/set/type/image.rb +1 -0
- data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +67 -0
- data/mod/carrierwave/spec/set/type/file_spec.rb +557 -0
- data/mod/{standard → carrierwave}/spec/set/type/image_spec.rb +22 -4
- data/mod/core/set/abstract/code_file.rb +3 -3
- data/mod/core/set/all/debug.rb +23 -0
- data/mod/core/set/all/name.rb +1 -1
- data/mod/core/set/all/permissions.rb +22 -12
- data/mod/core/set/all/tracked_attributes.rb +0 -76
- data/mod/core/set/all/trash.rb +50 -0
- data/mod/core/set/all/update_read_rules.rb +84 -0
- data/mod/core/set/all/utils.rb +1 -75
- data/mod/email/set/type_plus_right/user/follow.rb +4 -8
- data/mod/history/lib/card/act.rb +3 -1
- data/mod/history/lib/card/action.rb +3 -1
- data/mod/history/lib/card/action/differ.rb +12 -1
- data/mod/history/set/all/history.rb +2 -1
- data/mod/machines/file/all_script_machine_output/file.js +211 -0
- data/mod/machines/file/all_style_machine_output/file.css +19 -0
- data/mod/machines/set/abstract/machine.rb +270 -0
- data/mod/machines/set/abstract/machine_input.rb +76 -0
- data/mod/machines/set/right/machine_output.rb +9 -1
- data/mod/machines/set/type/coffee_script.rb +2 -6
- data/mod/machines/set/type/css.rb +2 -2
- data/mod/machines/set/type/java_script.rb +2 -2
- data/mod/machines/set/type/skin.rb +2 -2
- data/mod/machines/spec/set/abstract/machine_spec.rb +10 -0
- data/mod/{basic_types → pointer}/spec/set/type/pointer_spec.rb +10 -26
- data/mod/settings/set/right/script.rb +1 -1
- data/mod/settings/set/right/style.rb +1 -1
- data/mod/solid_cache/set/all/solid_cache.rb +1 -1
- data/mod/standard/file/credit_image/image-icon.png +0 -0
- data/mod/standard/file/credit_image/image-large.png +0 -0
- data/mod/standard/file/credit_image/image-medium.png +0 -0
- data/mod/standard/file/credit_image/image-small.png +0 -0
- data/mod/standard/file/favicon/image-icon.png +0 -0
- data/mod/standard/file/favicon/image-large.png +0 -0
- data/mod/standard/file/favicon/image-medium.png +0 -0
- data/mod/standard/file/favicon/image-small.png +0 -0
- data/mod/standard/file/logo/image-icon.png +0 -0
- data/mod/standard/file/logo/image-large.png +0 -0
- data/mod/standard/file/logo/image-medium.png +0 -0
- data/mod/standard/file/logo/image-small.png +0 -0
- data/mod/standard/set/all/links.rb +2 -2
- data/spec/spec_helper.rb +15 -3
- data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin.rb +47 -30
- data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin_info.rb +11 -11
- data/tmpsets/set/{mod014-admin → mod001-admin}/self/version.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/abstract/code_file.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/actify.rb +6 -5
- data/tmpsets/set/{mod001-core → mod002-core}/all/active_card.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/collection.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/content.rb +0 -0
- data/tmpsets/set/mod002-core/all/debug.rb +30 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/erb.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/event.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/export.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/fetch.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/haml.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/initialize.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/location_history.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/name.rb +1 -1
- data/tmpsets/set/{mod001-core → mod002-core}/all/name_validations.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/pattern.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/permissions.rb +22 -12
- data/tmpsets/set/{mod001-core → mod002-core}/all/phases.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/references.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/rules.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/stages.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/states.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/subcards.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/templating.rb +0 -0
- data/tmpsets/set/mod002-core/all/tracked_attributes.rb +78 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/trash.rb +50 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/type.rb +0 -0
- data/tmpsets/set/mod002-core/all/update_read_rules.rb +91 -0
- data/tmpsets/set/mod002-core/all/utils.rb +62 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/view_cache.rb +0 -0
- data/tmpsets/set/{mod002-history → mod003-history}/all/actions.rb +0 -0
- data/tmpsets/set/{mod002-history → mod003-history}/all/content_history.rb +0 -0
- data/tmpsets/set/{mod002-history → mod003-history}/all/history.rb +2 -1
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_css.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_csv.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_js.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/base.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/file.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/json.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/rss.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/text.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/01_head/javascript.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/head.rb +1 -1
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer/edit.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/code_pointer.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_editors.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_mods.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_pointer_config.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/type/pointer.rb +0 -0
- data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/abstract/ace_editor.rb +0 -0
- data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace.rb +0 -0
- data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace_config.rb +0 -0
- data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
- data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror.rb +0 -0
- data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
- data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/abstract/solid_cache.rb +0 -0
- data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/all/solid_cache.rb +0 -0
- data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/right/solid_cache.rb +0 -0
- data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/html.rb +0 -0
- data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/plain_text.rb +0 -0
- data/tmpsets/set/mod011-machines/abstract/machine.rb +277 -0
- data/tmpsets/set/mod011-machines/abstract/machine_input.rb +83 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/abstract/script.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/all/reset_machines.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_cache.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_input.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_output.rb +9 -1
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_card_menu.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_html5shiv_printshiv.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery_helper.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_slot.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_bootstrap_compatible.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_cards.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_jquery_ui_smoothness.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/coffee_script.rb +2 -6
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/css.rb +2 -2
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/java_script.rb +2 -2
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/scss.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/skin.rb +2 -2
- data/tmpsets/set/{mod011-settings → mod012-settings}/abstract/permission.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/add_help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/comment.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/create.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/default.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/delete.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/read.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/script.rb +1 -1
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/structure.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/style.rb +1 -1
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/update.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/accountable.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/add_help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/autoname.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/captcha.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/create.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/default.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/default_html_view.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/delete.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/follow_fields.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/input.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/layout.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_create.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_delete.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_update.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/options.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/options_label.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/read.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/recent_settings.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/script.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/structure.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/style.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/table_of_contents.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/thanks.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/update.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/type/setting.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/email_html.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/email_text.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/follow.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/notify.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/observer.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/bcc.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/cc.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/follow.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/follow_fields.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/followers.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/following.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/from.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/html_message.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/to.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/always.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/created.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/edited.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/follow.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/follow_defaults.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/never.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/type/email_template.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/type_plus_right/user/follow.rb +4 -8
- data/tmpsets/set/{mod015-developer → mod014-developer}/all/event_viz.rb +0 -0
- data/tmpsets/set/{mod015-developer → mod014-developer}/all/view_viz.rb +0 -0
- data/tmpsets/set/{mod015-developer → mod014-developer}/right/debug.rb +0 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +118 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +57 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +326 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +84 -0
- data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +35 -0
- data/tmpsets/set/mod015-carrierwave/self/admin.rb +30 -0
- data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/file.rb +27 -24
- data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/image.rb +1 -0
- data/tmpsets/set/mod016-standard/all/links.rb +2 -2
- data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
- data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
- data/vendor/carrierwave/.gitignore +19 -0
- data/vendor/carrierwave/.rubocop.yml +262 -0
- data/vendor/carrierwave/.travis.yml +58 -0
- data/vendor/carrierwave/CHANGELOG.md +81 -0
- data/vendor/carrierwave/CONTRIBUTING.md +37 -0
- data/vendor/carrierwave/Gemfile +5 -0
- data/vendor/carrierwave/README.md +995 -0
- data/vendor/carrierwave/Rakefile +26 -0
- data/vendor/carrierwave/carrierwave.gemspec +45 -0
- data/vendor/carrierwave/cucumber.yml +2 -0
- data/vendor/carrierwave/features/caching.feature +28 -0
- data/vendor/carrierwave/features/download.feature +20 -0
- data/vendor/carrierwave/features/file_storage.feature +37 -0
- data/vendor/carrierwave/features/file_storage_overridden_filename.feature +38 -0
- data/vendor/carrierwave/features/file_storage_overridden_store_dir.feature +38 -0
- data/vendor/carrierwave/features/file_storage_reversing_processor.feature +43 -0
- data/vendor/carrierwave/features/fixtures/bork.txt +1 -0
- data/vendor/carrierwave/features/fixtures/monkey.txt +1 -0
- data/vendor/carrierwave/features/fixtures/upcased_bork.txt +1 -0
- data/vendor/carrierwave/features/mount_activerecord.feature +46 -0
- data/vendor/carrierwave/features/step_definitions/activerecord_steps.rb +20 -0
- data/vendor/carrierwave/features/step_definitions/caching_steps.rb +12 -0
- data/vendor/carrierwave/features/step_definitions/datamapper_steps.rb +27 -0
- data/vendor/carrierwave/features/step_definitions/download_steps.rb +8 -0
- data/vendor/carrierwave/features/step_definitions/file_steps.rb +51 -0
- data/vendor/carrierwave/features/step_definitions/general_steps.rb +102 -0
- data/vendor/carrierwave/features/step_definitions/mount_steps.rb +17 -0
- data/vendor/carrierwave/features/step_definitions/store_steps.rb +16 -0
- data/vendor/carrierwave/features/support/activerecord.rb +18 -0
- data/vendor/carrierwave/features/support/env.rb +19 -0
- data/vendor/carrierwave/features/versions_basics.feature +50 -0
- data/vendor/carrierwave/features/versions_caching_from_versions.feature +32 -0
- data/vendor/carrierwave/features/versions_nested_versions.feature +70 -0
- data/vendor/carrierwave/features/versions_overridden_filename.feature +51 -0
- data/vendor/carrierwave/features/versions_overriden_store_dir.feature +41 -0
- data/vendor/carrierwave/gemfiles/rails-4-0-stable.gemfile +5 -0
- data/vendor/carrierwave/gemfiles/rails-4-1-stable.gemfile +5 -0
- data/vendor/carrierwave/gemfiles/rails-4-2-stable.gemfile +5 -0
- data/vendor/carrierwave/gemfiles/rails-master.gemfile +11 -0
- data/vendor/carrierwave/lib/carrierwave.rb +93 -0
- data/vendor/carrierwave/lib/carrierwave/compatibility/paperclip.rb +103 -0
- data/vendor/carrierwave/lib/carrierwave/error.rb +8 -0
- data/vendor/carrierwave/lib/carrierwave/locale/cs.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/de.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/el.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/en.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/es.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/fr-CA.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/fr.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/id.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/ja.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/nb.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/nl.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/pl.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/pt-BR.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/pt-PT.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/ru.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/sk.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/tr.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/zh-CN.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/zh-TW.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/mount.rb +444 -0
- data/vendor/carrierwave/lib/carrierwave/mounter.rb +163 -0
- data/vendor/carrierwave/lib/carrierwave/orm/activerecord.rb +103 -0
- data/vendor/carrierwave/lib/carrierwave/processing.rb +2 -0
- data/vendor/carrierwave/lib/carrierwave/processing/mini_magick.rb +328 -0
- data/vendor/carrierwave/lib/carrierwave/processing/rmagick.rb +379 -0
- data/vendor/carrierwave/lib/carrierwave/sanitized_file.rb +348 -0
- data/vendor/carrierwave/lib/carrierwave/storage.rb +2 -0
- data/vendor/carrierwave/lib/carrierwave/storage/abstract.rb +43 -0
- data/vendor/carrierwave/lib/carrierwave/storage/file.rb +118 -0
- data/vendor/carrierwave/lib/carrierwave/storage/fog.rb +462 -0
- data/vendor/carrierwave/lib/carrierwave/test/matchers.rb +394 -0
- data/vendor/carrierwave/lib/carrierwave/uploader.rb +67 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/cache.rb +207 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/callbacks.rb +33 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/configuration.rb +203 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/content_type_blacklist.rb +48 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/content_type_whitelist.rb +48 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/default_url.rb +17 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/download.rb +92 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/extension_blacklist.rb +51 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/extension_whitelist.rb +51 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/file_size.rb +41 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_blacklist.rb +94 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_whitelist.rb +94 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/mountable.rb +38 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/processing.rb +88 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/proxy.rb +86 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/remove.rb +21 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/serialization.rb +28 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/store.rb +93 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/url.rb +41 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/versions.rb +295 -0
- data/vendor/carrierwave/lib/carrierwave/utilities.rb +6 -0
- data/vendor/carrierwave/lib/carrierwave/utilities/uri.rb +21 -0
- data/vendor/carrierwave/lib/carrierwave/validations/active_model.rb +78 -0
- data/vendor/carrierwave/lib/carrierwave/version.rb +3 -0
- data/vendor/carrierwave/lib/generators/templates/uploader.rb +49 -0
- data/vendor/carrierwave/lib/generators/uploader_generator.rb +7 -0
- data/vendor/carrierwave/script/console +10 -0
- data/vendor/carrierwave/script/destroy +14 -0
- data/vendor/carrierwave/script/generate +14 -0
- data/vendor/carrierwave/spec/compatibility/paperclip_spec.rb +138 -0
- data/vendor/carrierwave/spec/fixtures/Uppercase.jpg +1 -0
- data/vendor/carrierwave/spec/fixtures/bork.ttxt +1 -0
- data/vendor/carrierwave/spec/fixtures/bork.txt +1 -0
- data/vendor/carrierwave/spec/fixtures/bork.txtt +1 -0
- data/vendor/carrierwave/spec/fixtures/case.JPG +1 -0
- data/vendor/carrierwave/spec/fixtures/landscape.jpg +0 -0
- data/vendor/carrierwave/spec/fixtures/multi_page.pdf +0 -0
- data/vendor/carrierwave/spec/fixtures/new.jpeg +1 -0
- data/vendor/carrierwave/spec/fixtures/new.txt +1 -0
- data/vendor/carrierwave/spec/fixtures/old.jpeg +1 -0
- data/vendor/carrierwave/spec/fixtures/old.txt +1 -0
- data/vendor/carrierwave/spec/fixtures/portrait.jpg +0 -0
- data/vendor/carrierwave/spec/fixtures/ruby.gif +0 -0
- data/vendor/carrierwave/spec/fixtures/sponsored.doc +1 -0
- data/vendor/carrierwave/spec/fixtures/test+.jpg +1 -0
- data/vendor/carrierwave/spec/fixtures/test.jpeg +1 -0
- data/vendor/carrierwave/spec/fixtures/test.jpg +1 -0
- data/vendor/carrierwave/spec/generators/uploader_generator_spec.rb +19 -0
- data/vendor/carrierwave/spec/mount_multiple_spec.rb +913 -0
- data/vendor/carrierwave/spec/mount_single_spec.rb +793 -0
- data/vendor/carrierwave/spec/orm/activerecord_spec.rb +1556 -0
- data/vendor/carrierwave/spec/processing/mini_magick_spec.rb +210 -0
- data/vendor/carrierwave/spec/processing/rmagick_spec.rb +250 -0
- data/vendor/carrierwave/spec/sanitized_file_spec.rb +805 -0
- data/vendor/carrierwave/spec/spec_helper.rb +105 -0
- data/vendor/carrierwave/spec/storage/file_spec.rb +82 -0
- data/vendor/carrierwave/spec/storage/fog_credentials.rb +46 -0
- data/vendor/carrierwave/spec/storage/fog_helper.rb +428 -0
- data/vendor/carrierwave/spec/storage/fog_spec.rb +48 -0
- data/vendor/carrierwave/spec/support/activerecord.rb +31 -0
- data/vendor/carrierwave/spec/support/file_utils_helper.rb +15 -0
- data/vendor/carrierwave/spec/uploader/cache_spec.rb +324 -0
- data/vendor/carrierwave/spec/uploader/callback_spec.rb +30 -0
- data/vendor/carrierwave/spec/uploader/configuration_spec.rb +133 -0
- data/vendor/carrierwave/spec/uploader/content_type_blacklist_spec.rb +61 -0
- data/vendor/carrierwave/spec/uploader/content_type_whitelist_spec.rb +63 -0
- data/vendor/carrierwave/spec/uploader/default_url_spec.rb +77 -0
- data/vendor/carrierwave/spec/uploader/download_spec.rb +204 -0
- data/vendor/carrierwave/spec/uploader/extension_blacklist_spec.rb +112 -0
- data/vendor/carrierwave/spec/uploader/extension_whitelist_spec.rb +102 -0
- data/vendor/carrierwave/spec/uploader/file_size_spec.rb +52 -0
- data/vendor/carrierwave/spec/uploader/mountable_spec.rb +26 -0
- data/vendor/carrierwave/spec/uploader/overrides_spec.rb +71 -0
- data/vendor/carrierwave/spec/uploader/paths_spec.rb +18 -0
- data/vendor/carrierwave/spec/uploader/processing_spec.rb +159 -0
- data/vendor/carrierwave/spec/uploader/proxy_spec.rb +79 -0
- data/vendor/carrierwave/spec/uploader/remove_spec.rb +71 -0
- data/vendor/carrierwave/spec/uploader/store_spec.rb +400 -0
- data/vendor/carrierwave/spec/uploader/url_spec.rb +273 -0
- data/vendor/carrierwave/spec/uploader/versions_spec.rb +633 -0
- metadata +339 -187
- data/config/initializers/extensions.rb +0 -3
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/machines/lib/card/machine.rb +0 -261
- data/mod/machines/lib/card/machine_input.rb +0 -80
- data/mod/standard/file/credit/icon-image.png +0 -0
- data/mod/standard/file/credit/large-image.png +0 -0
- data/mod/standard/file/credit/medium-image.png +0 -0
- data/mod/standard/file/credit/original-image.png +0 -0
- data/mod/standard/file/credit/small-image.png +0 -0
- data/mod/standard/spec/set/type/file_spec.rb +0 -99
- data/tmpsets/set/mod001-core/all/tracked_attributes.rb +0 -154
- data/tmpsets/set/mod001-core/all/utils.rb +0 -132
- data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +0 -282
@@ -0,0 +1,805 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
# Use mime/types/columnar if available, for reduced memory usage
|
5
|
+
require 'mime/types/columnar'
|
6
|
+
rescue LoadError
|
7
|
+
require 'mime/types'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe CarrierWave::SanitizedFile do
|
11
|
+
before do
|
12
|
+
FileUtils.cp(file_path('test.jpg'), file_path('llama.jpg'))
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
if File.exist?(file_path('llama.jpg'))
|
17
|
+
FileUtils.rm(file_path('llama.jpg'))
|
18
|
+
end
|
19
|
+
FileUtils.rm_rf(public_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#empty?" do
|
23
|
+
it "should be empty for nil" do
|
24
|
+
sanitized_file = CarrierWave::SanitizedFile.new(nil)
|
25
|
+
|
26
|
+
expect(sanitized_file).to be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be empty for an empty string" do
|
30
|
+
sanitized_file = CarrierWave::SanitizedFile.new("")
|
31
|
+
|
32
|
+
expect(sanitized_file).to be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be empty for an empty StringIO" do
|
36
|
+
sanitized_file = CarrierWave::SanitizedFile.new(StringIO.new(""))
|
37
|
+
|
38
|
+
expect(sanitized_file).to be_empty
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#original_filename' do
|
44
|
+
it "should default to the original_filename" do
|
45
|
+
file = double('file', :original_filename => 'llama.jpg')
|
46
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
47
|
+
expect(sanitized_file.original_filename).to eq("llama.jpg")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should defer to the base name of the path if original_filename is unavailable" do
|
51
|
+
file = double('file', :path => '/path/to/test.jpg')
|
52
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
53
|
+
expect(sanitized_file.original_filename).to eq("test.jpg")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be nil otherwise" do
|
57
|
+
file = double('file')
|
58
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
59
|
+
expect(sanitized_file.original_filename).to be_nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#basename" do
|
64
|
+
it "should return the basename for complicated extensions" do
|
65
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex.filename.tar.gz"))
|
66
|
+
|
67
|
+
expect(sanitized_file.basename).to eq("complex.filename")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be the filename if the file has no extension" do
|
71
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex"))
|
72
|
+
|
73
|
+
expect(sanitized_file.basename).to eq("complex")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#extension" do
|
78
|
+
%w[gz bz2 z lz xz].each do |ext|
|
79
|
+
it "should return the extension for complicated extensions (tar.#{ext})" do
|
80
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex.filename.tar.#{ext}"))
|
81
|
+
|
82
|
+
expect(sanitized_file.extension).to eq("tar.#{ext}")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should return the extension for real-world user file names" do
|
87
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file_path("Photo on 2009-12-01 at 11.12.jpg"))
|
88
|
+
|
89
|
+
expect(sanitized_file.extension).to eq("jpg")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return the extension for basic filenames" do
|
93
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file_path("something.png"))
|
94
|
+
|
95
|
+
expect(sanitized_file.extension).to eq("png")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should be an empty string if the file has no extension" do
|
99
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file_path("complex"))
|
100
|
+
|
101
|
+
expect(sanitized_file.extension).to eq("")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#filename" do
|
106
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(nil) }
|
107
|
+
|
108
|
+
it "should default to the original filename if it is valid" do
|
109
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("llama.jpg")
|
110
|
+
expect(sanitized_file.filename).to eq("llama.jpg")
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should remove illegal characters from a filename" do
|
114
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("test-s,%&m#st?.jpg")
|
115
|
+
expect(sanitized_file.filename).to eq("test-s___m_st_.jpg")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should remove slashes from the filename" do
|
119
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("../../very_tricky/foo.bar")
|
120
|
+
expect(sanitized_file.filename).not_to match(/[\\\/]/)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should remove illegal characters if there is no extension" do
|
124
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("`*foo")
|
125
|
+
expect(sanitized_file.filename).to eq("__foo")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should remove the path prefix on Windows" do
|
129
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return('c:\temp\foo.txt')
|
130
|
+
expect(sanitized_file.filename).to eq("foo.txt")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should make sure the *nix directory thingies can't be used as filenames" do
|
134
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return(".")
|
135
|
+
expect(sanitized_file.filename).to eq("_.")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should maintain uppercase filenames" do
|
139
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("DSC4056.JPG")
|
140
|
+
expect(sanitized_file.filename).to eq("DSC4056.JPG")
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should remove illegal characters from a non-ASCII filename" do
|
144
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("⟲«Du côté des chars lourds»_123.doc")
|
145
|
+
expect(sanitized_file.filename).to eq("__Du_côté_des_chars_lourds__123.doc")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should default to the original non-ASCII filename if it is valid" do
|
149
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("тестовый.jpg")
|
150
|
+
expect(sanitized_file.filename).to eq("тестовый.jpg")
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should downcase non-ASCII characters properly" do
|
154
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("ТестоВый Ёжик.jpg")
|
155
|
+
expect(sanitized_file.filename).to eq("ТестоВый_Ёжик.jpg")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#filename with an overridden sanitize_regexp" do
|
160
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(nil) }
|
161
|
+
|
162
|
+
before do
|
163
|
+
allow(sanitized_file).to receive(:sanitize_regexp).and_return(/[^a-zA-Z\.\-\+_]/)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should default to the original filename if it is valid" do
|
167
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("llama.jpg")
|
168
|
+
expect(sanitized_file.filename).to eq("llama.jpg")
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should remove illegal characters from a filename" do
|
172
|
+
expect(sanitized_file).to receive(:original_filename).at_least(:once).and_return("123.jpg")
|
173
|
+
expect(sanitized_file.filename).to eq("___.jpg")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#content_type" do
|
178
|
+
it "preserves file's content_type" do
|
179
|
+
sanitized_file = CarrierWave::SanitizedFile.new(content_type: "image/png")
|
180
|
+
|
181
|
+
expect(sanitized_file.content_type).to eq("image/png")
|
182
|
+
end
|
183
|
+
|
184
|
+
it "preserves file's content_type when passed as type (Rack)" do
|
185
|
+
sanitized_file = CarrierWave::SanitizedFile.new(type: "image/png")
|
186
|
+
|
187
|
+
expect(sanitized_file.content_type).to eq("image/png")
|
188
|
+
end
|
189
|
+
|
190
|
+
it "handles Mime::Type object" do
|
191
|
+
file = File.open(file_path('sponsored.doc'))
|
192
|
+
allow(file).to receive(:content_type).and_return(MIME::Type.new("application/msword"))
|
193
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
194
|
+
allow(sanitized_file).to receive(:file).and_return(file)
|
195
|
+
|
196
|
+
expect { sanitized_file.content_type }.not_to raise_error
|
197
|
+
expect(sanitized_file.content_type).to eq("application/msword")
|
198
|
+
end
|
199
|
+
|
200
|
+
it "reads content type from path if missing" do
|
201
|
+
sanitized_file = CarrierWave::SanitizedFile.new("llama.jpg")
|
202
|
+
|
203
|
+
expect(sanitized_file.content_type).to eq("image/jpeg")
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "#content_type=" do
|
208
|
+
it "sets content_type" do
|
209
|
+
sanitized_file = CarrierWave::SanitizedFile.new(content_type: "image/png")
|
210
|
+
sanitized_file.content_type = "text/html"
|
211
|
+
|
212
|
+
expect(sanitized_file.content_type).to eq("text/html")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
shared_examples_for "all valid sanitized files" do
|
217
|
+
describe '#empty?' do
|
218
|
+
it "should not be empty" do
|
219
|
+
expect(sanitized_file).not_to be_empty
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe '#original_filename' do
|
224
|
+
it "should return the original filename" do
|
225
|
+
expect(sanitized_file.original_filename).to eq("llama.jpg")
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe "#filename" do
|
230
|
+
it "should return the filename" do
|
231
|
+
expect(sanitized_file.filename).to eq("llama.jpg")
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "#basename" do
|
236
|
+
it "should return the basename" do
|
237
|
+
expect(sanitized_file.basename).to eq("llama")
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "#extension" do
|
242
|
+
it "should return the extension" do
|
243
|
+
expect(sanitized_file.extension).to eq("jpg")
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe "#read" do
|
248
|
+
it "should return the contents of the file" do
|
249
|
+
expect(sanitized_file.read).to eq("this is stuff")
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe "#size" do
|
254
|
+
it "should return the size of the file" do
|
255
|
+
expect(sanitized_file.size).to eq(13)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe "#move_to" do
|
260
|
+
after do
|
261
|
+
FileUtils.rm_f(file_path("gurr.png"))
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should be moved to the correct location" do
|
265
|
+
sanitized_file.move_to(file_path("gurr.png"))
|
266
|
+
|
267
|
+
expect(File.exist?( file_path("gurr.png") )).to be_truthy
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should have changed its path when moved" do
|
271
|
+
sanitized_file.move_to(file_path("gurr.png"))
|
272
|
+
|
273
|
+
expect(sanitized_file.path).to eq(file_path("gurr.png"))
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should have changed its filename when moved" do
|
277
|
+
sanitized_file.move_to(file_path("gurr.png"))
|
278
|
+
|
279
|
+
expect(sanitized_file.filename).to eq("gurr.png")
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should have changed its basename when moved" do
|
283
|
+
sanitized_file.move_to(file_path("gurr.png"))
|
284
|
+
|
285
|
+
expect(sanitized_file.basename).to eq("gurr")
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should have changed its extension when moved" do
|
289
|
+
sanitized_file.move_to(file_path("gurr.png"))
|
290
|
+
|
291
|
+
expect(sanitized_file.extension).to eq("png")
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should set the right permissions" do
|
295
|
+
sanitized_file.move_to(file_path("gurr.png"), 0755)
|
296
|
+
|
297
|
+
expect(sanitized_file).to have_permissions(0755)
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should set the right directory permissions" do
|
301
|
+
sanitized_file.move_to(file_path("new_dir","gurr.png"), nil, 0775)
|
302
|
+
|
303
|
+
expect(sanitized_file).to have_directory_permissions(0775)
|
304
|
+
FileUtils.rm_rf(file_path("new_dir"))
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should return itself" do
|
308
|
+
expect(sanitized_file.move_to(file_path("gurr.png"))).to eq(sanitized_file)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
describe "#copy_to" do
|
313
|
+
after do
|
314
|
+
FileUtils.rm_f(file_path("gurr.png"))
|
315
|
+
end
|
316
|
+
|
317
|
+
it "should be copied to the correct location" do
|
318
|
+
sanitized_file.copy_to(file_path("gurr.png"))
|
319
|
+
|
320
|
+
expect(File.exist?( file_path("gurr.png") )).to be_truthy
|
321
|
+
|
322
|
+
expect(file_path("gurr.png")).to be_identical_to(file_path("llama.jpg"))
|
323
|
+
end
|
324
|
+
|
325
|
+
it "should not have changed its path when copied" do
|
326
|
+
expect(running { sanitized_file.copy_to(file_path("gurr.png")) }).not_to change(sanitized_file, :path)
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should not have changed its filename when copied" do
|
330
|
+
expect(running { sanitized_file.copy_to(file_path("gurr.png")) }).not_to change(sanitized_file, :filename)
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should return an object of the same class when copied" do
|
334
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"))
|
335
|
+
|
336
|
+
expect(new_file).to be_an_instance_of(sanitized_file.class)
|
337
|
+
end
|
338
|
+
|
339
|
+
it "should adjust the path of the object that is returned when copied" do
|
340
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"))
|
341
|
+
|
342
|
+
expect(new_file.path).to eq(file_path("gurr.png"))
|
343
|
+
end
|
344
|
+
|
345
|
+
it "should adjust the filename of the object that is returned when copied" do
|
346
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"))
|
347
|
+
|
348
|
+
expect(new_file.filename).to eq("gurr.png")
|
349
|
+
end
|
350
|
+
|
351
|
+
it "should adjust the basename of the object that is returned when copied" do
|
352
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"))
|
353
|
+
|
354
|
+
expect(new_file.basename).to eq("gurr")
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should adjust the extension of the object that is returned when copied" do
|
358
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"))
|
359
|
+
|
360
|
+
expect(new_file.extension).to eq("png")
|
361
|
+
end
|
362
|
+
|
363
|
+
it "should set the right permissions" do
|
364
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"), 0755)
|
365
|
+
|
366
|
+
expect(new_file).to have_permissions(0755)
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should set the right directory permissions" do
|
370
|
+
new_file = sanitized_file.copy_to(file_path("new_dir", "gurr.png"), nil, 0755)
|
371
|
+
|
372
|
+
expect(new_file).to have_directory_permissions(0755)
|
373
|
+
FileUtils.rm_rf(file_path("new_dir"))
|
374
|
+
end
|
375
|
+
|
376
|
+
it "should preserve the file's content type" do
|
377
|
+
new_file = sanitized_file.copy_to(file_path("gurr.png"))
|
378
|
+
|
379
|
+
expect(new_file.content_type).to eq(sanitized_file.content_type)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
shared_examples_for "all valid sanitized files that are stored on disk" do
|
385
|
+
describe "#move_to" do
|
386
|
+
it "should not raise an error when moved to its own location" do
|
387
|
+
expect(running { sanitized_file.move_to(sanitized_file.path) }).not_to raise_error
|
388
|
+
end
|
389
|
+
|
390
|
+
it "should remove the original file" do
|
391
|
+
original_path = sanitized_file.path
|
392
|
+
sanitized_file.move_to(public_path("blah.txt"))
|
393
|
+
|
394
|
+
expect(File.exist?(original_path)).to be_falsey
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
describe '#copy_to' do
|
399
|
+
it "should return a new instance when copied to its own location" do
|
400
|
+
expect(running {
|
401
|
+
new_file = sanitized_file.copy_to(sanitized_file.path)
|
402
|
+
expect(new_file).to be_an_instance_of(sanitized_file.class)
|
403
|
+
}).not_to raise_error
|
404
|
+
end
|
405
|
+
|
406
|
+
it "should not remove the original file" do
|
407
|
+
new_file = sanitized_file.copy_to(public_path("blah.txt"))
|
408
|
+
|
409
|
+
expect(File.exist?(sanitized_file.path)).to be_truthy
|
410
|
+
expect(File.exist?(new_file.path)).to be_truthy
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
describe "#exists?" do
|
415
|
+
it "should be true" do
|
416
|
+
expect(sanitized_file.exists?).to be_truthy
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
describe "#delete" do
|
421
|
+
it "should remove it from the filesystem" do
|
422
|
+
expect(File.exist?(sanitized_file.path)).to be_truthy
|
423
|
+
|
424
|
+
sanitized_file.delete
|
425
|
+
|
426
|
+
expect(File.exist?(sanitized_file.path)).to be_falsey
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
describe "#to_file" do
|
431
|
+
it "should return a File object" do
|
432
|
+
expect(sanitized_file.to_file).to be_a(File)
|
433
|
+
end
|
434
|
+
|
435
|
+
it "should have the same path as the SanitizedFile" do
|
436
|
+
expect(sanitized_file.to_file.path).to eq(sanitized_file.path)
|
437
|
+
end
|
438
|
+
|
439
|
+
it "should have the same contents as the SantizedFile" do
|
440
|
+
expect(sanitized_file.to_file.read).to eq(sanitized_file.read)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
shared_examples_for "all valid sanitized files that are read from an IO object" do
|
446
|
+
|
447
|
+
describe "#read" do
|
448
|
+
it "should have an open IO object" do
|
449
|
+
expect(sanitized_file.instance_variable_get(:@file).closed?).to be_falsey
|
450
|
+
end
|
451
|
+
|
452
|
+
it "should close the IO object after reading" do
|
453
|
+
sanitized_file.read
|
454
|
+
|
455
|
+
expect(sanitized_file.instance_variable_get(:@file).closed?).to be_truthy
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
describe "with a valid Hash" do
|
461
|
+
let(:hash) {
|
462
|
+
{
|
463
|
+
"tempfile" => stub_merb_tempfile("llama.jpg"),
|
464
|
+
"filename" => "llama.jpg",
|
465
|
+
"content_type" => "image/jpeg"
|
466
|
+
}
|
467
|
+
}
|
468
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(hash) }
|
469
|
+
|
470
|
+
it_should_behave_like "all valid sanitized files"
|
471
|
+
|
472
|
+
it_should_behave_like "all valid sanitized files that are stored on disk"
|
473
|
+
|
474
|
+
it_should_behave_like "all valid sanitized files that are read from an IO object"
|
475
|
+
|
476
|
+
describe "#path" do
|
477
|
+
it "should return the path of the tempfile" do
|
478
|
+
expect(sanitized_file.path).not_to be_nil
|
479
|
+
expect(sanitized_file.path).to eq(hash["tempfile"].path)
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
describe "#is_path?" do
|
484
|
+
it "should be false" do
|
485
|
+
expect(sanitized_file.is_path?).to be_falsey
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
describe "with a valid Tempfile" do
|
491
|
+
let(:tempfile) { stub_tempfile("llama.jpg", "image/jpeg") }
|
492
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(tempfile) }
|
493
|
+
|
494
|
+
it_should_behave_like "all valid sanitized files"
|
495
|
+
|
496
|
+
it_should_behave_like "all valid sanitized files that are stored on disk"
|
497
|
+
|
498
|
+
it_should_behave_like "all valid sanitized files that are read from an IO object"
|
499
|
+
|
500
|
+
describe "#is_path?" do
|
501
|
+
it "should be false" do
|
502
|
+
expect(sanitized_file.is_path?).to be_falsey
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
describe "#path" do
|
507
|
+
it "should return the path of the tempfile" do
|
508
|
+
expect(sanitized_file.path).not_to be_nil
|
509
|
+
expect(sanitized_file.path).to eq(tempfile.path)
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
describe "with a valid StringIO" do
|
515
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(stub_stringio("llama.jpg", "image/jpeg")) }
|
516
|
+
|
517
|
+
it_should_behave_like "all valid sanitized files"
|
518
|
+
|
519
|
+
it_should_behave_like "all valid sanitized files that are read from an IO object"
|
520
|
+
|
521
|
+
describe "#exists?" do
|
522
|
+
it "should be false" do
|
523
|
+
expect(sanitized_file.exists?).to be_falsey
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
describe "#is_path?" do
|
528
|
+
it "should be false" do
|
529
|
+
expect(sanitized_file.is_path?).to be_falsey
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
describe "#path" do
|
534
|
+
it "should be nil" do
|
535
|
+
expect(sanitized_file.path).to be_nil
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
describe "#delete" do
|
540
|
+
it "should not raise an error" do
|
541
|
+
expect(running { sanitized_file.delete }).not_to raise_error
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
describe "#to_file" do
|
546
|
+
it "should be nil" do
|
547
|
+
expect(sanitized_file.to_file).to be_nil
|
548
|
+
end
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
describe "with a valid File object" do
|
553
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(stub_file("llama.jpg", "image/jpeg")) }
|
554
|
+
|
555
|
+
before do
|
556
|
+
FileUtils.cp(file_path("test.jpg"), file_path("llama.jpg"))
|
557
|
+
|
558
|
+
expect(sanitized_file).not_to be_empty
|
559
|
+
end
|
560
|
+
|
561
|
+
it_should_behave_like "all valid sanitized files"
|
562
|
+
|
563
|
+
it_should_behave_like "all valid sanitized files that are stored on disk"
|
564
|
+
|
565
|
+
it_should_behave_like "all valid sanitized files that are read from an IO object"
|
566
|
+
|
567
|
+
describe "#is_path?" do
|
568
|
+
it "should be false" do
|
569
|
+
expect(sanitized_file.is_path?).to be_falsey
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
describe "#path" do
|
574
|
+
it "should return the path of the file" do
|
575
|
+
expect(sanitized_file.path).not_to be_nil
|
576
|
+
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
|
577
|
+
end
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
581
|
+
describe "with a valid File object and an empty file" do
|
582
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(stub_file("llama.jpg", "image/jpeg")) }
|
583
|
+
|
584
|
+
before do
|
585
|
+
FileUtils.cp(file_path("test.jpg"), file_path("llama.jpg"))
|
586
|
+
FileUtils.rm file_path("llama.jpg")
|
587
|
+
FileUtils.touch file_path("llama.jpg")
|
588
|
+
|
589
|
+
expect(sanitized_file).not_to be_empty
|
590
|
+
end
|
591
|
+
|
592
|
+
it_should_behave_like "all valid sanitized files that are stored on disk"
|
593
|
+
|
594
|
+
it_should_behave_like "all valid sanitized files that are read from an IO object"
|
595
|
+
|
596
|
+
describe "#is_path?" do
|
597
|
+
it "should be false" do
|
598
|
+
expect(sanitized_file.is_path?).to be_falsey
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
describe "#path" do
|
603
|
+
it "should return the path of the file" do
|
604
|
+
expect(sanitized_file.path).not_to be_nil
|
605
|
+
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
|
606
|
+
end
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
describe "with a valid path" do
|
611
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(file_path("llama.jpg")) }
|
612
|
+
|
613
|
+
before do
|
614
|
+
FileUtils.cp(file_path("test.jpg"), file_path("llama.jpg"))
|
615
|
+
|
616
|
+
expect(sanitized_file).not_to be_empty
|
617
|
+
end
|
618
|
+
|
619
|
+
it_should_behave_like "all valid sanitized files"
|
620
|
+
|
621
|
+
it_should_behave_like "all valid sanitized files that are stored on disk"
|
622
|
+
|
623
|
+
describe "#is_path?" do
|
624
|
+
it "should be true" do
|
625
|
+
expect(sanitized_file.is_path?).to be_truthy
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
describe "#path" do
|
630
|
+
it "should return the path of the file" do
|
631
|
+
expect(sanitized_file.path).not_to be_nil
|
632
|
+
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
end
|
637
|
+
|
638
|
+
describe "with a valid Pathname" do
|
639
|
+
let(:sanitized_file) { CarrierWave::SanitizedFile.new(Pathname.new(file_path("llama.jpg"))) }
|
640
|
+
|
641
|
+
before do
|
642
|
+
FileUtils.copy_file(file_path("test.jpg"), file_path("llama.jpg"))
|
643
|
+
|
644
|
+
expect(sanitized_file).not_to be_empty
|
645
|
+
end
|
646
|
+
|
647
|
+
it_should_behave_like "all valid sanitized files"
|
648
|
+
|
649
|
+
it_should_behave_like "all valid sanitized files that are stored on disk"
|
650
|
+
|
651
|
+
describe "#is_path?" do
|
652
|
+
it "should be true" do
|
653
|
+
expect(sanitized_file.is_path?).to be_truthy
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
describe "#path" do
|
658
|
+
it "should return the path of the file" do
|
659
|
+
expect(sanitized_file.path).not_to be_nil
|
660
|
+
expect(sanitized_file.path).to eq(file_path("llama.jpg"))
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
end
|
665
|
+
|
666
|
+
describe "that is empty" do
|
667
|
+
let(:empty) { CarrierWave::SanitizedFile.new(nil) }
|
668
|
+
|
669
|
+
describe "#empty?" do
|
670
|
+
it "should be true" do
|
671
|
+
expect(empty).to be_empty
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
describe "#exists?" do
|
676
|
+
it "should be false" do
|
677
|
+
expect(empty.exists?).to be_falsey
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
describe "#is_path?" do
|
682
|
+
it "should be false" do
|
683
|
+
expect(empty.is_path?).to be_falsey
|
684
|
+
end
|
685
|
+
end
|
686
|
+
|
687
|
+
describe "#size" do
|
688
|
+
it "should be zero" do
|
689
|
+
expect(empty.size).to be_zero
|
690
|
+
end
|
691
|
+
end
|
692
|
+
|
693
|
+
describe "#path" do
|
694
|
+
it "should be nil" do
|
695
|
+
expect(empty.path).to be_nil
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
describe "#original_filename" do
|
700
|
+
it "should be nil" do
|
701
|
+
expect(empty.original_filename).to be_nil
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
describe "#filename" do
|
706
|
+
it "should be nil" do
|
707
|
+
expect(empty.filename).to be_nil
|
708
|
+
end
|
709
|
+
end
|
710
|
+
|
711
|
+
describe "#basename" do
|
712
|
+
it "should be nil" do
|
713
|
+
expect(empty.basename).to be_nil
|
714
|
+
end
|
715
|
+
end
|
716
|
+
|
717
|
+
describe "#extension" do
|
718
|
+
it "should be nil" do
|
719
|
+
expect(empty.extension).to be_nil
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
723
|
+
describe "#delete" do
|
724
|
+
it "should not raise an error" do
|
725
|
+
expect(running { empty.delete }).not_to raise_error
|
726
|
+
end
|
727
|
+
end
|
728
|
+
|
729
|
+
describe "#to_file" do
|
730
|
+
it "should be nil" do
|
731
|
+
expect(empty.to_file).to be_nil
|
732
|
+
end
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
describe "that is an empty string" do
|
737
|
+
let(:empty) { CarrierWave::SanitizedFile.new("") }
|
738
|
+
|
739
|
+
describe "#empty?" do
|
740
|
+
it "should be true" do
|
741
|
+
expect(empty).to be_empty
|
742
|
+
end
|
743
|
+
end
|
744
|
+
|
745
|
+
describe "#exists?" do
|
746
|
+
it "should be false" do
|
747
|
+
expect(empty.exists?).to be_falsey
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
describe "#is_path?" do
|
752
|
+
it "should be false" do
|
753
|
+
expect(empty.is_path?).to be_falsey
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
757
|
+
describe "#size" do
|
758
|
+
it "should be zero" do
|
759
|
+
expect(empty.size).to be_zero
|
760
|
+
end
|
761
|
+
end
|
762
|
+
|
763
|
+
describe "#path" do
|
764
|
+
it "should be nil" do
|
765
|
+
expect(empty.path).to be_nil
|
766
|
+
end
|
767
|
+
end
|
768
|
+
|
769
|
+
describe "#original_filename" do
|
770
|
+
it "should be nil" do
|
771
|
+
expect(empty.original_filename).to be_nil
|
772
|
+
end
|
773
|
+
end
|
774
|
+
|
775
|
+
describe "#filename" do
|
776
|
+
it "should be nil" do
|
777
|
+
expect(empty.filename).to be_nil
|
778
|
+
end
|
779
|
+
end
|
780
|
+
|
781
|
+
describe "#basename" do
|
782
|
+
it "should be nil" do
|
783
|
+
expect(empty.basename).to be_nil
|
784
|
+
end
|
785
|
+
end
|
786
|
+
|
787
|
+
describe "#extension" do
|
788
|
+
it "should be nil" do
|
789
|
+
expect(empty.extension).to be_nil
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
793
|
+
describe "#delete" do
|
794
|
+
it "should not raise an error" do
|
795
|
+
expect(running { empty.delete }).not_to raise_error
|
796
|
+
end
|
797
|
+
end
|
798
|
+
|
799
|
+
describe "#to_file" do
|
800
|
+
it "should be nil" do
|
801
|
+
expect(empty.to_file).to be_nil
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
end
|