Last active
July 4, 2019 15:53
-
-
Save cyrilchampier/c6a445b6abc9322464cf270edb8ed94e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://github.com/doctolib/doctolib/blob/144688fe1aec739ffc6fcf7e6cd30a9d24759f82/test/integration/doctor/desktop/agenda/appointment/modal/booking1_test.rb#L254 | |
# full inherited setup | |
describe 'not described in fact' do | |
setup do | |
@agenda = create :agenda, agenda_options | |
@account = create :account, account_options.merge(kind: Account::Kind::DOCTOR, job: Account::Job::PRACTITIONER) | |
agenda_authorization = create :agenda_authorization, account: account, agenda: agenda | |
@account.update agenda_preferences: @account.agenda_preferences.merge(splitCalendarWeekColumns: false) | |
@date = Time.zone.parse('19th Oct 2013 3:00pm') | |
@date = Time.zone.parse('20th Oct 2016 10:00am') | |
Timecop.travel @date - 2.months do | |
@account = create :account, kind: Account::Kind::DOCTOR | |
@account.update! agenda_preferences: { features: ['appointment-reminder'].to_json } | |
speciality = create :speciality, :dentist | |
@agenda = create :agenda, speciality: speciality | |
create(:agenda_authorization, account: @account, agenda: @agenda) | |
create_visit_motives | |
create_visit_motives [{ duration: 20 }] | |
create_visit_motives([ | |
{ insurance: 'public', duration: 20 }, | |
{ insurance: 'private', duration: 20, disabled: true }, | |
]) | |
create_visit_motives [{ insurance: 'public', duration: 40 }, { insurance: 'private', duration: 50 }] | |
create_openings | |
@patients = | |
%w(Patient1 Patient2).map { |first| create(:patient, patient_base: @agenda.patient_base, first_name: first) } | |
end | |
Timecop.travel(@date) | |
end | |
def create_visit_motives(configurations = [{}]) | |
@visit_motives ||= [] | |
@visit_motives << @agenda.organization.visit_motives.create!( | |
name: "Visit Motive #{VisitMotive.count + 1} #{@agenda.speciality.name}", | |
speciality: @agenda.speciality, | |
configurations_attributes: configurations | |
.map { |configuration| VisitMotiveConfiguration::DEFAULTS.merge(duration: 30).merge(configuration) }, | |
) | |
end | |
def create_openings | |
create(:recurring_event, | |
agenda: @agenda, | |
start_date: 3.weeks.ago.change(hour: 9, min: 30), | |
end_date: 3.weeks.ago.change(hour: 12, min: 0), | |
visit_motive_ids: @agenda.organization.visit_motives.map(&:id), | |
kind: 'open', | |
on: [4, 5]) | |
end | |
let(:patient) { create(:patient, patient_base: @agenda.patient_base, last_name: 'DOE') } | |
let!(:appointment) { | |
create(:appointment, | |
agenda: @agenda, | |
start_date: @date, | |
end_date: @date + 30.minutes, | |
patient: patient, | |
visit_motive: @visit_motives[0]) | |
} | |
it 'should alert on booking popin when patient does not have phone number and email' do | |
patient.update!(phone_number: nil, email: nil) | |
login_session | |
# ... | |
end | |
end | |
# really needed setup | |
describe 'when patient does not have phone number and email' do | |
let(:agenda) { create :agenda, :with_practitioner } | |
let(:patient) { create(:patient, last_name: 'DOE', phone_number: nil, email: nil) } | |
let!(:appointment) { create(:appointment, agenda: agenda, patient: patient) } | |
it 'should alert on booking popin' do | |
login_session(account: @agenda.practitioner) | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment