-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove hardcoding from the queue, check for others. Except for setup … (
#350) Remove hardcoding from the queue, check for others. Except for setup (and upgrade), the table name only comes from config now. Fixes #346
- Loading branch information
Showing
2 changed files
with
24 additions
and
7 deletions.
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
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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'helper' | ||
|
||
class HardCodingTest < Minitest::Test | ||
def test_for_hard_coded_table_names | ||
# This is a simple way to do this, but prolly there could be a better way. | ||
# | ||
# TLDR: do not hard code the table name! It should (at the moment) only appear twice. Once for setup (all the upgrade SQL is currently hardcoded...), | ||
# and once for the config. If you change this test to add more hard coded table names, please reconsider. | ||
# | ||
# Ideally, you should use the config throughout the codebase; more context @ https://github.com/QueueClassic/queue_classic/issues/346 | ||
# | ||
# | ||
# | ||
assert_equal `grep queue_classic_jobs lib -R`.split("\n").sort, ['lib/queue_classic/config.rb: @table_name ||= "queue_classic_jobs"', 'lib/queue_classic/setup.rb: conn.execute("DROP TABLE IF EXISTS queue_classic_jobs CASCADE")'].sort | ||
end | ||
end |