The personal finance app for everyone
Sync notifications and troubleshooting guides (#998)
Zach Gollwitzerfa08f027c7d8
diff --git a/Gemfile b/Gemfileindex 6261d8e2..52b57177 100644--- a/Gemfile+++ b/Gemfile@@ -44,6 +44,7 @@ gem "pagy"gem "rails-settings-cached"gem "tzinfo-data", platforms: %i[ windows jruby ]gem "csv"+gem "redcarpet"group :development, :test dogem "debug", platforms: %i[ mri windows ]diff --git a/Gemfile.lock b/Gemfile.lockindex ae720526..fcbcc8cc 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -336,6 +336,7 @@ GEMloggerrdoc (6.7.0)psych (>= 4.0.0)+ redcarpet (3.6.0)regexp_parser (2.9.2)reline (0.5.9)io-console (~> 0.5)@@ -492,6 +493,7 @@ DEPENDENCIESpuma (>= 5.0)rails!rails-settings-cached+ redcarpetrubocop-rails-omakaseruby-lsp-railsselenium-webdriverdiff --git a/app/controllers/account/entries_controller.rb b/app/controllers/account/entries_controller.rbindex 21e971a1..b12ae099 100644--- a/app/controllers/account/entries_controller.rb+++ b/app/controllers/account/entries_controller.rb@@ -31,7 +31,7 @@ class Account::EntriesController < ApplicationControllerelse# TODO: this is not an ideal way to handle errors and should eventually be improved.# See: https://github.com/hotwired/turbo-rails/pull/367- flash[:error] = @entry.errors.full_messages.to_sentence+ flash[:alert] = @entry.errors.full_messages.to_sentenceredirect_to account_path(@account)endenddiff --git a/app/controllers/account/transfers_controller.rb b/app/controllers/account/transfers_controller.rbindex a494285c..ac60583a 100644--- a/app/controllers/account/transfers_controller.rb+++ b/app/controllers/account/transfers_controller.rb@@ -23,7 +23,7 @@ class Account::TransfersController < ApplicationControllerelse# TODO: this is not an ideal way to handle errors and should eventually be improved.# See: https://github.com/hotwired/turbo-rails/pull/367- flash[:error] = @transfer.errors.full_messages.to_sentence+ flash[:alert] = @transfer.errors.full_messages.to_sentenceredirect_to transactions_pathendenddiff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rbindex 4f4c2b1e..568f440f 100644--- a/app/controllers/accounts_controller.rb+++ b/app/controllers/accounts_controller.rb@@ -68,8 +68,6 @@ class AccountsController < ApplicationControllerunless @account.syncing?@account.sync_laterend-- redirect_to account_path(@account), notice: t(".success")enddef sync_alldiff --git a/app/controllers/help/articles_controller.rb b/app/controllers/help/articles_controller.rbnew file mode 100644index 00000000..17ff8fae--- /dev/null+++ b/app/controllers/help/articles_controller.rb@@ -0,0 +1,11 @@+class Help::ArticlesController < ApplicationController+ layout "with_sidebar"++ def show+ @article = Help::Article.find(params[:id])++ unless @article+ head :not_found+ end+ end+enddiff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rbindex 0857e278..90086684 100644--- a/app/controllers/imports_controller.rb+++ b/app/controllers/imports_controller.rb@@ -42,13 +42,13 @@ class ImportsController < ApplicationControllerbegin@import.raw_csv_str = import_params[:raw_csv_str].readrescue NoMethodError- flash.now[:error] = "Please select a file to upload"+ flash.now[:alert] = "Please select a file to upload"render :load, status: :unprocessable_entity and returnendif @import.saveredirect_to configure_import_path(@import), notice: t(".import_loaded")else- flash.now[:error] = @import.errors.full_messages.to_sentence+ flash.now[:alert] = @import.errors.full_messages.to_sentencerender :load, status: :unprocessable_entityendend@@ -57,7 +57,7 @@ class ImportsController < ApplicationControllerif @import.update(import_params)redirect_to configure_import_path(@import), notice: t(".import_loaded")else- flash.now[:error] = @import.errors.full_messages.to_sentence+ flash.now[:alert] = @import.errors.full_messages.to_sentencerender :load, status: :unprocessable_entityendenddiff --git a/app/controllers/settings/hostings_controller.rb b/app/controllers/settings/hostings_controller.rbindex 89a42946..3058074f 100644--- a/app/controllers/settings/hostings_controller.rb+++ b/app/controllers/settings/hostings_controller.rb@@ -19,7 +19,7 @@ class Settings::HostingsController < SettingsControllerdef send_test_emailunless Setting.smtp_settings_populated?- flash[:error] = t(".missing_smtp_setting_error")+ flash[:alert] = t(".missing_smtp_setting_error")render(:show, status: :unprocessable_entity)returnend@@ -27,7 +27,7 @@ class Settings::HostingsController < SettingsControllerbeginNotificationMailer.with(user: Current.user).test_email.deliver_nowrescue => _e- flash[:error] = t(".error")+ flash[:alert] = t(".error")render :show, status: :unprocessable_entityreturnenddiff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex bb9462a5..141db192 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -13,11 +13,18 @@ module ApplicationHelpername.underscoreend- def notification(text, **options, &block)- content = tag.p(text)- content = capture &block if block_given?+ def family_notifications_stream+ turbo_stream_from [ Current.family, :notifications ] if Current.family+ end++ def render_flash_notifications+ notifications = flash.flat_map do |type, message_or_messages|+ Array(message_or_messages).map do |message|+ render partial: "shared/notification", locals: { type: type, message: message }+ end+ end- render partial: "shared/notification", locals: { type: options[:type], content: { body: content } }+ safe_join(notifications)end##diff --git a/app/models/account.rb b/app/models/account.rbindex 7d999835..2ce6495f 100644--- a/app/models/account.rb+++ b/app/models/account.rb@@ -2,8 +2,6 @@ class Account < ApplicationRecordinclude Syncableinclude Monetizable- broadcasts_refreshes-validates :name, :balance, :currency, presence: truebelongs_to :familydiff --git a/app/models/account/sync.rb b/app/models/account/sync.rbindex 0f8a1c9a..5db21b89 100644--- a/app/models/account/sync.rb+++ b/app/models/account/sync.rb@@ -48,13 +48,35 @@ class Account::Sync < ApplicationRecorddef start!update! status: "syncing", last_ran_at: Time.now+ broadcast_startenddef complete!update! status: "completed"+ broadcast_result type: "notice", message: "Sync complete"enddef fail!(error)update! status: "failed", error: error.message+ broadcast_result type: "alert", message: error.message+ end++ def broadcast_start+ broadcast_append_to(+ [ account.family, :notifications ],+ target: "notification-tray",+ partial: "shared/notification",+ locals: { id: id, type: "processing", message: "Syncing account balances" }+ )+ end++ def broadcast_result(type:, message:)+ broadcast_remove_to account.family, :notifications, target: id # Remove persistent syncing notification+ broadcast_append_to(+ [ account.family, :notifications ],+ target: "notification-tray",+ partial: "shared/notification",+ locals: { type: type, message: message }+ )endenddiff --git a/app/models/current.rb b/app/models/current.rbindex fd51b793..316a2cf5 100644--- a/app/models/current.rb+++ b/app/models/current.rb@@ -1,5 +1,5 @@class Current < ActiveSupport::CurrentAttributesattribute :user- delegate :family, to: :user+ delegate :family, to: :user, allow_nil: trueenddiff --git a/app/models/help/article.rb b/app/models/help/article.rbnew file mode 100644index 00000000..40f79474--- /dev/null+++ b/app/models/help/article.rb@@ -0,0 +1,54 @@+class Help::Article+ attr_reader :frontmatter, :content++ def initialize(frontmatter:, content:)+ @frontmatter = frontmatter+ @content = content+ end++ def title+ frontmatter["title"]+ end++ def html+ render_markdown(content)+ end++ class << self+ def root_path+ Rails.root.join("docs", "help")+ end++ def find(slug)+ Dir.glob(File.join(root_path, "*.md")).each do |file_path|+ file_content = File.read(file_path)+ frontmatter, markdown_content = parse_frontmatter(file_content)++ return new(frontmatter:, content: markdown_content) if frontmatter["slug"] == slug+ end++ nil+ end++ private++ def parse_frontmatter(content)+ if content =~ /\A---(.+?)---/m+ frontmatter = YAML.safe_load($1)+ markdown_content = content[($~.end(0))..-1].strip+ else+ frontmatter = {}+ markdown_content = content+ end++ [ frontmatter, markdown_content ]+ end+ end++ private++ def render_markdown(content)+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)+ markdown.render(content)+ end+enddiff --git a/app/views/accounts/_alert.html.erb b/app/views/accounts/_alert.html.erbnew file mode 100644index 00000000..697f0942--- /dev/null+++ b/app/views/accounts/_alert.html.erb@@ -0,0 +1,19 @@+<%# locals: (message:, help_path: nil) -%>+<%= tag.div class: "flex gap-6 items-center rounded-xl px-4 py-3 bg-error/5",+ data: { controller: "element-removal" },+ role: "alert" do %>+ <div class="flex gap-3 items-center text-red-500 grow overflow-x-scroll">+ <%= lucide_icon("alert-octagon", class: "w-5 h-5 shrink-0") %>+ <p class="text-sm whitespace-nowrap"><%= message %></p>+ </div>++ <div class="flex items-center gap-4 ml-auto">+ <% if help_path %>+ <%= link_to "Troubleshoot", help_path, class: "text-red-500 font-medium hover:underline", data: { turbo_frame: :drawer } %>+ <% end %>++ <%= tag.button data: { action: "click->element-removal#remove" } do %>+ <%= lucide_icon("x", class: "w-5 h-5 shrink-0 text-red-500") %>+ <% end %>+ </div>+<% end %>diff --git a/app/views/accounts/_sync_message.html.erb b/app/views/accounts/_sync_message.html.erbdeleted file mode 100644index fe0bf405..00000000--- a/app/views/accounts/_sync_message.html.erb+++ /dev/null@@ -1,8 +0,0 @@-<%# locals: (is_syncing:) %>-<% if is_syncing %>- <div class="my-4 px-8 py-4 rounded-lg bg-yellow-500/10 flex items-center justify-between">- <p class="text-gray-900 text-sm">- Syncing your account balances.- </p>- </div>-<% end %>diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erbindex de2a57e1..2459a7eb 100644--- a/app/views/accounts/show.html.erb+++ b/app/views/accounts/show.html.erb@@ -1,5 +1,3 @@-<%= turbo_stream_from @account %>-<div class="space-y-4"><div class="flex justify-between items-center"><div class="flex items-center gap-3">@@ -45,12 +43,8 @@</div></div>- <%= turbo_frame_tag "sync_message" do %>- <%= render partial: "accounts/sync_message", locals: { is_syncing: @account.syncing? } %>- <% end %>-<% if @account.alert %>- <%= render partial: "shared/alert", locals: { type: "error", content: t("." + @account.alert) } %>+ <%= render "alert", message: @account.alert, help_path: help_article_path("troubleshooting") %><% end %><div class="bg-white shadow-xs rounded-xl border border-alpha-black-25 rounded-lg">diff --git a/app/views/help/articles/show.html.erb b/app/views/help/articles/show.html.erbnew file mode 100644index 00000000..d2a9eeff--- /dev/null+++ b/app/views/help/articles/show.html.erb@@ -0,0 +1,7 @@+<%= drawer do %>+ <div class="prose">+ <%= tag.h1 @article.title %>++ <%= sanitize(@article.html).html_safe %>+ </div>+<% end %>diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erbindex 6fe949fb..ab57b5d3 100644--- a/app/views/layouts/application.html.erb+++ b/app/views/layouts/application.html.erb@@ -25,8 +25,13 @@</head><body class="h-full">- <div id="notification-tray" class="fixed z-50 space-y-1 top-6 right-10"></div>- <%= safe_join(flash.map { |type, message| notification(message, type: type) }) %>+ <div class="fixed z-50 space-y-1 top-6 right-10">+ <div id="notification-tray">+ <%= render_flash_notifications %>+ </div>+ </div>++ <%= family_notifications_stream %><%= content_for?(:content) ? yield(:content) : yield %>@@ -39,5 +44,4 @@<%= render "shared/app_version" %><% end %></body>-</html>diff --git a/app/views/shared/_alert.html.erb b/app/views/shared/_alert.html.erbdeleted file mode 100644index 21091fe4..00000000--- a/app/views/shared/_alert.html.erb+++ /dev/null@@ -1,11 +0,0 @@-<%# locals: (type: "error", content: "") -%>-<%= content_tag :div,- class: "flex justify-between rounded-xl p-3 #{type == "error" ? "bg-red-50" : "bg-yellow-50"}",- data: {controller: "element-removal" },- role: type == "error" ? "alert" : "status" do %>- <div class="flex gap-3 items-center <%= type == "error" ? "text-red-500" : "text-yellow-500" %>">- <%= lucide_icon("info", class: "w-5 h-5 shrink-0") %>- <p class="text-sm"><%= content %></p>- </div>- <%= content_tag :a, lucide_icon("x", class: "w-5 h-5 shrink-0 #{type == "error" ? "text-red-500" : "text-yellow-500"}"), data: { action: "click->element-removal#remove" }, class:"flex gap-1 font-medium items-center text-gray-900 px-3 py-1.5 rounded-lg cursor-pointer" %>-<% end %>diff --git a/app/views/shared/_drawer.html.erb b/app/views/shared/_drawer.html.erbindex 321667c8..4bce63fc 100644--- a/app/views/shared/_drawer.html.erb+++ b/app/views/shared/_drawer.html.erb@@ -1,5 +1,5 @@<%= turbo_frame_tag "drawer" do %>- <dialog class="bg-white border border-alpha-black-25 rounded-2xl max-h-[calc(100vh-32px)] max-w-[480px] w-full shadow-xs h-full mt-4 mr-4" data-controller="modal" data-action="click->modal#clickOutside">+ <dialog class="bg-white border border-alpha-black-25 rounded-2xl max-h-[calc(100vh-32px)] max-w-[480px] w-full shadow-xs h-full mt-4 mr-4 focus-visible:outline-none" data-controller="modal" data-action="click->modal#clickOutside"><div class="flex flex-col h-full p-4"><div class="flex justify-end items-center h-9"><div data-action="click->modal#close" class="cursor-pointer">diff --git a/app/views/shared/_notification.html.erb b/app/views/shared/_notification.html.erbindex 9e3a1706..48e4c731 100644--- a/app/views/shared/_notification.html.erb+++ b/app/views/shared/_notification.html.erb@@ -1,45 +1,45 @@-<%# locals: (type: "success", content: { title: '', body: ''}, action: { label:'' , url:'' }, options: { auto_dismiss: true }) -%>+<%# locals: (message:, type: "notice", id: nil, **_opts) %>-<turbo-stream action="append" target="notification-tray">- <template>- <% actions = options[:auto_dismiss] ? "animationend->element-removal#remove" : "" %>- <% animation = options[:auto_dismiss] ? "animate-[appear-then-fades_5s_300ms_both]" : "animate-[appear_5s_300ms_both]" %>- <%= content_tag :div,- class: "max-w-80 bg-white shadow-xs border border-alpha-black-50 border-solid py-4 px-4 rounded-[10px] text-sm font-medium flex gap-4 #{animation} group",- data: {controller: "element-removal", action: actions },- role: type == "error" ? "alert" : "status" do -%>- <% base_class = "w-5 h-5 p-1 text-white flex shrink-0 items-center justify-center rounded-full" %>- <%= type.in?(["error", "alert"]) ? lucide_icon("x", class: "#{base_class} bg-error") : lucide_icon("check", class: "#{base_class} bg-success") %>- <div class="flex flex-col">- <div class="flex flex-col">- <% if content[:title].present? %>- <h1 class="text-sm text-gray-900 font-medium"><%= content[:title] %></h1>- <% end %>- <p class="text-sm text-gray-500 font-normal"><%= content[:body] %></p>- </div>+<% type = type.to_sym %>+<% action = "animationend->element-removal#remove" if type == :notice %>- <div class="flex flex-row justify-end gap-2">- <% if !options[:auto_dismiss] %>- <%= content_tag :a, t(".dismiss"), data: { action: "click->element-removal#remove" }, class:"flex gap-1 font-medium items-center text-gray-900 px-3 py-1.5 rounded-lg cursor-pointer" %>- <% end %>- <% if action[:label].present? && action[:url].present? %>- <%= link_to action[:label], action[:url], class: "flex gap-1 font-medium items-center bg-gray-50 text-gray-900 px-3 py-1.5 rounded-lg" %>- <% end %>- </div>+<%= tag.div class: "flex gap-3 rounded-lg border bg-white p-4 group max-w-80 shadow-xs border-alpha-black-25",+ id: id,+ data: {+ controller: "element-removal",+ action: action+ } do %>++ <div class="h-5 w-5 shrink-0 p-px text-white">+ <% case type %>+ <% when :notice %>+ <div class="flex h-full items-center justify-center rounded-full bg-success">+ <%= lucide_icon "check", class: "w-3 h-3" %>+ </div>+ <% when :alert %>+ <div class="flex h-full items-center justify-center rounded-full bg-error">+ <%= lucide_icon "x", class: "w-3 h-3" %></div>+ <% when :processing %>+ <%= lucide_icon "loader", class: "w-5 h-5 text-gray-500 animate-pulse" %>+ <% end %>+ </div>++ <%= tag.p message, class: "text-gray-900 text-sm font-medium" %>- <% if options[:auto_dismiss] %>- <div class="shrink-0 h-5">- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="shrink-0">- <path d="M18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2C14.4183 2 18 5.58172 18 10ZM3.6 10C3.6 13.5346 6.46538 16.4 10 16.4C13.5346 16.4 16.4 13.5346 16.4 10C16.4 6.46538 13.5346 3.6 10 3.6C6.46538 3.6 3.6 6.46538 3.6 10Z" fill="#E5E5E5" />- <circle class="origin-center -rotate-90 animate-[stroke-fill_5s_300ms_forwards]" stroke="#141414" stroke-opacity="0.4" r="7.2" cx="10" cy="10" stroke-dasharray="43.9822971503" stroke-dashoffset="43.9822971503" />- </svg>- <div class="absolute -top-2 -right-2">- <%= lucide_icon "x", class: "w-5 h-5 p-0.5 hidden group-hover:inline-block border border-alpha-black-50 border-solid rounded-lg bg-white text-gray-400 cursor-pointer", data: { action: "click->element-removal#remove" } %>- </div>+ <div class="ml-auto">+ <% if type.to_sym == :notice %>+ <div class="h-5 shrink-0">+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="shrink-0">+ <path d="M18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2C14.4183 2 18 5.58172 18 10ZM3.6 10C3.6 13.5346 6.46538 16.4 10 16.4C13.5346 16.4 16.4 13.5346 16.4 10C16.4 6.46538 13.5346 3.6 10 3.6C6.46538 3.6 3.6 6.46538 3.6 10Z" fill="#E5E5E5" />+ <circle class="origin-center -rotate-90 animate-[stroke-fill_5s_300ms_forwards]" stroke="#141414" stroke-opacity="0.4" r="7.2" cx="10" cy="10" stroke-dasharray="43.9822971503" stroke-dashoffset="43.9822971503" />+ </svg>+ <div class="absolute -top-2 -right-2">+ <%= lucide_icon "x", class: "w-5 h-5 p-0.5 hidden group-hover:inline-block border border-alpha-black-50 border-solid rounded-lg bg-white text-gray-400 cursor-pointer", data: { action: "click->element-removal#remove" } %></div>- <% end %>- <% end -%>+ </div>+ <% elsif type.to_sym == :alert %>+ <%= lucide_icon "x", data: { action: "click->element-removal#remove" }, class: "w-5 h-5 text-gray-500 hover:text-gray-600 cursor-pointer" %>+ <% end %></div>-</template>-</turbo-stream>+<% end %>diff --git a/config/locales/views/accounts/en.yml b/config/locales/views/accounts/en.ymlindex f838f961..b9f425fd 100644--- a/config/locales/views/accounts/en.yml+++ b/config/locales/views/accounts/en.yml@@ -66,8 +66,6 @@ en:value: Valuesummary:new: New account- sync:- success: Account sync startedsync_all:success: Successfully queued accounts for syncing.update:diff --git a/config/locales/views/shared/en.yml b/config/locales/views/shared/en.ymlindex 5df96bb3..46ad461e 100644--- a/config/locales/views/shared/en.yml+++ b/config/locales/views/shared/en.yml@@ -13,8 +13,6 @@ en:no_account_subtitle: Since no accounts have been added, there's no data to display.Add your first accounts to start viewing dashboard data.no_account_title: No accounts yet- notification:- dismiss: Dismissupgrade_notification:app_upgraded: The app has been upgraded to %{version}.dismiss: Dismissdiff --git a/config/routes.rb b/config/routes.rbindex ea5d31d5..093ac809 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -10,6 +10,10 @@ Rails.application.routes.draw doresource :password_resetresource :password+ namespace :help do+ resources :articles, only: :show+ end+namespace :settings doresource :profile, only: %i[show update destroy]resource :preferences, only: %i[show update]diff --git a/docs/help/placeholder.md b/docs/help/placeholder.mdnew file mode 100644index 00000000..3ede4e8b--- /dev/null+++ b/docs/help/placeholder.md@@ -0,0 +1,10 @@+---+title: Troubleshooting+slug: troubleshooting+---++Coming soon...++We're working on new guides to help troubleshoot various issues within the app.++Help us out by reporting [issues on Github](https://github.com/maybe-finance/maybe/issues).diff --git a/test/controllers/account/entries_controller_test.rb b/test/controllers/account/entries_controller_test.rbindex 48e2c1c1..5442fae5 100644--- a/test/controllers/account/entries_controller_test.rb+++ b/test/controllers/account/entries_controller_test.rb@@ -69,7 +69,7 @@ class Account::EntriesControllerTest < ActionDispatch::IntegrationTest}end- assert_equal "Date has already been taken", flash[:error]+ assert_equal "Date has already been taken", flash[:alert]assert_redirected_to account_path(@valuation.account)enddiff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rbindex dfed6d36..09e64c09 100644--- a/test/controllers/accounts_controller_test.rb+++ b/test/controllers/accounts_controller_test.rb@@ -27,7 +27,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTesttest "can sync an account" dopost sync_account_path(@account)- assert_redirected_to account_url(@account)+ assert_response :no_contentendtest "can sync all accounts" dodiff --git a/test/controllers/help/articles_controller_test.rb b/test/controllers/help/articles_controller_test.rbnew file mode 100644index 00000000..42f4998d--- /dev/null+++ b/test/controllers/help/articles_controller_test.rb@@ -0,0 +1,18 @@+require "test_helper"++class Help::ArticlesControllerTest < ActionDispatch::IntegrationTest+ setup do+ sign_in @user = users(:family_admin)++ @article = Help::Article.new(frontmatter: { title: "Test Article", slug: "test-article" }, content: "")++ Help::Article.stubs(:find).returns(@article)+ end++ test "can view help article" do+ get help_article_path(@article)++ assert_response :success+ assert_dom "h1", text: @article.title, count: 1+ end+enddiff --git a/test/controllers/imports_controller_test.rb b/test/controllers/imports_controller_test.rbindex e7cdbc3c..b1798c77 100644--- a/test/controllers/imports_controller_test.rb+++ b/test/controllers/imports_controller_test.rb@@ -81,7 +81,7 @@ class ImportsControllerTest < ActionDispatch::IntegrationTestpatch load_import_url(@empty_import), params: { import: { raw_csv_str: malformed_csv_str } }assert_response :unprocessable_entity- assert_equal "Raw csv str is not a valid CSV format", flash[:error]+ assert_equal "Raw csv str is not a valid CSV format", flash[:alert]endtest "should flash error message if invalid CSV file upload" do@@ -91,14 +91,14 @@ class ImportsControllerTest < ActionDispatch::IntegrationTestpatch upload_import_url(@empty_import), params: { import: { raw_csv_str: Rack::Test::UploadedFile.new(temp, ".csv") } }assert_response :unprocessable_entity- assert_equal "Raw csv str is not a valid CSV format", flash[:error]+ assert_equal "Raw csv str is not a valid CSV format", flash[:alert]endendtest "should flash error message if no fileprovided for upload" dopatch upload_import_url(@empty_import), params: { import: { raw_csv_str: nil } }assert_response :unprocessable_entity- assert_equal "Please select a file to upload", flash[:error]+ assert_equal "Please select a file to upload", flash[:alert]endtest "should get configure" dodiff --git a/test/controllers/settings/hostings_controller_test.rb b/test/controllers/settings/hostings_controller_test.rbindex 81db36ff..05e70789 100644--- a/test/controllers/settings/hostings_controller_test.rb+++ b/test/controllers/settings/hostings_controller_test.rb@@ -76,7 +76,7 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTestpost send_test_email_settings_hosting_pathassert_response :unprocessable_entity- assert controller.flash[:error].present?+ assert controller.flash[:alert].present?endend@@ -87,7 +87,7 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTestpost send_test_email_settings_hosting_pathassert_response :unprocessable_entity- assert controller.flash[:error].present?+ assert controller.flash[:alert].present?endendenddiff --git a/test/fixtures/files/help_article.md b/test/fixtures/files/help_article.mdnew file mode 100644index 00000000..b2dc0b3d--- /dev/null+++ b/test/fixtures/files/help_article.md@@ -0,0 +1,6 @@+---+title: Placeholder+slug: placeholder+---++Test help article\ No newline at end of filediff --git a/test/models/account/sync_test.rb b/test/models/account/sync_test.rbindex 564889ce..1167a41d 100644--- a/test/models/account/sync_test.rb+++ b/test/models/account/sync_test.rb@@ -26,9 +26,15 @@ class Account::SyncTest < ActiveSupport::TestCase@sync.run+ streams = capture_turbo_stream_broadcasts [ @account.family, :notifications ]+assert_equal "completed", @sync.statusassert_equal [ "test balance sync warning", "test holding sync warning" ], @sync.warningsassert @sync.last_ran_at++ assert_equal "append", streams.first["action"]+ assert_equal "remove", streams.second["action"]+ assert_equal "append", streams.third["action"]endtest "handles sync errors" dodiff --git a/test/models/help/article_test.rb b/test/models/help/article_test.rbnew file mode 100644index 00000000..eaac5377--- /dev/null+++ b/test/models/help/article_test.rb@@ -0,0 +1,21 @@+require "test_helper"++class Help::ArticleTest < ActiveSupport::TestCase+ include ActiveJob::TestHelper++ setup do+ Help::Article.stubs(:root_path).returns(Rails.root.join("test", "fixtures", "files"))+ end++ test "returns nil if article not found" do+ assert_nil Help::Article.find("missing")+ end++ test "find and renders markdown article" do+ article = Help::Article.find("placeholder")++ assert_equal "Placeholder", article.title+ assert_equal "Test help article", article.content+ assert_equal "<p>Test help article</p>\n", article.html+ end+end