bard-file_field 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.nvmrc +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +98 -0
- data/LICENSE +21 -0
- data/README.md +29 -0
- data/Rakefile +4 -0
- data/app/assets/javascripts/bard-file.js +4913 -0
- data/app/controllers/bard/file_field/blobs_controller.rb +11 -0
- data/bard-file/.gitignore +1 -0
- data/bard-file/bun.lockb +0 -0
- data/bard-file/index.js +2 -0
- data/bard-file/package.json +20 -0
- data/bard-file/rollup.config.js +26 -0
- data/bard-file_field.gemspec +34 -0
- data/config/routes.rb +6 -0
- data/dummy/.gitattributes +7 -0
- data/dummy/.gitignore +36 -0
- data/dummy/Gemfile +29 -0
- data/dummy/Gemfile.lock +353 -0
- data/dummy/README.md +24 -0
- data/dummy/Rakefile +13 -0
- data/dummy/app/assets/config/manifest.js +3 -0
- data/dummy/app/assets/images/.keep +0 -0
- data/dummy/app/assets/stylesheets/application.css +22 -0
- data/dummy/app/controllers/application_controller.rb +2 -0
- data/dummy/app/controllers/concerns/.keep +0 -0
- data/dummy/app/controllers/edge_cases_controller.rb +23 -0
- data/dummy/app/controllers/posts_controller.rb +33 -0
- data/dummy/app/controllers/validations_controller.rb +18 -0
- data/dummy/app/helpers/application_helper.rb +2 -0
- data/dummy/app/javascript/application.js +2 -0
- data/dummy/app/javascript/controllers/application.js +9 -0
- data/dummy/app/javascript/controllers/index.js +11 -0
- data/dummy/app/models/application_record.rb +3 -0
- data/dummy/app/models/concerns/.keep +0 -0
- data/dummy/app/models/post.rb +9 -0
- data/dummy/app/views/edge_cases/rails_validation_error.html.erb +16 -0
- data/dummy/app/views/layouts/application.html.erb +18 -0
- data/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/dummy/app/views/posts/form.html.erb +39 -0
- data/dummy/app/views/posts/show.html.erb +16 -0
- data/dummy/app/views/validations/form.html.erb +19 -0
- data/dummy/app/views/validations/optional_file.html.erb +10 -0
- data/dummy/app/views/validations/optional_file_with_max_size.html.erb +10 -0
- data/dummy/app/views/validations/optional_image.html.erb +10 -0
- data/dummy/app/views/validations/required_file.html.erb +10 -0
- data/dummy/app/views/validations/required_media.html.erb +10 -0
- data/dummy/bin/bundle +114 -0
- data/dummy/bin/importmap +4 -0
- data/dummy/bin/rails +4 -0
- data/dummy/bin/rake +4 -0
- data/dummy/bin/setup +33 -0
- data/dummy/config/application.rb +22 -0
- data/dummy/config/boot.rb +4 -0
- data/dummy/config/cable.yml +10 -0
- data/dummy/config/credentials.yml.enc +1 -0
- data/dummy/config/cucumber.yml +2 -0
- data/dummy/config/database.yml +25 -0
- data/dummy/config/environment.rb +5 -0
- data/dummy/config/environments/development.rb +70 -0
- data/dummy/config/environments/production.rb +93 -0
- data/dummy/config/environments/test.rb +60 -0
- data/dummy/config/importmap.rb +4 -0
- data/dummy/config/initializers/assets.rb +12 -0
- data/dummy/config/initializers/content_security_policy.rb +25 -0
- data/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/dummy/config/initializers/inflections.rb +16 -0
- data/dummy/config/initializers/permissions_policy.rb +11 -0
- data/dummy/config/locales/en.yml +33 -0
- data/dummy/config/puma.rb +43 -0
- data/dummy/config/routes.rb +7 -0
- data/dummy/config/storage.yml +34 -0
- data/dummy/config.ru +6 -0
- data/dummy/db/migrate/20231013175203_create_posts.rb +8 -0
- data/dummy/db/migrate/20231013175257_create_active_storage_tables.active_storage.rb +57 -0
- data/dummy/db/migrate/20231102131420_add_name_to_posts.rb +5 -0
- data/dummy/db/schema.rb +50 -0
- data/dummy/db/seeds.rb +7 -0
- data/dummy/features/edge_cases.feature +17 -0
- data/dummy/features/form-persistence.feature +40 -0
- data/dummy/features/form_bard_file_field_helper.feature +98 -0
- data/dummy/features/support/env.rb +21 -0
- data/dummy/features/support/fixtures/empty.3gpp +0 -0
- data/dummy/features/support/fixtures/empty.JPEG +0 -0
- data/dummy/features/support/fixtures/empty.M4V +0 -0
- data/dummy/features/support/fixtures/empty.avi +0 -0
- data/dummy/features/support/fixtures/empty.bmp +0 -0
- data/dummy/features/support/fixtures/empty.flv +0 -0
- data/dummy/features/support/fixtures/empty.gif +0 -0
- data/dummy/features/support/fixtures/empty.heic +0 -0
- data/dummy/features/support/fixtures/empty.jpeg +0 -0
- data/dummy/features/support/fixtures/empty.jpg +0 -0
- data/dummy/features/support/fixtures/empty.m4v +0 -0
- data/dummy/features/support/fixtures/empty.mkv +0 -0
- data/dummy/features/support/fixtures/empty.mov +0 -0
- data/dummy/features/support/fixtures/empty.mp4 +0 -0
- data/dummy/features/support/fixtures/empty.png +0 -0
- data/dummy/features/support/fixtures/empty.tiff +0 -0
- data/dummy/features/support/fixtures/empty.webm +0 -0
- data/dummy/features/support/fixtures/empty.wmv +0 -0
- data/dummy/features/support/fixtures/image.jpg +0 -0
- data/dummy/features/support/fixtures/image2.jpg +0 -0
- data/dummy/features/support/fixtures/video.mp4 +0 -0
- data/dummy/features/support/selectors.rb +63 -0
- data/dummy/features/support/step_definitions/download_steps.rb +4 -0
- data/dummy/features/support/step_definitions/web_steps.rb +94 -0
- data/dummy/features/validations.feature +71 -0
- data/dummy/lib/assets/.keep +0 -0
- data/dummy/lib/tasks/.keep +0 -0
- data/dummy/log/.keep +0 -0
- data/dummy/public/404.html +67 -0
- data/dummy/public/422.html +67 -0
- data/dummy/public/500.html +66 -0
- data/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/dummy/public/apple-touch-icon.png +0 -0
- data/dummy/public/favicon.ico +0 -0
- data/dummy/public/robots.txt +1 -0
- data/dummy/storage/.keep +0 -0
- data/dummy/test/application_system_test_case.rb +21 -0
- data/dummy/test/channels/application_cable/connection_test.rb +11 -0
- data/dummy/test/controllers/.keep +0 -0
- data/dummy/test/fixtures/files/.keep +0 -0
- data/dummy/test/helpers/.keep +0 -0
- data/dummy/test/integration/.keep +0 -0
- data/dummy/test/mailers/.keep +0 -0
- data/dummy/test/models/.keep +0 -0
- data/dummy/test/system/.keep +0 -0
- data/dummy/test/system/tests_test.rb +9 -0
- data/dummy/test/test_helper.rb +13 -0
- data/dummy/tmp/.keep +0 -0
- data/dummy/tmp/pids/.keep +0 -0
- data/dummy/tmp/storage/.keep +0 -0
- data/lib/bard/file_field/field.rb +27 -0
- data/lib/bard/file_field/form_builder.rb +12 -0
- data/lib/bard/file_field/version.rb +7 -0
- data/lib/bard/file_field.rb +20 -0
- metadata +197 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
|
8
|
+
Rails.application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
10
|
+
|
11
|
+
# Turn false under Spring and add config.action_view.cache_template_loading = true.
|
12
|
+
config.cache_classes = true
|
13
|
+
|
14
|
+
# Eager loading loads your whole application. When running a single test locally,
|
15
|
+
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
16
|
+
# system, or in some way before deploying your code.
|
17
|
+
config.eager_load = ENV["CI"].present?
|
18
|
+
|
19
|
+
# Configure public file server for tests with Cache-Control for performance.
|
20
|
+
config.public_file_server.enabled = true
|
21
|
+
config.public_file_server.headers = {
|
22
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
23
|
+
}
|
24
|
+
|
25
|
+
# Show full error reports and disable caching.
|
26
|
+
config.consider_all_requests_local = true
|
27
|
+
config.action_controller.perform_caching = false
|
28
|
+
config.cache_store = :null_store
|
29
|
+
|
30
|
+
# Raise exceptions instead of rendering exception templates.
|
31
|
+
config.action_dispatch.show_exceptions = :none
|
32
|
+
|
33
|
+
# Disable request forgery protection in test environment.
|
34
|
+
config.action_controller.allow_forgery_protection = false
|
35
|
+
|
36
|
+
# Store uploaded files on the local file system in a temporary directory.
|
37
|
+
config.active_storage.service = :test
|
38
|
+
|
39
|
+
config.action_mailer.perform_caching = false
|
40
|
+
|
41
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
42
|
+
# The :test delivery method accumulates sent emails in the
|
43
|
+
# ActionMailer::Base.deliveries array.
|
44
|
+
config.action_mailer.delivery_method = :test
|
45
|
+
|
46
|
+
# Print deprecation notices to the stderr.
|
47
|
+
config.active_support.deprecation = :stderr
|
48
|
+
|
49
|
+
# Raise exceptions for disallowed deprecations.
|
50
|
+
config.active_support.disallowed_deprecation = :raise
|
51
|
+
|
52
|
+
# Tell Active Support which deprecation messages to disallow.
|
53
|
+
config.active_support.disallowed_deprecation_warnings = []
|
54
|
+
|
55
|
+
# Raises error for missing translations.
|
56
|
+
# config.i18n.raise_on_missing_translations = true
|
57
|
+
|
58
|
+
# Annotate rendered view with file names.
|
59
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
60
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
pin "application", preload: true
|
2
|
+
pin "@rails/activestorage", to: "https://ga.jspm.io/npm:@rails/activestorage@7.1.1/app/assets/javascripts/activestorage.esm.js"
|
3
|
+
pin "form-persistence", to: "https://cdn.jsdelivr.net/gh/botandrose/FormPersistence.js@hooks/form-persistence.js"
|
4
|
+
pin "bard-file", to: "bard-file.js"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = "1.0"
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path.
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
11
|
+
# folder are already added.
|
12
|
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Define an application-wide content security policy.
|
4
|
+
# See the Securing Rails Applications Guide for more information:
|
5
|
+
# https://guides.rubyonrails.org/security.html#content-security-policy-header
|
6
|
+
|
7
|
+
# Rails.application.configure do
|
8
|
+
# config.content_security_policy do |policy|
|
9
|
+
# policy.default_src :self, :https
|
10
|
+
# policy.font_src :self, :https, :data
|
11
|
+
# policy.img_src :self, :https, :data
|
12
|
+
# policy.object_src :none
|
13
|
+
# policy.script_src :self, :https
|
14
|
+
# policy.style_src :self, :https
|
15
|
+
# # Specify URI for violation reports
|
16
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# # Generate session nonces for permitted importmap and inline scripts
|
20
|
+
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
|
21
|
+
# config.content_security_policy_nonce_directives = %w(script-src)
|
22
|
+
#
|
23
|
+
# # Report violations without enforcing the policy.
|
24
|
+
# # config.content_security_policy_report_only = true
|
25
|
+
# end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
|
4
|
+
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
|
5
|
+
# notations and behaviors.
|
6
|
+
Rails.application.config.filter_parameters += [
|
7
|
+
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
|
8
|
+
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
8
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
9
|
+
# inflect.irregular "person", "people"
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym "RESTful"
|
16
|
+
# end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Define an application-wide HTTP permissions policy. For further
|
2
|
+
# information see https://developers.google.com/web/updates/2018/06/feature-policy
|
3
|
+
#
|
4
|
+
# Rails.application.config.permissions_policy do |f|
|
5
|
+
# f.camera :none
|
6
|
+
# f.gyroscope :none
|
7
|
+
# f.microphone :none
|
8
|
+
# f.usb :none
|
9
|
+
# f.fullscreen :self
|
10
|
+
# f.payment :self, "https://secure.example.com"
|
11
|
+
# end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t "hello"
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t("hello") %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# The following keys must be escaped otherwise they will not be retrieved by
|
20
|
+
# the default I18n backend:
|
21
|
+
#
|
22
|
+
# true, false, on, off, yes, no
|
23
|
+
#
|
24
|
+
# Instead, surround them with single quotes.
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# "true": "foo"
|
28
|
+
#
|
29
|
+
# To learn more, please read the Rails Internationalization guide
|
30
|
+
# available at https://guides.rubyonrails.org/i18n.html.
|
31
|
+
|
32
|
+
en:
|
33
|
+
hello: "Hello world"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum; this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
+
threads min_threads_count, max_threads_count
|
10
|
+
|
11
|
+
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
12
|
+
# terminating a worker in development environments.
|
13
|
+
#
|
14
|
+
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
|
15
|
+
|
16
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
17
|
+
#
|
18
|
+
port ENV.fetch("PORT") { 3000 }
|
19
|
+
|
20
|
+
# Specifies the `environment` that Puma will run in.
|
21
|
+
#
|
22
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
23
|
+
|
24
|
+
# Specifies the `pidfile` that Puma will use.
|
25
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
26
|
+
|
27
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
28
|
+
# Workers are forked web server processes. If using threads and workers together
|
29
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
30
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
31
|
+
# processes).
|
32
|
+
#
|
33
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
34
|
+
|
35
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
36
|
+
# This directive tells Puma to first boot the application and load code
|
37
|
+
# before forking the application. This takes advantage of Copy On Write
|
38
|
+
# process behavior so workers use less memory.
|
39
|
+
#
|
40
|
+
# preload_app!
|
41
|
+
|
42
|
+
# Allow puma to be restarted by `bin/rails restart` command.
|
43
|
+
plugin :tmp_restart
|
@@ -0,0 +1,34 @@
|
|
1
|
+
test:
|
2
|
+
service: Disk
|
3
|
+
root: <%= Rails.root.join("tmp/storage") %>
|
4
|
+
|
5
|
+
local:
|
6
|
+
service: Disk
|
7
|
+
root: <%= Rails.root.join("storage") %>
|
8
|
+
|
9
|
+
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
10
|
+
# amazon:
|
11
|
+
# service: S3
|
12
|
+
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
13
|
+
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
14
|
+
# region: us-east-1
|
15
|
+
# bucket: your_own_bucket-<%= Rails.env %>
|
16
|
+
|
17
|
+
# Remember not to checkin your GCS keyfile to a repository
|
18
|
+
# google:
|
19
|
+
# service: GCS
|
20
|
+
# project: your_project
|
21
|
+
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
22
|
+
# bucket: your_own_bucket-<%= Rails.env %>
|
23
|
+
|
24
|
+
# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
25
|
+
# microsoft:
|
26
|
+
# service: AzureStorage
|
27
|
+
# storage_account_name: your_account_name
|
28
|
+
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
29
|
+
# container: your_container_name-<%= Rails.env %>
|
30
|
+
|
31
|
+
# mirror:
|
32
|
+
# service: Mirror
|
33
|
+
# primary: local
|
34
|
+
# mirrors: [ amazon, google, microsoft ]
|
data/dummy/config.ru
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# This migration comes from active_storage (originally 20170806125915)
|
2
|
+
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
# Use Active Record's configured type for primary and foreign keys
|
5
|
+
primary_key_type, foreign_key_type = primary_and_foreign_key_types
|
6
|
+
|
7
|
+
create_table :active_storage_blobs, id: primary_key_type do |t|
|
8
|
+
t.string :key, null: false
|
9
|
+
t.string :filename, null: false
|
10
|
+
t.string :content_type
|
11
|
+
t.text :metadata
|
12
|
+
t.string :service_name, null: false
|
13
|
+
t.bigint :byte_size, null: false
|
14
|
+
t.string :checksum
|
15
|
+
|
16
|
+
if connection.supports_datetime_with_precision?
|
17
|
+
t.datetime :created_at, precision: 6, null: false
|
18
|
+
else
|
19
|
+
t.datetime :created_at, null: false
|
20
|
+
end
|
21
|
+
|
22
|
+
t.index [ :key ], unique: true
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table :active_storage_attachments, id: primary_key_type do |t|
|
26
|
+
t.string :name, null: false
|
27
|
+
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
|
28
|
+
t.references :blob, null: false, type: foreign_key_type
|
29
|
+
|
30
|
+
if connection.supports_datetime_with_precision?
|
31
|
+
t.datetime :created_at, precision: 6, null: false
|
32
|
+
else
|
33
|
+
t.datetime :created_at, null: false
|
34
|
+
end
|
35
|
+
|
36
|
+
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
|
37
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :active_storage_variant_records, id: primary_key_type do |t|
|
41
|
+
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
|
42
|
+
t.string :variation_digest, null: false
|
43
|
+
|
44
|
+
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
|
45
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def primary_and_foreign_key_types
|
51
|
+
config = Rails.configuration.generators
|
52
|
+
setting = config.options[config.orm][:primary_key_type]
|
53
|
+
primary_key_type = setting || :primary_key
|
54
|
+
foreign_key_type = setting || :bigint
|
55
|
+
[primary_key_type, foreign_key_type]
|
56
|
+
end
|
57
|
+
end
|
data/dummy/db/schema.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema[7.1].define(version: 2023_11_02_131420) do
|
14
|
+
create_table "active_storage_attachments", force: :cascade do |t|
|
15
|
+
t.string "name", null: false
|
16
|
+
t.string "record_type", null: false
|
17
|
+
t.bigint "record_id", null: false
|
18
|
+
t.bigint "blob_id", null: false
|
19
|
+
t.datetime "created_at", null: false
|
20
|
+
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
21
|
+
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table "active_storage_blobs", force: :cascade do |t|
|
25
|
+
t.string "key", null: false
|
26
|
+
t.string "filename", null: false
|
27
|
+
t.string "content_type"
|
28
|
+
t.text "metadata"
|
29
|
+
t.string "service_name", null: false
|
30
|
+
t.bigint "byte_size", null: false
|
31
|
+
t.string "checksum"
|
32
|
+
t.datetime "created_at", null: false
|
33
|
+
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
|
34
|
+
end
|
35
|
+
|
36
|
+
create_table "active_storage_variant_records", force: :cascade do |t|
|
37
|
+
t.bigint "blob_id", null: false
|
38
|
+
t.string "variation_digest", null: false
|
39
|
+
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
40
|
+
end
|
41
|
+
|
42
|
+
create_table "posts", force: :cascade do |t|
|
43
|
+
t.datetime "created_at", null: false
|
44
|
+
t.datetime "updated_at", null: false
|
45
|
+
t.string "name"
|
46
|
+
end
|
47
|
+
|
48
|
+
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
49
|
+
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
50
|
+
end
|
data/dummy/db/seeds.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
|
7
|
+
# Character.create(name: "Luke", movie: movies.first)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Various edge cases
|
2
|
+
Scenario: File remains in form after rails validation error
|
3
|
+
Given I am on "/edge_cases/rails_validation_error"
|
4
|
+
When I attach the file "image.jpg" to "Image"
|
5
|
+
Then I should see a preview of "image.jpg" within the "Image" bard-file
|
6
|
+
When I fill in "Number" with "NOT A NUMBER"
|
7
|
+
And I press "Submit"
|
8
|
+
|
9
|
+
Then I should not see "Post created!"
|
10
|
+
And I should see "Number is not a number"
|
11
|
+
And I should see a preview of "image.jpg" within the "Image" bard-file
|
12
|
+
|
13
|
+
When I fill in "Number" with "0"
|
14
|
+
And I press "Submit"
|
15
|
+
Then I should see "Post created!"
|
16
|
+
And I should see a preview of "image.jpg" within the "Image" bard-file
|
17
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: It supports naive serialization and resumption with the form-persistence npm package
|
2
|
+
Scenario: It works with not-yet-uploaded file
|
3
|
+
Given I am on the homepage
|
4
|
+
When I fill in "Name" with "Jerry"
|
5
|
+
And I attach the file "image.jpg" to "Image"
|
6
|
+
Then I should see an upload progress bar at 100% within the "image.jpg" uploaded-file
|
7
|
+
|
8
|
+
Given I am on the homepage
|
9
|
+
Then I should see "Name" filled in with "Jerry"
|
10
|
+
And I should see a preview of "image.jpg" within the "Image" bard-file
|
11
|
+
|
12
|
+
When I press "Submit"
|
13
|
+
Then I should see "Post created!"
|
14
|
+
And I should see "image.jpg"
|
15
|
+
And I should see the "image.jpg" image
|
16
|
+
|
17
|
+
Scenario: It works with an already uploaded file
|
18
|
+
Given I am on the homepage
|
19
|
+
When I fill in "Name" with "Jerry"
|
20
|
+
And I attach the file "image.jpg" to "Image"
|
21
|
+
Then I should see an upload progress bar at 100% within the "image.jpg" uploaded-file
|
22
|
+
And I should see a preview of "image.jpg" within the "Image" bard-file
|
23
|
+
When I press "Submit"
|
24
|
+
Then I should see "Post created!"
|
25
|
+
|
26
|
+
When I follow "Edit"
|
27
|
+
Then I should see "Name" filled in with "Jerry"
|
28
|
+
And I should see an upload progress bar at 100% within the "image.jpg" uploaded-file
|
29
|
+
And I should see a preview of "image.jpg" within the "Image" bard-file
|
30
|
+
|
31
|
+
When I reload the page
|
32
|
+
Then I should see "Name" filled in with "Jerry"
|
33
|
+
And I should see an upload progress bar at 100% within the "image.jpg" uploaded-file
|
34
|
+
And I should see a preview of "image.jpg" within the "Image" bard-file
|
35
|
+
|
36
|
+
When I press "Submit"
|
37
|
+
Then I should see "Post updated!"
|
38
|
+
And I should see "image.jpg"
|
39
|
+
And I should see the "image.jpg" image
|
40
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
Feature: form.bard_file_field is an improved form.file_field input with extra features
|
2
|
+
Background:
|
3
|
+
Given I am on the homepage
|
4
|
+
|
5
|
+
Scenario: I can use bard-file to attach a file to a form
|
6
|
+
When I attach the file "image.jpg" to "Image"
|
7
|
+
And I press "Submit"
|
8
|
+
Then I should see "Post created!"
|
9
|
+
And I should see "image.jpg"
|
10
|
+
And I should see the "image.jpg" image
|
11
|
+
|
12
|
+
Scenario: It displays a preview
|
13
|
+
When I attach the file "image.jpg" to "Image"
|
14
|
+
Then I should see a preview of "image.jpg" within the "Image" bard-file
|
15
|
+
|
16
|
+
Scenario: It uploads the file before form submission
|
17
|
+
When I attach the file "image.jpg" to "Image"
|
18
|
+
Then I should see an upload progress bar at 100% within the "image.jpg" uploaded-file
|
19
|
+
|
20
|
+
Scenario: It can display an existing file
|
21
|
+
When I attach the file "image.jpg" to "Image"
|
22
|
+
And I press "Submit"
|
23
|
+
Then I should see "Post created!"
|
24
|
+
When I follow "Edit"
|
25
|
+
Then I should see a preview of "image.jpg" within the "Image" bard-file
|
26
|
+
|
27
|
+
Scenario: Filename is a download link to the file when the file already exists
|
28
|
+
When I fill in "Name" with "Image"
|
29
|
+
And I attach the file "image.jpg" to "Image"
|
30
|
+
And I press "Submit"
|
31
|
+
Then I should see "Post created!"
|
32
|
+
And I should see "image.jpg"
|
33
|
+
And I should see the "image.jpg" image
|
34
|
+
|
35
|
+
When I follow "Edit"
|
36
|
+
And I follow "image.jpg" within the "image.jpg" uploaded-file
|
37
|
+
Then I should download a file named "image.jpg"
|
38
|
+
|
39
|
+
Scenario: It can remove a not-yet-submitted file
|
40
|
+
When I fill in "Name" with "No Image"
|
41
|
+
And I attach the file "image.jpg" to "Image"
|
42
|
+
Then I should see a preview of "image.jpg" within the "Image" bard-file
|
43
|
+
When I follow "Remove media" within the "image.jpg" uploaded-file
|
44
|
+
And I press "Submit"
|
45
|
+
Then I should see "Post created!"
|
46
|
+
And I should see "No Image"
|
47
|
+
And I should not see "image.jpg"
|
48
|
+
And I should not see the "image.jpg" image
|
49
|
+
|
50
|
+
Scenario: It can remove an existing file
|
51
|
+
When I fill in "Name" with "Image"
|
52
|
+
And I attach the file "image.jpg" to "Image"
|
53
|
+
And I press "Submit"
|
54
|
+
Then I should see "Post created!"
|
55
|
+
And I should see "image.jpg"
|
56
|
+
And I should see the "image.jpg" image
|
57
|
+
|
58
|
+
When I follow "Edit"
|
59
|
+
And I follow "Remove media" within the "image.jpg" uploaded-file
|
60
|
+
And I press "Submit"
|
61
|
+
Then I should see "Post updated!"
|
62
|
+
And I should not see "image.jpg"
|
63
|
+
And I should not see the "image.jpg" image
|
64
|
+
|
65
|
+
Scenario: It can update an existing file
|
66
|
+
When I fill in "Name" with "Image"
|
67
|
+
And I attach the file "image.jpg" to "Image"
|
68
|
+
And I press "Submit"
|
69
|
+
Then I should see "Post created!"
|
70
|
+
And I should see "image.jpg"
|
71
|
+
And I should see the "image.jpg" image
|
72
|
+
|
73
|
+
When I follow "Edit"
|
74
|
+
And I attach the file "image2.jpg" to "Image"
|
75
|
+
And I press "Submit"
|
76
|
+
Then I should see "Post updated!"
|
77
|
+
And I should see "image2.jpg"
|
78
|
+
And I should see the "image2.jpg" image
|
79
|
+
|
80
|
+
Scenario: It supports multiple files
|
81
|
+
When I attach the following files to "Images":
|
82
|
+
| image.jpg |
|
83
|
+
| image2.jpg |
|
84
|
+
And I press "Submit"
|
85
|
+
Then I should see "Post created!"
|
86
|
+
And I should see "image.jpg"
|
87
|
+
And I should see the "image.jpg" image
|
88
|
+
And I should see "image2.jpg"
|
89
|
+
And I should see the "image2.jpg" image
|
90
|
+
|
91
|
+
# Scenario: It supports drag and drop
|
92
|
+
# Scenario: The delete button is clicked mid-upload
|
93
|
+
# Scenario: A new file is chosen mid-upload
|
94
|
+
# Scenario: Submit button is disabled and summary displays when submitted before uploads complete
|
95
|
+
# Scenario: It is disabled with the disabled attribute
|
96
|
+
# Scenario: It is disabled when in a disabled fieldset
|
97
|
+
|
98
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "cucumber/rails"
|
2
|
+
require "capybara/cuprite"
|
3
|
+
require "cuprite/downloads/cucumber"
|
4
|
+
require "capybara/shadowdom"
|
5
|
+
require "capybara-screenshot/cucumber" unless ENV["CI"]
|
6
|
+
|
7
|
+
Capybara.register_driver(:cuprite) do |app|
|
8
|
+
Capybara::Cuprite::Driver.new(app, {
|
9
|
+
window_size: [1920, 2160],
|
10
|
+
timeout: 20,
|
11
|
+
process_timeout: 20,
|
12
|
+
js_errors: true,
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
Capybara.server = :puma, { Silent: true }
|
17
|
+
Capybara.default_driver = :cuprite
|
18
|
+
Capybara.default_normalize_ws = true
|
19
|
+
|
20
|
+
DatabaseCleaner.strategy = :truncation
|
21
|
+
DatabaseCleaner.clean_with :truncation
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|