1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

Fix a bug: unable to sync projects with openprojects

This commit is contained in:
Nicolas Florentin 2023-09-27 15:36:19 +02:00
parent fa15d83820
commit fe1b555990
3 changed files with 27 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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