Open
Conversation
Test coverage89.77% line coverage reported by SimpleCov. |
Contributor
There was a problem hiding this comment.
Pull request overview
Implements Scratch asset persistence and retrieval in the API using ActiveStorage, aligning with the referenced ADR for Scratch project storage and enabling save/load of uploaded assets.
Changes:
- Added
ScratchAssetmodel + DB table for storing asset metadata and attaching uploaded files via ActiveStorage. - Implemented Scratch asset
show(redirect to blob) andcreate(store-once upload) endpoints and updated routes to include optionalformat. - Added request specs and a factory for creating Scratch assets with attachments; added middleware + gem to default content-type for binary uploads.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/features/scratch/showing_a_scratch_asset_spec.rb | Removes old placeholder “show SVG” request spec. |
| spec/features/scratch/creating_and_showing_a_scratch_asset_spec.rb | Adds request specs covering asset create + show redirect behavior. |
| spec/factories/scratch_assets.rb | Adds a scratch_asset factory with an attached fixture file. |
| db/schema.rb | Includes new scratch_assets table in schema. |
| db/migrate/20260310161646_create_scratch_assets.rb | Adds migration to create scratch_assets. |
| config/routes.rb | Updates Scratch asset create route to accept .:format. |
| config/application.rb | Inserts middleware to default POST content-type for scratch asset uploads. |
| app/models/scratch_asset.rb | Introduces ScratchAsset model with attachment and validations. |
| app/controllers/api/scratch/assets_controller.rb | Implements show redirect and create upload logic for assets. |
| Gemfile.lock | Adds rack_content_type_default dependency resolution. |
| Gemfile | Adds rack_content_type_default (and relocates flipper-ui). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| # frozen_string_literal: true | ||
|
|
||
| class ScratchAsset < ApplicationRecord | ||
| validates :filename, presence: true |
spec/features/scratch/creating_and_showing_a_scratch_asset_spec.rb
Outdated
Show resolved
Hide resolved
Comment on lines
38
to
40
| get '/assets/internalapi/asset/:id(.:format)/get/' => 'assets#show' | ||
| post '/assets/:id' => 'assets#create' | ||
| post '/assets/:id(.:format)' => 'assets#create' | ||
| end |
Comment on lines
+15
to
+21
| begin | ||
| filename_with_extension = "#{params[:id]}.#{params[:format]}" | ||
| ScratchAsset.find_or_create_by!(filename: filename_with_extension) do |a| | ||
| a.file.attach(io: request.body, filename: filename_with_extension) | ||
| end | ||
| rescue ActiveRecord::RecordNotUnique => e | ||
| logger.error(e) |
| def create | ||
| begin | ||
| filename_with_extension = "#{params[:id]}.#{params[:format]}" | ||
| ScratchAsset.find_or_create_by!(filename: filename_with_extension) do |a| |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
Points for consideration:
What's changed?
showandcreatefor Scratch assets using ActiveStorage.