diff --git a/CHANGELOG.md b/CHANGELOG.md index 3418d072..c62ba3e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ ## v1.0.8 - 10 November 2023 -- Prepped for Rails 7.1 compatibility +- Updated configs, et al. in prep for Rails 7.1 compatibility +- Added explicit coder for serialize commands +- Added ActiveRecord Adapter (database) info to admin footer +- Added commented defaults for MySQL and Postgres to database.yml +- Updated documentation +- Refactored lib files for better test coverage awareness ## v1.0.7.3 - 7 October 2023 diff --git a/Gemfile b/Gemfile index 9935c32a..69d4db43 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec -gem 'rails', '~> 7.1.1' +gem 'rails', '~> 7.1.2' group :development, :test do gem 'autoprefixer-rails', '~> 8.1.0' diff --git a/lib/occams/routes/cms.rb b/lib/occams/routes/cms.rb new file mode 100644 index 00000000..c76a5479 --- /dev/null +++ b/lib/occams/routes/cms.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class ActionDispatch::Routing::Mapper + def occams_route_cms(options = {}) + Occams.configuration.public_cms_path = options[:path] + + scope module: :occams, as: :occams do + namespace :cms, path: options[:path] do + get 'cms-css/:site_id/:identifier(/:cache_buster)' => 'assets#render_css', as: 'render_css' + get 'cms-js/:site_id/:identifier(/:cache_buster)' => 'assets#render_js', as: 'render_js' + + get '(*cms_path)' => 'content#show', as: 'render_page', action: '/:format' + end + end + end +end diff --git a/lib/occams/routes/cms_admin.rb b/lib/occams/routes/cms_admin.rb new file mode 100644 index 00000000..0e83492f --- /dev/null +++ b/lib/occams/routes/cms_admin.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +class ActionDispatch::Routing::Mapper + def occams_route_cms_admin(path: 'admin') + scope module: :occams, as: :occams do + scope module: :admin do + namespace :cms, as: :admin_cms, path: path, except: :show do + get '/', to: 'base#jump' + + concern :with_revisions do |options| + resources :revisions, options.merge(only: %i[index show]) do + patch :revert, on: :member + end + end + + concern :with_reorder do + put :reorder, on: :collection + end + + concern :with_form_fragments do + get :form_fragments, on: :member + end + + resources :sites do + resources :pages do + concerns :with_reorder + concerns :with_form_fragments + concerns :with_revisions, controller: 'revisions/page' + + get :toggle_branch, on: :member + + resources :translations, except: [:index] do + concerns :with_form_fragments + concerns :with_revisions, controller: 'revisions/translation' + end + end + + resources :files, concerns: [:with_reorder] + + resources :layouts do + concerns :with_reorder + concerns :with_revisions, controller: 'revisions/layout' + end + + resources :snippets do + concerns :with_reorder + concerns :with_revisions, controller: 'revisions/snippet' + end + + resources :categories + end + end + end + end + end +end diff --git a/test/lib/routes/admin_routes_test.rb b/test/lib/routes/admin_routes_test.rb new file mode 100644 index 00000000..30d71561 --- /dev/null +++ b/test/lib/routes/admin_routes_test.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require_relative '../../test_helper' + +class AdminRoutesTest < ActionDispatch::IntegrationTest + def setup + @site = occams_cms_sites(:default) + end + + def teardown + Rails.application.reload_routes! + end + + def test_cms_admin_routes + assert_routing '/admin', controller: 'occams/admin/cms/base', action: 'jump' + assert_routing '/auth/identity/callback', + :controller => 'occams/cms/content', + :action => 'show', + cms_path: 'auth/identity/callback' + + + end + +end diff --git a/test/test_helper.rb b/test/test_helper.rb index c56f98c1..ce794468 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,6 +15,7 @@ add_filter 'lib/tasks' add_filter 'lib/generators' add_filter 'lib/occams/engine' + # add_filter 'lib/occams/routes' add_filter 'lib/occams/version' end