Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,6 @@ Metrics/PerceivedComplexity:
- 'app/services/invitation_manager.rb'
- 'lib/omniauth/strategies/codebar.rb'

# Offense count: 10
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
# NamePrefix: is_, has_, have_, does_
# ForbiddenPrefixes: is_, has_, have_, does_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicatePrefix:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/models/workshop.rb'
- 'app/policies/application_policy.rb'
- 'app/policies/chapter_policy.rb'
- 'app/policies/event_policy.rb'
- 'app/policies/workshop_policy.rb'

# Offense count: 2
RSpec/AnyInstance:
Exclude:
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def manager?
helper_method :manager?
helper_method :admin_namespace?

def is_logged_in?
def require_login
unless logged_in?
flash[:notice] = t('notifications.not_logged_in')
redirect_to root_path
end
end

def has_access?
is_logged_in?
def require_access
require_login
end

def admin_namespace?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class DashboardController < ApplicationController
before_action :is_logged_in?, only: %i[dashboard]
before_action :require_login, only: %i[dashboard]
skip_before_action :accept_terms, except: %i[dashboard show]

helper_method :year_param
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'services/ticket'

class EventsController < ApplicationController
before_action :is_logged_in?, only: %i[student coach]
before_action :require_login, only: %i[student coach]

def index
redirect_to upcoming_events_path
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class InvitationsController < ApplicationController
before_action :is_logged_in?, only: [:index]
before_action :require_login, only: [:index]
before_action :set_invitation, only: %i[show attend reject]

def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/mailing_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class MailingListsController < ApplicationController
include MailingListConcerns

before_action :has_access?
before_action :require_access

def create
subscribe_to_newsletter(current_user)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/member/details_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Member::DetailsController < ApplicationController

before_action :set_member
before_action :suppress_notices
before_action :is_logged_in?, only: %i[edit]
before_action :require_login, only: %i[edit]

def edit
accept_terms
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class PaymentsController < ApplicationController
before_action :is_logged_in?
before_action :require_login

def new; end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SubscriptionsController < ApplicationController
before_action :has_access?
before_action :require_access

def index
@mailing_list = MailingListForm.new
Expand Down
6 changes: 3 additions & 3 deletions app/models/workshop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def coach_waiting_list
waiting_list.select(&:for_coach?)
end

def has_host?
def host?
WorkshopSponsor.exists?(host: true, workshop: self)
end

def has_valid_host?
has_host? && host.address.present?
def valid_host?
host? && host.address.present?
end

def rsvp_available?
Expand Down
6 changes: 3 additions & 3 deletions app/policies/application_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def scope

private

def is_admin_or_chapter_organiser?
def admin_or_chapter_organiser?
return false unless user

user.is_admin? || user.has_role?(:organiser) || is_chapter_organiser?
user.is_admin? || user.has_role?(:organiser) || chapter_organiser?
end

def is_chapter_organiser?
def chapter_organiser?
Chapter.find_roles(:organiser, user).any?
end
end
12 changes: 6 additions & 6 deletions app/policies/chapter_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ def index?
end

def create?
is_admin_or_organiser?
admin_or_organiser?
end

def show?
is_admin_or_organiser?
admin_or_organiser?
end

def edit?
is_admin_or_organiser?
admin_or_organiser?
end

def update?
is_admin_or_organiser?
admin_or_organiser?
end

def members?
is_admin_or_organiser?
admin_or_organiser?
end

private

def is_admin_or_organiser?
def admin_or_organiser?
user.is_admin? || user.has_role?(:organiser, record) || user.has_role?(:organiser)
end
end
6 changes: 3 additions & 3 deletions app/policies/event_policy.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class EventPolicy < ApplicationPolicy
def invite?
is_admin_or_organiser?
admin_or_organiser?
end

def show?
is_admin_or_organiser?
admin_or_organiser?
end

private

def is_admin_or_organiser?
def admin_or_organiser?
return false unless user

user.is_admin? || user.has_role?(:organiser, record)
Expand Down
2 changes: 1 addition & 1 deletion app/policies/group_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def create?
end

def show?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end
end
4 changes: 2 additions & 2 deletions app/policies/invitation_log_policy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class InvitationLogPolicy < ApplicationPolicy
def index?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def show?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end
end
10 changes: 5 additions & 5 deletions app/policies/sponsor_policy.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
class SponsorPolicy < ApplicationPolicy
def index?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def create?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def show?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def edit?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def update?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end
end
10 changes: 5 additions & 5 deletions app/policies/workshop_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ def create?
end

def show?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def invite?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def update?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

def destroy?
is_admin_or_chapter_organiser?
admin_or_chapter_organiser?
end

private

def is_chapter_organiser?
def chapter_organiser?
user.has_role?(:organiser, record) ||
user.has_role?(:organiser, record.chapter) ||
user.has_role?(:organiser, Chapter)
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/workshops/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
= link_to '#', class: 'btn btn-primary py-3 disabled', title: t('messages.already_taken_place') do
%i.fas.fa-paper-plane
%label.text-white Invite
- elsif (@workshop.has_valid_host? || @workshop.virtual?) and @workshop.invitable?
- elsif (@workshop.valid_host? || @workshop.virtual?) and @workshop.invitable?
= link_to admin_workshop_send_invites_path(@workshop), class: 'btn btn-primary py-3' do
%i.fas.fa-paper-plane
%label.text-white Invite
Expand Down