Skip to content

Commit

Permalink
Update test cases and add GA docker requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
petecheslock committed Jun 21, 2024
1 parent d9567e9 commit f21b3c3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ on:
jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Start MongoDB
uses: supercharge/mongodb-github-action@v1

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Run tests
run: bundle exec rails test
run: PARALLEL_WORKERS=1 bundle exec rails test

- name: Save AppMaps
uses: actions/cache/save@v3
Expand Down
38 changes: 23 additions & 15 deletions test/integration/billing_address_test.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
# test/integration/billing_address_test.rb
require "test_helper"

class BillingAddressTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
DatabaseCleaner.strategy = :deletion
DatabaseCleaner.start
end

test "create new billing address" do
# Ensure no billing address exists before this test
UserBilling.where(user_id: @user.id).destroy_all
teardown do
DatabaseCleaner.clean_with(:deletion)
DatabaseCleaner.clean
end

test "create new billing address" do
get billing_user_path(@user)
assert_template 'users/billing'

assert_difference 'UserBilling.count', 1 do
patch billing_user_path(@user), params: { billing: { address: "123 Main Street", city: "Sample City", state: "SC", zip_code: "12345" } }
end

patch billing_user_path(@user), params: { billing: { address: "123 Main Street", city: "Sample City", state: "SC", zip_code: "12345" } }

assert_redirected_to billing_user_path(@user)
follow_redirect!
assert_match "Billing address updated", response.body
@user.reload
user_billing = UserBilling.find_by(user_id: @user.id)
assert_not_nil user_billing
assert_equal "123 Main Street", user_billing.address
assert_equal "Sample City", user_billing.city
assert_equal "SC", user_billing.state
assert_equal "12345", user_billing.zip_code
end

test "update existing billing address" do
Expand All @@ -29,19 +37,19 @@ def setup
get billing_user_path(@user)
assert_template 'users/billing'

assert_no_difference 'UserBilling.count' do
patch billing_user_path(@user), params: { billing: { address: "456 Another St", city: "Updated City", state: "UC", zip_code: "67890" } }
end
patch billing_user_path(@user), params: { billing: { address: "456 Another St", city: "Updated City", state: "UC", zip_code: "67890" } }

assert_redirected_to billing_user_path(@user)
follow_redirect!
assert_match "Billing address updated", response.body

# Verify the attributes are updated
@user.reload
assert_equal "456 Another St", @user.billing_address.address
assert_equal "Updated City", @user.billing_address.city
assert_equal "UC", @user.billing_address.state
assert_equal "67890", @user.billing_address.zip_code
user_billing = UserBilling.find_by(user_id: @user.id)
assert_not_nil user_billing
assert_equal "456 Another St", user_billing.address
assert_equal "Updated City", user_billing.city
assert_equal "UC", user_billing.state
assert_equal "67890", user_billing.zip_code
end
end
13 changes: 3 additions & 10 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
require 'database_cleaner/mongoid'
Minitest::Reporters.use!

DatabaseCleaner.allow_production = false
DatabaseCleaner.allow_remote_database_url = false

class ActiveSupport::TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
Expand All @@ -27,14 +30,4 @@ def log_in_as(user, password: 'password', remember_me: '1')
password: password,
remember_me: remember_me } }
end

DatabaseCleaner.strategy = :deletion

setup do
DatabaseCleaner.start
end

teardown do
DatabaseCleaner.clean
end
end

0 comments on commit f21b3c3

Please sign in to comment.