summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-01 18:50:43 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 12:58:58 -0300
commit7d6a02aaae8572686aadb7f3cd01b1c0e39cfefd (patch)
tree2f022309f6731ed57b85b9536ca54fe9a87a612e /app
parent547d218e6bb25fb2b2fa13cd86f08c3ac1e69b8b (diff)
downloadgitlab-ce-7d6a02aaae8572686aadb7f3cd01b1c0e39cfefd.tar.gz
Handle formats at the controller level in Projects::BoardListsController
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/board_lists_controller.rb40
1 files changed, 18 insertions, 22 deletions
diff --git a/app/controllers/projects/board_lists_controller.rb b/app/controllers/projects/board_lists_controller.rb
index ab3a4f71bb9..0969fef6999 100644
--- a/app/controllers/projects/board_lists_controller.rb
+++ b/app/controllers/projects/board_lists_controller.rb
@@ -1,48 +1,40 @@
class Projects::BoardListsController < Projects::ApplicationController
+ respond_to :json
+
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def create
list = Boards::Lists::CreateService.new(project, list_params).execute
- respond_to do |format|
- if list.valid?
- format.json { render json: list.as_json(only: [:id, :list_type, :position], methods: [:title], include: { label: { only: [:id, :title, :color] } }) }
- else
- format.json { render json: list.errors, status: :unprocessable_entity }
- end
+ if list.valid?
+ render json: list.as_json(only: [:id, :list_type, :position], methods: [:title], include: { label: { only: [:id, :title, :color] } })
+ else
+ render json: list.errors, status: :unprocessable_entity
end
end
def update
service = Boards::Lists::MoveService.new(project, move_params)
- respond_to do |format|
- if service.execute
- format.json { head :ok }
- else
- format.json { head :unprocessable_entity }
- end
+ if service.execute
+ head :ok
+ else
+ head :unprocessable_entity
end
end
def destroy
service = Boards::Lists::DestroyService.new(project, params)
- respond_to do |format|
- if service.execute
- format.json { head :ok }
- else
- format.json { head :unprocessable_entity }
- end
+ if service.execute
+ head :ok
+ else
+ head :unprocessable_entity
end
end
private
- def record_not_found(exception)
- render json: { error: exception.message }, status: :not_found
- end
-
def list_params
params.require(:list).permit(:label_id)
end
@@ -50,4 +42,8 @@ class Projects::BoardListsController < Projects::ApplicationController
def move_params
params.require(:list).permit(:position).merge(id: params[:id])
end
+
+ def record_not_found(exception)
+ render json: { error: exception.message }, status: :not_found
+ end
end