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

pulibrary / pdc_describe / 35525209-8c8b-426d-b992-849111d800ff

02 Jun 2026 07:47PM UTC coverage: 41.528% (-54.0%) from 95.52%
35525209-8c8b-426d-b992-849111d800ff

Pull #2324

circleci

carolyncole
Updating code to allow for multiple WorkActivity classes based on the transition
Pull Request #2324: Updating code to allow for multiple WorkActivity classes based on the…

35 of 87 new or added lines in 6 files covered. (40.23%)

2096 existing lines in 79 files now uncovered.

1647 of 3966 relevant lines covered (41.53%)

4.81 hits per line

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

25.53
/app/controllers/groups_controller.rb
1
# frozen_string_literal: true
2
class GroupsController < ApplicationController
1✔
3
  def index; end
1✔
4

5
  def show
1✔
UNCOV
6
    @group = Group.find(params[:id])
×
UNCOV
7
    @can_edit = can_edit?
×
8
  end
9

10
  def edit
1✔
UNCOV
11
    @group = Group.find(params[:id])
×
UNCOV
12
    if can_edit?
×
UNCOV
13
      render "edit"
×
14
    else
UNCOV
15
      Rails.logger.warn("Unauthorized to edit group #{@group.id} (current user: #{current_user.id})")
×
UNCOV
16
      redirect_to groups_path
×
17
    end
18
  end
19

20
  # rubocop:disable Metrics/MethodLength
21
  def update
1✔
UNCOV
22
    @group = Group.find(params[:id])
×
UNCOV
23
    if can_edit?
×
UNCOV
24
      respond_to do |format|
×
UNCOV
25
        if @group.update(group_params)
×
UNCOV
26
          format.html { redirect_to group_url(@group), notice: "Group was successfully updated." }
×
UNCOV
27
          format.json { render :show, status: :ok, location: @group }
×
28
        else
29
          # return 200 so the loadbalancer doesn't capture the error
UNCOV
30
          format.html { render :edit }
×
UNCOV
31
          format.json { render json: @group.errors }
×
32
        end
33
      end
34
    else
UNCOV
35
      Rails.logger.warn("Unauthorized to update group #{@group.id} (current user: #{current_user.id})")
×
UNCOV
36
      redirect_to groups_path
×
37
    end
38
  end
39
  # rubocop:enable Metrics/MethodLength
40

41
  # This is a JSON only endpoint
42
  def add_admin
1✔
UNCOV
43
    @group = Group.find(params[:id])
×
UNCOV
44
    @group.add_administrator(current_user, User.new_for_uid(params[:uid]))
×
UNCOV
45
    check_and_render
×
46
  end
47

48
  # This is a JSON only endpoint
49
  def add_submitter
1✔
UNCOV
50
    @group = Group.find(params[:id])
×
UNCOV
51
    user = @group.default_user(params[:uid])
×
UNCOV
52
    @group.add_submitter(current_user, user)
×
UNCOV
53
    check_and_render
×
54
  end
55

56
  # This is a JSON only endpoint
57
  def delete_user_from_group
1✔
UNCOV
58
    @group = Group.find(params[:id])
×
UNCOV
59
    role = params[:role] || "submitter"
×
UNCOV
60
    @group.delete_permission(current_user, User.find_by(uid: params[:uid]), role)
×
UNCOV
61
    check_and_render
×
62
  end
63

64
  private
1✔
65

66
    def check_and_render
1✔
UNCOV
67
      if @group.errors.count > 0 && @group.errors.first.message == "Unauthorized"
×
UNCOV
68
        render status: :unauthorized, json: { message: "Unauthorized" }
×
UNCOV
69
      elsif @group.errors.count > 0
×
UNCOV
70
        render status: :bad_request, json: { message: @group.errors.first.message }
×
71
      else
UNCOV
72
        render status: :ok, json: { message: "OK" }
×
73
      end
74
    end
75

76
    # Only allow trusted parameters through.
77
    def group_params
1✔
UNCOV
78
      params.require(:group).permit([:title, :description])
×
79
    end
80

81
    def can_edit?
1✔
UNCOV
82
      current_user.can_admin? @group
×
83
    end
84
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