discourse/spec/models/draft_sequence_spec.rb

22 lines
559 B
Ruby
Raw Normal View History

require 'rails_helper'
2013-02-06 03:16:51 +08:00
describe DraftSequence do
2017-09-15 16:44:04 +08:00
let(:user) { Fabricate(:user) }
2013-02-06 03:16:51 +08:00
it 'should produce next sequence for a key' do
2017-09-15 16:44:04 +08:00
expect(DraftSequence.next!(user, 'test')).to eq 1
expect(DraftSequence.next!(user, 'test')).to eq 2
2013-02-06 03:16:51 +08:00
end
2017-09-15 16:44:04 +08:00
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
2013-02-06 03:16:51 +08:00
end
end