FIX: flaky order in spec (#16)

In Spec we were creating two topics:
```ruby
  fab!(:topic) { Fabricate(:topic, category: category) }
  fab!(:topic2) { Fabricate(:topic, category: category) }
```

Because we didn't set title explicitly it was using sequence from Fabricator
```ruby
  title { sequence(:title) { |i| "This is a test topic #{i}" } }
```

If you have two titles `This is a test topic 9` and `This is a test topic 10` Spec testing if topics are sorted will fail. Therefore, we should explicitly set topic title when creating test instances to avoid that randomness.
This commit is contained in:
Krzysztof Kotlarek 2020-11-05 14:48:02 +11:00 committed by GitHub
parent 6e974250f9
commit ab66d70fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -4,8 +4,8 @@ require 'rails_helper'
describe KnowledgeExplorer::KnowledgeExplorerController do
fab!(:category) { Fabricate(:category) }
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:topic2) { Fabricate(:topic, category: category) }
fab!(:topic) { Fabricate(:topic, title: "I love carrot today", category: category) }
fab!(:topic2) { Fabricate(:topic, title: "I love pineapple today", category: category) }
fab!(:tag) { Fabricate(:tag, topics: [topic], name: 'test') }
before do