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

codebar / planner / 22035661028

15 Feb 2026 12:27PM UTC coverage: 95.47% (-0.06%) from 95.525%
22035661028

Pull #2483

github

web-flow
Merge c4a4ae827 into 299c366ef
Pull Request #2483: Refactor invitation and workshop sponsor handling

33 of 39 new or added lines in 8 files covered. (84.62%)

3267 of 3422 relevant lines covered (95.47%)

44.82 hits per line

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

81.72
/app/controllers/application_controller.rb
1
class ApplicationController < ActionController::Base
6✔
2
  protect_from_forgery with: :exception
6✔
3

4
  include Pundit::Authorization
6✔
5
  include Pagy::Method
6✔
6

7
  if Rails.env.production?
6✔
8
    rescue_from Exception do |ex|
×
9
      Rollbar.error(ex)
×
10
      Rails.logger.fatal(ex)
×
11

12
      respond_to do |format|
×
13
        format.html { render 'errors/error', layout: false, status: :internal_server_error }
×
14
        format.all  { head :internal_server_error }
×
15
      end
16
    end
17
  end
18

19
  rescue_from ActionController::RoutingError, with: :render_not_found
6✔
20
  rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
6✔
21

22
  rescue_from ActiveRecord::RecordInvalid do |exception|
6✔
NEW
23
    Rails.logger.error("Validation failed: #{exception.message}")
×
NEW
24
    redirect_back(fallback_location: root_path,
×
25
                  alert: 'Unable to complete action. Please check your input and try again.')
26
  end
27

28
  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
6✔
29
  rescue_from Pundit::AuthorizationNotPerformedError, with: :user_not_authorized
6✔
30

31
  helper_method :logged_in?
6✔
32
  helper_method :current_user
6✔
33
  helper_method :current_service
6✔
34

35
  before_action :set_locale
6✔
36
  before_action :accept_terms, if: :logged_in?
6✔
37

38
  def render_not_found
6✔
39
    respond_to do |format|
3✔
40
      format.html { render template: 'errors/not_found', layout: false, status: :not_found }
6✔
41
      format.all  { head :not_found }
3✔
42
    end
43
  end
44

45
  protected
6✔
46

47
  def current_user
6✔
48
    if session.key?(:member_id)
881✔
49
      @current_member ||= Member.find(session[:member_id])
382✔
50
    end
51
  rescue ActiveRecord::RecordNotFound
52
    session[:member_id] = nil
×
53
  end
54

55
  def current_service
6✔
56
    if session.key?(:service_id)
×
57
      @current_service ||= Service.find_by(member_id: session[:member_id],
×
58
                                           id: session[:service_id])
59
    end
60
  rescue ActiveRecord::RecordNotFound
61
    session[:service_id] = nil
×
62
  end
63

64
  def current_user?
6✔
65
    !!current_user
1,818✔
66
  end
67

68
  def logged_in?
6✔
69
    current_user?
1,818✔
70
  end
71

72
  def accept_terms
6✔
73
    store_path
547✔
74
    redirect_to terms_and_conditions_path if current_user.accepted_toc_at.blank?
547✔
75
  end
76

77
  def authenticate_member!
6✔
78
    if current_user
35✔
79
      finish_registration
34✔
80
    else
81
      redirect_to redirect_path
1✔
82
    end
83
  end
84

85
  def store_path
6✔
86
    session[:previous_request_url] = request.url
547✔
87
  end
88

89
  def previous_path
6✔
90
    session[:previous_request_url]
7✔
91
  end
92

93
  def finish_registration
6✔
94
    if current_user.requires_additional_details? && !providing_additional_details?
42✔
95
      redirect_to edit_member_details_path
×
96
    end
97
  end
98

99
  def providing_additional_details?
6✔
100
    [edit_member_path, edit_member_details_path].include? request.path
×
101
  end
102

103
  def logout!
6✔
104
    @current_member = nil
×
105
    reset_session
×
106
  end
107

108
  helper_method :redirect_path
6✔
109
  def redirect_path
6✔
110
    '/auth/github'
8✔
111
  end
112

113
  def authenticate_admin!
6✔
114
    redirect_to root_path, notice: "You can't be here" unless logged_in? && current_user.is_admin?
19✔
115
  end
116

117
  def authenticate_admin_or_organiser!
6✔
118
    redirect_to root_path, notice: "You can't be here" unless manager?
237✔
119
  end
120

121
  def manager?
6✔
122
    logged_in? && current_user.manager?
237✔
123
  end
124

125
  helper_method :manager?
6✔
126

127
  def is_logged_in?
6✔
128
    unless logged_in?
72✔
129
      flash[:notice] = t('notifications.not_logged_in')
1✔
130
      redirect_to root_path
1✔
131
    end
132
  end
133

134
  def has_access?
6✔
135
    is_logged_in?
53✔
136
  end
137

138
  private
6✔
139

140
  def set_locale
6✔
141
    store_locale_to_cookie(params[:locale]) if locale
774✔
142
    I18n.locale = cookies[:locale] || I18n.default_locale
774✔
143
  end
144

145
  def user_not_authorized
6✔
146
    redirect_to(user_path, notice: 'You are not authorized to perform this action.')
1✔
147
  end
148

149
  def user_path
6✔
150
    request.referer || root_path
1✔
151
  end
152

153
  def chapters
6✔
154
    @chapters ||= Chapter.all
×
155
  end
156

157
  def redirect_back(fallback_location:, **args)
6✔
158
    if referer = request.headers['Referer']
83✔
159
      redirect_to referer, **args
65✔
160
    else
161
      redirect_to fallback_location, **args
18✔
162
    end
163
  end
164

165
  def store_locale_to_cookie(locale)
6✔
166
    cookies[:locale] = { value: locale,
1✔
167
                         expires: Time.zone.now + 36_000 }
168
  end
169

170
  def locale
6✔
171
    params[:locale] if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
774✔
172
  end
173
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