gitlab-org--gitlab-foss/app/controllers/concerns/boards_actions.rb
charlieablett 27dd0b8e36 Use serialization for project boards
- Add serializers and Grape::Entity
- Replace to_json
- Add specs
2019-06-06 22:13:14 +12:00

46 lines
933 B
Ruby

# frozen_string_literal: true
module BoardsActions
include Gitlab::Utils::StrongMemoize
extend ActiveSupport::Concern
included do
include BoardsResponses
before_action :boards, only: :index
before_action :board, only: :show
end
def index
respond_with_boards
end
def show
# Add / update the board in the recent visits table
Boards::Visits::CreateService.new(parent, current_user).execute(board) if request.format.html?
respond_with_board
end
private
def boards
strong_memoize(:boards) do
Boards::ListService.new(parent, current_user).execute
end
end
def board
strong_memoize(:board) do
boards.find(params[:id])
end
end
def serializer
BoardSerializer.new(current_user: current_user)
end
def serialize_as_json(resource)
serializer.represent(resource, serializer: 'board', include_full_project_path: board.group_board?)
end
end