FIX: flaky fix_query_id_spec because id conflict (#73)

This rake task is responsible for fixing broken ids - move them back to the original values - ones before migration to a separate table.

Rake task can only fix queries with unique names.

In the test, we are creating duplicated queries and using `original_id` 4. Spec is ensuring that after rake tasks valuation, queries id is different than `4`

However, spec run in random order may create a query with id 4 and in that case, the spec would fail.

Therefore, when we create queries for test purpose, we should control what ids they are given to avoid conflict.
This commit is contained in:
Krzysztof Kotlarek 2020-10-13 12:31:51 +11:00 committed by GitHub
parent 44f0eadb49
commit 8cc2d4e4e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -133,6 +133,7 @@ describe 'fix query ids rake task' do
def attributes(name) def attributes(name)
{ {
id: DataExplorer::Query.count == 0 ? 5 : DataExplorer::Query.maximum(:id) + 1,
name: name, name: name,
description: 'A Query', description: 'A Query',
sql: "SELECT 1", sql: "SELECT 1",