Refactor seat_link_base_service_spec for public interface testing
Problem
The spec/services/utilization/seat_link_base_service_spec.rb spec has several tests that dive too deeply into implementation specifics rather than testing observable behavior. Here are the main concerns:
-
Private method testing - The spec extensively tests private methods directly (:build_cloud_license, :license_by_license_key, :find_or_build_seat_link, etc.). These should be tested through public behavior instead.
-
Attribute assignment verification - Tests like
#save_seat_linkverify exact attribute assignments (expect(seat_link.active_user_count).to eq(10)). This tests implementation details rather than the outcome. We should verify the returnedseat_link -
Helper method tests - Methods like
#billable_users_count,#max_count,#gitlab_version,#report_timestampare simple accessors/transformers that don't need individual test coverage. They're tested implicitly through #execute. -
Mocking internal calls - Tests mock
LicenseSeatLink.create_withandfind_or_initialize_bycalls, which are implementation details. The test should verify the seat link is created/found correctly, not how it's done. -
Abstract method testing - The #abstract_methods test uses .send() to call private methods, which violates the "no private method testing" rule.
Proposal
Focus tests on:
- Public #execute behavior - Does it return the right result? Does it call the right tasks?
- Observable outcomes - Is the seat link saved with correct data? Are errors logged appropriately?
- Edge cases at the boundary - Invalid versions, missing data, save failures
Remove or consolidate:
- Individual private method tests
- Tests verifying exact attribute assignments (test through the saved/returned record instead)
- Helper method tests that are just parameter extraction
- The abstract methods test using .send()