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

AgileVentures / WebsiteOne / #233

pending completion
#233

push

semaphore

web-flow
add last_github_update to project list (#3838)

* add last_github_update to project list

* add test for display of last_github_update

* test for display of last_github_update

4929 of 5374 relevant lines covered (91.72%)

14.12 hits per line

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

84.62
/app/controllers/users_controller.rb
1
# frozen_string_literal: true
2

3
class UsersController < ApplicationController
1✔
4
  layout 'layouts/user_profile_layout', only: [:show]
1✔
5

6
  skip_before_action :verify_authenticity_token, only: %i(index show)
1✔
7

8
  before_action :get_user, only: %i(show destroy add_status)
1✔
9
  before_action :get_user, only: %i(show add_status)
1✔
10
  before_action :authenticate_user!, only: [:add_status]
1✔
11

12
  def index
1✔
13
    @users = users
1✔
14
    @users_count = @users.total_count
1✔
15
    @projects = Project.where(status: 'active').sort { |a, b| a.title <=> b.title }
1✔
16
    @user_type = params[:title].blank? ? 'Volunteer' : params[:title]
1✔
17
    @user_type = 'Premium Member' if params[:title] == 'Premium'
1✔
18

19
    respond_to do |format|
1✔
20
      format.js
1✔
21
      format.html
1✔
22
    end
23
  end
24

25
  def new
1✔
26
    @user = User.new(Karma.new)
×
27
    @user.status.build
×
28
  end
29

30
  def hire_me
1✔
31
    @user = User.find(params[:contact_form][:recipient_id])
8✔
32
    message_params = params.fetch(:contact_form, {})
8✔
33
    @contact_form = ContactForm.new(name: message_params['name'],
8✔
34
                                    email: message_params['email'],
35
                                    message: message_params['message'])
36

37
    if @contact_form.valid?
8✔
38
      Mailer.hire_me_form(@user, message_params).deliver_now
3✔
39
      redirect_to({ action: :show, id: @user.id }, notice: 'Your message has been sent successfully!')
3✔
40
    else
41
      flash[:alert] = @contact_form.errors.full_messages
5✔
42
      render :show
5✔
43
    end
44
  end
45

46
  def show
1✔
47
    @contact_form = ContactForm.new
4✔
48
    if should_display_user?(@user)
4✔
49
      @event_instances = EventInstance.where(user_id: @user.id)
3✔
50
                                      .order(created_at: :desc).limit(5)
51
      set_activity_tab(params[:tab])
3✔
52
    else
53
      raise ActiveRecord::RecordNotFound, 'User has not exposed their profile publicly'
1✔
54
    end
55
  end
56

57
  def destroy
1✔
58
    user = User.find(current_user.id)
×
59
    user.destroy
×
60
    flash[:notice] = 'Your account has been deactivated'
×
61
    redirect_to users_path
×
62
  end
63

64
  def add_status
1✔
65
    if user_has_status(params)
4✔
66
      @user.status.create({ status: (params[:user][:status]), user_id: @user })
3✔
67
      flash[:notice] = 'Your status has been set'
3✔
68
      redirect_to user_path(@user)
3✔
69
    else
70
      flash[:alert] = 'Something went wrong...'
1✔
71
      render :show
1✔
72
    end
73
  end
74

75
  private
1✔
76

77
  def user_has_status(params)
1✔
78
    params.key?(:user) && params[:user].key?(:status)
4✔
79
  end
80

81
  def users
1✔
82
    users = User.page(params[:page]).per(15)
1✔
83
                .includes(:status, :titles, :karma)
84
                .param_filter(set_filter_params)
85
                .order('karmas.total DESC')
86

87
    users = users.allow_to_display unless privileged_visitor?
1✔
88
    users = users.where(email: params[:email]) if params[:email]
1✔
89
    users
1✔
90
  end
91

92
  def should_display_user?(user)
1✔
93
    user.display_profile || current_user == @user || privileged_visitor?
4✔
94
  end
95

96
  def get_user
1✔
97
    @user = User.friendly.find(params[:id])
8✔
98
  end
99

100
  def set_filter_params
1✔
101
    params.slice(:project_filter, :online, :title)
1✔
102
  end
103

104
  def set_activity_tab(param)
1✔
105
    return unless param.present?
3✔
106

107
    @param_tab = param
×
108
    unless UserPresenter.new(@user).contributed?
×
109
      @param_tab = nil
×
110
      flash.now[:notice] = 'User does not have activity log'
×
111
    end
112
  end
113
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