난 내가 제출을 클릭 단계에서이오이 테스트에서 왜 이런 현상이 발생합니까?
Given /^initial data$/ do |table|
@schedule_05 = Factory.build :schedule_05
@schedule_05.save
puts "count of rows #{@schedule_05.cycles.count}" - # is 7
end
#....... there are same steps and where filling text fields and so on/
When /^i click a submit button "([^"]*)" in form$/ do |runs|
click_button(runs) # this is ajax request
end
Then /^count of SchOfWorkInformation is 365$/ do
puts "count of rows #{ScheduleOfWorking.count}" # is - 1
s_c = ScheduleOfWorking.find_by_schedule_code("05") # is too 1
puts "05 schedule is presents #{s_c.blank?}" # false
unless s_c.blank?
puts "05 schedule is presents #{s_c.date_of_countings.blank?}" #false
end
end
같은 시나리오는 컨트롤러 ScheduleOfWorkingController의 충전 작업을 포함해야
def filling
unless request.xhr?
@classifier_schedule = ScheduleOfWorking.classifiers_numbers
@schedule_number = ScheduleOfWorking.classifiers_numbers false
else
if params[:date_begin].blank? || params[:date_end].blank?
render :js => "alert('date fields is empty !')"
return
end
ScheduleOfWorking.fill_information_for(params[:date_begin].to_date,params[:date_end].to_date)
end
끝
ScheduleOfWorking 번호
def self.fill_information_for(date_begin, date_end)
sch = all
sch.each do |e_sch|
e_sch.date_of_countings.each do |d_counting|
h_calculate = d_counting.roll_cycle(date_begin, date_end)
transaction do
SchOfWorkInformation.delete_all("(date >= '#{date_begin}' and date <= '#{date_end}') and schedule_code = #{d_counting.sch_code}")
SchOfWorkInformation.create! h_calculate
end
end
end
end
SchOfWor에서 fill_information_for kInformation이 같은 사용자 지정 유효성 검사 메서드가 있습니다
def customer_validate
s = SchOfWorkInformation.where(:date => self.date, :schedule_code => self.schedule_code).first
if !s.blank? && (new_record? || s.id != self.id)
self.errors[:base] = "Запись не уникально!(date=#{self.date.to_s(:db)}, schedule_code=#{self.schedule_code})"
end
sch_number = schedule_code[0..1].blank? ? "0" : schedule_code[0..1]
session_number = schedule_code[2].blank? ? "0" : schedule_code[2]
logger.info "---------------------------------------"
ss_a = ScheduleOfWorking.all
s = ScheduleOfWorking.where("schedule_code='#{sch_number}'").
joins(:date_of_countings).
where("date_countings.session_number=#{session_number}")
# In Given section of my step i load the data, but s.balnk? gives true
if s.blank?
self.errors[:base] = "Schedule - #{sch_number} with session number #{session_number}), is not exists in DB"
end
end
왜 유효성 검사 방법에서 데이터가 손실됩니까? 도와주세요!
개발 중. 모든 권리는 있지만 테스트에서는 그렇지 않습니다.
.. 오랫동안 죄송합니다.
: 내 응용 프로그램에서
, 나는 공유 연결을 사용하는 자바 스크립트 테스트에 대한 설정이 env.rb에 shared_connection을,하지만 지금 get Mysql2 :: Error :이 연결은 여전히 결과를 기다리고 있습니다. 결과가 나오면 다시 시도하십시오. 내 서버 로그에 ... – dilshod
ajax 요청이 비동기이며 오이가 reqeust를 완료하기 전에 다음 단계로 이동하기 때문입니다. 다음 단계로 이동하기 전에 이벤트가 끝나기를 기다리거나 페이지의 일부 요소를 찾아서 기다리는 것을 포함하여 몇 가지 옵션이 있습니다. –
다음은 http://pivotallabs.com/users/mgehard/blog/articles/1671-waiting-for-jquery-ajax-calls-to-finish-in-cucumber의 예입니다. 자세한 내용은 https의 AJAX 섹션을 참조하십시오. : //github.com/jnicklas/capybara –