Skip to content

Commit

Permalink
Ajustes no FCM (#4)
Browse files Browse the repository at this point in the history
* fix: Adiciona o status "cancelado" de um lote nas condições de encerramento de uma licitação

* fix: Adiciona validação do status "cancelado" de um lote ao encerrar novamente uma licitação

* feat: Atualiza endpoint Administrator::Biddings::RegenerateMinutesController para considerar as situações Fracassada, Deserta e Concluída

* fix: Retorna mecanismo de fracassar licitação no admin

* feat: Ajusta importador de fornecedores

* feat: Remove envio de push notification

Co-authored-by: MarivalViana <[email protected]>
Co-authored-by: alexandrecrvg <[email protected]>
  • Loading branch information
3 people authored Jan 16, 2023
1 parent 9e6d266 commit 87a10ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/services/notifications/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
module Notifications
class Base

attr_accessor :send_fcm_notification

def call
notify
end
Expand All @@ -46,7 +48,11 @@ def notify
notification = Notification.create(notification_attributes(receiver))

if notification
::Notifications::Fcm.delay.call(notification.id)
# XXX: A configuração do envio de push notification para a PB não é possível no momento,
# pois a atualização da gem fcm entra em conflito com outras gems que utilizam
# versões diferentes da gem Faraday.
# Assim que o sistema puder ser atualizado e testado, a funcionalidade poderá ser validada novamente.
::Notifications::Fcm.delay.call(notification.id) if send_fcm_notification?

# Envia e-mail junto com a notificação com o mesmo conteúdo.
# Email deve ser enviado apenas para usuários que não sejam fornecedores
Expand All @@ -57,6 +63,10 @@ def notify
end
end

def send_fcm_notification?
send_fcm_notification || false
end

def notification_attributes(receiver)
{
receivable: receiver,
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/setup/pb/importers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace :pb do
def find_city_id(city_id)
city_id_integer = city_id.to_i

city_id_integer > 3540 ? city_id_integer + 1 : city_id_integer
city_id_integer > 3540 ? city_id_integer - 1 : city_id_integer
end

CSV.foreach(file, headers: false, col_sep: '|') do |row|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
describe 'fcm' do
let(:notification) { create(:notification) }
let(:fcm_response) { double('call', call: true) }
let(:send_fcm_notification) { true }

before do
allow(::Notifications::Fcm).to receive(:delay).and_return(fcm_response)
allow(Notification).to receive(:create).and_return(notification_response)
# XXX: A configuração do envio de push notification para a PB não é possível no momento,
# pois a atualização da gem fcm entra em conflito com outras gems que utilizam
# versões diferentes da gem Faraday.
# Assim que o sistema puder ser atualizado e testado, a funcionalidade poderá ser validada novamente.
allow(service).to receive(:send_fcm_notification).and_return(send_fcm_notification)

service.call
end
Expand All @@ -23,5 +29,12 @@

it { expect(::Notifications::Fcm).not_to have_received(:delay) }
end

context 'when send_fcm_notification param is false' do
let(:send_fcm_notification) { false }
let(:notification_response) { notification }

it { expect(::Notifications::Fcm).not_to have_received(:delay) }
end
end
end

0 comments on commit 87a10ff

Please sign in to comment.