/posts.atom: fix banned posts being visible to Members.
Bug: /posts.atom only hid loli/shota, not banned posts and not unsafe posts when safe mode was on.
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<author><name><%= Danbooru.config.app_name %></name></author>
|
<author><name><%= Danbooru.config.app_name %></name></author>
|
||||||
|
|
||||||
<% Danbooru.config.select_posts_visible_to_user(CurrentUser.user, @posts).each do |post| %>
|
<% @posts.select(&:visible?).each do |post| %>
|
||||||
<entry>
|
<entry>
|
||||||
<title><%= post.presenter.humanized_essential_tag_string %></title>
|
<title><%= post.presenter.humanized_essential_tag_string %></title>
|
||||||
<link href="<%= post_url(post) %>" rel="alternate"/>
|
<link href="<%= post_url(post) %>" rel="alternate"/>
|
||||||
|
|||||||
@@ -405,10 +405,6 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_posts_visible_to_user(user, posts)
|
|
||||||
posts.select {|x| can_user_see_post?(user, x)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def max_appeals_per_day
|
def max_appeals_per_day
|
||||||
1
|
1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
context "The posts controller" do
|
context "The posts controller" do
|
||||||
setup do
|
setup do
|
||||||
PopularSearchService.stubs(:enabled?).returns(false)
|
PopularSearchService.stubs(:enabled?).returns(false)
|
||||||
|
|
||||||
@user = travel_to(1.month.ago) {create(:user)}
|
@user = travel_to(1.month.ago) {create(:user)}
|
||||||
as_user do
|
as_user do
|
||||||
@post = create(:post, :tag_string => "aaaa")
|
@post = create(:post, :tag_string => "aaaa")
|
||||||
@@ -92,6 +92,30 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with the .atom format" do
|
||||||
|
should "render without tags" do
|
||||||
|
get posts_path(format: :atom)
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_select "entry", 1
|
||||||
|
end
|
||||||
|
|
||||||
|
should "render with tags" do
|
||||||
|
get posts_path(format: :atom), params: { tags: "aaaa" }
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_select "entry", 1
|
||||||
|
end
|
||||||
|
|
||||||
|
should "hide restricted posts" do
|
||||||
|
@post.update(is_banned: true)
|
||||||
|
get posts_path(format: :atom)
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_select "entry", 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "show_seq action" do
|
context "show_seq action" do
|
||||||
|
|||||||
Reference in New Issue
Block a user