tests: fix broken tests.
This commit is contained in:
@@ -42,11 +42,11 @@ class PostPreviewComponentTest < ViewComponent::TestCase
|
|||||||
|
|
||||||
context "for a post with restricted tags" do
|
context "for a post with restricted tags" do
|
||||||
setup do
|
setup do
|
||||||
Danbooru.config.stubs(:restricted_tags).returns(["touhou"])
|
|
||||||
@post = create(:post, tag_string: "touhou")
|
@post = create(:post, tag_string: "touhou")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "should be visible to Gold users" do
|
should "should be visible to Gold users" do
|
||||||
|
@post.stubs(:levelblocked?).returns(false)
|
||||||
node = render_preview(@post, current_user: create(:gold_user))
|
node = render_preview(@post, current_user: create(:gold_user))
|
||||||
|
|
||||||
assert_equal(post_path(@post), node.css("article a").attr("href").value)
|
assert_equal(post_path(@post), node.css("article a").attr("href").value)
|
||||||
@@ -54,6 +54,7 @@ class PostPreviewComponentTest < ViewComponent::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not be visible to Members" do
|
should "not be visible to Members" do
|
||||||
|
@post.stubs(:levelblocked?).returns(true)
|
||||||
node = render_preview(@post, current_user: create(:user))
|
node = render_preview(@post, current_user: create(:user))
|
||||||
assert_equal("", node.to_s)
|
assert_equal("", node.to_s)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -412,17 +412,18 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
context "with restricted posts" do
|
context "with restricted posts" do
|
||||||
setup do
|
setup do
|
||||||
Danbooru.config.stubs(:restricted_tags).returns(["tagme"])
|
|
||||||
as(@user) { @post.update!(tag_string: "tagme") }
|
as(@user) { @post.update!(tag_string: "tagme") }
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not show restricted posts if user doesn't have permission" do
|
should "not show restricted posts if user doesn't have permission" do
|
||||||
|
Post.any_instance.stubs(:levelblocked?).returns(true)
|
||||||
get posts_path
|
get posts_path
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "#post_#{@post.id}", 0
|
assert_select "#post_#{@post.id}", 0
|
||||||
end
|
end
|
||||||
|
|
||||||
should "show restricted posts if user has permission" do
|
should "show restricted posts if user has permission" do
|
||||||
|
Post.any_instance.stubs(:levelblocked?).returns(false)
|
||||||
get_auth posts_path, create(:gold_user)
|
get_auth posts_path, create(:gold_user)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "#post_#{@post.id}", 1
|
assert_select "#post_#{@post.id}", 1
|
||||||
|
|||||||
Reference in New Issue
Block a user