show pending messages on posts
This commit is contained in:
@@ -14,6 +14,43 @@ RSpec.describe Domain::PostsController, type: :controller do
|
||||
allow(controller).to receive(:authorize).and_return(true)
|
||||
end
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns a successful response and renders the index template" do
|
||||
get :index
|
||||
expect(response).to be_successful
|
||||
expect(response).to render_template(:index)
|
||||
end
|
||||
|
||||
context "when post is pending scan" do
|
||||
let!(:post_pending_scan) do
|
||||
create(
|
||||
:domain_post_fa_post,
|
||||
scanned_at: nil,
|
||||
title: "Test Post Pending Scan",
|
||||
)
|
||||
end
|
||||
|
||||
it "displays 'Post pending scan' message" do
|
||||
get :index
|
||||
expect(response.body).to include("Post pending scan")
|
||||
end
|
||||
end
|
||||
|
||||
context "when post file is pending download" do
|
||||
let!(:post_with_pending_file) do
|
||||
create(
|
||||
:domain_post_fa_post,
|
||||
title: "Test Post with Pending File",
|
||||
).tap { |post| create(:domain_post_file, post: post, state: "pending") }
|
||||
end
|
||||
|
||||
it "displays 'File pending download' message" do
|
||||
get :index
|
||||
expect(response.body).to include("File pending download")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
shared_examples "a post" do
|
||||
it "returns a successful response and renders the show template" do
|
||||
@@ -37,6 +74,38 @@ RSpec.describe Domain::PostsController, type: :controller do
|
||||
let(:post) { create(:domain_post_e621_post) }
|
||||
it_behaves_like "a post"
|
||||
end
|
||||
|
||||
context "when post file is pending download" do
|
||||
let(:post) do
|
||||
create(
|
||||
:domain_post_fa_post,
|
||||
title: "Test Post with Pending File",
|
||||
).tap do |post|
|
||||
create(
|
||||
:domain_post_file,
|
||||
post: post,
|
||||
state: "pending",
|
||||
url_str: "https://example.com/image.jpg",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it "displays 'File pending download' message" do
|
||||
get :show, params: { id: post.to_param }
|
||||
expect(response.body).to include("File pending download")
|
||||
end
|
||||
end
|
||||
|
||||
context "when post has no file" do
|
||||
let(:post) do
|
||||
create(:domain_post_fa_post, title: "Test Post with No File")
|
||||
end
|
||||
|
||||
it "displays 'No file' message" do
|
||||
get :show, params: { id: post.to_param }
|
||||
expect(response.body).to include("No file")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #visual_search" do
|
||||
|
||||
Reference in New Issue
Block a user