2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-16 08:56:30 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Gitlab::ChatNameToken do
|
2016-11-16 08:56:30 -05:00
|
|
|
context 'when using unknown token' do
|
|
|
|
let(:token) { }
|
|
|
|
|
|
|
|
subject { described_class.new(token).get }
|
|
|
|
|
|
|
|
it 'returns empty data' do
|
|
|
|
is_expected.to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when storing data' do
|
2016-11-16 17:10:27 -05:00
|
|
|
let(:data) { { key: 'value' } }
|
2016-11-16 08:56:30 -05:00
|
|
|
|
|
|
|
subject { described_class.new(@token) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
@token = described_class.new.store!(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns stored data' do
|
|
|
|
expect(subject.get).to eq(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and after deleting them' do
|
|
|
|
before do
|
|
|
|
subject.delete
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'data are removed' do
|
|
|
|
expect(subject.get).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|