Skip to content

Commit

Permalink
refs #2 deleteでdel_flgがアップデートされているか確認
Browse files Browse the repository at this point in the history
  • Loading branch information
hamapu committed Sep 29, 2019
1 parent c508131 commit 1caee57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/controllers/issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ def create

def update
if Issue.where( id: issue_params[:id] ).update( title: issue_params[:title], body: issue_params[:body], kind: issue_params[:kind] )
render_ok(issue_params)
issue = Issue.find(issue_params[:id])
render_ok(issue)
else
render_ng(400, issue.errors)
end
end

def delete
if Issue.where( id: issue_params[:id] ).update( title: issue_params[:del_flg] )
render_ok(issue_params)
if Issue.where( id: issue_params[:id] ).update( del_flg: issue_params[:del_flg] )
issue = Issue.find(issue_params[:id])
render_ok(issue)
else
render_ng(400, issue.errors)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/issues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
{ issue: { id: target.id, del_flg: 1 } }
}
before { post "/issues/delete", params: del_params }
let(:upd_response_body) { JSON.parse(response.body, object_class: OpenStruct) }
let(:del_response_body) { JSON.parse(response.body, object_class: OpenStruct) }
it { expect(response.code).to eq "200" }

it { expect(del_response_body.payload.del_flg.to_i).to eq 1 }
end

end

0 comments on commit 1caee57

Please sign in to comment.