From 842efbba7b563ee2e7ff3d6f07c08ab294239ef5 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 19 Dec 2022 14:45:22 +0100 Subject: [PATCH] fix some stuff --- config/environments/test.rb | 2 ++ test/fixtures/communication/website/posts.yml | 1 - test/fixtures/education/cohorts.yml | 2 ++ test/fixtures/education/schools.yml | 3 +++ test/integration/summernote_test.rb | 23 ------------------- test/services/variant_service_test.rb | 8 ++++++- 6 files changed, 14 insertions(+), 25 deletions(-) create mode 100644 test/fixtures/education/schools.yml delete mode 100644 test/integration/summernote_test.rb diff --git a/config/environments/test.rb b/config/environments/test.rb index 6ea4d1e70..131f38a3a 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -33,6 +33,8 @@ Rails.application.configure do # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.active_record.verify_foreign_keys_for_fixtures = false + # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test diff --git a/test/fixtures/communication/website/posts.yml b/test/fixtures/communication/website/posts.yml index 6904e28b4..40e32e5fd 100644 --- a/test/fixtures/communication/website/posts.yml +++ b/test/fixtures/communication/website/posts.yml @@ -48,4 +48,3 @@ test_post_2: slug: test-2 published: true published_at: 2010-11-28 00:00:00 - text: new content diff --git a/test/fixtures/education/cohorts.yml b/test/fixtures/education/cohorts.yml index 13f18884f..9299e067d 100644 --- a/test/fixtures/education/cohorts.yml +++ b/test/fixtures/education/cohorts.yml @@ -28,12 +28,14 @@ one: university: default_university + school: default_school program: one academic_year: one name: MyString two: university: default_university + school: default_school program: two academic_year: two name: MyString diff --git a/test/fixtures/education/schools.yml b/test/fixtures/education/schools.yml new file mode 100644 index 000000000..51fbf5bc6 --- /dev/null +++ b/test/fixtures/education/schools.yml @@ -0,0 +1,3 @@ +default_school: + name: École de test + university: default_university \ No newline at end of file diff --git a/test/integration/summernote_test.rb b/test/integration/summernote_test.rb deleted file mode 100644 index 83c739653..000000000 --- a/test/integration/summernote_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "test_helper" - -class SummernoteTest < ActiveSupport::TestCase - HTML_HYDRATED = "<action-text-attachment sgid=\"sgid\" content-type=\"image/jpeg\" url=\"http://localhost:3000/dan-gold.jpeg\" filename=\"test.jpg\" filesize=\"352931\" width=\"588\" height=\"746\" previewable=\"true\" presentation=\"gallery\"><figure class=\"attachment attachment--preview\">\n <img width=\"588\" height=\"746\" src=\"http://localhost:3000/dan-gold.jpeg\">\n</figure></action-text-attachment>\n" - - HTML_DEHYDRATED = "<action-text-attachment sgid=\"sgid\" content-type=\"image/jpeg\" url=\"http://localhost:3000/dan-gold.jpeg\" filename=\"test.jpg\" filesize=\"352931\" width=\"588\" height=\"746\" previewable=\"true\" presentation=\"gallery\"></action-text-attachment>" - - test "dehydrate actiontext" do - post = communication_website_posts(:test_post) - post.text = HTML_HYDRATED - post.save - post.reload - assert_equal HTML_DEHYDRATED, post.text_before_type_cast - end - - test "rehydrate actiontext" do - post = communication_website_posts(:test_post) - post.text = HTML_DEHYDRATED - post.save - post.reload - assert_equal HTML_HYDRATED, communication_website_posts(:test_post).text.to_s - end - end diff --git a/test/services/variant_service_test.rb b/test/services/variant_service_test.rb index 2f2d08636..37ab72cc2 100644 --- a/test/services/variant_service_test.rb +++ b/test/services/variant_service_test.rb @@ -437,7 +437,13 @@ class VariantServiceTest < ActiveSupport::TestCase private def create_file_blob(key: nil, filename: "dan-gold.jpeg", content_type: "image/jpeg", metadata: nil, service_name: nil, record: nil) - ActiveStorage::Blob.create_and_upload! io: file_fixture(filename).open, filename: filename, content_type: content_type, metadata: metadata, service_name: service_name, record: record + ActiveStorage::Blob.create_and_upload! io: file_fixture(filename).open, + filename: filename, + content_type: content_type, + metadata: metadata, + service_name: service_name, + record: record, + university_id: universities(:default_university).id end def read_image(blob_or_variant) -- GitLab