diff --git a/app/controllers/api/v1/event_procedures_controller.rb b/app/controllers/api/v1/event_procedures_controller.rb index ebd42a3..149fb46 100644 --- a/app/controllers/api/v1/event_procedures_controller.rb +++ b/app/controllers/api/v1/event_procedures_controller.rb @@ -116,14 +116,6 @@ def serialized_event_procedures(event_procedures) each_serializer: EventProcedureSerializer ) end - - def total_amount_cents_params - { - user_id: current_user.id, - month: params[:month], - year: params[:year] - } - end end end end diff --git a/app/controllers/api/v1/pdf_reports_controller.rb b/app/controllers/api/v1/pdf_reports_controller.rb index a832f5d..45676d6 100644 --- a/app/controllers/api/v1/pdf_reports_controller.rb +++ b/app/controllers/api/v1/pdf_reports_controller.rb @@ -75,14 +75,6 @@ def permitted_query_params health_insurance: [:name] ).to_h end - - def total_amount_cents_params - { - user_id: current_user.id, - month: permitted_query_params[:month], - year: permitted_query_params[:year] - } - end end end end diff --git a/app/pdfs/header_pdf.rb b/app/pdfs/header_pdf.rb index 4dc5053..a74f909 100644 --- a/app/pdfs/header_pdf.rb +++ b/app/pdfs/header_pdf.rb @@ -39,10 +39,6 @@ def header_spacing pdf.move_down 50 end - def title_font_size - 20 - end - def header_current_date pdf.text "Data: #{Time.zone.now.strftime('%d/%m/%Y')}", align: :right, size: @header_font_size end diff --git a/db/seeds/02_procedures_default.rb b/db/seeds/02_procedures_default.rb index fb5ab52..9e53f2a 100644 --- a/db/seeds/02_procedures_default.rb +++ b/db/seeds/02_procedures_default.rb @@ -10,17 +10,13 @@ batch_files = Rails.root.glob("lib/data/procedures/batch_*.json") -if batch_files.empty? - Rails.logger.debug "No JSON files found." -else - batch_files.each do |batch_file| - next unless File.exist?(batch_file) +batch_files.each do |batch_file| + next unless File.exist?(batch_file) - Rails.logger.debug { "Importing #{batch_file}" } + Rails.logger.debug { "Importing #{batch_file}" } - Rake::Task["procedures:persist_in_database"].invoke(batch_file) - Rake::Task["procedures:persist_in_database"].reenable - end + Rake::Task["procedures:persist_in_database"].invoke(batch_file) + Rake::Task["procedures:persist_in_database"].reenable end Rails.logger.debug { "Created #{batch_files.count} default Procedures!" } diff --git a/spec/pdfs/medical_shifts_report_pdf_spec.rb b/spec/pdfs/medical_shifts_report_pdf_spec.rb index 5e8de3a..217dc04 100644 --- a/spec/pdfs/medical_shifts_report_pdf_spec.rb +++ b/spec/pdfs/medical_shifts_report_pdf_spec.rb @@ -6,7 +6,7 @@ it "generates a report with the correct content" do user = create(:user) pdf = Prawn::Document.new - medical_shifts = create_list(:medical_shift, 3, user_id: user.id) + medical_shifts = create_list(:medical_shift, 20, user_id: user.id) amount = MedicalShifts::TotalAmountCents.call(medical_shifts: medical_shifts) described_class.new(pdf: pdf, amount: amount, items: medical_shifts, title: "Plantões", email: user.email).generate diff --git a/spec/requests/api/v1/patients_request_spec.rb b/spec/requests/api/v1/patients_request_spec.rb index 742bd7e..22ddd51 100644 --- a/spec/requests/api/v1/patients_request_spec.rb +++ b/spec/requests/api/v1/patients_request_spec.rb @@ -192,6 +192,23 @@ ) end end + + context "when theres an error on destroy" do + it "returns unprocessable_content" do + patient = create(:patient, user: user) + + result_object = Struct.new(:success?, :error).new( + false, + { error: "Error message." } + ) + + allow(Patients::Destroy).to receive(:result).with(id: patient.id.to_s).and_return(result_object) + + delete "/api/v1/patients/#{patient.id}", headers: headers + + expect(response).to have_http_status(:unprocessable_content) + end + end end include_context "when user is not authenticated"