From 455257bf513460c76117d1e7d45a077606bcca83 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Tue, 5 Nov 2024 19:08:45 -0500 Subject: [PATCH] Show onboarding unless invitation present Fixes #1421 --- app/controllers/onboardings_controller.rb | 2 +- app/models/invitation.rb | 1 - test/system/transactions_test.rb | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/onboardings_controller.rb b/app/controllers/onboardings_controller.rb index a98694712a8..bf1ecae27ac 100644 --- a/app/controllers/onboardings_controller.rb +++ b/app/controllers/onboardings_controller.rb @@ -19,6 +19,6 @@ def set_user end def load_invitation - @invitation = Invitation.accepted.most_recent_for_email(Current.user.email) + @invitation = Current.family.invitations.accepted.find_by(email: Current.user.email) end end diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 41770b50ac4..625d125e72e 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -12,7 +12,6 @@ class Invitation < ApplicationRecord scope :pending, -> { where(accepted_at: nil).where("expires_at > ?", Time.current) } scope :accepted, -> { where.not(accepted_at: nil) } - scope :most_recent_for_email, ->(email) { where(email: email).order(accepted_at: :desc).first } def pending? accepted_at.nil? && expires_at > Time.current diff --git a/test/system/transactions_test.rb b/test/system/transactions_test.rb index e51c81835b4..0552db92765 100644 --- a/test/system/transactions_test.rb +++ b/test/system/transactions_test.rb @@ -183,8 +183,10 @@ class TransactionsTest < ApplicationSystemTestCase investment_account.entries.create!(name: "Investment account", date: Date.current, amount: 1000, currency: "USD", entryable: Account::Transaction.new) transfer_date = Date.current visit account_url(investment_account) - click_on "New" - click_on "New transaction" + within "[data-testid='activity-menu']" do + click_on "New" + click_on "New transaction" + end select "Deposit", from: "Type" fill_in "Date", with: transfer_date fill_in "account_entry[amount]", with: 175.25