Skip to content

Default Custom Field Format Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make new custom-field forms default to visible Text format instead of first alphabetically sorted format.

Architecture: Initialize new custom-field instances with internal format string in controller lifecycle before safe request attributes are applied. This keeps model state, selected option, and format-specific partial consistent while preserving explicit user selections.

Tech Stack: Ruby 4.0, Rails 8.1, RSpec controller specs


Task 1: Default new custom fields to Text

Files: - Modify: app/controllers/custom_fields_controller.rb:192-201 - Test: spec/controllers/custom_fields_controller_spec.rb

  • [ ] Step 1: Write failing controller specs

Add request coverage under a describe "GET #new" block:

describe "GET #new" do
  subject(:request) { get :new, params: }

  let(:params) { { type: "IssueCustomField" } }

  it "defaults field format to text" do
    request
    expect(assigns(:custom_field).field_format).to eq("string")
  end

  context "with an explicitly selected format" do
    let(:params) { { type: "IssueCustomField", custom_field: { field_format: "float" } } }

    it "keeps selected field format" do
      request
      expect(assigns(:custom_field).field_format).to eq("float")
    end
  end
end
  • [ ] Step 2: Run specs and verify red state

Run: bundle exec rspec spec/controllers/custom_fields_controller_spec.rb

Expected: default-format example fails because actual format is blank; explicit-format example passes.

  • [ ] Step 3: Implement minimal default

Update initialization in build_new_custom_field:

@custom_field = CustomField.new_subclass_instance(params[:type], field_format: "string")

Keep subsequent safe-attribute assignment unchanged so explicit request value overrides default.

  • [ ] Step 4: Run focused specs

Run: bundle exec rspec spec/controllers/custom_fields_controller_spec.rb

Expected: all examples pass.

  • [ ] Step 5: Run Ruby style checks

Run: bundle exec rubocop app/controllers/custom_fields_controller.rb spec/controllers/custom_fields_controller_spec.rb

Expected: no offenses.

  • [ ] Step 6: Commit implementation
git add app/controllers/custom_fields_controller.rb spec/controllers/custom_fields_controller_spec.rb docs/superpowers/specs/2026-08-05-default-custom-field-format-design.md docs/superpowers/plans/2026-08-05-default-custom-field-format.md
git commit -m "feat(custom_fields): default new fields to text format"