2019-09-30 08:06:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-28 15:50:57 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe RssHelper do
|
2017-02-28 15:50:57 -05:00
|
|
|
describe '#rss_url_options' do
|
|
|
|
context 'when signed in' do
|
2018-05-31 10:01:04 -04:00
|
|
|
it "includes the current_user's feed_token" do
|
2017-02-28 15:50:57 -05:00
|
|
|
current_user = create(:user)
|
|
|
|
allow(helper).to receive(:current_user).and_return(current_user)
|
2018-05-31 10:01:04 -04:00
|
|
|
expect(helper.rss_url_options).to include feed_token: current_user.feed_token
|
2017-02-28 15:50:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed out' do
|
2018-05-31 10:01:04 -04:00
|
|
|
it "does not have a feed_token" do
|
2017-02-28 15:50:57 -05:00
|
|
|
allow(helper).to receive(:current_user).and_return(nil)
|
2018-05-31 10:01:04 -04:00
|
|
|
expect(helper.rss_url_options[:feed_token]).to be_nil
|
2017-02-28 15:50:57 -05:00
|
|
|
end
|
|
|
|
end
|
2020-12-06 22:09:49 -05:00
|
|
|
|
|
|
|
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-02-28 15:50:57 -05:00
|
|
|
end
|
|
|
|
end
|