Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7839933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:36:10+00:00 2026-06-02T15:36:10+00:00

I have scenario like this Given /^initial data$/ do |table| @schedule_05 = Factory.build :schedule_05

  • 0

I have scenario like this

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

In step when i click submit involves a controller ScheduleOfWorkingController’s filling action

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

end

ScheduleOfWorking#fill_information_for

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

In SchOfWorkInformation i have custom validation method like this

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

Why my data lose in validation method? Help, please!

In development env. all rights, but in test not.

..sorry for long letter..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:36:12+00:00Added an answer on June 2, 2026 at 3:36 pm

    What database strategy are you using for these tests? If it’s running in a transaction, the data is never actually persisted to the database. You should be using some other method for these steps since the data is guaranteed to be persisted regardless of how many threads or processes are running. When you make an ajax request, it’s in a separate request to the server and the database transaction is only available to that request.

    In my application, I have a setting for the javascript tests that uses a shared connection:

    Cucumber::Rails::Database.javascript_strategy = :shared_connection
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my feature file I have something like this: Scenario: Things Given the table
I have a scenario like this: form = MockRepository.GenerateMock<IAddAddressForm>(); mediator = new AddAddressMediator(form); The
In a multithreaded scenario, I have a method like this: bool WaitForChange( time_duration WaitTime
I have this scenario where I would like to redirect my domains using the
I have a scenario outline table that looks like the following: Scenario Outline: Verify
let me ask you something, if a have scenario like this: Scenario: Listing the
Our current scenario is like this: we have an existing database that needs to
Suppose we have a NAME table like this: PERSON_ID PART_TYPE VALUE and PERSON_ID is
I will like to know: I have a scenario. If a user adds a
I have an architecture scenario and I would like to discuss to get your

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.