-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: change item seeding removal strategy #4264
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
RSpec.describe User, type: :mailer, seed_items: false do | ||
RSpec.describe User, type: :mailer, skip_seed: true do | ||
describe "#role_added" do | ||
let(:user) { create(:user, email: "[email protected]") } | ||
let(:partner) { create(:partner, name: "Partner 1") } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,8 +204,6 @@ def seed_base_data_for_tests | |
] | ||
) | ||
end | ||
|
||
seed_base_data_for_tests if !ENV["SKIP_SEED"] | ||
end | ||
|
||
config.before(:each, type: :system) do | ||
|
@@ -214,10 +212,29 @@ def seed_base_data_for_tests | |
Capybara.server = :puma, { Silent: true } | ||
end | ||
|
||
config.before(:each) do | ||
# Defined shared @ global variables used throughout the test suite. | ||
define_global_variables if RSpec.current_example.metadata[:seed_items] != false | ||
config.before(:all) do | ||
seed_current = self.class.metadata[:skip_seed].nil? || self.class.metadata[:skip_seed] == false | ||
seeded_last = Thread.current[:seeded_last] | ||
|
||
if seeded_last && !seed_current | ||
DatabaseCleaner.clean_with(:truncation) | ||
elasticspoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
if seeded_last && seed_current | ||
define_global_variables | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can reorganize this a bit like so:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was doing it the other way do be explicit about all the cases, also why I added the comment about the !seeded && !seeded case. You think this is better? |
||
end | ||
|
||
if !seeded_last && seed_current | ||
seed_base_data_for_tests | ||
define_global_variables | ||
end | ||
|
||
# if !seeded_last && !seed_current do nothing | ||
|
||
Thread.current[:seeded_last] = seed_current | ||
end | ||
|
||
config.before(:each) do | ||
if ENV['EVENTS_READ'] == 'true' | ||
allow(Event).to receive(:read_events?).and_return(true) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only real file with changes worth looking at, all the rest is adding tags to spec files.