From ecf76bc9c3b1b70718afbb0d4e785fc708fc7754 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 06:19:05 +0000 Subject: [PATCH 01/13] Use Ruby on Rails starter workflow --- .semaphore/semaphore.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .semaphore/semaphore.yml diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml new file mode 100644 index 000000000..ff31a23e3 --- /dev/null +++ b/.semaphore/semaphore.yml @@ -0,0 +1,26 @@ +version: v1.0 +name: Test MyApp +agent: + machine: + type: e1-standard-2 + os_image: ubuntu2004 + +blocks: + - name: Test + task: + env_vars: + - name: DATABASE_URL + value: "postgresql://postgres:@0.0.0.0:5432/myapp_test" + - name: RAILS_ENV + value: test + jobs: + - name: Test + commands: + - checkout + - sem-service start postgres 11 + - sem-version ruby 2.6.5 + - cache restore + - bundle install --deployment --path vendor/bundle + - cache store + - bundle exec rake db:setup + - bundle exec rspec From 2a79f01c0f6ba4a9482ff31d73345b81d7755c74 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 06:26:54 +0000 Subject: [PATCH 02/13] Update Semaphore configuration --- .semaphore/semaphore.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index ff31a23e3..4b623588b 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -4,23 +4,31 @@ agent: machine: type: e1-standard-2 os_image: ubuntu2004 - blocks: - - name: Test + - name: 'Test ' task: env_vars: - name: DATABASE_URL - value: "postgresql://postgres:@0.0.0.0:5432/myapp_test" + value: 'postgresql://postgres:@0.0.0.0:5432/myapp_test' - name: RAILS_ENV value: test jobs: - - name: Test - commands: - - checkout - - sem-service start postgres 11 - - sem-version ruby 2.6.5 - - cache restore - - bundle install --deployment --path vendor/bundle - - cache store - - bundle exec rake db:setup - - bundle exec rspec + - name: Test + commands: + - checkout + - sem-service start postgres 11 + - sem-version ruby 2.7.6 + - cache restore + - bundle install --deployment --path vendor/bundle + - cache store + - 'bundle exec rake db:setup' + - bundle exec rake test CKEDITOR_BACKEND=paperclip + - bundle exec rake test CKEDITOR_BACKEND=active_storage + - bundle exec rake test CKEDITOR_BACKEND=carrierwave + - bundle exec rake test CKEDITOR_BACKEND=dragonfly + - bundle exec rake test CKEDITOR_BACKEND=shrine + - bundle exec rake test CKEDITOR_ORM=mongoid + - 'bundle exec rake test:controllers' + - 'bundle exec rake test:generators' + - 'bundle exec rake test:integration' + - 'bundle exec rake test:models' From d0ea81813180e4cfceb6e5301c0fabcda1b5bfc8 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 09:32:44 +0300 Subject: [PATCH 03/13] Update test name --- .semaphore/semaphore.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 4b623588b..f29419773 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -1,11 +1,11 @@ version: v1.0 -name: Test MyApp +name: Test CKEditor gem agent: machine: type: e1-standard-2 os_image: ubuntu2004 blocks: - - name: 'Test ' + - name: 'Test' task: env_vars: - name: DATABASE_URL @@ -21,14 +21,14 @@ blocks: - cache restore - bundle install --deployment --path vendor/bundle - cache store - - 'bundle exec rake db:setup' + - bundle exec rake db:setup - bundle exec rake test CKEDITOR_BACKEND=paperclip - bundle exec rake test CKEDITOR_BACKEND=active_storage - bundle exec rake test CKEDITOR_BACKEND=carrierwave - bundle exec rake test CKEDITOR_BACKEND=dragonfly - bundle exec rake test CKEDITOR_BACKEND=shrine - bundle exec rake test CKEDITOR_ORM=mongoid - - 'bundle exec rake test:controllers' - - 'bundle exec rake test:generators' - - 'bundle exec rake test:integration' - - 'bundle exec rake test:models' + - bundle exec rake test:controllers + - bundle exec rake test:generators + - bundle exec rake test:integration + - bundle exec rake test:models From cba23d7f68368d3dfd51c6763e1d1a1d6d4ebbcd Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 11:34:12 +0300 Subject: [PATCH 04/13] Upgrade rails to 6.1 version --- .semaphore/semaphore.yml | 4 +- Gemfile | 19 +-- Gemfile.lock | 360 ++++++++++++++++++++------------------- 3 files changed, 194 insertions(+), 189 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index f29419773..af6caba92 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -19,10 +19,10 @@ blocks: - sem-service start postgres 11 - sem-version ruby 2.7.6 - cache restore - - bundle install --deployment --path vendor/bundle + - bundle install --path vendor/bundle - cache store - bundle exec rake db:setup - - bundle exec rake test CKEDITOR_BACKEND=paperclip + # - bundle exec rake test CKEDITOR_BACKEND=paperclip - bundle exec rake test CKEDITOR_BACKEND=active_storage - bundle exec rake test CKEDITOR_BACKEND=carrierwave - bundle exec rake test CKEDITOR_BACKEND=dragonfly diff --git a/Gemfile b/Gemfile index 4e0bb01d5..4dc3bec30 100644 --- a/Gemfile +++ b/Gemfile @@ -4,19 +4,15 @@ source 'http://rubygems.org' gemspec -gem 'rails', '~> 5.2.4.6' +gem 'rails', '~> 6.1' platforms :ruby do gem 'sass' - gem 'sqlite3', '~> 1.3.6' - gem 'sprockets', '~> 3.7.2' + gem 'sqlite3' + gem 'sprockets' group :development, :test do - gem 'capybara', '>= 0.4.0' - gem 'jquery-rails', '~> 4.3.3' - gem 'mynyml-redgreen', '~> 0.7.1', require: 'redgreen' - gem 'rails-controller-testing' - + gem 'capybara' gem 'rubocop-rails' end @@ -24,14 +20,13 @@ platforms :ruby do gem 'carrierwave' gem 'dragonfly' gem 'mini_magick' - gem 'paperclip', '~> 6.1.0' + # gem 'paperclip', '~> 6.1.0' end group :mongoid do - gem 'bson_ext' gem 'carrierwave-mongoid', require: 'carrierwave/mongoid' - gem 'mongoid', '~> 7.0.2' - gem 'mongoid-paperclip', require: 'mongoid_paperclip' + gem 'mongoid' + # gem 'mongoid-paperclip', require: 'mongoid_paperclip' gem 'shrine' gem 'shrine-mongoid' gem 'image_processing' diff --git a/Gemfile.lock b/Gemfile.lock index 8f57ae3f6..dd6e47d75 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,270 +1,280 @@ PATH remote: . specs: - ckeditor (5.1.1) + ckeditor (5.1.2) orm_adapter (~> 0.5.0) GEM remote: http://rubygems.org/ specs: - actioncable (5.2.4.6) - actionpack (= 5.2.4.6) + actioncable (6.1.7.8) + actionpack (= 6.1.7.8) + activesupport (= 6.1.7.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.6) - actionpack (= 5.2.4.6) - actionview (= 5.2.4.6) - activejob (= 5.2.4.6) + actionmailbox (6.1.7.8) + actionpack (= 6.1.7.8) + activejob (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) + mail (>= 2.7.1) + actionmailer (6.1.7.8) + actionpack (= 6.1.7.8) + actionview (= 6.1.7.8) + activejob (= 6.1.7.8) + activesupport (= 6.1.7.8) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.6) - actionview (= 5.2.4.6) - activesupport (= 5.2.4.6) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.7.8) + actionview (= 6.1.7.8) + activesupport (= 6.1.7.8) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.6) - activesupport (= 5.2.4.6) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7.8) + actionpack (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) + nokogiri (>= 1.8.5) + actionview (6.1.7.8) + activesupport (= 6.1.7.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4.6) - activesupport (= 5.2.4.6) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7.8) + activesupport (= 6.1.7.8) globalid (>= 0.3.6) - activemodel (5.2.4.6) - activesupport (= 5.2.4.6) - activerecord (5.2.4.6) - activemodel (= 5.2.4.6) - activesupport (= 5.2.4.6) - arel (>= 9.0) - activestorage (5.2.4.6) - actionpack (= 5.2.4.6) - activerecord (= 5.2.4.6) - marcel (~> 0.3.1) - activesupport (5.2.4.6) + activemodel (6.1.7.8) + activesupport (= 6.1.7.8) + activerecord (6.1.7.8) + activemodel (= 6.1.7.8) + activesupport (= 6.1.7.8) + activestorage (6.1.7.8) + actionpack (= 6.1.7.8) + activejob (= 6.1.7.8) + activerecord (= 6.1.7.8) + activesupport (= 6.1.7.8) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.8) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - arel (9.0.0) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) - bson (4.12.0) - bson_ext (1.5.1) - builder (3.2.4) - capybara (3.35.3) + bson (5.0.0) + builder (3.3.0) + capybara (3.39.2) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.0) + carrierwave (2.2.6) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) image_processing (~> 1.1) - mimemagic (>= 0.3.0) + marcel (~> 1.0.0) mini_mime (>= 0.1.3) ssrf_filter (~> 1.0) - carrierwave-mongoid (1.3.0) + carrierwave-mongoid (1.4.0) carrierwave (>= 0.8, < 3) - mongoid (>= 3.0, < 8.0) + mongoid (>= 3.0, < 9.0) mongoid-grid_fs (>= 1.3, < 3.0) - climate_control (0.2.0) - concurrent-ruby (1.1.9) + concurrent-ruby (1.3.3) content_disposition (1.0.0) crass (1.0.6) - down (5.2.0) - addressable (~> 2.5) + date (3.3.4) + down (5.4.2) + addressable (~> 2.8) dragonfly (1.4.0) addressable (~> 2.3) multi_json (~> 1.0) rack (>= 1.3) - erubi (1.10.0) - ffi (1.15.0) - globalid (0.5.2) - activesupport (>= 5.0) - i18n (1.8.11) + erubi (1.13.0) + ffi (1.17.0-arm64-darwin) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - image_processing (1.12.1) + image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - jquery-rails (4.3.5) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - loofah (2.12.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (1.0.0) - mime-types (3.3.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.1.0) + mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0225) - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_magick (4.11.0) - mini_mime (1.1.2) - mini_portile2 (2.6.1) - minitest (5.14.4) - mongo (2.14.0) - bson (>= 4.8.2, < 5.0.0) - mongoid (7.0.12) - activemodel (>= 5.1, < 6.2) - mongo (>= 2.7.0, < 3.0.0) - mongoid-grid_fs (2.4.0) + mime-types-data (3.2024.0604) + mini_magick (4.13.1) + mini_mime (1.1.5) + mini_portile2 (2.8.7) + minitest (5.24.1) + mongo (2.20.0) + bson (>= 4.14.1, < 6.0.0) + mongoid (8.1.5) + activemodel (>= 5.1, < 7.2, != 7.0.0) + concurrent-ruby (>= 1.0.5, < 2.0) + mongo (>= 2.18.0, < 3.0.0) + ruby2_keywords (~> 0.0.5) + mongoid-grid_fs (2.5.0) mime-types (>= 1.0, < 4.0) - mongoid (>= 3.0, < 8.0) - mongoid-paperclip (0.0.11) - mongoid - paperclip (>= 2.3.6, != 4.3.0) + mongoid (>= 3.0, < 9.0) multi_json (1.15.0) - mynyml-redgreen (0.7.1) - term-ansicolor (>= 1.0.4) - nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + net-imap (0.4.14) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.15.6-arm64-darwin) racc (~> 1.4) orm_adapter (0.5.0) - paperclip (6.1.0) - activemodel (>= 4.2.0) - activesupport (>= 4.2.0) - mime-types - mimemagic (~> 0.3.0) - terrapin (~> 0.6.0) - parallel (1.21.0) - parser (3.0.2.0) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) - public_suffix (4.0.6) - racc (1.6.0) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.4.6) - actioncable (= 5.2.4.6) - actionmailer (= 5.2.4.6) - actionpack (= 5.2.4.6) - actionview (= 5.2.4.6) - activejob (= 5.2.4.6) - activemodel (= 5.2.4.6) - activerecord (= 5.2.4.6) - activestorage (= 5.2.4.6) - activesupport (= 5.2.4.6) - bundler (>= 1.3.0) - railties (= 5.2.4.6) + racc + public_suffix (5.1.1) + racc (1.8.0) + rack (2.2.9) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.1.7.8) + actioncable (= 6.1.7.8) + actionmailbox (= 6.1.7.8) + actionmailer (= 6.1.7.8) + actionpack (= 6.1.7.8) + actiontext (= 6.1.7.8) + actionview (= 6.1.7.8) + activejob (= 6.1.7.8) + activemodel (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) + bundler (>= 1.15.0) + railties (= 6.1.7.8) sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.5) - actionpack (>= 5.0.1.rc1) - actionview (>= 5.0.1.rc1) - activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - railties (5.2.4.6) - actionpack (= 5.2.4.6) - activesupport (= 5.2.4.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (6.1.7.8) + actionpack (= 6.1.7.8) + activesupport (= 6.1.7.8) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) - rake (13.0.6) - rb-fsevent (0.10.4) - rb-inotify (0.10.1) + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - regexp_parser (2.1.1) - rexml (3.2.5) - rubocop (1.22.3) + regexp_parser (2.9.2) + rexml (3.3.1) + strscan + rubocop (1.64.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.12.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.13.0) - parser (>= 3.0.1.1) - rubocop-rails (2.12.4) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - ruby-progressbar (1.11.0) - ruby-vips (2.1.0) + rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (1.13.0) + ruby-vips (2.2.1) ffi (~> 1.12) + ruby2_keywords (0.0.5) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - shrine (3.3.0) + shrine (3.6.0) content_disposition (~> 1.0) down (~> 5.1) shrine-mongoid (1.0.0) mongoid (>= 5.0) shrine (>= 3.0.0.beta3, < 4) - sprockets (3.7.2) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.3.0) - actionpack (>= 5.2) - activesupport (>= 5.2) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - sqlite3 (1.3.13) - ssrf_filter (1.0.7) - sync (0.5.0) - term-ansicolor (1.7.1) - tins (~> 1.0) - terrapin (0.6.0) - climate_control (>= 0.0.3, < 1.0) - thor (1.1.0) - thread_safe (0.3.6) - tins (1.28.0) - sync - tzinfo (1.2.9) - thread_safe (~> 0.1) - unicode-display_width (2.1.0) - websocket-driver (0.7.5) + sqlite3 (1.7.3) + mini_portile2 (~> 2.8.0) + ssrf_filter (1.1.2) + strscan (3.1.0) + thor (1.3.1) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.6.16) PLATFORMS - ruby + arm64-darwin-21 DEPENDENCIES - bson_ext - capybara (>= 0.4.0) + capybara carrierwave carrierwave-mongoid ckeditor! dragonfly image_processing - jquery-rails (~> 4.3.3) mini_magick - mongoid (~> 7.0.2) - mongoid-paperclip - mynyml-redgreen (~> 0.7.1) - paperclip (~> 6.1.0) - rails (~> 5.2.4.6) - rails-controller-testing + mongoid + rails (~> 6.1) rubocop-rails sass shrine shrine-mongoid - sprockets (~> 3.7.2) - sqlite3 (~> 1.3.6) + sprockets + sqlite3 BUNDLED WITH - 1.17.3 + 2.3.25 From 5af4d81df2580b16365300aa1d3549924167b167 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 11:38:42 +0300 Subject: [PATCH 05/13] Remove postgres service --- .semaphore/semaphore.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index af6caba92..06b622778 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -8,20 +8,16 @@ blocks: - name: 'Test' task: env_vars: - - name: DATABASE_URL - value: 'postgresql://postgres:@0.0.0.0:5432/myapp_test' - name: RAILS_ENV value: test jobs: - name: Test commands: - checkout - - sem-service start postgres 11 - sem-version ruby 2.7.6 - cache restore - bundle install --path vendor/bundle - cache store - - bundle exec rake db:setup # - bundle exec rake test CKEDITOR_BACKEND=paperclip - bundle exec rake test CKEDITOR_BACKEND=active_storage - bundle exec rake test CKEDITOR_BACKEND=carrierwave From b6a4cc3ed992aff09dd5ce62abaee0cf9bd2e279 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 11:42:02 +0300 Subject: [PATCH 06/13] Remove deprecated setting --- test/dummy/config/environments/test.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 59e0419fc..0eb3baa78 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -36,6 +36,4 @@ config.active_support.deprecation = :stderr config.active_support.test_order = :sorted - - config.active_record.sqlite3.represent_boolean_as_integer = true end From 08cf037c1019e6b80bba93ad31448816a5f086c4 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 11:44:48 +0300 Subject: [PATCH 07/13] Configure manifest.js --- test/dummy/app/assets/config/manifest.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/dummy/app/assets/config/manifest.js diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js new file mode 100644 index 000000000..b16e53d6d --- /dev/null +++ b/test/dummy/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css From e52aaf723dae6f488d7e0b8e3e114f3cae494930 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 13:08:15 +0300 Subject: [PATCH 08/13] Update active_storage migrations and configure manifest.js --- Gemfile | 3 ++- Gemfile.lock | 5 ++++- app/assets/config/manifest.js | 7 +++++++ .../active_record/active_storage/migration.rb | 2 +- .../active_record/carrierwave/migration.rb | 2 +- .../templates/active_record/dragonfly/migration.rb | 2 +- .../templates/active_record/paperclip/migration.rb | 2 +- .../controllers/attachment_files_controller_test.rb | 1 - test/controllers/pictures_controller_test.rb | 1 - test/dummy/app/assets/config/manifest.js | 4 +++- test/dummy/app/assets/javascripts/application.js | 2 -- test/dummy/config/environments/test.rb | 2 ++ .../dummy/db/migrate/20110623120047_create_posts.rb | 2 +- .../20170806125915_create_active_storage_tables.rb | 3 ++- ...2124877_create_active_storage_variant_records.rb | 13 +++++++++++++ test/orm/active_record.rb | 3 ++- test/test_helper.rb | 1 - 17 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 app/assets/config/manifest.js create mode 100644 test/dummy/db/migrate/20240702124877_create_active_storage_variant_records.rb diff --git a/Gemfile b/Gemfile index 4dc3bec30..4c36b0c74 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,8 @@ gem 'rails', '~> 6.1' platforms :ruby do gem 'sass' gem 'sqlite3' - gem 'sprockets' + gem 'sprockets-rails' + gem 'sassc' group :development, :test do gem 'capybara' diff --git a/Gemfile.lock b/Gemfile.lock index dd6e47d75..6ad24f670 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -227,6 +227,8 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) + sassc (2.4.0) + ffi (~> 1.9) shrine (3.6.0) content_disposition (~> 1.0) down (~> 5.1) @@ -271,9 +273,10 @@ DEPENDENCIES rails (~> 6.1) rubocop-rails sass + sassc shrine shrine-mongoid - sprockets + sprockets-rails sqlite3 BUNDLED WITH diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..0245ca2af --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,7 @@ +//= link_tree ../images + +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css + +//= link ckeditor/application.css +//= link application.css diff --git a/lib/generators/ckeditor/templates/active_record/active_storage/migration.rb b/lib/generators/ckeditor/templates/active_record/active_storage/migration.rb index 0d27b624a..a4d905c4c 100644 --- a/lib/generators/ckeditor/templates/active_record/active_storage/migration.rb +++ b/lib/generators/ckeditor/templates/active_record/active_storage/migration.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateCkeditorAssets < ActiveRecord::Migration[5.2] +class CreateCkeditorAssets < ActiveRecord::Migration[6.1] def up create_table :ckeditor_assets do |t| t.string :data_file_name, null: false diff --git a/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb b/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb index cbb307e66..c657599be 100644 --- a/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb +++ b/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateCkeditorAssets < ActiveRecord::Migration[5.2] +class CreateCkeditorAssets < ActiveRecord::Migration[6.1] def up create_table :ckeditor_assets do |t| t.string :data_file_name, null: false diff --git a/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb b/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb index ca60e72ed..7c2025cd7 100644 --- a/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb +++ b/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateCkeditorAssets < ActiveRecord::Migration[5.2] +class CreateCkeditorAssets < ActiveRecord::Migration[6.1] def up create_table :ckeditor_assets do |t| t.string :data_uid, null: false diff --git a/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb b/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb index 0d27b624a..a4d905c4c 100644 --- a/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb +++ b/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateCkeditorAssets < ActiveRecord::Migration[5.2] +class CreateCkeditorAssets < ActiveRecord::Migration[6.1] def up create_table :ckeditor_assets do |t| t.string :data_file_name, null: false diff --git a/test/controllers/attachment_files_controller_test.rb b/test/controllers/attachment_files_controller_test.rb index ac4f8d1d3..d6a879fce 100644 --- a/test/controllers/attachment_files_controller_test.rb +++ b/test/controllers/attachment_files_controller_test.rb @@ -18,7 +18,6 @@ def teardown get :index assert_equal 200, @response.status - assert_template 'ckeditor/attachment_files/index' end test 'create action via filebrowser' do diff --git a/test/controllers/pictures_controller_test.rb b/test/controllers/pictures_controller_test.rb index b9d7ac3ef..35685dad8 100644 --- a/test/controllers/pictures_controller_test.rb +++ b/test/controllers/pictures_controller_test.rb @@ -18,7 +18,6 @@ def teardown get :index assert_equal 200, @response.status - assert_template 'ckeditor/pictures/index' end test 'create action via filebrowser' do diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js index b16e53d6d..03c818ac1 100644 --- a/test/dummy/app/assets/config/manifest.js +++ b/test/dummy/app/assets/config/manifest.js @@ -1,3 +1,5 @@ -//= link_tree ../images //= link_directory ../javascripts .js //= link_directory ../stylesheets .css + +//= link ckeditor/application.css +//= link application.css diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js index fc19b8e61..c06621454 100644 --- a/test/dummy/app/assets/javascripts/application.js +++ b/test/dummy/app/assets/javascripts/application.js @@ -4,5 +4,3 @@ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // the compiled file. // -//= require jquery -//= require jquery_ujs diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 0eb3baa78..1ba44f88f 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -36,4 +36,6 @@ config.active_support.deprecation = :stderr config.active_support.test_order = :sorted + + config.assets.precompile += %w( ckeditor/application.css ckeditor/application.js application.css ) end diff --git a/test/dummy/db/migrate/20110623120047_create_posts.rb b/test/dummy/db/migrate/20110623120047_create_posts.rb index 15b0eba6d..774b41807 100644 --- a/test/dummy/db/migrate/20110623120047_create_posts.rb +++ b/test/dummy/db/migrate/20110623120047_create_posts.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreatePosts < ActiveRecord::Migration[5.2] +class CreatePosts < ActiveRecord::Migration[6.1] def up create_table :posts do |t| t.string :title diff --git a/test/dummy/db/migrate/20170806125915_create_active_storage_tables.rb b/test/dummy/db/migrate/20170806125915_create_active_storage_tables.rb index cfaf01cd5..54dfa0d6a 100644 --- a/test/dummy/db/migrate/20170806125915_create_active_storage_tables.rb +++ b/test/dummy/db/migrate/20170806125915_create_active_storage_tables.rb @@ -1,4 +1,4 @@ -class CreateActiveStorageTables < ActiveRecord::Migration[5.2] +class CreateActiveStorageTables < ActiveRecord::Migration[6.1] def change create_table :active_storage_blobs do |t| t.string :key, null: false @@ -8,6 +8,7 @@ def change t.bigint :byte_size, null: false t.string :checksum, null: false t.datetime :created_at, null: false + t.string :service_name, null: false t.index [ :key ], unique: true end diff --git a/test/dummy/db/migrate/20240702124877_create_active_storage_variant_records.rb b/test/dummy/db/migrate/20240702124877_create_active_storage_variant_records.rb new file mode 100644 index 000000000..70185bbf4 --- /dev/null +++ b/test/dummy/db/migrate/20240702124877_create_active_storage_variant_records.rb @@ -0,0 +1,13 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.1] + def up + create_table :active_storage_variant_records do |t| + t.belongs_to :blob, null: false, index: false + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", + unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/test/orm/active_record.rb b/test/orm/active_record.rb index dc7c09c43..2d475fb2a 100644 --- a/test/orm/active_record.rb +++ b/test/orm/active_record.rb @@ -7,5 +7,6 @@ def activerecord_below_5_2? if activerecord_below_5_2? ActiveRecord::Migrator.migrate('test/dummy/db/migrate') else - ActiveRecord::MigrationContext.new('test/dummy/db/migrate').migrate + schema_migration = ActiveRecord::Base.connection.schema_migration + ActiveRecord::MigrationContext.new('test/dummy/db/migrate', schema_migration).migrate end diff --git a/test/test_helper.rb b/test/test_helper.rb index 83f89afa5..0d36c6c00 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,7 +11,6 @@ require File.expand_path('../dummy/config/environment.rb', __FILE__) require 'rails/test_help' -require 'redgreen' Rails.backtrace_cleaner.remove_silencers! From 52c04d7b6b9ca47c98d838b7ff0c25e78f41ba36 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 13:46:45 +0300 Subject: [PATCH 09/13] Setup shrine uploader --- lib/ckeditor/backend/shrine.rb | 8 ++++-- lib/generators/ckeditor/install_generator.rb | 7 ++++++ .../active_record/shrine/ckeditor/asset.rb | 8 ++++++ .../shrine/ckeditor/attachment_file.rb | 7 ++++++ .../active_record/shrine/ckeditor/picture.rb | 11 ++++++++ .../active_record/shrine/migration.rb | 25 +++++++++++++++++++ .../base/shrine/attachment_uploader.rb | 3 +++ .../templates/base/shrine/initializer.rb | 7 +++--- test/support/helpers.rb | 4 +-- 9 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb create mode 100644 lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb create mode 100644 lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb create mode 100644 lib/generators/ckeditor/templates/active_record/shrine/migration.rb create mode 100644 lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb diff --git a/lib/ckeditor/backend/shrine.rb b/lib/ckeditor/backend/shrine.rb index a37a95e15..532186e72 100644 --- a/lib/ckeditor/backend/shrine.rb +++ b/lib/ckeditor/backend/shrine.rb @@ -8,8 +8,12 @@ def self.included(base) end module InstanceMethods + def data=(value) + self.attachment_data = value + end + def url - data_url + attachment.url end def data_file_name @@ -21,7 +25,7 @@ def data_file_size end def datasource - @datasource ||= data&.metadata || {} + @datasource ||= attachment&.metadata || {} end end end diff --git a/lib/generators/ckeditor/install_generator.rb b/lib/generators/ckeditor/install_generator.rb index 4f5effdd0..80b1ab403 100644 --- a/lib/generators/ckeditor/install_generator.rb +++ b/lib/generators/ckeditor/install_generator.rb @@ -47,7 +47,9 @@ def create_models template "#{generator_dir}/ckeditor/#{filename}.rb", File.join('app/models', ckeditor_dir, "#{filename}.rb") end + end + def create_uploaders if backend_carrierwave? template "#{uploaders_dir}/uploaders/ckeditor_attachment_file_uploader.rb", File.join('app/uploaders', 'ckeditor_attachment_file_uploader.rb') @@ -55,6 +57,11 @@ def create_models template "#{uploaders_dir}/uploaders/ckeditor_picture_uploader.rb", File.join('app/uploaders', 'ckeditor_picture_uploader.rb') end + + if backend_shrine? + template "base/shrine/attachment_uploader.rb", + File.join('app/uploaders', 'ckeditor_attachment_uploader.rb') + end end def create_ckeditor_migration diff --git a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb new file mode 100644 index 000000000..37dd78041 --- /dev/null +++ b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class Ckeditor::Asset < ActiveRecord::Base + include Ckeditor::Orm::ActiveRecord::AssetBase + include Ckeditor::Backend::Shrine + + include CkeditorAttachmentUploader::Attachment(:attachment) +end diff --git a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb new file mode 100644 index 000000000..dc315b5d1 --- /dev/null +++ b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class Ckeditor::AttachmentFile < Ckeditor::Asset + def url_thumb + Ckeditor::Utils.filethumb(filename) + end +end diff --git a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb new file mode 100644 index 000000000..e71046ddc --- /dev/null +++ b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class Ckeditor::Picture < Ckeditor::Asset + def url_content + attachment.url + end + + def url_thumb + attachment.url + end +end diff --git a/lib/generators/ckeditor/templates/active_record/shrine/migration.rb b/lib/generators/ckeditor/templates/active_record/shrine/migration.rb new file mode 100644 index 000000000..cf8a9ca4f --- /dev/null +++ b/lib/generators/ckeditor/templates/active_record/shrine/migration.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class CreateCkeditorAssets < ActiveRecord::Migration[6.1] + def up + create_table :ckeditor_assets do |t| + t.integer :data_size + t.string :type, limit: 30 + + # Shrine column + t.text :attachment_data + + # Uncomment these to save image dimensions, if your need them. + # t.integer :data_width + # t.integer :data_height + + t.timestamps null: false + end + + add_index :ckeditor_assets, :type + end + + def down + drop_table :ckeditor_assets + end +end diff --git a/lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb b/lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb new file mode 100644 index 000000000..0a36f5e2b --- /dev/null +++ b/lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb @@ -0,0 +1,3 @@ +class CkeditorAttachmentUploader < Shrine + # plugins and uploading logic +end diff --git a/lib/generators/ckeditor/templates/base/shrine/initializer.rb b/lib/generators/ckeditor/templates/base/shrine/initializer.rb index 981e36f56..56dac3d3f 100644 --- a/lib/generators/ckeditor/templates/base/shrine/initializer.rb +++ b/lib/generators/ckeditor/templates/base/shrine/initializer.rb @@ -8,16 +8,15 @@ require 'image_processing/mini_magick' SHRINE_PICTURE_PROCESSOR = ImageProcessing::MiniMagick -# require 'image_processing/vips' -# SHRINE_PICTURE_PROCESSOR = ImageProcessing::Vips - Shrine.storages = { cache: Shrine::Storage::FileSystem.new('public', prefix: 'uploads/cache'), store: Shrine::Storage::FileSystem.new('public', prefix: 'system') } -Shrine.plugin :determine_mime_type Shrine.plugin :mongoid +Shrine.plugin :activerecord + +Shrine.plugin :determine_mime_type Shrine.plugin :instrumentation Shrine.plugin :validation_helpers diff --git a/test/support/helpers.rb b/test/support/helpers.rb index 3a2987d28..7971d6a3a 100644 --- a/test/support/helpers.rb +++ b/test/support/helpers.rb @@ -9,7 +9,7 @@ class ActiveSupport::TestCase def new_attachment(data = nil) data ||= fixture_file_upload('files/rails.tar.gz', 'application/x-gzip') - Ckeditor.attachment_file_model.new(:data => data) + Ckeditor.attachment_file_model.new(data: data) end def create_attachment(data = nil) @@ -21,7 +21,7 @@ def create_attachment(data = nil) def new_picture(data = nil) data ||= fixture_file_upload('files/rails.png', 'image/png') - Ckeditor.picture_model.new(:data => data) + Ckeditor.picture_model.new(data: data) end def create_picture(data = nil) From b7381e2a7772f234e9ce57f1a0107f3a48bde5f4 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 14:20:35 +0300 Subject: [PATCH 10/13] Add uploader for shrine attachment toolkit --- .gitignore | 1 + lib/ckeditor/backend/shrine.rb | 4 ++-- lib/generators/ckeditor/install_generator.rb | 8 ++++---- .../templates/active_record/shrine/ckeditor/asset.rb | 2 ++ .../templates/active_record/shrine/ckeditor/picture.rb | 4 ++-- .../ckeditor/templates/base/shrine/attachment_uploader.rb | 3 --- .../base/shrine/uploaders/ckeditor_attachment_uploader.rb | 8 ++++++++ test/controllers/attachment_files_controller_test.rb | 3 ++- test/controllers/pictures_controller_test.rb | 2 +- test/models/picture_test.rb | 4 ++-- test/support/helpers.rb | 4 ++-- 11 files changed, 26 insertions(+), 17 deletions(-) delete mode 100644 lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb create mode 100644 lib/generators/ckeditor/templates/base/shrine/uploaders/ckeditor_attachment_uploader.rb diff --git a/.gitignore b/.gitignore index d4484ab46..54e603b88 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ test/dummy/public/uploads/* .DS_Store Gemfile.lock dragonfly.log +public/ diff --git a/lib/ckeditor/backend/shrine.rb b/lib/ckeditor/backend/shrine.rb index 532186e72..b991cecd2 100644 --- a/lib/ckeditor/backend/shrine.rb +++ b/lib/ckeditor/backend/shrine.rb @@ -9,11 +9,11 @@ def self.included(base) module InstanceMethods def data=(value) - self.attachment_data = value + self.attachment = value end def url - attachment.url + attachment&.url end def data_file_name diff --git a/lib/generators/ckeditor/install_generator.rb b/lib/generators/ckeditor/install_generator.rb index 80b1ab403..e56ac9e22 100644 --- a/lib/generators/ckeditor/install_generator.rb +++ b/lib/generators/ckeditor/install_generator.rb @@ -51,15 +51,15 @@ def create_models def create_uploaders if backend_carrierwave? - template "#{uploaders_dir}/uploaders/ckeditor_attachment_file_uploader.rb", + template "#{uploaders_dir}/ckeditor_attachment_file_uploader.rb", File.join('app/uploaders', 'ckeditor_attachment_file_uploader.rb') - template "#{uploaders_dir}/uploaders/ckeditor_picture_uploader.rb", + template "#{uploaders_dir}/ckeditor_picture_uploader.rb", File.join('app/uploaders', 'ckeditor_picture_uploader.rb') end if backend_shrine? - template "base/shrine/attachment_uploader.rb", + template "#{uploaders_dir}/ckeditor_attachment_uploader.rb", File.join('app/uploaders', 'ckeditor_attachment_uploader.rb') end end @@ -94,7 +94,7 @@ def generator_dir end def uploaders_dir - @uploaders_dir ||= 'base/carrierwave' + @uploaders_dir ||= "base/#{backend}/uploaders" end def orm diff --git a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb index 37dd78041..ded33403d 100644 --- a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb +++ b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb @@ -5,4 +5,6 @@ class Ckeditor::Asset < ActiveRecord::Base include Ckeditor::Backend::Shrine include CkeditorAttachmentUploader::Attachment(:attachment) + + validates :attachment_data, presence: true end diff --git a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb index e71046ddc..6920853df 100644 --- a/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb +++ b/lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb @@ -2,10 +2,10 @@ class Ckeditor::Picture < Ckeditor::Asset def url_content - attachment.url + attachment&.url end def url_thumb - attachment.url + attachment&.url end end diff --git a/lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb b/lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb deleted file mode 100644 index 0a36f5e2b..000000000 --- a/lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb +++ /dev/null @@ -1,3 +0,0 @@ -class CkeditorAttachmentUploader < Shrine - # plugins and uploading logic -end diff --git a/lib/generators/ckeditor/templates/base/shrine/uploaders/ckeditor_attachment_uploader.rb b/lib/generators/ckeditor/templates/base/shrine/uploaders/ckeditor_attachment_uploader.rb new file mode 100644 index 000000000..30d7921f2 --- /dev/null +++ b/lib/generators/ckeditor/templates/base/shrine/uploaders/ckeditor_attachment_uploader.rb @@ -0,0 +1,8 @@ +class CkeditorAttachmentUploader < Shrine + plugin :validation_helpers + + Attacher.validate do + validate_max_size 5*1024*1024 # file size must not be greater than 5 MB + validate_min_size 1024 # file size must not be less than 1 KB + end +end diff --git a/test/controllers/attachment_files_controller_test.rb b/test/controllers/attachment_files_controller_test.rb index d6a879fce..8f86878bb 100644 --- a/test/controllers/attachment_files_controller_test.rb +++ b/test/controllers/attachment_files_controller_test.rb @@ -6,7 +6,8 @@ class AttachmentFilesControllerTest < ActionController::TestCase tests Ckeditor::AttachmentFilesController def setup - @attachment = fixture_file_upload('files/rails.tar.gz', 'application/x-gzip') + @attachment = Rack::Test::UploadedFile.new('test/dummy/test/fixtures/files/rails.tar.gz', 'application/x-gzip') + @routes = Ckeditor::Engine.routes end diff --git a/test/controllers/pictures_controller_test.rb b/test/controllers/pictures_controller_test.rb index 35685dad8..011fbc843 100644 --- a/test/controllers/pictures_controller_test.rb +++ b/test/controllers/pictures_controller_test.rb @@ -6,7 +6,7 @@ class PicturesControllerTest < ActionController::TestCase tests Ckeditor::PicturesController def setup - @image = fixture_file_upload('files/rails.png', 'image/png') + @image = Rack::Test::UploadedFile.new('test/dummy/test/fixtures/files/rails.png', 'image/png') @routes = Ckeditor::Engine.routes end diff --git a/test/models/picture_test.rb b/test/models/picture_test.rb index 57809b91e..4de3b3390 100644 --- a/test/models/picture_test.rb +++ b/test/models/picture_test.rb @@ -10,7 +10,8 @@ def teardown test 'Set file content_type and size' do @picture = create_picture - assert_equal 'rails.png', @picture.data_file_name unless CKEDITOR_BACKEND == :shrine + assert_equal 'rails.png', @picture.data_file_name + case CKEDITOR_BACKEND when :dragonfly assert @picture.url_thumb.include?('thumb_rails') @@ -18,7 +19,6 @@ def teardown assert @picture.url_thumb =~ /\/representations\/.*\/rails.png/ when :shrine assert @picture.url_thumb =~ /\S{32}\.png/ - assert @picture.data_file_name =~ /image_processing(\d{8})-(\d{5})-(\S{,7})\.png/ else assert @picture.url_thumb.include?('thumb_rails.png') end diff --git a/test/support/helpers.rb b/test/support/helpers.rb index 7971d6a3a..61431a25a 100644 --- a/test/support/helpers.rb +++ b/test/support/helpers.rb @@ -7,7 +7,7 @@ class ActiveSupport::TestCase include ActionDispatch::TestProcess def new_attachment(data = nil) - data ||= fixture_file_upload('files/rails.tar.gz', 'application/x-gzip') + data ||= Rack::Test::UploadedFile.new('test/dummy/test/fixtures/files/rails.tar.gz', 'application/x-gzip') Ckeditor.attachment_file_model.new(data: data) end @@ -19,7 +19,7 @@ def create_attachment(data = nil) end def new_picture(data = nil) - data ||= fixture_file_upload('files/rails.png', 'image/png') + data ||= Rack::Test::UploadedFile.new('test/dummy/test/fixtures/files/rails.png', 'image/png') Ckeditor.picture_model.new(data: data) end From 1b62a7e7f87656dc0c8c1ae49a8ee65a43a6937c Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 14:26:43 +0300 Subject: [PATCH 11/13] Start mongodb service before tests --- .semaphore/semaphore.yml | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 06b622778..288c51c44 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -14,6 +14,7 @@ blocks: - name: Test commands: - checkout + - sem-service start mongodb - sem-version ruby 2.7.6 - cache restore - bundle install --path vendor/bundle diff --git a/README.md b/README.md index fc845987e..4916867ad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ckeditor -[![Build Status](https://semaphoreci.com/api/v1/igor-galeta/ckeditor/branches/master/shields_badge.svg)](https://semaphoreci.com/igor-galeta/ckeditor) +[![Build Status](https://galetahub.semaphoreci.com/badges/ckeditor/branches/master.svg?style=shields&key=eabcab57-9b51-4460-9b27-9c61c28efcdb)](https://galetahub.semaphoreci.com/projects/ckeditor) [![Code Climate](https://codeclimate.com/github/galetahub/ckeditor/badges/gpa.svg)](https://codeclimate.com/github/galetahub/ckeditor) [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua) From a7988f3446a2b72cca67449adbb8c071f4b873fe Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 14:31:39 +0300 Subject: [PATCH 12/13] Run tests for mongoid orm with carrierwave backend --- .semaphore/semaphore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 288c51c44..5bd2bbbc8 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -14,7 +14,7 @@ blocks: - name: Test commands: - checkout - - sem-service start mongodb + - sem-service start mongodb - sem-version ruby 2.7.6 - cache restore - bundle install --path vendor/bundle @@ -24,7 +24,7 @@ blocks: - bundle exec rake test CKEDITOR_BACKEND=carrierwave - bundle exec rake test CKEDITOR_BACKEND=dragonfly - bundle exec rake test CKEDITOR_BACKEND=shrine - - bundle exec rake test CKEDITOR_ORM=mongoid + - bundle exec rake test CKEDITOR_ORM=mongoid CKEDITOR_BACKEND=carrierwave - bundle exec rake test:controllers - bundle exec rake test:generators - bundle exec rake test:integration From e853e6dedffbc7eb98530a9d6c9bfe20aedfd1f8 Mon Sep 17 00:00:00 2001 From: Igor Galeta Date: Tue, 2 Jul 2024 14:37:21 +0300 Subject: [PATCH 13/13] Change default backend to carrierwave --- CHANGELOG.md | 1 + test/controllers/pictures_controller_test.rb | 2 +- test/test_helper.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d39c51277..096076638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Upgrade CKEditor to 4.22.1 version * Bump ruby version to 2.7.6 + * Temporarily turn off paperclip gem support ## Ckeditor 5.1.1 (12-1-2021) diff --git a/test/controllers/pictures_controller_test.rb b/test/controllers/pictures_controller_test.rb index 011fbc843..942d6b188 100644 --- a/test/controllers/pictures_controller_test.rb +++ b/test/controllers/pictures_controller_test.rb @@ -53,7 +53,7 @@ def teardown end test 'destroy action via filebrowser' do - @picture = Ckeditor::Picture.create data: @image + @picture = Ckeditor::Picture.create! data: @image assert_difference 'Ckeditor::Picture.count', -1 do delete :destroy, params: { id: @picture.id } diff --git a/test/test_helper.rb b/test/test_helper.rb index 0d36c6c00..e1e2f7080 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -3,7 +3,7 @@ # Configure Rails Envinronment ENV['RAILS_ENV'] = 'test' CKEDITOR_ORM = (ENV['CKEDITOR_ORM'] || :active_record).to_sym -CKEDITOR_BACKEND = (ENV['CKEDITOR_BACKEND'] || :paperclip).to_sym +CKEDITOR_BACKEND = (ENV['CKEDITOR_BACKEND'] || :carrierwave).to_sym $:.unshift File.dirname(__FILE__) puts "\n==> Ckeditor.orm = #{CKEDITOR_ORM.inspect}. CKEDITOR_ORM = (active_record|mongoid)"