Skip to content

Commit eb2976c

Browse files
committed
Make verify/reject member routes of school
This feels more idiomatic as these actions operate on a single school.
1 parent 1970115 commit eb2976c

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

app/controllers/admin/schools_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Admin
44
class SchoolsController < Admin::ApplicationController
55
def verify_school
6-
school_id = params[:school_id]
6+
school_id = params[:id]
77
service = SchoolVerificationService.new(school_id)
88

99
if service.verify
@@ -16,7 +16,7 @@ def verify_school
1616
end
1717

1818
def reject_school
19-
school_id = params[:school_id]
19+
school_id = params[:id]
2020
service = SchoolVerificationService.new(school_id)
2121

2222
if service.reject

app/views/admin/schools/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ as well as a link to its edit page.
3232

3333
<%= link_to(
3434
t("administrate.actions.verify_school"),
35-
admin_school_verify_school_path(page.resource),
35+
verify_school_admin_school_path(page.resource),
3636
class: "button button--verify",
3737
method: :post,
3838
style: "background-color: green; margin: 5px;",
@@ -41,7 +41,7 @@ as well as a link to its edit page.
4141

4242
<%= link_to(
4343
t("administrate.actions.reject_school"),
44-
admin_school_reject_school_path(page.resource),
44+
reject_school_admin_school_path(page.resource),
4545
class: "button button--danger",
4646
method: :patch,
4747
style: "background-color: hsla(0, 88%, 33%, 1); margin: 5px 5px 5px 0;",

config/routes.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
end
1212

1313
resources :schools, only: %i[index show edit update] do
14-
post :verify_school
15-
patch :reject_school
14+
member do
15+
post :verify_school
16+
patch :reject_school
17+
end
1618
end
1719

1820
resources :school_classes, only: %i[show]

spec/features/admin/schools_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
stub_user_info_api_for(creator)
7676
allow(SchoolVerificationService).to receive(:new).with(school.id).and_return(verification_service)
7777

78-
post admin_school_verify_school_path(school)
78+
post verify_school_admin_school_path(school)
7979
end
8080

8181
it 'redirects to school path' do
@@ -117,7 +117,7 @@
117117
stub_user_info_api_for(creator)
118118
allow(SchoolVerificationService).to receive(:new).with(school.id).and_return(verification_service)
119119

120-
patch admin_school_reject_school_path(school)
120+
patch reject_school_admin_school_path(school)
121121
end
122122

123123
it 'redirects to school path' do

0 commit comments

Comments
 (0)