2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe RssHelper do
|
2017-08-17 22:00:37 +05:30
|
|
|
describe '#rss_url_options' do
|
|
|
|
context 'when signed in' do
|
2018-11-08 19:23:39 +05:30
|
|
|
it "includes the current_user's feed_token" do
|
2017-08-17 22:00:37 +05:30
|
|
|
current_user = create(:user)
|
|
|
|
allow(helper).to receive(:current_user).and_return(current_user)
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(helper.rss_url_options).to include feed_token: current_user.feed_token
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed out' do
|
2018-11-08 19:23:39 +05:30
|
|
|
it "does not have a feed_token" do
|
2017-08-17 22:00:37 +05:30
|
|
|
allow(helper).to receive(:current_user).and_return(nil)
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(helper.rss_url_options[:feed_token]).to be_nil
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
context 'when feed_token disabled' do
|
|
|
|
it "does not have a feed_token" do
|
|
|
|
current_user = create(:user)
|
|
|
|
allow(helper).to receive(:current_user).and_return(current_user)
|
|
|
|
allow(Gitlab::CurrentSettings).to receive(:disable_feed_token).and_return(true)
|
|
|
|
expect(helper.rss_url_options[:feed_token]).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|