Skip to content

Commit

Permalink
Fix create templates job failing on first run
Browse files Browse the repository at this point in the history
Fixes #2044

The first time the job is run the
three_sixty_dialog_client_waba_account_id is nil so it calls the
fetch_client_info method. This method successfully updates the
organization, but as it's the last line of the method it saves the
return of the update `true` to the local variable that is used in the
url to create the templates. This results in an error. Subsequent times
it's ran it does not error because it uses the value of the
organization's attribute, which is the correct value.
  • Loading branch information
mattwr18 committed Oct 10, 2024
1 parent 078227b commit 86f7466
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/jobs/whats_app_adapter/create_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def fetch_client_info
waba_account = client_hash['waba_account']
organization.update!(three_sixty_dialog_whats_app_template_namespace: waba_account['namespace'],
three_sixty_dialog_client_waba_account_id: waba_account['id'])
waba_account
end

# rubocop:disable Metrics/MethodLength
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
describe '#call' do
subject { -> { described_class.new(organization_id: organization.id, file_id: file_id).call } }

let(:organization) { create(:organization) }
let!(:organization) { create(:organization) }
let(:file_id) { 'some_valid_id' }

let(:path) { '/whatsapp_business/attachments/' }
Expand Down

0 comments on commit 86f7466

Please sign in to comment.