Skip to content

Commit 6c87e05

Browse files
authored
Remove CasesController (#35)
- Got rid of unnecessary redirect when case not found - Remove CasesController - Change superclass of PassportCasesController to ApplicationController - Add index.html.erb for PassportCasesController Eliminate the concept of reusable controllers and instead focus on reusable views. Controllers are often tied to application specific middleware logic such as authentication.
1 parent b3869a5 commit 6c87e05

5 files changed

Lines changed: 41 additions & 43 deletions

File tree

template/{{app_name}}/engines/flex/app/controllers/flex/cases_controller.rb

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
class PassportCasesController < Flex::CasesController
1+
class PassportCasesController < ApplicationController
2+
def index
3+
@cases = PassportCase.order(created_at: :desc)
4+
.all
5+
end
6+
7+
def closed
8+
@cases = PassportCase.where(status: "closed")
9+
.order(created_at: :desc)
10+
render :index
11+
end
12+
13+
def new
14+
end
15+
16+
def create
17+
end
18+
19+
def show
20+
@case = PassportCase.find(params[:id])
21+
end
22+
23+
def edit
24+
end
25+
26+
def update
27+
end
28+
29+
def model_class
30+
controller_path.classify.constantize
31+
end
232
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= render template: 'flex/cases/index', locals: { model_class: PassportCase } %>

template/{{app_name}}/engines/flex/spec/dummy/app/views/passport_cases/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
<button class="usa-button usa-button--outline">Reject</button>
99
<% end %>
1010

11-
<%= render template: 'flex/cases/show' %>
11+
<%= render template: 'flex/cases/show', locals: { model_class: PassportCase } %>

template/{{app_name}}/engines/flex/spec/dummy/spec/requests/passport_cases_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
require 'rails_helper'
22

33
RSpec.describe "PassportCases", type: :request do
4+
describe "GET /index" do
5+
it "returns http success" do
6+
get "/passport_cases"
7+
expect(response).to have_http_status(:success)
8+
end
9+
end
10+
411
describe "GET /show" do
512
let!(:passport_case) { PassportCase.create }
613

@@ -11,7 +18,7 @@
1118

1219
it "returns redirects if case not found" do
1320
get "/passport_cases/00000000"
14-
expect(response).to have_http_status(:redirect)
21+
expect(response).to have_http_status(:not_found)
1522
end
1623
end
1724
end

0 commit comments

Comments
 (0)