diff --git a/Procfile.staging b/Procfile.staging
index 37d10b8f..b1a65f51 100644
--- a/Procfile.staging
+++ b/Procfile.staging
@@ -2,4 +2,4 @@ rails: RAILS_ENV=staging HTTP_PORT=3001 bundle exec thrust ./bin/rails server
wp-client: RAILS_ENV=development HMR=true ./bin/webpacker-dev-server
wp-server: RAILS_ENV=development HMR=true SERVER_BUNDLE_ONLY=yes ./bin/webpacker --watch
css: RAILS_ENV=development yarn "build:css[debug]" --watch
-prometheus_exporter: RAILS_ENV=staging bundle exec prometheus_exporter --bind 0.0.0.0 --prefix redux_ --label '{"environment": "staging"}'
+prometheus-exporter: RAILS_ENV=staging bundle exec prometheus_exporter --bind 0.0.0.0 --prefix redux_ --label '{"environment": "staging"}'
diff --git a/app/helpers/domain/posts_helper.rb b/app/helpers/domain/posts_helper.rb
index 5ab60b75..051041ca 100644
--- a/app/helpers/domain/posts_helper.rb
+++ b/app/helpers/domain/posts_helper.rb
@@ -75,10 +75,12 @@ module Domain::PostsHelper
file
end
- sig { params(post: Domain::Post).returns(T.nilable(String)) }
+ sig { params(post: Domain::Post).returns(T.any(T.nilable(String), Symbol)) }
def gallery_file_info_for_post(post)
+ return :post_pending if post.pending_scan?
file = post.primary_file_for_view
return nil unless file.present?
+ return :file_pending if file.state_pending?
return nil unless file.state_ok?
return nil unless file.log_entry_id.present?
content_type = file.log_entry&.content_type || ""
diff --git a/app/models/domain/post.rb b/app/models/domain/post.rb
index 5cae2830..c8d50050 100644
--- a/app/models/domain/post.rb
+++ b/app/models/domain/post.rb
@@ -162,6 +162,11 @@ class Domain::Post < ReduxApplicationRecord
:id
end
+ sig { overridable.returns(T::Boolean) }
+ def pending_scan?
+ false
+ end
+
sig { abstract.returns(T.nilable(String)) }
def title
end
diff --git a/app/models/domain/post/fa_post.rb b/app/models/domain/post/fa_post.rb
index 58bc46b7..94206937 100644
--- a/app/models/domain/post/fa_post.rb
+++ b/app/models/domain/post/fa_post.rb
@@ -100,6 +100,11 @@ class Domain::Post::FaPost < Domain::Post
self.file
end
+ sig { override.returns(T::Boolean) }
+ def pending_scan?
+ scanned_at.nil?
+ end
+
sig { override.returns(T.nilable(String)) }
def description_html_for_view
description
diff --git a/app/views/domain/posts/_as_gallery_item.html.erb b/app/views/domain/posts/_as_gallery_item.html.erb
index 841e535d..37a89685 100644
--- a/app/views/domain/posts/_as_gallery_item.html.erb
+++ b/app/views/domain/posts/_as_gallery_item.html.erb
@@ -13,10 +13,16 @@
alt: post.title_for_view %>
<% end %>
<% elsif file_info = gallery_file_info_for_post(post) %>
-
-
- <%= file_info %>, <%= gallery_file_size_for_post(post) %>
-
+ <% if file_info == :post_pending %>
+ Post pending scan
+ <% elsif file_info == :file_pending %>
+ File pending download
+ <% else %>
+
+
+ <%= file_info %>, <%= gallery_file_size_for_post(post) %>
+
+ <% end %>
<% else %>
No file available
<% end %>
diff --git a/app/views/domain/posts/default/_section_primary_file.html.erb b/app/views/domain/posts/default/_section_primary_file.html.erb
index d02e2451..fab1c3ec 100644
--- a/app/views/domain/posts/default/_section_primary_file.html.erb
+++ b/app/views/domain/posts/default/_section_primary_file.html.erb
@@ -1,6 +1,7 @@
<% if policy(post).view_file? %>
+ <% file = post.primary_file_for_view %>
- <% if (log_entry = post.primary_file_for_view&.log_entry) %>
+ <% if file.present? && (log_entry = file.log_entry) %>
<% if log_entry.status_code == 200 %>
<%= render partial: "log_entries/content_container",
locals: {
@@ -19,6 +20,13 @@
<% end %>
+ <% elsif file.present? && file.state_pending? %>
+
+
+
+ File pending download
+
+
<% else %>
diff --git a/spec/controllers/domain/posts_controller_spec.rb b/spec/controllers/domain/posts_controller_spec.rb
index 9c9e5353..b796d194 100644
--- a/spec/controllers/domain/posts_controller_spec.rb
+++ b/spec/controllers/domain/posts_controller_spec.rb
@@ -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