-
-
Save lmiller1990/4067a8b2470f56e0bad96a055b1410c6 to your computer and use it in GitHub Desktop.
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
require 'rails_helper' | |
describe Test::DatabasesController do | |
describe '/clean_database' do | |
it 'truncates and seeds the database' do | |
category = create(:category) | |
5.times { |i| create(:post, category: category) } | |
post :clean_database, params: { 'database': { 'should_seed': true } } | |
# Seed db/seeds/test for default seeds | |
# Default 2 categories and 1 post | |
expect(Post.count).to eq 1 | |
expect(Category.count).to eq 2 | |
end | |
it 'truncates and seeds the database' do | |
category = create(:category) | |
5.times { |i| create(:post, category: category) } | |
post :clean_database, params: { 'database': { 'should_seed': false } } | |
expect(Post.count).to eq 0 | |
expect(Category.count).to eq 0 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment