mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 17:53:44 +08:00
Miscellaneous fixes from PR#3000
FIX: Don't require login to view post raw FIX: Don't submit read-guidelines for anonymous users (causes unnecessary 403 errors from ensure_logged_in) FIX: Don't pass nil to an array serializer
This commit is contained in:
parent
a6ce188f35
commit
85a7b925c7
|
@ -3,7 +3,9 @@ export default Em.ObjectController.extend({
|
|||
|
||||
actions: {
|
||||
markFaqRead: function() {
|
||||
Discourse.ajax("/users/read-faq", { method: "POST" });
|
||||
if (Discourse.User.current()) {
|
||||
Discourse.ajax("/users/read-faq", { method: "POST" });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -55,9 +55,11 @@ class TopicsController < ApplicationController
|
|||
begin
|
||||
@topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts)
|
||||
rescue Discourse::NotFound
|
||||
topic = Topic.find_by(slug: params[:id].downcase) if params[:id]
|
||||
raise Discourse::NotFound unless topic
|
||||
redirect_to_correct_topic(topic, opts[:post_number]) && return
|
||||
if params[:id]
|
||||
topic = Topic.find_by(slug: params[:id].downcase)
|
||||
return redirect_to_correct_topic(topic, opts[:post_number]) if topic
|
||||
end
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
|
||||
page = params[:page].to_i
|
||||
|
@ -150,8 +152,9 @@ class TopicsController < ApplicationController
|
|||
[:title, :raw].each { |key| check_length_of(key, params[key]) }
|
||||
|
||||
# Only suggest similar topics if the site has a minimum amount of topics present.
|
||||
topics = Topic.similar_to(title, raw, current_user).to_a if Topic.count_exceeds_minimum?
|
||||
return render json: [] unless Topic.count_exceeds_minimum?
|
||||
|
||||
topics = Topic.similar_to(title, raw, current_user).to_a
|
||||
render_serialized(topics, BasicTopicSerializer)
|
||||
end
|
||||
|
||||
|
|
|
@ -799,4 +799,26 @@ describe PostsController do
|
|||
|
||||
end
|
||||
|
||||
describe "view raw" do
|
||||
describe "by ID" do
|
||||
it "can be viewed by anonymous" do
|
||||
post = Fabricate(:post, raw: "123456789")
|
||||
xhr :get, :markdown_id, id: post.id
|
||||
response.should be_success
|
||||
response.body.should == "123456789"
|
||||
end
|
||||
end
|
||||
|
||||
describe "by post number" do
|
||||
it "can be viewed by anonymous" do
|
||||
topic = Fabricate(:topic)
|
||||
post = Fabricate(:post, topic: topic, post_number: 1, raw: "123456789")
|
||||
post.save
|
||||
xhr :get, :markdown_num, topic_id: topic.id, post_number: 1
|
||||
response.should be_success
|
||||
response.body.should == "123456789"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user