You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I was reading the documentation on restricting the sequence to an initial starting value. Following the documentation as written has no effect.
Reproduction Steps
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "factory_bot", "6.4.6"
gem "activerecord"
gem "sqlite3"
end
require "active_record"
require "factory_bot"
require "minitest/autorun"
require "logger"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.integer :number_of_characters
end
end
class Post < ActiveRecord::Base
end
FactoryBot.define do
factory :post do
sequence(:body, 1)
end
end
class FactoryBotTest < Minitest::Test
def test_factory_bot_stuff
post = FactoryBot.create(:post)
assert_equal post.number_of_characters, 1
end
end
Expected behavior
The sequence starts with the integer 1.
Actual behavior
The sequence starts with the integer 4.
System configuration
6.4.6: 6.1.7.7: 3.1.5:
The text was updated successfully, but these errors were encountered:
Thank you for the detailed issue. I tried running your reproduction steps, and even changed it to match your Rails version. I couldn't reproduce the bug you're describing.
Here's the modified version (with version pinning, added logger gem, as it was removed from a Rails dependency, an attribute name fix, and changed expectation to avoid using the default).
If this happened in a real application and isn't happening on your test run, I suspect other records had been created (or built) before, either in other tests, or as associated records.
Description
Hello! I was reading the documentation on restricting the sequence to an initial starting value. Following the documentation as written has no effect.
Reproduction Steps
Expected behavior
The sequence starts with the integer 1.
Actual behavior
The sequence starts with the integer 4.
System configuration
6.4.6:
6.1.7.7:
3.1.5:
The text was updated successfully, but these errors were encountered: