diff --git a/.codebeatsettings b/.codebeatsettings new file mode 100644 index 000000000..7ff72a765 --- /dev/null +++ b/.codebeatsettings @@ -0,0 +1,5 @@ +{ + "RUBY": { + "ABC": [15, 25, 50, 70] + } +} \ No newline at end of file diff --git a/Gemfile b/Gemfile index ed8bc48cb..3fed47413 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem 'devise' # assets: core asset dependencies gem 'coffee-rails', '~> 4.2' -gem 'sass-rails', '~> 5.0' +gem 'sassc-rails' gem 'uglifier', '>= 1.3.0' # view helpers: tools for forms, views, etc. @@ -48,7 +48,7 @@ gem 'pg_search' gem 'rollbar' # permalinks -gem 'friendly_id', '~> 5.1.0' +gem 'friendly_id', '~> 5.2.0' group :development, :test do gem 'brakeman', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 5e9ab9146..83d06c68b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,7 +70,7 @@ GEM bundler (~> 1.2) thor (~> 0.18) byebug (10.0.2) - capybara (3.3.1) + capybara (3.4.2) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -123,7 +123,7 @@ GEM ffi (1.9.25) font-awesome-rails (4.7.0.4) railties (>= 3.2, < 6.0) - friendly_id (5.1.0) + friendly_id (5.2.4) activerecord (>= 4.0.0) globalid (0.4.1) activesupport (>= 4.2.0) @@ -172,7 +172,7 @@ GEM mini_portile2 (~> 2.3.0) nori (2.6.0) orm_adapter (0.5.0) - pagy (0.13.1) + pagy (0.15.0) parallel (1.12.1) parser (2.5.1.2) ast (~> 2.4.0) @@ -192,7 +192,7 @@ GEM rack (2.0.5) rack-protection (2.0.3) rack - rack-test (1.0.0) + rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.0) actioncable (= 5.2.0) @@ -232,9 +232,9 @@ GEM responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) - rollbar (2.16.3) + rollbar (2.16.4) multi_json - rubocop (0.58.1) + rubocop (0.58.2) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) @@ -245,17 +245,21 @@ GEM ruby-progressbar (1.9.0) ruby_dep (1.5.0) rubyzip (1.2.1) - sass (3.5.6) + sass (3.5.7) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) + sassc (1.12.1) + ffi (~> 1.9.6) + sass (>= 3.3.0) + sassc-rails (1.3.0) + railties (>= 4.0.0) + sass + sassc (~> 1.9) + sprockets (> 2.11) + sprockets-rails + tilt savon (2.12.0) akami (~> 1.2) builder (>= 2.1.2) @@ -264,7 +268,7 @@ GEM nokogiri (>= 1.8.1) nori (~> 2.4) wasabi (~> 3.4) - selenium-webdriver (3.13.0) + selenium-webdriver (3.13.1) childprocess (~> 0.5) rubyzip (~> 1.2) sidekiq (5.1.3) @@ -300,7 +304,7 @@ GEM tilt (2.0.8) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.15) + uglifier (4.1.17) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext @@ -349,7 +353,7 @@ DEPENDENCIES dotenv-rails email_address font-awesome-rails - friendly_id (~> 5.1.0) + friendly_id (~> 5.2.0) groupdate jbuilder (~> 2.5) letter_opener @@ -364,7 +368,7 @@ DEPENDENCIES reek rollbar rubocop - sass-rails (~> 5.0) + sassc-rails savon (~> 2.12.0) selenium-webdriver sidekiq diff --git a/LICENCE.md b/LICENSE.md similarity index 100% rename from LICENCE.md rename to LICENSE.md diff --git a/README.md b/README.md index 7f47d26cd..12f06a7d2 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ export SECRET_KEY_BASE=GENERATED_SECRET_VALUE ## HowTo -See [Wiki pages](https://github.com/omu/nokul-bati/wiki) for how-to documents. +See [Wiki pages](https://github.com/omu/nokul/wiki) for how-to documents. ## Code Quality @@ -97,11 +97,13 @@ rake test ## Rake Tasks -- [OPTIONAL]. `setup` or `seed` already does it, but if you want to externally create YOKSIS references and departments inside your app, run the tasks shown below: +- [OPTIONAL]. `setup` or `seed` already does it, but if you want to externally create YOKSIS references, departments, country codes and academic staffs inside your app, run the tasks shown below: ```bash rake yoksis:fetch_references +rake yoksis:fetch_academic_staff rake yoksis:import_departments +rake yoksis:import_yoksis_country_codes ``` * `fetch` prefix has used for API operations, `import` prefix has used for local CSV importing operations. diff --git a/app/controllers/account/addresses_controller.rb b/app/controllers/account/addresses_controller.rb index 72681dacd..c09bd4411 100644 --- a/app/controllers/account/addresses_controller.rb +++ b/app/controllers/account/addresses_controller.rb @@ -2,8 +2,11 @@ module Account class AddressesController < ApplicationController - before_action :set_address, only: %i[edit update destroy mernis] + include LastUpdateFromMernis + + before_action :set_address, only: %i[edit update destroy] before_action :check_formality, only: %i[edit update destroy] + before_action :set_elapsed_time, only: %i[save_from_mernis] def index @addresses = current_user.addresses.includes(district: [:city]) @@ -28,27 +31,29 @@ def destroy @address.destroy ? redirect_with('success') : redirect_with('warning') end - def mernis - if (Time.zone.now - @address.updated_at) / 1.day < 7 - redirect_with('wait') - else - KpsAddressUpdateJob.perform_later(address) - redirect_with('will_update') - end + def save_from_mernis + KpsAddressSaveJob.perform_later(current_user) + redirect_with('will_update') end private + def set_address + @address = current_user.addresses.find(params[:id]) + end + def check_formality redirect_with('warning') if @address.formal? end - def redirect_with(message) - redirect_to(addresses_path, notice: t(".#{message}")) + def set_elapsed_time + formal_address = current_user.addresses.formal + return if formal_address.blank? + elapsed_time(formal_address) end - def set_address - @address = current_user.addresses.find(params[:id]) + def redirect_with(message) + redirect_to(addresses_path, notice: t(".#{message}")) end def address_params diff --git a/app/controllers/account/identities_controller.rb b/app/controllers/account/identities_controller.rb index b958bc235..8c5f65e4e 100644 --- a/app/controllers/account/identities_controller.rb +++ b/app/controllers/account/identities_controller.rb @@ -2,8 +2,11 @@ module Account class IdentitiesController < ApplicationController - before_action :set_identity, only: %i[edit update destroy mernis] + include LastUpdateFromMernis + + before_action :set_identity, only: %i[edit update destroy] before_action :check_formality, only: %i[edit update destroy] + before_action :set_elapsed_time, only: %i[save_from_mernis] def index @identities = current_user.identities @@ -28,27 +31,29 @@ def destroy @identity.destroy ? redirect_with('success') : redirect_with('warning') end - def mernis - if (Time.zone.now - @identity.updated_at) / 1.day < 7 - redirect_with('wait') - else - # TODO: KpsIdentityUpdateJob.perform_later(identity) - redirect_with('will_update') - end + def save_from_mernis + KpsIdentitySaveJob.perform_later(current_user) + redirect_with('will_update') end private + def set_identity + @identity = current_user.identities.find(params[:id]) + end + def check_formality redirect_with('warning') if @identity.formal? end - def redirect_with(message) - redirect_to(identities_path, notice: t(".#{message}")) + def set_elapsed_time + formal_identity = current_user.identities.formal + return if formal_identity.blank? + elapsed_time(formal_identity) end - def set_identity - @identity = current_user.identities.find(params[:id]) + def redirect_with(message) + redirect_to(identities_path, notice: t(".#{message}")) end def identity_params diff --git a/app/controllers/concerns/last_update_from_mernis.rb b/app/controllers/concerns/last_update_from_mernis.rb new file mode 100644 index 000000000..0a00b2944 --- /dev/null +++ b/app/controllers/concerns/last_update_from_mernis.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module LastUpdateFromMernis + extend ActiveSupport::Concern + + def elapsed_time(resource) + elapsed_time = (Time.zone.now - resource.first.updated_at) / 1.day + redirect_with('wait') if elapsed_time.present? && elapsed_time < 7 + end +end diff --git a/app/jobs/kps_address_create_job.rb b/app/jobs/kps_address_save_job.rb similarity index 54% rename from app/jobs/kps_address_create_job.rb rename to app/jobs/kps_address_save_job.rb index 86525350e..efa5e3e9c 100644 --- a/app/jobs/kps_address_create_job.rb +++ b/app/jobs/kps_address_save_job.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class KpsAddressCreateJob < ApplicationJob +class KpsAddressSaveJob < ApplicationJob queue_as :high # slow operation @@ -11,6 +11,8 @@ def perform(user) # callbacks after_perform do |job| district = District.find_by(mernis_code: @response[:district_id]) - job.arguments.first.addresses.formal.create(district: district, full_address: @response[:full_address]) + address = job.arguments.first.addresses.formal + response = { district: district, full_address: @response[:full_address] } + address.present? ? address.update(response) : address.create(response) end end diff --git a/app/jobs/kps_address_update_job.rb b/app/jobs/kps_address_update_job.rb deleted file mode 100644 index b8f27c6a2..000000000 --- a/app/jobs/kps_address_update_job.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -class KpsAddressUpdateJob < ApplicationJob - queue_as :low - - # slow operation - def perform(address) - @params = Services::Kps::Omu::Adres.new.sorgula(address.id_number.to_i) - end - - # callbacks - after_perform do |job| - district = District.find_by(mernis_code: @params[:district_id]) - job.arguments.first.update(district: district, name: :formal, full_address: @params[:full_address]) - end -end diff --git a/app/jobs/kps_identity_create_job.rb b/app/jobs/kps_identity_save_job.rb similarity index 51% rename from app/jobs/kps_identity_create_job.rb rename to app/jobs/kps_identity_save_job.rb index c0013be17..99ae43cc3 100644 --- a/app/jobs/kps_identity_create_job.rb +++ b/app/jobs/kps_identity_save_job.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true -class KpsIdentityCreateJob < ApplicationJob +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| - @user.identities.formal.create(@response.merge(student_id: @student_id)) + response = @response.merge(student_id: @student_id) + formal_address = job.arguments.first.identities.formal + formal_address.present? ? formal_address.update(response) : formal_address.create(response) end end diff --git a/app/models/accounts/student.rb b/app/models/accounts/student.rb index cc49805a9..97ea0b805 100644 --- a/app/models/accounts/student.rb +++ b/app/models/accounts/student.rb @@ -17,6 +17,6 @@ class Student < ApplicationRecord after_create_commit :build_identity_information, if: proc { identity.nil? } def build_identity_information - KpsIdentityCreateJob.perform_later(user, id) + KpsIdentitySaveJob.perform_later(user, id) end end diff --git a/app/models/user.rb b/app/models/user.rb index 7612fb2da..43b5453c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -38,11 +38,11 @@ class User < ApplicationRecord after_create_commit :build_identity_information, if: proc { identities.formal.empty? } def build_address_information - KpsAddressCreateJob.perform_later(self) + KpsAddressSaveJob.perform_later(self) end def build_identity_information - KpsIdentityCreateJob.perform_later(self) + KpsIdentitySaveJob.perform_later(self) end # custom methods diff --git a/app/services/kps/omu/adres.rb b/app/services/kps/omu/adres.rb index 550c45b4f..ee81a4edd 100644 --- a/app/services/kps/omu/adres.rb +++ b/app/services/kps/omu/adres.rb @@ -15,24 +15,23 @@ def sorgula(queried_id_number) :adres_sorgula, message: message ).body[:adres_sorgula_response][:return][:sorgula_result][:sorgu_sonucu][:kimlik_noile_kisi_adres_bilgileri] - if response[:hata_bilgisi].present? - raise IdNumberError i - else - yerlesim_yeri = response[:yerlesim_yeri_adresi] - address_root = if yerlesim_yeri[:il_ilce_merkez_adresi].present? - yerlesim_yeri[:il_ilce_merkez_adresi] - elsif yerlesim_yeri[:koy_adresi].present? - yerlesim_yeri[:koy_adresi] - elsif yerlesim_yeri[:yurt_disi_adresi].present? - yerlesim_yeri[:yurt_disi_adresi] - end - # return a hash, ready to use for building an Address. - address_information = { - full_address: yerlesim_yeri[:acik_adres], - district_id: address_root[:ilce_kodu].to_i - } - address_information - end + raise IdNumberError if response[:hata_bilgisi].present? + + yerlesim_yeri = response[:yerlesim_yeri_adresi] + address_root = if yerlesim_yeri[:il_ilce_merkez_adresi].present? + yerlesim_yeri[:il_ilce_merkez_adresi] + elsif yerlesim_yeri[:koy_adresi].present? + yerlesim_yeri[:koy_adresi] + elsif yerlesim_yeri[:yurt_disi_adresi].present? + yerlesim_yeri[:yurt_disi_adresi] + end + + # return a hash, ready to use for building an Address. + address_information = { + full_address: yerlesim_yeri[:acik_adres], + district_id: address_root[:ilce_kodu].to_i + } + address_information end end end diff --git a/app/views/account/addresses/index.html.erb b/app/views/account/addresses/index.html.erb index 87b7cc158..115f767c9 100644 --- a/app/views/account/addresses/index.html.erb +++ b/app/views/account/addresses/index.html.erb @@ -1,5 +1,7 @@
<%= link_to_new(new_address_path, t('.new_address')) %> + <%= link_to (@addresses.formal.present? ? t('.update_from_mernis') : t('.create_from_mernis') ), save_from_mernis_addresses_path, class: "btn btn-outline-primary btn-sm" %> +
@@ -35,16 +37,6 @@ <%= t('.district_and_city') %> <%= address.district.name %> / <%= address.district.city.name %> - - - <% if address.formal? %> - <%= link_to(t('.update_from_mernis'), mernis_address_path(address), class: 'btn btn-outline-primary btn-sm') %> - <% else %> - <%= link_to_edit(edit_address_path(address)) %> - <%= link_to_destroy(address) %> - <% end %> - -
diff --git a/app/views/account/identities/index.html.erb b/app/views/account/identities/index.html.erb index b23df90fb..8aaf6c1eb 100644 --- a/app/views/account/identities/index.html.erb +++ b/app/views/account/identities/index.html.erb @@ -1,5 +1,6 @@
<%= link_to_new(new_identity_path, t('.new_identity')) %> + <%= link_to (@identities.formal.present? ? t('.update_from_mernis') : t('.create_from_mernis') ), save_from_mernis_identities_path, class: "btn btn-outline-primary btn-sm" %>
@@ -57,16 +58,6 @@ <%= t('.registered_to') %> <%= identity.registered_to %> - - - <% if identity.formal? %> - <%= link_to(t('.update_from_mernis'), mernis_identity_path(identity), class: 'btn btn-outline-primary btn-sm') %> - <% else %> - <%= link_to_edit(edit_identity_path(identity)) %> - <%= link_to_destroy(identity) %> - <% end %> - -
diff --git a/app/views/layouts/guest.html.erb b/app/views/layouts/guest.html.erb index 9e4764e17..4f1596c4d 100644 --- a/app/views/layouts/guest.html.erb +++ b/app/views/layouts/guest.html.erb @@ -4,13 +4,34 @@ <%= render 'layouts/shared/meta' %> <%= stylesheet_link_tag 'guest', media: 'all' %> - -
-
- <%= yield %> + + + +
+
+
+ <%= yield %> +
+
<%= javascript_include_tag 'guest' %> <%= render 'layouts/shared/toastr' %> - + \ No newline at end of file diff --git a/config/locales/models/addresses/en.yml b/config/locales/models/addresses/en.yml index 0595fccce..002e49c0d 100644 --- a/config/locales/models/addresses/en.yml +++ b/config/locales/models/addresses/en.yml @@ -34,6 +34,7 @@ en: card_header: Address Information district_and_city: District / City update_from_mernis: Update from MERNİS + create_from_mernis: Create from MERNIS new: form_title: Create Address edit: @@ -46,6 +47,6 @@ en: destroy: success: Address successfully deleted! warning: Address can not be deleted! - mernis: + save_from_mernis: wait: You recently created or updated your address. You can update your address once every week. - will_update: We got your address update request. In a couple of seconds/minutes you will be able to see your new address. + will_update: We got your address create or update request. In a couple of seconds/minutes you will be able to see your new address. diff --git a/config/locales/models/addresses/tr.yml b/config/locales/models/addresses/tr.yml index 27120d3d3..a4eece299 100644 --- a/config/locales/models/addresses/tr.yml +++ b/config/locales/models/addresses/tr.yml @@ -34,6 +34,7 @@ tr: card_header: Adres Bilgileri district_and_city: İlçe / İl update_from_mernis: MERNİS'ten Güncelle + create_from_mernis: MERNİS'ten Oluştur new: form_title: Adres Oluştur edit: @@ -46,6 +47,6 @@ tr: destroy: success: Adres başarıyla silindi! warning: Adres silinemedi! - mernis: + save_from_mernis: wait: Adresinizi yakın bir zamanda oluşturdunuz veya güncellediniz. Adresinizi haftada bir güncelleyebilirsiniz. - will_update: Adres güncelleme talebinizi aldık, bir kaç saniye/dakika içerisinde adresiniz güncellenecek. + will_update: Adres oluşturma veya güncelleme talebinizi aldık, bir kaç saniye/dakika içerisinde adresiniz güncellenecek. diff --git a/config/locales/models/identities/en.yml b/config/locales/models/identities/en.yml index ce363ef46..a318e601d 100644 --- a/config/locales/models/identities/en.yml +++ b/config/locales/models/identities/en.yml @@ -42,6 +42,7 @@ en: new_identity: Add a New Identity card_header: Identity Information update_from_mernis: Update from MERNIS + create_from_mernis: Create from MERNIS edit: warning: You can not edit your formal identity! form_title: Edit Identity @@ -54,6 +55,6 @@ en: destroy: success: Identity successfully deleted! warning: Identity can not be deleted! - mernis: + save_from_mernis: wait: You recently created or updated your identity. You can only update your identity once a week from MERNIS. - will_update: We have received your identity update request. Your identity will be updated in a couple of seconds/minutes. + will_update: We have received your identity create or update request. Your identity will be updated in a couple of seconds/minutes. diff --git a/config/locales/models/identities/tr.yml b/config/locales/models/identities/tr.yml index 91fa95823..60c336749 100644 --- a/config/locales/models/identities/tr.yml +++ b/config/locales/models/identities/tr.yml @@ -42,6 +42,7 @@ tr: new_identity: Yeni Kimlik Ekle card_header: Kimlik Bilgileri update_from_mernis: MERNİS'ten Güncelle + create_from_mernis: MERNİS'ten Oluştur edit: warning: Yasal kimlik bilgilerinizi düzenleyemezsiniz! form_title: Kimliği Düzenle @@ -54,6 +55,6 @@ tr: destroy: success: Kimlik başarıyla silindi! warning: Kimlik silinemedi! - mernis: + save_from_mernis: wait: Kimliğinizi yakın bir zamanda oluşturdunuz veya güncellediniz. Kimliğinizi haftada bir güncelleyebilirsiniz. - will_update: Kimlik güncelleme talebinizi aldık, bir kaç saniye/dakika içerisinde adresiniz güncellenecek. + will_update: Kimlik oluşturma veya güncelleme talebinizi aldık, bir kaç saniye/dakika içerisinde adresiniz güncellenecek. diff --git a/config/routes.rb b/config/routes.rb index f18707308..1efee9e59 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,10 +20,10 @@ # Account home page scope module: :account do resources :identities, except: [:show] do - get 'mernis', on: :member + get 'save_from_mernis', on: :collection end resources :addresses, except: :show do - get 'mernis', on: :member + get 'save_from_mernis', on: :collection end end diff --git a/test/jobs/kps_address_job_test.rb b/test/jobs/kps_address_job_test.rb index a1d849910..2f7206634 100644 --- a/test/jobs/kps_address_job_test.rb +++ b/test/jobs/kps_address_job_test.rb @@ -3,44 +3,29 @@ require 'test_helper' class KpsAddressJobTest < ActiveJob::TestCase - %w[ - KpsAddressCreateJob - KpsAddressUpdateJob - ].each do |property| - test "can enqueue #{property}" do - assert_enqueued_jobs 0 - property.constantize.perform_later(addresses(:formal)) - assert_enqueued_jobs 1 - end + test 'can enqueue KpsAddressSaveJob' do + assert_enqueued_jobs 0 + KpsAddressSaveJob.perform_later(users(:serhat)) + assert_enqueued_jobs 1 + end - test "can initialize KPS queries as #{property} for given user and address" do - client = Minitest::Mock.new - def client.sorgula - true - end + test 'can initialize KPS queries as KpsAddressSaveJob for given user and address' do + client = Minitest::Mock.new + def client.sorgula + true + end - Services::Kps::Omu::Adres.stub :new, client do - assert property.constantize.perform_later({}) # dummy hash - end + Services::Kps::Omu::Adres.stub :new, client do + assert KpsAddressSaveJob.perform_later({}) # dummy hash end end - %w[ - KpsAddressCreateJob - KpsAddressUpdateJob - ].each do |property| - test "can perform enqueued jobs for #{property}" do - skip 'this block on CircleCI since it needs IP permissions to run.' if ENV['CI'] - assert_performed_jobs 0 - args = if property.eql?('KpsAddressCreateJob') - users(:serhat) - else - addresses(:formal) - end - perform_enqueued_jobs do - property.constantize.perform_later(args) - end - assert_performed_jobs 1 + test 'can perform enqueued jobs for KpsAddressSaveJob' do + skip 'this block on CircleCI since it needs IP permissions to run.' if ENV['CI'] + assert_performed_jobs 0 + perform_enqueued_jobs do + KpsAddressSaveJob.perform_later(users(:serhat)) end + assert_performed_jobs 1 end end diff --git a/test/jobs/kps_identity_job_test.rb b/test/jobs/kps_identity_job_test.rb new file mode 100644 index 000000000..779a9f92b --- /dev/null +++ b/test/jobs/kps_identity_job_test.rb @@ -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 diff --git a/test/models/accounts/student_test.rb b/test/models/accounts/student_test.rb index 0e4d42ecc..d684207a3 100644 --- a/test/models/accounts/student_test.rb +++ b/test/models/accounts/student_test.rb @@ -37,8 +37,8 @@ class StudentTest < ActiveSupport::TestCase end # callback tests - test 'student runs KpsIdentityCreateJob after being created' do - assert_enqueued_with(job: KpsIdentityCreateJob) do + test 'student runs KpsIdentitySaveJob after being created' do + assert_enqueued_with(job: KpsIdentitySaveJob) do Student.create(student_number: '1234', user: users(:serhat), unit: units(:omu)) end end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index ef9beef1a..e144a7c7f 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -84,8 +84,8 @@ class UserTest < ActiveSupport::TestCase end # callback tests - test 'user runs KpsAddressCreateJob after being created' do - assert_enqueued_with(job: KpsAddressCreateJob) do + test 'user runs KpsAddressSaveJob after being created' do + assert_enqueued_with(job: KpsAddressSaveJob) do User.create( id_number: '12345678912', email: 'fakeuser@fakemail.com', @@ -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: 'anotherfakeuser@fakemail.com',