Update blob entry handling and enhance staging configuration

- Changed the staging server port from 3000 to 3001 in the Procfile for better port management.
- Introduced a new BlobEntry model to replace BlobEntryP, ensuring a more consistent data structure across the application.
- Updated various controllers and views to utilize the new BlobEntry model, enhancing data retrieval and rendering processes.
- Added a new BlobEntriesController to manage blob entries, including a show action for retrieving content based on SHA256.
- Enhanced the Rakefile to enqueue periodic jobs for updating posts, improving background processing capabilities.
- Updated routes to reflect the new BlobEntry model and ensure proper resource handling.
- Improved tests for blob entry functionality, ensuring robust coverage and reliability in data handling.
This commit is contained in:
Dylan Knutson
2024-12-30 19:35:27 +00:00
parent 2681502c3e
commit 15c11b2b89
41 changed files with 608 additions and 168 deletions

View File

@@ -1,6 +1,6 @@
require "test_helper"
class BlobEntryPTest < ActiveSupport::TestCase
class BlobEntryTest < ActiveSupport::TestCase
test "building a blob works" do
blob = TestUtil.build_blob_entry
assert blob.valid?
@@ -20,17 +20,17 @@ class BlobEntryPTest < ActiveSupport::TestCase
assert_raises(ActiveRecord::ReadOnlyRecord) { model.destroy }
end
test "model dual-writes a BlobEntryP model" do
test "model dual-writes a BlobEntry model" do
model = TestUtil.build_blob_entry
model.save!
model_p = BlobEntryP.find_by(sha256: model.sha256)
model_p = BlobEntry.find_by(sha256: model.sha256)
assert_same_blob_entry model, model_p
end
test "ensure works for creating a blob entry" do
model = TestUtil.build_blob_entry
model.save!
model_p = BlobEntryP.ensure(model.sha256)
model_p = BlobEntry.ensure(model.sha256)
assert_same_blob_entry model, model_p
end

View File

@@ -53,14 +53,14 @@ class BlobFileTest < ActiveSupport::TestCase
["abcd1234", [2], %w[ab abcd1234]],
["abcd1234", [4, 2], %w[abcd 12 abcd1234]],
["abcd1234", [4, 2, 2], %w[abcd 12 34 abcd1234]],
["abcd1234", [2, 2, 1], %w[ab cd 1 abcd1234]]
["abcd1234", [2, 2, 1], %w[ab cd 1 abcd1234]],
]
test_cases.each do |sha256_hex, pattern, expected|
assert_equal BlobFile.path_segments(pattern, sha256_hex), expected
end
end
test "from an initialized BlobEntryP" do
test "from an initialized BlobEntry" do
blob_entry = TestUtil.build_blob_entry
blob_file = BlobFile.initialize_from_blob_entry(blob_entry)
assert blob_file.save

View File

@@ -31,7 +31,7 @@ module TestUtil
end
def self.build_blob_entry(content_type: "text/plain", contents: nil)
BlobEntryP.find_or_build(
BlobEntry.find_or_build(
content_type: content_type,
contents: contents || random_string(1024),
)