File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ class Partner < ApplicationRecord
2626 . order ( :name )
2727 }
2828
29+ after_create :register_on_partnerbase
30+
2931 # better to extract this outside of the model
3032 def self . import_csv ( data , organization_id )
3133 CSV . parse ( data , headers : true ) do |row |
@@ -43,4 +45,8 @@ def self.csv_export_headers
4345 def csv_export_attributes
4446 [ name , email ]
4547 end
48+
49+ def register_on_partnerbase
50+ UpdateDiaperPartnerJob . perform_async ( id )
51+ end
4652end
Original file line number Diff line number Diff line change 4949 expect { subject } . to change ( Partner , :count ) . by ( 1 )
5050 end
5151
52- it "enqueues a UpdateDiaperPartnerJob job" do
53- expect ( UpdateDiaperPartnerJob ) . to receive ( :perform_async )
54- subject
55- end
56-
5752 it "redirects to #index" do
5853 expect ( subject ) . to redirect_to ( partners_path )
5954 end
Original file line number Diff line number Diff line change 5151 # end
5252 # end
5353 # end
54+
55+ it 'fires send_email method as after_create method callbacks' do
56+ expect ( subject ) . to receive ( :register_on_partnerbase )
57+ subject . run_callbacks ( :create )
58+ end
59+
5460 describe "import_csv" do
5561 let ( :organization ) { create ( :organization ) }
5662
You can’t perform that action at this time.
0 commit comments