How to use start method of Reportable Package

Best Minitest_ruby code snippet using Reportable.start

reports_controller.rb

Source:reports_controller.rb Github

copy

Full Screen

...18 end19 end20 def update21 # Hack to allow users to update the report dates with best_in_place, YUCK!22 start_date = params[:report].delete(:display_start_date)23 end_date = params[:report].delete(:display_end_date)24 if start_date || end_date25 if @report.updatable?26 if start_date27 if start_date =~ /\A\d{4}-\d{2}\z/28 params[:report][:start_date] = start_date + '-01'29 else30 render :json => ["Report date format must be YYYY-MM"], :status => :unprocessable_entity31 return32 end33 end34 if end_date35 if end_date =~ /\A\d{4}-\d{2}\z/36 params[:report][:end_date] = end_date + '-01'37 else38 render :json => ["Report date format must be YYYY-MM"], :status => :unprocessable_entity39 return40 end41 end42 else43 render :json => ["Report dates cannot be updated as the report is still being processed."], :status => :unprocessable_entity44 return45 end46 end47 # End of hack48 if @report.update_attributes(params[:report])49 head :ok50 else51 render :json => @report.errors.full_messages, :status => :unprocessable_entity52 end53 end54 def new55 @report = current_user.reports.new56 if params[:report][:reportable_id]57 reportable = get_reportable58 # Regenerate the report if it one already exists59 if reportable.report60 @report = reportable.report61 regenerate62 return63 end64 @report.reportable = reportable65 else66 @report.reportable_type = params[:report][:reportable_type]67 end68 load_reportables69 end70 def create71 # Hack to allow users to set year-month dates for the report72 params[:report][:start_date] = params[:report][:start_date] + '-01' if params[:report][:start_date]73 params[:report][:end_date] = params[:report][:end_date] + '-01' if params[:report][:end_date]74 @report = current_user.reports.new(params[:report])75 reportable = get_reportable76 if reportable.report77 redirect_to reports_url, :flash => {:error => 'A report already exists for that source, you can regenerate it if needed.'}78 return79 end80 @report.reportable = reportable81 if @report.save82 Delayed::Job.enqueue(Reports::Job.new(@report))83 redirect_to reports_url, :flash => {:success => 'Report is being created, this should only take a minute...'}84 else85 load_reportables86 render :new...

Full Screen

Full Screen

completion_reports_controller.rb

Source:completion_reports_controller.rb Github

copy

Full Screen

...44 end45 end46 def index47 if params[:m].present? && params[:y].present?48 range_start = DateTime.new(params[:y].to_i, params[:m].to_i, 1, 0, 0).beginning_of_month49 last_day = DateTime.new(params[:y].to_i, params[:m].to_i, -1, 23, 59).end_of_month50 range_end = (Time.current + 10.hours) < last_day ? (Time.current + 10.hours) : last_day51 elsif params[:day].present?52 day = params[:day].to_date rescue nil 53 range_start = day.try(:beginning_of_day)54 range_end = day.try(:end_of_day)55 end56 @appointments_without_reports = Appointment.left_outer_joins(:completion_report).where(completion_reports: {id: nil}).includes(:nurse, :patient).operational.where('appointments.starts_at between ? and ?', range_start, range_end).order(starts_at: :desc)57 @recent_completion_reports = CompletionReport.includes(reportable: [:nurse, :patient]).from_appointments.joins('left join appointments on appointments.id = completion_reports.reportable_id').where('appointments.starts_at between ? and ?', range_start, range_end).order('appointments.starts_at desc')58 59 set_main_nurse if request.format.html?60 @appointments_without_reports = @appointments_without_reports.where(nurse_id: params[:nurse_id]) if params[:nurse_id].present?61 @appointments_without_reports = @appointments_without_reports.where(patient_id: params[:patient_id]) if params[:patient_id].present?62 @appointments_without_reports = @appointments_without_reports.where(nurse_id: @main_nurse.id) if @main_nurse.present?63 @recent_completion_reports = @recent_completion_reports.where('appointments.nurse_id = ?', params[:nurse_id]) if params[:nurse_id].present?64 @recent_completion_reports = @recent_completion_reports.where('appointments.nurse_id = ?', @main_nurse.id) if @main_nurse.present?65 @recent_completion_reports = @recent_completion_reports.where('appointments.patient_id = ?', params[:patient_id]) if params[:patient_id].present?66 end67 def destroy68 @completion_report.destroy69 end70 private71 def set_reportable...

Full Screen

Full Screen

knight.rb

Source:knight.rb Github

copy

Full Screen

1# frozen_string_literal:true2# represents the knight piece, gets destination but has a default start value # that can be updated3class Knight4 attr_accessor :knight_position, :destination, :reportable_position, :reportable_destination5 def initialize6 @knight_position = [3, 3]7 @destination8 @reportable_position9 @reportable_destination10 end11 def run12 ask_destination13 destination_converter14 end15 def report_position_destination16 position_converter17 puts "Current knight position is : #{@reportable_position.join} \n "18 puts "Destination set to: #{@reportable_destination} \n "19 end20 private21 def ask_destination22 puts 'Where would you like to move to?'23 puts "You must use this format to choose a new destination, ex: a1 \n "24 @reportable_destination = gets.chomp25 ask_destination_error26 end27 def position_converter28 @reportable_position = @knight_position.dup29 case @reportable_position[0]30 when 031 @reportable_position[0] = 'a'32 when 133 @reportable_position[0] = 'b'34 when 235 @reportable_position[0] = 'c'36 when 337 @reportable_position[0] = 'd'38 when 439 @reportable_position[0] = 'e'40 when 541 @reportable_position[0] = 'f'42 when 643 @reportable_position[0] = 'g'44 when 745 @reportable_position[0] = 'h'46 end47 @reportable_position[1] += 148 end49 def destination_converter50 @destination = @reportable_destination.split(//)51 case @destination[0]52 when 'a'53 @destination[0] = 054 when 'b'55 @destination[0] = 156 when 'c'57 @destination[0] = 258 when 'd'59 @destination[0] = 360 when 'e'61 @destination[0] = 462 when 'f'63 @destination[0] = 564 when 'g'65 @destination[0] = 666 when 'h'67 @destination[0] = 768 end69 @destination[1] = @destination[1].to_i70 @destination[1] -= 171 end72 def ask_destination_error73 a = @reportable_destination.split(//)74 if (!('a'..'h').include? a[0]) || (!('1'..'8').include? a[1])75 puts "Incorrect format used, must follow format. \n "76 ask_destination77 elsif @reportable_destination == 'd4'78 puts "d4 is the starting point! \n "79 ask_destination80 end81 end82end

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Minitest_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful