-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from virolea/improve-key-syncing-with-job
Replace autodiscovery queue with autodiscovery job
- Loading branch information
Showing
8 changed files
with
65 additions
and
32 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,11 @@ | ||
module Rosetta | ||
class AutodiscoveryJob < Rosetta::ApplicationJob | ||
queue_as { Rosetta.config.queues[:autodiscovery] } | ||
|
||
discard_on ActiveRecord::RecordNotUnique | ||
|
||
def perform(value) | ||
TranslationKey.create!(value: value) | ||
end | ||
end | ||
end |
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
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
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,21 @@ | ||
require "test_helper" | ||
|
||
module Rosetta | ||
class AutodiscoveryJobTest < ActiveJob::TestCase | ||
test "creates a new key" do | ||
assert_difference "Rosetta::TranslationKey.count", 1 do | ||
Rosetta::AutodiscoveryJob.perform_now("Test creation from job") | ||
end | ||
end | ||
|
||
test "ignores duplicate keys" do | ||
TranslationKey.create(value: "duplicate") | ||
|
||
perform_enqueued_jobs do | ||
assert_nothing_raised do | ||
Rosetta::AutodiscoveryJob.perform_later("duplicate") | ||
end | ||
end | ||
end | ||
end | ||
end |
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