• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sleede / fab-manager / #106

pending completion
#106

push

coveralls-ruby

sylvainbx
Merge branch 'dev' for release 6.0.0

704 of 704 new or added lines in 168 files covered. (100.0%)

7919 of 13474 relevant lines covered (58.77%)

15.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/controllers/api/product_categories_controller.rb
1
# frozen_string_literal: true
2

3
# API Controller for resources of type ProductCategory
4
# ProductCategories are used to group Products
5
class API::ProductCategoriesController < API::APIController
×
6
  before_action :authenticate_user!, except: :index
×
7
  before_action :set_product_category, only: %i[update destroy position]
×
8

9
  def index
×
10
    @product_categories = ProductCategoryService.list
×
11
  end
×
12

13
  def show
×
14
    @product_category = ProductCategory.friendly.find(params[:id])
×
15
  end
×
16

17
  def create
×
18
    authorize ProductCategory
×
19
    @product_category = ProductCategory.new(product_category_params)
×
20
    if @product_category.save
×
21
      render status: :created
×
22
    else
×
23
      render json: @product_category.errors.full_messages, status: :unprocessable_entity
×
24
    end
×
25
  end
×
26

27
  def update
×
28
    authorize @product_category
×
29

30
    if @product_category.update(product_category_params)
×
31
      render status: :ok
×
32
    else
×
33
      render json: @product_category.errors.full_messages, status: :unprocessable_entity
×
34
    end
×
35
  end
×
36

37
  def position
×
38
    authorize @product_category
×
39
    render json: @product_category, status: :not_modified and return if @product_category.position == params[:position]
×
40

41
    if @product_category.insert_at(params[:position])
×
42
      render :show
×
43
    else
×
44
      render json: @product_category.errors.full_messages, status: :unprocessable_entity
×
45
    end
×
46
  end
×
47

48
  def destroy
×
49
    authorize @product_category
×
50
    ProductCategoryService.destroy(@product_category)
×
51
    head :no_content
×
52
  end
×
53

54
  private
×
55

56
  def set_product_category
×
57
    @product_category = ProductCategory.find(params[:id])
×
58
  end
×
59

60
  def product_category_params
×
61
    params.require(:product_category).permit(:name, :parent_id, :slug)
×
62
  end
×
63
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc