Commit bab1c8ec authored by Rémy Coutable's avatar Rémy Coutable

Add new non_existing_record_id/non_existing_record_iid spec helpers

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 51aad1dd
......@@ -78,6 +78,10 @@ FDOC=1 bin/rspec spec/[path]/[to]/[spec].rb
- Use `focus: true` to isolate parts of the specs you want to run.
- Use [`:aggregate_failures`](https://relishapp.com/rspec/rspec-core/docs/expectation-framework-integration/aggregating-failures) when there is more than one expectation in a test.
- For [empty test description blocks](https://github.com/rubocop-hq/rspec-style-guide#it-and-specify), use `specify` rather than `it do` if the test is self-explanatory.
- Use `non_existing_record_id`/`non_existing_record_iid`/`non_existing_record_access_level`
when you need an ID/IID/access level that doesn't actually exists. Using 123, 1234,
or even 999 is brittle as these IDs could actually exist in the database in the
context of a CI run.
### Coverage
......
......@@ -100,6 +100,7 @@ RSpec.configure do |config|
config.include ExpectOffense
config.include FactoryBot::Syntax::Methods
config.include FixtureHelpers
config.include NonExistingRecordsHelpers
config.include GitlabRoutingHelper
config.include StubFeatureFlags
config.include StubExperiments
......
# frozen_string_literal: true
module NonExistingRecordsHelpers
# Max value for PG `serial` type: https://www.postgresql.org/docs/12/datatype-numeric.html
ACTIVE_MODEL_INTEGER_MAX = 2147483647
def non_existing_record_id
ACTIVE_MODEL_INTEGER_MAX
end
alias_method :non_existing_record_iid, :non_existing_record_id
alias_method :non_existing_record_access_level, :non_existing_record_id
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment