FIX: Use Guardian.basic_user instead of new (anon) (#270)
c.f. de983796e1b66aa2ab039a4fb6e32cec8a65a098 There will soon be additional login_required checks for Guardian, and the intent of many checks by automated systems is better fulfilled by using BasicUser, which simulates a logged in TL0 forum user, rather than an anon user.
This commit is contained in:
parent
ad1b7c9608
commit
7edf6d86e4
|
@ -1,3 +1,4 @@
|
|||
< 3.2.0.beta4-dev: ad1b7c9608bf32c3a991580347302a071d5902d9
|
||||
< 3.2.0.beta2-dev: 9fbf43e2f077e86f0a1ff769af6036d4e78bfff1
|
||||
3.1.999: b5d487d6a5bfe2571d936eec5911d02a5f3fcc32
|
||||
3.1.0.beta1: 62fe282c756ac7de43a22a09b0d675882a507743
|
||||
|
|
|
@ -703,8 +703,10 @@ SQL
|
|||
category_id_changes = topic_changes.diff["category_id"].to_a
|
||||
tag_changes = topic_changes.diff["tags"].to_a
|
||||
|
||||
old_allowed = Guardian.new.allow_accepted_answers?(category_id_changes[0], tag_changes[0])
|
||||
new_allowed = Guardian.new.allow_accepted_answers?(category_id_changes[1], tag_changes[1])
|
||||
old_allowed =
|
||||
Guardian.basic_user.allow_accepted_answers?(category_id_changes[0], tag_changes[0])
|
||||
new_allowed =
|
||||
Guardian.basic_user.allow_accepted_answers?(category_id_changes[1], tag_changes[1])
|
||||
|
||||
options[:refresh_stream] = true if old_allowed != new_allowed
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ require_dependency "site"
|
|||
|
||||
describe Site do
|
||||
let(:category) { Fabricate(:category) }
|
||||
let(:guardian) { Guardian.new }
|
||||
let(:guardian) { Guardian.basic_user }
|
||||
|
||||
before { SiteSetting.show_filter_by_solved_status = true }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ require "rails_helper"
|
|||
describe TopicAnswerMixin do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let(:post) { Fabricate(:post, topic: topic) }
|
||||
let(:guardian) { Guardian.new }
|
||||
let(:guardian) { Guardian.basic_user }
|
||||
|
||||
before do
|
||||
topic.custom_fields["accepted_answer_post_id"] = post.id
|
||||
|
|
|
@ -4,7 +4,7 @@ require "rails_helper"
|
|||
|
||||
describe UserCardSerializer do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:serializer) { described_class.new(user, scope: Guardian.new, root: false) }
|
||||
let(:serializer) { described_class.new(user, scope: Guardian.basic_user, root: false) }
|
||||
let(:json) { serializer.as_json }
|
||||
|
||||
it "accepted_answers serializes number of accepted answers" do
|
||||
|
|
Loading…
Reference in New Issue