tests: fix broken tests.

This commit is contained in:
evazion
2021-12-16 01:27:10 -06:00
parent a62ae69740
commit c3f61a5888
2 changed files with 4 additions and 2 deletions

View File

@@ -42,11 +42,11 @@ class PostPreviewComponentTest < ViewComponent::TestCase
context "for a post with restricted tags" do
setup do
Danbooru.config.stubs(:restricted_tags).returns(["touhou"])
@post = create(:post, tag_string: "touhou")
end
should "should be visible to Gold users" do
@post.stubs(:levelblocked?).returns(false)
node = render_preview(@post, current_user: create(:gold_user))
assert_equal(post_path(@post), node.css("article a").attr("href").value)
@@ -54,6 +54,7 @@ class PostPreviewComponentTest < ViewComponent::TestCase
end
should "not be visible to Members" do
@post.stubs(:levelblocked?).returns(true)
node = render_preview(@post, current_user: create(:user))
assert_equal("", node.to_s)
end

View File

@@ -412,17 +412,18 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
context "with restricted posts" do
setup do
Danbooru.config.stubs(:restricted_tags).returns(["tagme"])
as(@user) { @post.update!(tag_string: "tagme") }
end
should "not show restricted posts if user doesn't have permission" do
Post.any_instance.stubs(:levelblocked?).returns(true)
get posts_path
assert_response :success
assert_select "#post_#{@post.id}", 0
end
should "show restricted posts if user has permission" do
Post.any_instance.stubs(:levelblocked?).returns(false)
get_auth posts_path, create(:gold_user)
assert_response :success
assert_select "#post_#{@post.id}", 1