Skip to content

Instantly share code, notes, and snippets.

@davidyang
Created January 19, 2011 06:50
Show Gist options
  • Save davidyang/785793 to your computer and use it in GitHub Desktop.
Save davidyang/785793 to your computer and use it in GitHub Desktop.
context "creates Visits and Patients" do
before(:all) do
ActiveRecord::Base.connection.begin_db_transaction
@query = Factory.create(:query)
@params = {}
@params[:practice_key] = @query.functionality.practice.subdomain_key
@params[:query_id] = @query.id
Visit.stub!(:strip_time_zone).and_return(Time.zone.now.tomorrow.to_s)
end
it "should create two new Patients and Visits" do
#Patient.should_receive(:create).twice
do_post('upload_xml_011411.xml', @params)
Patient.count.should == 2
Visit.count.should == 2
VoiceNotification.count.should == 0
EmailNotification.count.should == 0
# generate both email and voice notifications
@query.email_active = true
@query.actively_notify = true
@query.create_notifications
VoiceNotification.count.should == 2
EmailNotification.count.should == 2
@query.create_notifications
EmailNotification.should_not_receive(:create)
VoiceNotification.should_not_receive(:create)
end
it "should not create notifications for various reasons" do
do_post('upload_xml_011411.xml', @params)
Patient.count.should == 2
end
after(:all) do
ActiveRecord::Base.connection.rollback_db_transaction
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment