This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create KpsIdentityUpdateJob * Add test for KpsIdentityUpdateJob * Merge KpsIdentityCreateJob and KpsIdentityUpdateJob jobs with name KpsIdentityCreateOrUpdate * Fix rubocop offenses * Rename KpsIdentityCreateOrUpdateJob to KpsIdentitySaveJob * Clean test codes * Remove unused variables * Rename data to response
- Loading branch information
Showing
7 changed files
with
57 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class KpsIdentitySaveJob < ApplicationJob | ||
queue_as :high | ||
|
||
# slow operation | ||
def perform(user, student_id = nil) | ||
@user = user | ||
@student_id = student_id | ||
@response = Services::Kps::Omu::Kimlik.new.sorgula(user.id_number.to_i) | ||
end | ||
|
||
# callbacks | ||
after_perform do |_job| | ||
response = @response.merge(student_id: @student_id) | ||
formal = @user.identities.formal | ||
# Eğer kişinin formal kimliği varsa; kimlik bilgilerini güncelle, yoksa formal kimlik oluştur. | ||
formal.present? ? formal.update(response) : formal.create(response) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class KpsIdentityJobTest < ActiveJob::TestCase | ||
test 'can enqueue KpsIdentitySaveJob' do | ||
assert_enqueued_jobs 0 | ||
KpsIdentitySaveJob.perform_later(users(:serhat)) | ||
assert_enqueued_jobs 1 | ||
end | ||
|
||
test 'can initialize KPS queries as KpsIdentitySaveJob for given user and identities' do | ||
client = Minitest::Mock.new | ||
def client.sorgula | ||
true | ||
end | ||
|
||
Services::Kps::Omu::Kimlik.stub :new, client do | ||
assert KpsIdentitySaveJob.perform_later({}) # dummy hash | ||
end | ||
end | ||
|
||
test 'can perform enqueued jobs for KpsIdentitySaveJob' do | ||
skip 'this block on CircleCI since it needs IP permissions to run.' if ENV['CI'] | ||
assert_performed_jobs 0 | ||
perform_enqueued_jobs do | ||
KpsIdentitySaveJob.perform_later(users(:serhat)) | ||
end | ||
assert_performed_jobs 1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,8 @@ class UserTest < ActiveSupport::TestCase | |
end | ||
end | ||
|
||
test 'user runs KpsIdentityCreateJob after being created' do | ||
assert_enqueued_with(job: KpsIdentityCreateJob) do | ||
test 'user runs KpsIdentitySaveJob after being created' do | ||
assert_enqueued_with(job: KpsIdentitySaveJob) do | ||
User.create( | ||
id_number: '98765432198', | ||
email: '[email protected]', | ||
|