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

MarkUsProject / Markus / 20143075828

11 Dec 2025 06:18PM UTC coverage: 91.513%. Remained the same
20143075828

Pull #7763

github

web-flow
Merge 9f55e660a into 3421ef3b2
Pull Request #7763: Release 2.9.0

914 of 1805 branches covered (50.64%)

Branch coverage included in aggregate %.

1584 of 1666 new or added lines in 108 files covered. (95.08%)

573 existing lines in 35 files now uncovered.

43650 of 46892 relevant lines covered (93.09%)

121.63 hits per line

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

91.89
/app/controllers/api/tags_controller.rb
1
module Api
1✔
2
  # Api controller for tags
3
  # Uses Rails' RESTful routes (check 'rake routes' for the configured routes)
4
  class TagsController < MainApiController
1✔
5
    def index
1✔
6
      assignment = Assignment.find_by(id: params[:assignment_id])
4✔
7

8
      respond_to do |format|
4✔
9
        parent = assignment || current_course
4✔
10
        tags = parent.tags.includes(:role, :groupings).order(:name)
4✔
11

12
        tag_info = tags.map do |tag|
4✔
13
          {
14
            id: tag.id,
4✔
15
            name: tag.name,
16
            description: tag.description,
17
            creator: tag.role.display_name,
18
            use: tag.groupings.size
19
          }
20
        end
21
        format.xml do
4✔
22
          render xml: tag_info
2✔
23
        end
24
        format.json do
4✔
25
          render json: tag_info
2✔
26
        end
27
      end
28
    end
29

30
    # Creates a new instance of the tag.
31
    def create
1✔
32
      assignment = current_course.assignments.find_by(id: params[:assignment_id])
4✔
33
      new_tag = Tag.create!(course: current_course, role: current_role, assessment: assignment, **self.tag_params)
4✔
34
      if params[:grouping_id]
4✔
35
        grouping = assignment.groupings.find(params[:grouping_id])
3✔
36
        grouping.tags << new_tag
1✔
37
      end
38
    rescue StandardError => e
39
      render 'shared/http_status', locals: { code: '422', message: e.to_s }, status: :unprocessable_content
2✔
40
    else
41
      render 'shared/http_status',
2✔
42
             locals: { code: '201', message: HttpStatusHelper::ERROR_CODE['message']['201'] }, status: :created
43
    end
44

45
    def update
1✔
46
      tag = Tag.find_by(id: params[:id])
3✔
47
      if tag.nil?
3✔
48
        render 'shared/http_status', locals: { code: '404', message: I18n.t('tags.not_found') }, status: :not_found
×
49
      else
50
        begin
51
          tag.update!(**self.tag_params)
3✔
52
        rescue StandardError => e
NEW
53
          render 'shared/http_status', locals: { code: '422', message: e.to_s }, status: :unprocessable_content
×
54
        else
55
          render 'shared/http_status',
3✔
56
                 locals: { code: '200', message: HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok
57
        end
58
      end
59
    end
60

61
    def destroy
1✔
62
      tag = Tag.find_by(id: params[:id])
1✔
63
      if tag.nil?
1✔
64
        render 'shared/http_status', locals: { code: '404', message: I18n.t('tags.not_found') }, status: :not_found
×
65
      else
66
        tag.destroy!
1✔
67
        render 'shared/http_status',
1✔
68
               locals: { code: '200', message: HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok
69
      end
70
    end
71

72
    private
1✔
73

74
    def tag_params
1✔
75
      params.permit(:name, :description)
7✔
76
    end
77
  end
78
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