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

pulibrary / tigerdata-app / c1b95eca-1a93-46ae-84a7-6db974460d57

06 Aug 2025 07:39PM UTC coverage: 75.714% (+0.04%) from 75.677%
c1b95eca-1a93-46ae-84a7-6db974460d57

Pull #1680

circleci

web-flow
Merge branch 'main' into 1606-user-edit
Pull Request #1680: Add edit screens for Users

27 of 32 new or added lines in 1 file covered. (84.38%)

2201 of 2907 relevant lines covered (75.71%)

177.67 hits per line

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

86.49
/app/controllers/users_controller.rb
1
# frozen_string_literal: true
2
class UsersController < ApplicationController
1✔
3
  before_action :set_breadcrumbs
1✔
4
  before_action :check_user_access
1✔
5

6
  def index
1✔
7
    @users = User.order("uid ASC NULLS LAST").page params[:page]
3✔
8
  end
9

10
  def show
1✔
11
    add_breadcrumb("User")
2✔
12
    @user = User.find(params[:id])
2✔
13
  end
14

15
  def edit
1✔
16
    add_breadcrumb("Edit User")
1✔
17
    @user = User.find(params[:id])
1✔
18
  end
19

20
  def update
1✔
21
    update_user_with_params
1✔
22
    redirect_to user_path(@user)
1✔
23
  rescue => ex
NEW
24
    short_message = "Error saving user #{params[:id]}"
×
NEW
25
    Rails.logger.error "#{short_message}: #{ex.message}"
×
NEW
26
    Honeybadger.notify "#{short_message}: #{ex.message}"
×
NEW
27
    flash[:alert] = short_message
×
NEW
28
    redirect_to user_path(id: params[:id])
×
29
  end
30

31
  private
1✔
32

33
    def set_breadcrumbs
1✔
34
      add_breadcrumb("Users", users_path)
11✔
35
    end
36

37
    def check_user_access
1✔
38
      return if current_user.superuser || current_user.sysadmin || current_user.trainer
11✔
39
      flash[:notice] = "You do not have access to this page (#{current_user.uid})"
4✔
40
      redirect_to dashboard_path
4✔
41
    end
42

43
    # rubocop:disable Metrics/AbcSize
44
    def update_user_with_params
1✔
45
      @user = User.find(params[:id])
1✔
46
      @user.given_name = params["user"]["given_name"]
1✔
47
      @user.family_name = params["user"]["family_name"]
1✔
48
      @user.display_name = params["user"]["display_name"]
1✔
49
      @user.eligible_sponsor = params["user"]["eligible_sponsor"] == "1"
1✔
50
      @user.eligible_manager = params["user"]["eligible_manager"] == "1"
1✔
51
      @user.superuser = params["user"]["superuser"] == "1"
1✔
52
      @user.sysadmin = params["user"]["sysadmin"] == "1"
1✔
53
      @user.trainer = params["user"]["trainer"] == "1"
1✔
54
      @user.save!
1✔
55
    end
56
  # rubocop:enable Metrics/AbcSize
57
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

© 2025 Coveralls, Inc