diff --git a/CHANGELOG.md b/CHANGELOG.md index caa42abbc..5cb635acb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog Fab-manager +## next release + +- Fix a bug: unable to sync projects with openprojects + +- [TODO DEPLOY] `rails fablab:openlab:bulk_export` +- [TODO DEPLOY] `rails fablab:openlab:bulk_update` + ## v6.1.0 2023 September 25 - improves api/notification controller to avoid failing when there is a notification with wrong notification_type in db diff --git a/app/services/open_lab_service.rb b/app/services/open_lab_service.rb index 0aae0d0ec..c05385e76 100644 --- a/app/services/open_lab_service.rb +++ b/app/services/open_lab_service.rb @@ -3,8 +3,6 @@ # Provides methods to sync projects on OpenLab class OpenLabService class << self - include ActionView::Helpers::SanitizeHelper - def to_hash(project) { id: project.id, @@ -20,9 +18,9 @@ class OpenLabService steps_body: steps_body(project), image_path: project.project_image&.attachment&.medium&.url, project_path: "/#!/projects/#{project.slug}", - updated_at: project.updated_at.to_s(:iso8601), - created_at: project.created_at.to_s(:iso8601), - published_at: project.published_at.to_s(:iso8601) + updated_at: project.updated_at.to_fs(:iso8601), + created_at: project.created_at.to_fs(:iso8601), + published_at: project.published_at.to_fs(:iso8601) } end @@ -32,7 +30,7 @@ class OpenLabService .gsub("\r\n", ' ').gsub("\n\r", ' ') .gsub("\n", ' ').gsub("\r", ' ').gsub("\t", ' ') - strip_tags(concatenated_steps).strip + ActionController::Base.helpers.strip_tags(concatenated_steps).strip end end end diff --git a/test/services/open_lab_service_test.rb b/test/services/open_lab_service_test.rb new file mode 100644 index 000000000..03de1a5bd --- /dev/null +++ b/test/services/open_lab_service_test.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'test_helper' + +# In the following tests, amounts are expressed in centimes, ie. 1000 = 1000 cts = 10,00 EUR +class OpenLabServiceTest < ActiveSupport::TestCase + test "do not raise any error" do + h = nil + + assert_nothing_raised do + h = OpenLabService.to_hash(projects(:project_1)) + end + + assert_instance_of Hash, h + end +end \ No newline at end of file