mirror of
https://github.com/discourse/discourse.git
synced 2024-12-20 09:03:45 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
44 lines
997 B
Ruby
44 lines
997 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe UnsubscribeKey do
|
|
|
|
describe 'post unsubscribe key' do
|
|
it 'can generate a correct url' do
|
|
post = Fabricate(:post)
|
|
url = post.unsubscribe_url(post.user)
|
|
|
|
route = Rails.application.routes.recognize_path(url)
|
|
|
|
key = UnsubscribeKey.find_by(key: route[:key])
|
|
|
|
expect(key.post_id).to eq(post.id)
|
|
expect(key.topic_id).to eq(post.topic_id)
|
|
expect(key.unsubscribe_key_type).to eq("topic")
|
|
end
|
|
end
|
|
|
|
describe 'key' do
|
|
|
|
fab!(:user) { Fabricate(:user) }
|
|
let!(:key) { UnsubscribeKey.create_key_for(user, UnsubscribeKey::DIGEST_TYPE) }
|
|
|
|
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(UnsubscribeKey.user_for_key(key)).to eq(user)
|
|
end
|
|
|
|
it 'returns nil with an invalid key' do
|
|
expect(UnsubscribeKey.user_for_key('asdfasdf')).to be_blank
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|