Skip to content
This repository was archived by the owner on Nov 6, 2021. It is now read-only.

Commit 49e7977

Browse files
authored
Merge pull request #385 from rubyforgood/remove-unused-child-related-code
Remove unused child association & related endpoint
2 parents 516596a + 550e20e commit 49e7977

File tree

6 files changed

+11
-46
lines changed

6 files changed

+11
-46
lines changed

app/controllers/children_controller.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ def update
6565
end
6666
end
6767

68-
def destroy
69-
child = current_partner.children.find_by(id: params[:id])
70-
if child.present?
71-
child.destroy
72-
redirect_to children_url, notice: "Child was successfully destroyed."
73-
end
74-
end
75-
7668
private
7769

7870
def family

app/models/child.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
class Child < ApplicationRecord
2424
serialize :child_lives_with, Array
2525
belongs_to :family
26-
has_many :family_request_child, dependent: :destroy
27-
has_many :family_requests, through: :family_request_child
2826
has_many :child_item_requests, dependent: :destroy
2927

3028
include Filterable

config/routes.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
sessions: "users/sessions",
1010
invitations: "users/invitations"
1111
}
12-
# TODO: remove these two
13-
resources :children do
12+
resources :children, except: [:destroy] do
1413
post :active
1514
end
1615
resources :families

spec/requests/children_controller_spec.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

spec/controllers/children_controller_spec.rb renamed to spec/requests/children_spec.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
sign_in(user)
1010
end
1111

12+
describe "GET #index" do
13+
context "when specifying the csv format in the request" do
14+
it "responds correct Content-Type" do
15+
get children_path, headers: { "ACCEPT" => "text/csv" }
16+
expect(response.content_type).to eq "text/csv"
17+
end
18+
end
19+
end
20+
1221
describe "POST #create" do
1322
it "should create and redirect to child_path" do
1423
post children_path, params: { family_id: family.id, child: attributes_for(:child) }
@@ -30,15 +39,6 @@
3039
end
3140
end
3241

33-
describe "DELETE #destroy" do
34-
it "should destroy and redirect to child_path" do
35-
delete child_path(child)
36-
37-
expect(response).to redirect_to(children_path)
38-
expect(request.flash[:notice]).to eql "Child was successfully destroyed."
39-
end
40-
end
41-
4242
describe "POST #active" do
4343
it "should verify if child is active" do
4444
post child_active_path(child), params: { child_id: child.id }
@@ -47,3 +47,4 @@
4747
end
4848
end
4949
end
50+

spec/routing/children_routing_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,5 @@
2929
it "routes to #update via PATCH" do
3030
expect(patch: "/children/1").to route_to("children#update", id: "1")
3131
end
32-
33-
it "routes to #destroy" do
34-
expect(delete: "/children/1").to route_to("children#destroy", id: "1")
35-
end
3632
end
3733
end

0 commit comments

Comments
 (0)