mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
Second review fixes
This commit is contained in:
parent
f96fffeb34
commit
0229df4c73
@ -72,7 +72,7 @@ class TopicsController < ApplicationController
|
||||
if opts[:print]
|
||||
raise Discourse::InvalidAccess unless SiteSetting.max_prints_per_hour_per_user > 0
|
||||
begin
|
||||
RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! unless @guardian.is_admin?
|
||||
RateLimiter.new(current_user, "print-topic-per-hour", SiteSetting.max_prints_per_hour_per_user, 1.hour).performed! unless @guardian.is_admin?
|
||||
rescue RateLimiter::LimitExceeded
|
||||
render_json_error(I18n.t("rate_limiter.slow_down"))
|
||||
end
|
||||
|
@ -910,7 +910,7 @@ rate_limits:
|
||||
shadowed_by_global: true
|
||||
default: 0
|
||||
max_prints_per_hour_per_user:
|
||||
default: 0
|
||||
default: 5
|
||||
client: true
|
||||
|
||||
developer:
|
||||
|
@ -137,11 +137,7 @@ class TopicView
|
||||
end
|
||||
|
||||
def relative_url
|
||||
if !@print
|
||||
@topic.relative_url
|
||||
else
|
||||
@topic.relative_url + '/print'
|
||||
end
|
||||
"#{@topic.relative_url}#{@print ? '/print' : ''}"
|
||||
end
|
||||
|
||||
def page_title
|
||||
|
@ -88,10 +88,6 @@ describe TopicsController do
|
||||
render_views
|
||||
|
||||
context "when the SiteSetting is enabled" do
|
||||
before do
|
||||
SiteSetting.stubs(:max_prints_per_hour_per_user).returns(10)
|
||||
end
|
||||
|
||||
it "uses the application layout when there's no param" do
|
||||
get :show, topic_id: topic.id, slug: topic.slug
|
||||
expect(response).to render_template(layout: 'application')
|
||||
|
@ -747,20 +747,19 @@ describe TopicsController do
|
||||
expect(IncomingLink.count).to eq(1)
|
||||
end
|
||||
|
||||
it "doesn't renders the print view by default" do
|
||||
user = Fabricate(:user)
|
||||
get :show, topic_id: topic.id, slug: topic.slug, print: true
|
||||
context 'print' do
|
||||
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
it "doesn't renders the print view when disabled" do
|
||||
SiteSetting.max_prints_per_hour_per_user = 0
|
||||
get :show, topic_id: topic.id, slug: topic.slug, print: true
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
||||
it 'renders the print view when enabled' do
|
||||
SiteSetting.max_prints_per_hour_per_user = 10
|
||||
|
||||
user = Fabricate(:user)
|
||||
get :show, topic_id: topic.id, slug: topic.slug, print: true
|
||||
|
||||
expect(response).to be_successful
|
||||
it 'renders the print view when enabled' do
|
||||
SiteSetting.max_prints_per_hour_per_user = 10
|
||||
get :show, topic_id: topic.id, slug: topic.slug, print: true
|
||||
expect(response).to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
it 'records redirects' do
|
||||
|
Loading…
Reference in New Issue
Block a user