Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .opencode/skills/rails-controllers/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create
result = FacilityCreateService.call(facility_params)

if result.errors.any?
render json: { errors: result.errors }, status: :unprocessable_entity
render json: { errors: result.errors }, status: :unprocessable_content
else
render json: result.data, status: :created
end
Expand Down Expand Up @@ -62,7 +62,7 @@ end
- `401 Unauthorized` - Not authenticated
- `403 Forbidden` - Not authorized
- `404 Not Found` - Resource not found
- `422 Unprocessable Entity` - Validation errors
- `422 Unprocessable Content` - Validation errors
- `500 Internal Server Error` - Server error

## Response Formats
Expand All @@ -75,7 +75,7 @@ render json: @facility
render json: @facility, status: :ok

# JSON with errors
render json: { errors: ["Validation failed"] }, status: :unprocessable_entity
render json: { errors: ["Validation failed"] }, status: :unprocessable_content

# Redirect
redirect_to @facility, notice: "Success"
Expand Down Expand Up @@ -111,7 +111,7 @@ class FacilitiesController < ApplicationController
result = FacilityCreateService.call(facility_params)

if result.errors.any?
render json: { errors: result.errors }, status: :unprocessable_entity
render json: { errors: result.errors }, status: :unprocessable_content
else
render json: result.data, status: :created
end
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ gem 'rack-cors'
group :development, :test do
gem 'dotenv-rails'

gem "rspec-rails", "~> 7.1.1"
gem "rspec-rails", "~> 8.0"
gem "shoulda-matchers", ">= 6.2.0"
gem "capybara"
gem "rails-controller-testing"
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ GEM
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (7.1.1)
actionpack (>= 7.0)
activesupport (>= 7.0)
railties (>= 7.0)
rspec-rails (8.0.2)
actionpack (>= 7.2)
activesupport (>= 7.2)
railties (>= 7.2)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
Expand Down Expand Up @@ -525,7 +525,7 @@ DEPENDENCIES
rails-controller-testing
redis (~> 5.4.1)
requestjs-rails
rspec-rails (~> 7.1.1)
rspec-rails (~> 8.0)
rubocop (>= 1.81.1)
rubocop-packaging
rubocop-performance
Expand Down
3 changes: 2 additions & 1 deletion app/components/facilities/discard_reason_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def self.select_options
end

def call
VALID_REASONS[discard_reason] || "Unsupported value '#{discard_reason}'"
text = VALID_REASONS[discard_reason] || "Unsupported value '#{discard_reason}'"
tag.span(text)
end
end
2 changes: 1 addition & 1 deletion app/components/facilities/status_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def call
end

def call_title_only
title
tag.span(title)
end

private
Expand Down
2 changes: 0 additions & 2 deletions app/components/facilities/welcomes_icon_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Facilities::WelcomesIconComponent < ViewComponent::Base
def initialize(welcomes, variant: :full)
super()

Rails.logger.debug { "ICON: #{welcomes} => #{icon_location}" }

@variant = variant
@welcomes = welcomes.to_s.underscore.to_sym
end
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/admin/alerts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Admin::AlertsController < Admin::BaseController

def index; end

def show; end

def new
@alert = Alert.new(active: false) #(admin: false, verified: false)
@alert = Alert.new(active: false) # (admin: false, verified: false)
end

def show; end

def edit; end

def create
Expand All @@ -21,7 +21,7 @@ def create
else
flash.now[:alert] = "Failed to create alert. Errors: #{@alert.errors.full_messages.join('; ')}"

render action: :new, status: :unprocessable_entity
render action: :new, status: :unprocessable_content
end
end

Expand All @@ -31,7 +31,7 @@ def update
else
flash.now[:alert] = "Failed to update alert (id: #{@alert.id}). Errors: #{@alert.errors.full_messages.join('; ')}"

render action: :edit, status: :unprocessable_entity
render action: :edit, status: :unprocessable_content
end
end

Expand All @@ -44,7 +44,7 @@ def destroy
# Error when turning Welcome on.
flash[:error] = "Failed to delete Alert #{@alert.title} (id: #{@alert.id}). Errors: #{@alert.errors.full_messages.join('; ')}"

render action: :show, status: :unprocessable_entity
render action: :show, status: :unprocessable_content
end
end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/admin/facilities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def index; end

def show; end

def edit; end

def new
@facility = Facility.new(
zone: current_user.zones.first
)
end

def edit; end

def create
@facility = Facility.new(new_facility_params)

Expand All @@ -26,7 +26,7 @@ def create
else
flash.now[:alert] = "Failed to create facility. Errors: #{@facility.errors.full_messages.join('; ')}"

render action: :new, status: :unprocessable_entity
render action: :new, status: :unprocessable_content
end
end

Expand All @@ -42,7 +42,7 @@ def update
else
flash.now[:alert] = "Failed to update facility (id: #{@facility.id}). Errors: #{@facility.errors.full_messages.join('; ')}"

render action: :edit, status: :unprocessable_entity
render action: :edit, status: :unprocessable_content
end
end

Expand All @@ -55,7 +55,7 @@ def destroy
else
# Error when turning Welcome on.
flash[:alert] = "Failed to discard Facility #{@facility.name} (id: #{@facility.id}). Errors: #{@facility.errors.full_messages.join('; ')}"
render action: :show, status: :unprocessable_entity
render action: :show, status: :unprocessable_content
end
end

Expand Down
8 changes: 3 additions & 5 deletions app/controllers/admin/facility_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ class Admin::FacilityLocationsController < Admin::BaseController
before_action :load_location
before_action :search_and_load_locations

def index
end
def index; end

def new
end
def new; end

def create
@facility.assign_attributes(location_params)
Expand All @@ -29,7 +27,7 @@ def create
end
else
flash.now[:error] = location_params.inspect
render :new, status: :unprocessable_entity
render :new, status: :unprocessable_content
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/admin/notices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Admin::NoticesController < Admin::BaseController

def index; end

def show; end

def new
@notice = Notice.new(published: false, notice_type: :general)
end

def show; end

def edit; end

def create
Expand All @@ -21,7 +21,7 @@ def create
else
flash.now[:notice] = "Failed to create notice. Errors: #{@notice.errors.full_messages.join('; ')}"

render action: :new, status: :unprocessable_entity
render action: :new, status: :unprocessable_content
end
end

Expand All @@ -31,7 +31,7 @@ def update
else
flash.now[:notice] = "Failed to update notice (id: #{@notice.id}). Errors: #{@notice.errors.full_messages.join('; ')}"

render action: :edit, status: :unprocessable_entity
render action: :edit, status: :unprocessable_content
end
end

Expand All @@ -44,7 +44,7 @@ def destroy
# Error when turning Welcome on.
flash[:error] = "Failed to delete Notice #{@notice.title} (id: #{@notice.id}). Errors: #{@notice.errors.full_messages.join('; ')}"

render action: :show, status: :unprocessable_entity
render action: :show, status: :unprocessable_content
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create
else
flash.now[:alert] = "Failed to reset password for user #{user_description}. Errors: #{@user.errors.full_messages.join('; ')}"

render action: :new, status: :unprocessable_entity
render action: :new, status: :unprocessable_content
end
end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Admin::UsersController < Admin::BaseController

def index; end

def show; end

def new
@user = User.new(admin: false, verified: false)
end

def show; end

def edit; end

def create
Expand All @@ -21,7 +21,7 @@ def create
else
flash.now[:alert] = "Failed to create user. Errors: #{@user.errors.full_messages.join('; ')}"

render action: :new, status: :unprocessable_entity
render action: :new, status: :unprocessable_content
end
end

Expand All @@ -31,7 +31,7 @@ def update
else
flash.now[:alert] = "Failed to update user (id: #{@user.id}). Errors: #{@user.errors.full_messages.join('; ')}"

render action: :edit, status: :unprocessable_entity
render action: :edit, status: :unprocessable_content
end
end

Expand All @@ -44,7 +44,7 @@ def destroy
# Error when turning Welcome on.
flash[:error] = "Failed to delete User #{@user.name} (id: #{@user.id}, email: #{@user.email}). Errors: #{@user.errors.full_messages.join('; ')}"

render action: :show, status: :unprocessable_entity
render action: :show, status: :unprocessable_content
end
end

Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
module LinkvanApi
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.1
config.load_defaults 8.0

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"

# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
Expand Down Expand Up @@ -311,6 +311,6 @@

# Configs to improve compatibility with Hotwire/Turbo
# see: https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-%5BHotwire-Turbo-integration%5D
config.responder.error_status = :unprocessable_entity
config.responder.error_status = :unprocessable_content
config.responder.redirect_status = :see_other
end
30 changes: 0 additions & 30 deletions config/initializers/new_framework_defaults_8_0.rb

This file was deleted.

8 changes: 4 additions & 4 deletions spec/components/facilities/discard_reason_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
let(:discard_reason) { key }

it "returns the correct text" do
expect(component.call).to eq(expected_text)
expect(component.call).to have_text(expected_text)
end
end
end
Expand All @@ -42,7 +42,7 @@
let(:discard_reason) { key.to_s }

it "returns the correct text" do
expect(component.call).to eq(expected_text)
expect(component.call).to have_text(expected_text)
end
end
end
Expand All @@ -52,15 +52,15 @@
let(:discard_reason) { :invalid_reason }

it "returns error message" do
expect(component.call).to eq("Unsupported value 'invalid_reason'")
expect(component.call).to have_text("Unsupported value 'invalid_reason'")
end
end

context "with nil discard_reason" do
let(:discard_reason) { nil }

it "returns error message for nil" do
expect(component.call).to eq("Unsupported value ''")
expect(component.call).to have_text("Unsupported value ''")
end
end
end
Expand Down
Loading
Loading