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

Commit 18e23b9

Browse files
committed
Remove unused child association & related endpoint
1 parent 516596a commit 18e23b9

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
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_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require "rails_helper"
2+
3+
RSpec.describe "Children", type: :request do
4+
let(:partner) { create(:partner) }
5+
let(:family) { create(:family, partner_id: partner.id) }
6+
7+
before do
8+
user = create(:user, partner: partner)
9+
sign_in(user)
10+
end
11+
12+
describe "POST #create" do
13+
it "should create and redirect to child_path" do
14+
post children_path, params: { family_id: family.id, child: attributes_for(:child) }
15+
16+
select_child = Child.select(:id).last
17+
expect(response).to redirect_to(child_path(select_child.id))
18+
expect(request.flash[:notice]).to eql "Child was successfully created."
19+
end
20+
end
21+
22+
let(:child) { create(:child, family_id: family.id) }
23+
24+
describe "PUT #update" do
25+
it "should update and redirect to child_path" do
26+
put child_path(child), params: { child: attributes_for(:child) }
27+
28+
expect(response).to redirect_to(child_path(child.id))
29+
expect(request.flash[:notice]).to eql "Child was successfully updated."
30+
end
31+
end
32+
33+
describe "POST #active" do
34+
it "should verify if child is active" do
35+
post child_active_path(child), params: { child_id: child.id }
36+
37+
expect(child.active).to eq true
38+
end
39+
end
40+
end
41+

0 commit comments

Comments
 (0)