This repository was archived by the owner on Nov 6, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +42
-12
lines changed
Expand file tree Collapse file tree 4 files changed +42
-12
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 2323class 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments