Skip to content

Commit

Permalink
Merge pull request #1021 from texpert/fix-comment-in-system-json
Browse files Browse the repository at this point in the history
Fix comment in config/system.json to avoid Oj exception on parsing
  • Loading branch information
texpert authored May 25, 2022
2 parents 32b2111 + 71b29e4 commit 46a1b1a
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 33 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source 'https://rubygems.org'
gemspec
gem 'rails', '~> 7.0.0.rc1'
gem 'non-digest-assets', github: 'mvz/non-digest-assets'
gem 'oj'
gem 'sassc', '!= 2.3.0' # this version segfaults
gem 'selenium-webdriver'
gem 'webdrivers'
Expand Down
3 changes: 1 addition & 2 deletions config/system.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// Note: after any change in this file, you need to restart your server to apply changes.
"default_template": "default", // default template name for new sites
"hooks": { }, // system hooks
"skip_format_url": true, // enable or disable .html extension in the urls.
Expand All @@ -15,5 +16,3 @@
"auto_include_migrations": true, // permit to auto include all migrations of camaleon cms and its related plugins, if false you can generate manually with: rake camaleon_cms:generate_migrations
"default_layout": "index" // define default layout name for camaleon frontend
}

// Note: after any change in this file, you need to restart your server to apply changes.
1 change: 1 addition & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'selenium-webdriver'
gem 'webdrivers'
gem 'capybara-screenshot'
gem 'puma'
gem 'oj'
gem 'factory_bot'
gem 'faker'
gem 'rack_session_access'
1 change: 1 addition & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'selenium-webdriver'
gem 'webdrivers'
gem 'capybara-screenshot'
gem 'puma'
gem 'oj'
gem 'factory_bot'
gem 'faker'
gem 'rack_session_access'
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'selenium-webdriver'
gem 'webdrivers'
gem 'capybara-screenshot'
gem 'puma'
gem 'oj'
gem 'factory_bot'
gem 'faker'
gem 'rack_session_access'
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'selenium-webdriver'
gem 'webdrivers'
gem 'capybara-screenshot'
gem 'puma'
gem 'oj'
gem 'factory_bot'
gem 'faker'
gem 'rack_session_access'
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gem 'selenium-webdriver'
gem 'webdrivers'
gem 'capybara-screenshot'
gem 'puma'
gem 'oj'
gem 'factory_bot'
gem 'faker'
gem 'rack_session_access'
Expand Down
5 changes: 5 additions & 0 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ class Application < Rails::Application
# Do not swallow errors in after_commit/after_rollback callbacks.
# config.active_record.raise_in_transactional_callbacks = true
config.active_record.sqlite3.represent_boolean_as_integer = true if Rails.version.to_f == 5.2

config.active_record.legacy_connection_handling = false if Rails.version.to_f >= 6.1 && Rails.version.to_f < 7.1
end
end

Oj.default_options = { mode: :custom, cache_keys: true, cache_str: 5 }
Oj.optimize_rails
26 changes: 14 additions & 12 deletions spec/features/admin/media_spec.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
require "rails_helper"
describe "the Media", js: true do
# frozen_string_literal: true

require 'rails_helper'

describe 'the Media', js: true do
init_site

it "list media" do
it 'list media' do
admin_sign_in
visit "#{cama_root_relative_path}/admin/media"
within '#cama_media_gallery' do
execute_script("$('#cama_search_form .dropdown-toggle.btn').click()")
execute_script('$(\'#cama_search_form .dropdown-toggle.btn\').click()')
find('.add_folder').click
end

within '#add_folder_form' do
fill_in "folder", with: "test_folder_created_by_testing"
fill_in 'folder', with: 'test_folder_created_by_testing'
find('button[type="submit"]').click
wait_for_ajax
end
expect(page).to have_content('test_folder_created_by_testing')

within '#cama_media_gallery' do
# access into inner folder
page.execute_script("$('#cama_media_gallery .folder_item[data-key=\"test_folder_created_by_testing\"]').click()")
page.execute_script('$(\'#cama_media_gallery .folder_item[data-key="test_folder_created_by_testing"]\').click()')
wait_for_ajax
# attach_file('cama-upload-files', Rails.root.join('config', 'system.json').to_s)

within '#cama_media_external' do
fill_in "remote_file", with: "http://camaleon.tuzitio.com/media/132/slider/slider-camaleon.jpg"
fill_in 'remote_file', with: 'https://upload.wikimedia.org/wikipedia/commons/1/15/Jpegvergroessert.jpg'
find('button[type="submit"]').click
wait_for_ajax
end
Expand All @@ -33,18 +36,17 @@
# expect(page).to have_content('slider-camaleon.jpg')

# delete uploaded file
page.execute_script("$('#cama_media_gallery .file_item[data-key=\"slider_camaleon.jpg\"] .del_item').click()")
page.execute_script('$(\'#cama_media_gallery .file_item[data-key="slider_camaleon.jpg"] .del_item\').click()')
confirm_dialog
wait_for_ajax

# back to root
page.execute_script("$('#cama_media_gallery .media_folder_breadcrumb a:first').click()")
page.execute_script('$(\'#cama_media_gallery .media_folder_breadcrumb a:first\').click()')
wait_for_ajax

# delete folder
page.execute_script("$('#cama_media_gallery .folder_item[data-key=\"test_folder_created_by_testing\"] .del_folder').click()")
page.execute_script('$(\'#cama_media_gallery .folder_item[data-key="test_folder_created_by_testing"] .del_folder\').click()')
confirm_dialog
wait_for_ajax

end
end
end
42 changes: 23 additions & 19 deletions spec/helpers/uploader_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
# frozen_string_literal: true

require 'rails_helper'

describe CamaleonCms::UploaderHelper do
init_site
before(:each) do
@path = "#{CAMALEON_CMS_ROOT}/spec/support/fixtures/rails_tmp.png"
FileUtils.cp("#{CAMALEON_CMS_ROOT}/spec/support/fixtures/rails.png", @path)
end
it "upload a local file" do

it 'upload a local file' do
expect(upload_file(File.open(@path)).keys.include?(:error)).not_to eql(true)
expect(upload_file(File.open(@path), {thumb_size: '20x20'}).keys.include?(:error)).not_to eql(true)
expect(upload_file(File.open(@path), {folder: 'sample'}).keys.include?(:error)).not_to eql(true)
end
it "upload a local file max size" do

it 'upload a local file max size' do
expect(upload_file(File.open(@path), {maximum: 1.byte}).keys.include?(:error)).to eql(true)
end

it "upload a local file custom dimension" do
it 'upload a local file custom dimension' do
expect(upload_file(File.open(@path), {dimension: '50x50'}).keys.include?(:error)).not_to eql(true)
expect(upload_file(File.open(@path), {dimension: 'x50'}).keys.include?(:error)).not_to eql(true)
expect(upload_file(File.open(@path), {dimension: '50x'}).keys.include?(:error)).not_to eql(true)
expect(upload_file(File.open(@path), {dimension: '50x20?'}).keys.include?(:error)).not_to eql(true)
end

it "upload a local file invalid format" do
it 'upload a local file invalid format' do
expect(upload_file(File.open(@path), {formats: 'audio'}).keys.include?(:error)).to eql(true)
end

it "upload a local file with versions" do
it 'upload a local file with versions' do
expect(upload_file(File.open(@path), {versions: '300x300,505x350,20x'}).keys.include?(:error)).not_to eql(true)
end
it "add auto orient for cropping images" do
callback = lambda do |params|
params[:img] = params[:img].auto_orient

it 'add auto orient for cropping images' do
callback = lambda do |params|
params[:img] = params[:img].auto_orient
end
PluginRoutes.add_anonymous_hook('before_crop_image', callback, 'my_custom_hook')
expect(upload_file(File.open(@path), {versions: '300x300,505x350,20x'}).keys.include?(:error)).not_to eql(true)
PluginRoutes.remove_anonymous_hook('before_crop_image','my_custom_hook')
end
it "add auto orient for resizing" do

it 'add auto orient for resizing' do
callback = lambda do |params|
params[:img] = params[:img].auto_orient
params[:img] = params[:img].auto_orient
end
PluginRoutes.add_anonymous_hook('before_resize_crop', callback, 'my_custom_hook')
expect(upload_file(File.open(@path), {versions: '300x300,505x350,20x'}).keys.include?(:error)).not_to eql(true)
PluginRoutes.remove_anonymous_hook('before_resize_crop','my_custom_hook')
end

it "upload a external file" do
expect(upload_file('http://camaleon.tuzitio.com/media/132/slider/slide33.jpg').keys.include?(:error)).not_to eql(true)
end

end
it 'upload a external file' do
expect(
upload_file('https://upload.wikimedia.org/wikipedia/commons/1/15/Jpegvergroessert.jpg').keys.include?(:error)
).not_to eql(true)
end
end

0 comments on commit 46a1b1a

Please sign in to comment.