You will probably need to clean your database between some (or each) of yours test cases/scenarios.
When running Capybara+PhantomJS, using table truncation is preferred since transactions are not shared between the test process and the browser process.
This means that you need to authorize the app account to truncate the appropriate tables. In the database setup transactions, this can be done for the accounts
table with:
run "GRANT TRUNCATE ON account_password_hashes TO #{user}"
Make sure that you do the same for each table created by the Rodauth features you have enabled, e.g. here for the disallow_password_reuse
feature:
run "GRANT TRUNCATE ON account_previous_password_hashes TO #{user}"
Remember to restrict these additional privileges to the test database.
If you happen to be using the Database Cleaner gem, you will find that you need to protect the schema_info
, schema_info_password
and account_statuses
tables from being wiped.
This is easily achieved using the except options of the :truncation
strategy:
DatabaseCleaner.strategy = :truncation, {except: %w[schema_info_password account_statuses]}
(N.B. The schema_info
table is protected by default)