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
26
26
. order ( :name )
27
27
}
28
28
29
+ after_create :register_on_partnerbase
30
+
29
31
# better to extract this outside of the model
30
32
def self . import_csv ( data , organization_id )
31
33
CSV . parse ( data , headers : true ) do |row |
@@ -43,4 +45,8 @@ def self.csv_export_headers
43
45
def csv_export_attributes
44
46
[ name , email ]
45
47
end
48
+
49
+ def register_on_partnerbase
50
+ UpdateDiaperPartnerJob . perform_async ( id )
51
+ end
46
52
end
Original file line number Diff line number Diff line change 49
49
expect { subject } . to change ( Partner , :count ) . by ( 1 )
50
50
end
51
51
52
- it "enqueues a UpdateDiaperPartnerJob job" do
53
- expect ( UpdateDiaperPartnerJob ) . to receive ( :perform_async )
54
- subject
55
- end
56
-
57
52
it "redirects to #index" do
58
53
expect ( subject ) . to redirect_to ( partners_path )
59
54
end
Original file line number Diff line number Diff line change 51
51
# end
52
52
# end
53
53
# 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
+
54
60
describe "import_csv" do
55
61
let ( :organization ) { create ( :organization ) }
56
62
You can’t perform that action at this time.
0 commit comments