Answers for "rails fixture without timestamping"

0

rails fixture without timestamping

without_timestamping_of Article do
  Factory(:article, :created_at => 1.week.ago, :updated_at => 1.week.ago)
end
Posted by: Guest on January-30-2021
0

rails fixture without timestamping

# test_helper.rb
class Test::Unit::TestCase # or class ActiveSupport::TestCase in Rails 2.3.x
  def without_timestamping_of(*klasses)
    if block_given?
      klasses.delete_if { |klass| !klass.record_timestamps }
      klasses.each { |klass| klass.record_timestamps = false }
      begin
        yield
      ensure
        klasses.each { |klass| klass.record_timestamps = true }
      end
    end
  end
end
Posted by: Guest on January-30-2021
0

rails fixture without timestamping

Factory(:article, :created_at => 1.week.ago, :updated_at => 1.week.ago)
Posted by: Guest on January-30-2021
0

rails fixture without timestamping

without_timestamping_of Article, Comment, User do
  Factory(:article, :created_at => 1.week.ago, :updated_at => 1.week.ago)
  Factory(:comment, :created_at => 1.day.ago)
  Factory(:user, :updated_at => 5.hours.ago)
end
Posted by: Guest on January-30-2021

Code answers related to "rails fixture without timestamping"

Browse Popular Code Answers by Language