Skip to content

Get tests back to a passing state #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

BrandonKlotz
Copy link
Collaborator

@BrandonKlotz BrandonKlotz commented Mar 21, 2025

Screenshot 2025-03-21 at 12 25 29 PM

rails test runs all tests without errors but there are 4 failures, that need to be looked into.

Currently the forked repository passes when running tests.
https://github.com/bullet-train-pro/bullet_train-billing-usage

FactoryBot.create(:count, tracker: tracker, action: "created", name: "Blah", count: 3)

Billing::Usage::ProductCatalog.stub(:all_products, all_products) do
assert_equal limiter.exhausted_usage_for(limit, :create, "Blah"), 3
assert_equal 3, limiter.exhausted_usage_for(limit, :create, "Blah")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-03-21 at 11 02 20 AM

Updated so the test correctly returns what was expected vs. actual

Comment on lines +10 to +41
# Determine if workspace_id is a valid column
has_workspace_column = Billing::Usage::Tracker.column_names.include?('workspace_id')
has_team_column = Billing::Usage::Tracker.column_names.include?('team_id')

# Get the attributes common to all environments
tracker_attributes = {
duration: duration,
interval: interval
)
}

# Only add workspace_id if it exists in the schema
if has_workspace_column
workspace_id = if defined?(::Workspace) && proxy_association.owner.is_a?(::Workspace)
proxy_association.owner.id
elsif proxy_association.owner.respond_to?(:workspace) && proxy_association.owner.workspace.present?
proxy_association.owner.workspace.id
elsif proxy_association.owner.respond_to?(:workspace_id) && proxy_association.owner.workspace_id.present?
proxy_association.owner.workspace_id
else
proxy_association.owner.id # Fallback to owner's ID
end

tracker_attributes[:workspace_id] = workspace_id
end

if has_team_column
team_id = proxy_association.owner.id
tracker_attributes[:team_id] = team_id
end

# Find or create the tracker with the appropriate attributes
order(created_at: :desc).includes(:counts).find_or_create_by(tracker_attributes)
Copy link
Collaborator Author

@BrandonKlotz BrandonKlotz Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty hesitant about these changes, and don't know what the best move-forward plan would be. Currently, our Gem has an undesirable dependency on Workspace from our use in the admin repo which is preventing tests from running without errors in the Gem context.

@BrandonKlotz BrandonKlotz changed the title update: tests running without errors Get tests back to a passing state Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant