-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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) |
There was a problem hiding this comment.
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.
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