discourse/spec/models/digest_unsubscribe_key_spec.rb
Robin Ward 3ce2077aa8 Migrate unsubscribe keys to the database.
This should reduce a lot of the keys in redis.
2015-02-13 14:24:15 -05:00

32 lines
639 B
Ruby

require 'spec_helper'
require_dependency 'digest_unsubscribe_key'
describe DigestUnsubscribeKey do
it { is_expected.to belong_to :user }
describe 'key' do
let(:user) { Fabricate(:user) }
let!(:key) { DigestUnsubscribeKey.create_key_for(user) }
it 'has a temporary key' do
expect(key).to be_present
end
describe '#user_for_key' do
it 'can be used to find the user' do
expect(DigestUnsubscribeKey.user_for_key(key)).to eq(user)
end
it 'returns nil with an invalid key' do
expect(DigestUnsubscribeKey.user_for_key('asdfasdf')).to be_blank
end
end
end
end