Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Fix onboarding guide asset paths (#3524)

Juan José Mata83b518222c99
diff --git a/app/controllers/settings/guides_controller.rb b/app/controllers/settings/guides_controller.rb
index c078d15ddd..1ca65c6e18 100644
--- a/app/controllers/settings/guides_controller.rb
+++ b/app/controllers/settings/guides_controller.rb
@@ -13,6 +13,11 @@ class Settings::GuidesController < ApplicationController
strikethrough: true,
superscript: true
)
- @guide_content = markdown.render(File.read(Rails.root.join("docs/onboarding/guide.md")))
+ guide_source = File.read(Rails.root.join("docs/onboarding/guide.md"))
+ guide_source.gsub!(/src="assets\/([^"]+)"/) do
+ %(src="#{helpers.asset_path(Regexp.last_match(1))}")
+ end
+
+ @guide_content = markdown.render(guide_source)
end
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index d06e93b097..d3235e3b40 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -6,3 +6,6 @@ Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
Rails.application.config.assets.paths << "app/components"
Rails.application.config.importmap.cache_sweepers << Rails.root.join("app/components")
+
+# Serve screenshots embedded by the in-app onboarding guide.
+Rails.application.config.assets.paths << Rails.root.join("docs/onboarding/assets")
diff --git a/test/controllers/settings/guides_controller_test.rb b/test/controllers/settings/guides_controller_test.rb
new file mode 100644
index 0000000000..55fe6ccf20
--- /dev/null
+++ b/test/controllers/settings/guides_controller_test.rb
@@ -0,0 +1,13 @@
+require "test_helper"
+
+class Settings::GuidesControllerTest < ActionDispatch::IntegrationTest
+ test "guide images use asset pipeline paths" do
+ sign_in users(:family_admin)
+
+ get settings_guides_path
+
+ assert_response :success
+ assert_select 'img[src^="/assets/guide-create-account"]', count: 1
+ assert_select 'img[src^="assets/"]', count: 0
+ end
+end