Update Issue Board API to handle with has_many association

parent d1458d92
...@@ -22,13 +22,7 @@ module API ...@@ -22,13 +22,7 @@ module API
segment ':id/boards/:board_id' do segment ':id/boards/:board_id' do
helpers do helpers do
def project_board def project_board
board = user_project.boards.first user_project.boards.find(params[:board_id])
if params[:board_id] == board.id
board
else
not_found!('Board')
end
end end
def board_lists def board_lists
...@@ -92,12 +86,12 @@ module API ...@@ -92,12 +86,12 @@ module API
requires :position, type: Integer, desc: 'The position of the list' requires :position, type: Integer, desc: 'The position of the list'
end end
put '/lists/:list_id' do put '/lists/:list_id' do
list = project_board.lists.movable.find(params[:list_id]) list = board_lists.find(params[:list_id])
authorize!(:admin_list, user_project) authorize!(:admin_list, user_project)
service = ::Boards::Lists::MoveService.new(user_project, current_user, service = ::Boards::Lists::MoveService.new(user_project, current_user,
{ position: params[:position] }) { position: params[:position].to_i })
if service.execute(list) if service.execute(list)
present list, with: Entities::List present list, with: Entities::List
......
...@@ -51,7 +51,7 @@ describe API::API, api: true do ...@@ -51,7 +51,7 @@ describe API::API, api: true do
end end
context "when authenticated" do context "when authenticated" do
it "returns the project issue board" do it "returns the project issue boards" do
get api(base_url, user) get api(base_url, user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment