show pending messages on posts

This commit is contained in:
Dylan Knutson
2025-07-25 19:15:58 +00:00
parent bd6246d29a
commit 56ed78faaf
7 changed files with 102 additions and 7 deletions

View File

@@ -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