mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 00:56:19 +08:00
e219588142
* Introduced fab!, a helper that creates database state for a group It's almost identical to let_it_be, except: 1. It creates a new object for each test by default, 2. You can disable it using PREFABRICATION=0
24 lines
591 B
Ruby
24 lines
591 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe DraftSequence do
|
|
fab!(:user) { Fabricate(:user) }
|
|
|
|
it 'should produce next sequence for a key' do
|
|
expect(DraftSequence.next!(user, 'test')).to eq 1
|
|
expect(DraftSequence.next!(user, 'test')).to eq 2
|
|
end
|
|
|
|
describe '.current' do
|
|
it 'should return 0 by default' do
|
|
expect(DraftSequence.current(user, 'test')).to eq 0
|
|
end
|
|
|
|
it 'should return the right sequence' do
|
|
expect(DraftSequence.next!(user, 'test')).to eq(1)
|
|
expect(DraftSequence.current(user, 'test')).to eq(1)
|
|
end
|
|
end
|
|
end
|