```ruby
module ModelStubbingHelpers
  def stub_record(type, options = {})
    result = build(type, options)
    result.stubs(:id).returns(next_record_id)
    result.stubs(:new_record?).returns(false)
    result.stubs(:created_at).returns(Time.zone.now) if result.respond_to?(:created_at)
    result.stubs(:updated_at).returns(Time.zone.now) if result.respond_to?(:updated_at)
    result
  end

  def stub_edition(type, options = {})
    document = stub_record(:document)
    document.stubs(:to_param).returns(document.slug)
    stub_record(type, options.merge(document: document))
  end

  def next_record_id
    @next_id ||= 0
    @next_id += 1
  end
end
```

Use FactoryGirl.build_stubbed instead of a hand-rolled solution.
user
```ruby
module ModelStubbingHelpers
  def stub_record(type, options = {})
    build_stubbed(type, options)
  end

  def stub_edition(type, options = {})
    document = stub_record(:document)
    document.stubs(:to_param).returns(document.slug)
    stub_record(type, options.merge(document: document))
  end

  def next_record_id
    @next_id ||= 0
    @next_id += 1
  end
end
```
assistant