From f77269ac8aae0022fdd06329411ac03be1d0f994 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Fri, 12 May 2023 14:14:46 +0200 Subject: [PATCH] wip test multilingue --- app/models/communication/extranet.rb | 57 ++++++------- app/models/communication/website.rb | 10 +-- .../communication/website/configs/base.rb | 37 +++++++- db/schema.rb | 85 +++++++++---------- test/fixtures/communication/extranets.yml | 57 ++++++------- .../communication/website/dependency_test.rb | 38 ++++----- 6 files changed, 156 insertions(+), 128 deletions(-) diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index 1a4615b3d..0dc316363 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 65ca666b2..f798c3443 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -91,12 +91,10 @@ class Communication::Website < ApplicationRecord # Le website est le SEUL cas d'auto-dƩpendance [self] + configs + - # TODO: Le nettoyage du multilingue ne se fait pas correctement - # quand on supprime une langue d'un site - pages + - posts + - categories + - menus + + pages.where(language_id: language_ids) + + posts.where(language_id: language_ids) + + categories.where(language_id: language_ids) + + menus.where(language_id: language_ids) + [about] end diff --git a/app/models/communication/website/configs/base.rb b/app/models/communication/website/configs/base.rb index 9535e9f89..1be3ddf57 100644 --- a/app/models/communication/website/configs/base.rb +++ b/app/models/communication/website/configs/base.rb @@ -1,3 +1,38 @@ +# == Schema Information +# +# Table name: communication_websites +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# git_branch :string +# git_endpoint :string +# git_provider :integer default("github") +# in_production :boolean default(FALSE) +# name :string +# plausible_url :string +# repository :string +# style :text +# style_updated_at :date +# theme_version :string default("NA") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# default_language_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_websites_on_about (about_type,about_id) +# index_communication_websites_on_default_language_id (default_language_id) +# index_communication_websites_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_2b6d929310 (default_language_id => languages.id) +# fk_rails_bb6a496c08 (university_id => universities.id) +# class Communication::Website::Configs::Base < Communication::Website def self.polymorphic_name @@ -20,4 +55,4 @@ class Communication::Website::Configs::Base < Communication::Website [] end -end \ No newline at end of file +end diff --git a/db/schema.rb b/db/schema.rb index 320e151e6..be5196c9f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -16,7 +16,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do enable_extension "plpgsql" enable_extension "unaccent" - create_table "action_text_rich_texts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "action_text_rich_texts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name", null: false t.text "body" t.string "record_type", null: false @@ -26,7 +26,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true end - create_table "active_storage_attachments", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "active_storage_attachments", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false t.uuid "record_id", null: false @@ -36,7 +36,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end - create_table "active_storage_blobs", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "active_storage_blobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "key", null: false t.string "filename", null: false t.string "content_type" @@ -50,13 +50,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_active_storage_blobs_on_university_id" end - create_table "active_storage_variant_records", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "active_storage_variant_records", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "blob_id", null: false t.string "variation_digest", null: false t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end - create_table "administration_qualiopi_criterions", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "administration_qualiopi_criterions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.integer "number" t.text "name" t.text "description" @@ -64,7 +64,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.datetime "updated_at", null: false end - create_table "administration_qualiopi_indicators", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "administration_qualiopi_indicators", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "criterion_id", null: false t.integer "number" t.text "name" @@ -78,7 +78,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id" end - create_table "communication_blocks", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_blocks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "about_type" t.uuid "about_id" @@ -175,7 +175,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_communication_extranet_posts_on_university_id" end - create_table "communication_extranets", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_extranets", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.uuid "university_id", null: false t.string "host" @@ -203,12 +203,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.text "home_sentence" t.text "sass" t.text "css" - t.boolean "allow_experiences_modification", default: true t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about" t.index ["university_id"], name: "index_communication_extranets_on_university_id" end - create_table "communication_website_categories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "name" @@ -257,7 +256,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_connections_on_website_id" end - create_table "communication_website_git_files", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_git_files", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "previous_path" t.string "about_type", null: false t.uuid "about_id", null: false @@ -269,7 +268,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_git_files_on_website_id" end - create_table "communication_website_imported_authors", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_authors", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "author_id" @@ -285,7 +284,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "idx_communication_website_imported_auth_on_website" end - create_table "communication_website_imported_categories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "category_id" @@ -303,7 +302,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "idx_communication_website_imported_cat_on_website" end - create_table "communication_website_imported_media", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_media", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "identifier" t.jsonb "data" t.text "file_url" @@ -318,7 +317,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_imported_media_on_website_id" end - create_table "communication_website_imported_pages", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "page_id" @@ -342,7 +341,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_imported_pages_on_website_id" end - create_table "communication_website_imported_posts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "post_id" @@ -367,7 +366,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_imported_posts_on_website_id" end - create_table "communication_website_imported_websites", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_imported_websites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.integer "status", default: 0 @@ -377,7 +376,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_imported_websites_on_website_id" end - create_table "communication_website_menu_items", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_menu_items", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false t.uuid "menu_id", null: false @@ -397,7 +396,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_menu_items_on_website_id" end - create_table "communication_website_menus", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_menus", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "title" @@ -413,7 +412,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_communication_website_menus_on_university_id" end - create_table "communication_website_pages", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "title" @@ -428,10 +427,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.text "github_path" t.string "featured_image_alt" t.text "text" - t.text "summary" t.string "breadcrumb_title" t.text "header_text" t.integer "kind" + t.text "summary" t.string "bodyclass" t.uuid "language_id", null: false t.text "featured_image_credit" @@ -459,7 +458,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["website_id"], name: "index_communication_website_permalinks_on_website_id" end - create_table "communication_website_posts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_website_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "communication_website_id", null: false t.string "title" @@ -485,7 +484,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_communication_website_posts_on_university_id" end - create_table "communication_websites", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_websites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "url" @@ -537,7 +536,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["priority", "run_at"], name: "delayed_jobs_priority" end - create_table "education_academic_years", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "education_academic_years", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.integer "year" t.datetime "created_at", null: false @@ -552,7 +551,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_person_id", "education_academic_year_id"], name: "index_person_academic_year" end - create_table "education_cohorts", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "education_cohorts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "program_id", null: false t.uuid "academic_year_id", null: false @@ -573,7 +572,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_person_id", "education_cohort_id"], name: "index_person_cohort" end - create_table "education_diplomas", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "education_diplomas", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "short_name" t.integer "level", default: 0 @@ -587,7 +586,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_education_diplomas_on_university_id" end - create_table "education_programs", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "education_programs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.integer "capacity" @@ -647,7 +646,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["education_program_id", "user_id"], name: "index_education_programs_users_on_program_id_and_user_id" end - create_table "education_schools", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "education_schools", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "address" @@ -663,7 +662,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_education_schools_on_university_id" end - create_table "imports", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "imports", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.integer "number_of_lines" t.jsonb "processing_errors" t.integer "kind" @@ -676,7 +675,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["user_id"], name: "index_imports_on_user_id" end - create_table "languages", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "languages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "iso_code" t.datetime "created_at", null: false @@ -743,7 +742,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_research_journal_paper_kinds_on_university_id" end - create_table "research_journal_papers", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "research_journal_papers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "title" t.datetime "published_at", precision: nil t.uuid "university_id", null: false @@ -780,7 +779,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["researcher_id"], name: "index_research_journal_papers_researchers_on_researcher_id" end - create_table "research_journal_volumes", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "research_journal_volumes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_journal_id", null: false t.string "title" @@ -800,7 +799,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_research_journal_volumes_on_university_id" end - create_table "research_journals", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "research_journals", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "title" t.text "meta_description" @@ -811,7 +810,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_research_journals_on_university_id" end - create_table "research_laboratories", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "research_laboratories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "address" @@ -823,7 +822,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_research_laboratories_on_university_id" end - create_table "research_laboratory_axes", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "research_laboratory_axes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_laboratory_id", null: false t.string "name" @@ -837,7 +836,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id" end - create_table "research_theses", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "research_theses", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "research_laboratory_id", null: false t.uuid "author_id", null: false @@ -855,7 +854,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_research_theses_on_university_id" end - create_table "universities", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "universities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.string "identifier" t.string "address" @@ -894,7 +893,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_university_organization_categories_on_university_id" end - create_table "university_organizations", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "university_organizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "name" t.string "long_name" @@ -932,7 +931,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["organization_id"], name: "index_university_organizations_categories_on_organization_id" end - create_table "university_people", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "university_people", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "user_id" t.string "last_name" @@ -988,7 +987,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_university_person_categories_on_university_id" end - create_table "university_person_experiences", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "university_person_experiences", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "person_id", null: false t.uuid "organization_id", null: false @@ -1002,7 +1001,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_university_person_experiences_on_university_id" end - create_table "university_person_involvements", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "university_person_involvements", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "person_id", null: false t.integer "kind" @@ -1017,7 +1016,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_university_person_involvements_on_university_id" end - create_table "university_roles", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "university_roles", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "target_type" t.uuid "target_id" @@ -1029,7 +1028,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_142031) do t.index ["university_id"], name: "index_university_roles_on_university_id" end - create_table "users", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| + create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.string "first_name" t.string "last_name" diff --git a/test/fixtures/communication/extranets.yml b/test/fixtures/communication/extranets.yml index 5b00f559b..c4a725645 100644 --- a/test/fixtures/communication/extranets.yml +++ b/test/fixtures/communication/extranets.yml @@ -2,35 +2,34 @@ # # Table name: communication_extranets # -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# allow_experiences_modification :boolean default(TRUE) -# color :string -# cookies_policy :text -# css :text -# feature_alumni :boolean default(FALSE) -# feature_contacts :boolean default(FALSE) -# feature_jobs :boolean default(FALSE) -# feature_library :boolean default(FALSE) -# feature_posts :boolean default(FALSE) -# has_sso :boolean default(FALSE) -# home_sentence :text -# host :string -# name :string -# privacy_policy :text -# registration_contact :string -# sass :text -# sso_button_label :string -# sso_cert :text -# sso_mapping :jsonb -# sso_name_identifier_format :string -# sso_provider :integer default("saml") -# sso_target_url :string -# terms :text -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# university_id :uuid not null, indexed +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# color :string +# cookies_policy :text +# css :text +# feature_alumni :boolean default(FALSE) +# feature_contacts :boolean default(FALSE) +# feature_jobs :boolean default(FALSE) +# feature_library :boolean default(FALSE) +# feature_posts :boolean default(FALSE) +# has_sso :boolean default(FALSE) +# home_sentence :text +# host :string +# name :string +# privacy_policy :text +# registration_contact :string +# sass :text +# sso_button_label :string +# sso_cert :text +# sso_mapping :jsonb +# sso_name_identifier_format :string +# sso_provider :integer default("saml") +# sso_target_url :string +# terms :text +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed # # Indexes # diff --git a/test/models/communication/website/dependency_test.rb b/test/models/communication/website/dependency_test.rb index e422b3796..5d3b4c37c 100644 --- a/test/models/communication/website/dependency_test.rb +++ b/test/models/communication/website/dependency_test.rb @@ -48,18 +48,19 @@ class Communication::Website::DependencyTest < ActiveSupport::TestCase end def test_change_website_dependencies - dependencies_before_count = website_with_github.recursive_dependencies.count + website_with_github.save + dependencies_before_count = website_with_github.reload.recursive_dependencies.count # On modifie l'about du website en ajoutant une Ʃcole website_with_github.update(about: default_school) refute(destroy_obsolete_git_files_job) - delta = website_with_github.recursive_dependencies.count - dependencies_before_count + delta = website_with_github.reload.recursive_dependencies.count - dependencies_before_count # En ajoutant l'Ʃcole, on rajoute en dƩpendances : # - L'Ʃcole, et ses formations et diplƴmes en cascade (3) # - Les catƩgories d'actus liƩs aux formations, soit la catƩgorie racine et la catƩgorie de default_program (2) - # - N'ayant pas ƩtƩ crƩƩs avant, le save du website va crƩer les 3 menus par dƩfaut : primary, legal et social (3) - # Donc un total de 3 + 2 + 3 = 8 dƩpendances - assert_equal 8, delta + # - Les pages "Teachers", "Administrators", "Researchers", "EducationDiplomas", "EducationPrograms" (5) + # Donc un total de 3 + 2 + 5 = 10 dƩpendances + assert_equal 10, delta Delayed::Job.destroy_all @@ -68,23 +69,20 @@ class Communication::Website::DependencyTest < ActiveSupport::TestCase # On vƩrifie qu'on appelle bien la mƩthode destroy_obsolete_git_files sur le site assert(destroy_obsolete_git_files_job) - end - # TODO multilingue: faire marcher ce test - # def test_change_website_dependencies_with_multilingual - # - # dependencies_before_count = website_with_github.recursive_dependencies.count - # - # # On crƩe une copie anglaise de la homepage - # page_test_en = communication_website_pages(:page_root).dup - # page_test_en.language = languages(:en) - # page_test_en.save - # - # # Tant qu'on n'a pas activƩ l'anglais sur le website le nombre de dƩpendances ne doit pas bouger - # assert_equal dependencies_before_count, website_with_github.reload.recursive_dependencies.count - # - # end + def test_change_website_dependencies_with_multilingual + website_with_github.save + dependencies_before_count = website_with_github.recursive_dependencies.count + + # On crƩe une copie anglaise de la homepage + page_test_en = communication_website_pages(:page_root).dup + page_test_en.language = languages(:en) + page_test_en.save + + # Tant qu'on n'a pas activƩ l'anglais sur le website le nombre de dƩpendances ne doit pas bouger + assert_equal dependencies_before_count, website_with_github.reload.recursive_dependencies.count + end # TODO : Utile? def test_change_menu_item_dependencies -- GitLab