2019-05-14 15:19:25 +02:00
|
|
|
describe BillSignatureService do
|
|
|
|
describe ".grouped_unsigned_operation_until" do
|
|
|
|
subject { BillSignatureService.grouped_unsigned_operation_until(date).length }
|
|
|
|
|
2019-12-02 21:27:05 +01:00
|
|
|
let(:date) { Time.zone.now.beginning_of_day }
|
2019-05-14 15:19:25 +02:00
|
|
|
|
|
|
|
context "when operations of several days need to be signed" do
|
|
|
|
before do
|
|
|
|
create :dossier_operation_log, executed_at: 3.days.ago
|
|
|
|
create :dossier_operation_log, executed_at: 2.days.ago
|
|
|
|
create :dossier_operation_log, executed_at: 1.day.ago
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to eq 3 }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when operations on a single day need to be signed" do
|
|
|
|
before do
|
|
|
|
create :dossier_operation_log, executed_at: 1.day.ago
|
|
|
|
create :dossier_operation_log, executed_at: 1.day.ago
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to eq 1 }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when there are no operations to be signed" do
|
|
|
|
before do
|
|
|
|
create :dossier_operation_log, created_at: 1.day.ago, bill_signature: build(:bill_signature)
|
|
|
|
create :dossier_operation_log, created_at: 1.day.from_now
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to eq 0 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|