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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

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

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

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

20
  # rubocop:disable Metrics/MethodLength
UNCOV
21
  def update
×
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 }
×
UNCOV
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 }
×
UNCOV
32
        end
×
UNCOV
33
      end
×
UNCOV
34
    else
×
UNCOV
35
      Rails.logger.warn("Unauthorized to update group #{@group.id} (current user: #{current_user.id})")
×
UNCOV
36
      redirect_to groups_path
×
UNCOV
37
    end
×
UNCOV
38
  end
×
39
  # rubocop:enable Metrics/MethodLength
40

41
  # This is a JSON only endpoint
UNCOV
42
  def add_admin
×
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
×
UNCOV
46
  end
×
47

48
  # This is a JSON only endpoint
UNCOV
49
  def add_submitter
×
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
×
UNCOV
54
  end
×
55

56
  # This is a JSON only endpoint
UNCOV
57
  def delete_user_from_group
×
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
×
UNCOV
62
  end
×
63

UNCOV
64
  private
×
65

UNCOV
66
    def check_and_render
×
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 }
×
UNCOV
71
      else
×
UNCOV
72
        render status: :ok, json: { message: "OK" }
×
UNCOV
73
      end
×
UNCOV
74
    end
×
75

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

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