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
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ AllCops:
- vendor/bundle/**/*

plugins:
- rubocop-capybara
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails

Layout/LineLength:
Max: 120
Expand Down
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ gem 'rails', '~> 7.2.2.2' # LOCKED: It is Rails.
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem 'sprockets-rails'

gem "amazing_print" # colourful output (suggested by rails_semantic_logger)
gem "rails_semantic_logger" # condense log lines: https://github.com/codebar/planner/issues/2339
gem 'amazing_print' # colourful output (suggested by rails_semantic_logger)
gem 'rails_semantic_logger' # condense log lines: https://github.com/codebar/planner/issues/2339

gem 'acts-as-taggable-on'
gem 'benchmark' # LOCKED: Added because of activesupport 7.0
Expand Down Expand Up @@ -96,9 +96,11 @@ group :development, :test do
gem 'rspec-collection_matchers'
gem 'rspec-rails'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-capybara', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
gem 'rubocop-rspec_rails', require: false
gem 'bullet'
end

Expand All @@ -122,4 +124,4 @@ gem 'rollbar'
gem 'scout_apm'

gem 'carrierwave-aws', '~> 1.6'
gem "sitemap_generator", github: "kjvarga/sitemap_generator", branch: "master" # LOCKED: When a version higher than 6.3.0 is released, drop this LOCKED.
gem 'sitemap_generator', github: 'kjvarga/sitemap_generator', branch: 'master' # LOCKED: When a version higher than 6.3.0 is released, drop this LOCKED.
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ GEM
rubocop-ast (1.49.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-performance (1.26.1)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
Expand All @@ -497,6 +500,10 @@ GEM
rubocop-rspec (3.9.0)
lint_roller (~> 1.1)
rubocop (~> 1.81)
rubocop-rspec_rails (2.32.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec (~> 3.5)
ruby-progressbar (1.13.0)
ruby-vips (2.3.0)
ffi (~> 1.12)
Expand Down Expand Up @@ -664,9 +671,11 @@ DEPENDENCIES
rspec-collection_matchers
rspec-rails
rubocop
rubocop-capybara
rubocop-performance
rubocop-rails
rubocop-rspec
rubocop-rspec_rails
sassc-rails
scout_apm
selenium-webdriver
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def show
@attending_students = InvitationPresenter.decorate_collection(@original_event.attending_students)
@attending_coaches = InvitationPresenter.decorate_collection(@original_event.attending_coaches)

return render plain: @event.attendees_csv if request.format.csv?
render plain: @event.attendees_csv if request.format.csv?
end

def update
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
def show
@invitations = @meeting.invitations.accepted.includes(:member).order(:created_at)

return render plain: @meeting.attendees_csv if request.format.csv?
render plain: @meeting.attendees_csv if request.format.csv?
end

def edit; end
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 @@ -85,8 +85,8 @@ def previous_path
end

def finish_registration
if current_user.requires_additional_details?
redirect_to edit_member_details_path unless providing_additional_details?
if current_user.requires_additional_details? && !providing_additional_details?
redirect_to edit_member_details_path
end
end

Expand Down Expand Up @@ -141,7 +141,7 @@ def user_not_authorized
end

def user_path
request.referrer || root_path
request.referer || root_path
end

def chapters
Expand Down
16 changes: 7 additions & 9 deletions app/controllers/auth_services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ def create
provider: omnihash[:provider])
end
redirect_to root_path
else
if current_service
session[:member_id] = current_service.member.id
session[:service_id] = current_service.id
session[:oauth_token] = omnihash[:credentials][:token]
session[:oauth_token_secret] = omnihash[:credentials][:secret]
elsif current_service
session[:member_id] = current_service.member.id
session[:service_id] = current_service.id
session[:oauth_token] = omnihash[:credentials][:token]
session[:oauth_token_secret] = omnihash[:credentials][:secret]

finish_registration || redirect_to(referer_or_dashboard_path)
else
finish_registration || redirect_to(referer_or_dashboard_path)
else
member = Member.find_by(email: omnihash[:info][:email])
member ||= Member.new(email: omnihash[:info][:email])

Expand All @@ -48,7 +47,6 @@ def create
session[:oauth_token_secret] = omnihash[:credentials][:secret]

redirect_to edit_member_details_path(member_type: member_type)
end
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/controllers/chapter_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def upcoming_events_by_chapter(chapter)
end

def event_presenters_by_date(events)
events.map.inject({}) do |hash, (date, value)|
events.map.each_with_object({}) do |(date, value), hash|
hash[date] = EventPresenter.decorate_collection(value)
hash
end
end
end
6 changes: 3 additions & 3 deletions app/controllers/concerns/admin/sponsor_concerns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ module Admin::SponsorConcerns

module InstanceMethods
def sponsor
if workshop_sponsors.save
flash[:notice] = 'Sponsor added successfully'
flash[:notice] = if workshop_sponsors.save
'Sponsor added successfully'
else
flash[:notice] = workshop_sponsors.errors.full_messages.to_s
workshop_sponsors.errors.full_messages.to_s
end
Comment on lines -13 to 17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A style I've been using, to get balanced if/else/end blocks, is:

foo =
  if true
    # code here
  else
    # and here
  end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, if you feel strongly about it we can see if Rubocop supports its enforcement.

redirect_back fallback_location: root_path
end
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ class DashboardController < ApplicationController
def show
@chapters = Chapter.active.all.order(:created_at)
@user = current_user ? MemberPresenter.new(current_user) : nil
@upcoming_workshops = upcoming_events.map.inject({}) do |hash, (key, value)|
@upcoming_workshops = upcoming_events.map.each_with_object({}) do |(key, value), hash|
hash[key] = EventPresenter.decorate_collection(value)
hash
end

@testimonials = Testimonial.order(Arel.sql('RANDOM()')).limit(5).includes(:member)
end

def dashboard
@user = MemberPresenter.new(current_user)
@ordered_events = upcoming_events_for_user.map.inject({}) do |hash, (key, value)|
@ordered_events = upcoming_events_for_user.map.each_with_object({}) do |(key, value), hash|
hash[key] = EventPresenter.decorate_collection(value)
hash
end
@announcements = current_user.announcements.active
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def unsubscribe
authenticate_member!

redirect_to subscriptions_path
rescue
rescue StandardError
redirect_to root_path, notice: 'Your token is invalid. '
end

Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module ApplicationHelper

def humanize_date(datetime, end_time = nil, with_time: false, with_year: false)
return I18n.l(datetime, format: :humanised_with_year) if with_year
return humanize_date_with_time(datetime, end_time) if with_time
Expand Down
6 changes: 3 additions & 3 deletions app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Member < ApplicationRecord
validates :about_you, length: { maximum: 255 }

DIETARY_RESTRICTIONS = %w[vegan vegetarian pescetarian halal gluten_free dairy_free other].freeze
validates_inclusion_of :dietary_restrictions, in: DIETARY_RESTRICTIONS
validates_presence_of :other_dietary_restrictions, if: :other_dietary_restrictions?
validates :dietary_restrictions, inclusion: { in: DIETARY_RESTRICTIONS }
validates :other_dietary_restrictions, presence: { if: :other_dietary_restrictions? }

scope :accepted_toc, -> { where.not(accepted_toc_at: nil) }
scope :order_by_email, -> { order(:email) }
Expand Down Expand Up @@ -146,7 +146,7 @@ def other_dietary_restrictions?

def self.find_members_by_name(name)
name.strip!
name.eql?('') ? self.none : where("CONCAT(name, ' ', surname) ILIKE ?", "%#{name}%")
name.eql?('') ? none : where("CONCAT(name, ' ', surname) ILIKE ?", "%#{name}%")
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/tutorial.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Tutorial < ApplicationRecord
belongs_to :workshop, optional: true
belongs_to :workshop, optional: true

validates :title, presence: true
default_scope -> { order(:created_at) }
Expand Down
4 changes: 1 addition & 3 deletions app/uploaders/avatar_uploader.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# encoding: utf-8

class AvatarUploader < CarrierWave::Uploader::Base
storage :aws if Rails.env.production?

include CarrierWave::MiniMagick

def content_type_allowlist
[/image\//]
[%r{image/}]
end

# Override the directory where uploaded files will be stored.
Expand Down