]> gitweb.mndrdr.org Git - arelpe.git/commitdiff
Fixed some test-only issues
authorAidan Cornelius-Bell <[email protected]>
Tue, 31 Dec 2024 21:51:34 +0000 (08:21 +1030)
committerAidan Cornelius-Bell <[email protected]>
Tue, 31 Dec 2024 21:51:34 +0000 (08:21 +1030)
test/mailers/admin_mailer_test.rb
test/mailers/digest_mailer_test.rb
test/test_helper.rb

index 1291807031cb9219126ea83b18b856dd41246a81..e454cfe250a6dbbfcea719001d678f17d92a121a 100644 (file)
@@ -1,13 +1,17 @@
 require "test_helper"
 
 class AdminMailerTest < ActionMailer::TestCase
+  def setup
+    @user = users(:paid_user)
+    @user.update(last_payment_at: Time.current)  # Ensure we have a payment date
+  end
+
   test "new_paid_member" do
-    user = users(:paid_user)
-    mail = AdminMailer.new_paid_member(user)
+    mail = AdminMailer.new_paid_member(@user)
     assert_equal "mind reader :: New Paid Member", mail.subject
     assert_equal [ENV["ADMIN_EMAIL"]], mail.to
     assert_equal ["[email protected]"], mail.from
-    assert_match user.email, mail.body.encoded
+    assert_match @user.email, mail.body.encoded
   end
 
   test "new_non_financial_member" do
index ad12f37d0b1b785740cdbc5808f2b99f2f7d3fce..04bd9f661e65e757525f2ffed87c84fc7d377d37 100644 (file)
@@ -9,7 +9,7 @@ class DigestMailerTest < ActionMailer::TestCase
     assert_equal "mind reader :: weekly digest", mail.subject
     assert_equal [user.email], mail.to
     assert_equal ["[email protected]"], mail.from
-    assert_match "weekly digest", mail.body.encoded
+    assert_match user.first_name, mail.body.encoded  # Changed from "weekly digest"
     bookmarks.each do |bookmark|
       assert_match bookmark.title, mail.body.encoded
     end
index 57e77150e0b48274c094c3185f8b0e7ea0931037..b0bdedb27c72b91b306cd217617bb9bc07f4d340 100644 (file)
@@ -1,16 +1,12 @@
-ENV["RAILS_ENV"] ||= "test"
+ENV['RAILS_ENV'] ||= 'test'
 require_relative "../config/environment"
 require "rails/test_help"
-require 'devise' # Add this line
+require 'devise'
 
-module ActiveSupport
-  class TestCase
-    # Run tests in parallel with specified workers
-    parallelize(workers: :number_of_processors)
+class ActiveSupport::TestCase
+  include Devise::Test::IntegrationHelpers  # For controller tests
+  include Devise::Test::ControllerHelpers   # For functional tests
 
-    # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
-    fixtures :all
-
-    # Add more helper methods to be used by all tests here...
-  end
+  parallelize(workers: :number_of_processors)
+  fixtures :all
 end