blob: 4382758965cb96a93216d973584db96855dbc267 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe FeedTokenHelper, feature_category: :system_access do
describe '#generate_feed_token' do
context 'with type :atom' do
let(:current_user) { build(:user, feed_token: 'KNOWN VALUE') }
it "returns the current_user's atom feed_token" do
allow(helper).to receive(:current_user).and_return(current_user)
allow(helper).to receive(:current_request).and_return(instance_double(ActionDispatch::Request, path: 'url'))
expect(helper.generate_feed_token(:atom))
# The middle part is the output of OpenSSL::HMAC.hexdigest("SHA256", 'KNOWN VALUE', 'url.atom')
.to eq("glft-a8cc74ccb0de004d09a968705ba49099229b288b3de43f26c473a9d8d7fb7693-#{current_user.id}")
end
end
context 'when signed out' do
it "returns nil" do
allow(helper).to receive(:current_user).and_return(nil)
expect(helper.generate_feed_token(:atom)).to be_nil
end
end
end
end
|