-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to ensure seed is idempotent
- Loading branch information
1 parent
a121a87
commit 1f6b223
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,4 +88,4 @@ | |
end | ||
|
||
# reindex all talk in MeiliSearch | ||
Talk.reindex! | ||
Talk.reindex! unless Rails.env.test? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "test_helper" | ||
|
||
class DbSeedTest < ActiveSupport::TestCase | ||
setup do | ||
@event = events(:one) | ||
Rails.application.load_tasks | ||
Rake::Task["db:environment:set"].reenable | ||
Rake::Task["db:schema:load"].invoke | ||
end | ||
|
||
test "db:seed runs successfully" do | ||
assert_nothing_raised do | ||
Rake::Task["db:seed"].invoke | ||
end | ||
|
||
# Ensuring idempotency | ||
assert_no_difference "Talk.maximum(:created_at)" do | ||
Rake::Task["db:seed"].reenable | ||
Rake::Task["db:seed"].invoke | ||
end | ||
end | ||
end |