Skip to content

Commit

Permalink
Merge pull request #1 from joshua-arts/rubocop
Browse files Browse the repository at this point in the history
Add rubocop configuration and make appropriate style changes.
  • Loading branch information
Joshua Arts committed Jun 26, 2018
2 parents f0011a5 + ad5f218 commit 979f796
Show file tree
Hide file tree
Showing 65 changed files with 1,481 additions and 212 deletions.
1,176 changes: 1,176 additions & 0 deletions .rubocop.yml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) do |repo_name|
Expand Down Expand Up @@ -67,12 +69,16 @@ group :development, :test do

# Environment configuration.
gem 'dotenv-rails'

# Ruby linting.
gem 'rubocop'
end

group :test do
# Include Rspec and other testing utilities.
gem 'rspec-rails', '~> 3.7'
gem 'action-cable-testing'
gem 'rails-controller-testing'
gem 'shoulda-matchers', '~> 3.1'
gem 'faker'
gem "factory_bot_rails"
Expand Down
23 changes: 23 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
ast (2.4.0)
autoprefixer-rails (8.6.2)
execjs
bcrypt (3.1.12)
Expand Down Expand Up @@ -84,6 +85,7 @@ GEM
hashie (3.5.7)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand Down Expand Up @@ -133,8 +135,12 @@ GEM
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
parallel (1.12.1)
parser (2.5.1.0)
ast (~> 2.4.0)
pg (0.21.0)
popper_js (1.12.9)
powerpack (0.1.2)
puma (3.11.4)
rack (2.0.5)
rack-test (0.6.3)
Expand All @@ -151,6 +157,10 @@ GEM
bundler (>= 1.3.0)
railties (= 5.0.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
Expand All @@ -162,6 +172,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
Expand All @@ -184,6 +195,15 @@ GEM
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rubocop (0.57.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
sass (3.5.6)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand Down Expand Up @@ -222,6 +242,7 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.11)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.0)
web-console (3.6.2)
actionview (>= 5.0)
activemodel (>= 5.0)
Expand Down Expand Up @@ -254,8 +275,10 @@ DEPENDENCIES
pg (~> 0.18)
puma (~> 3.0)
rails (~> 5.0.7)
rails-controller-testing
redis (~> 3.0)
rspec-rails (~> 3.7)
rubocop
sass-rails (~> 5.0)
shoulda-matchers (~> 3.1)
spring
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/waiting_channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class WaitingChannel < ApplicationCable::Channel
def subscribed
stream_from "#{params[:uid]}_waiting_channel"
Expand Down
10 changes: 6 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bigbluebutton_api'

class ApplicationController < ActionController::Base
Expand Down Expand Up @@ -43,18 +45,18 @@ def allow_greenlight_users?

# Determines if a form field needs the is-invalid class.
def form_is_invalid?(obj, key)
'is-invalid' if !obj.errors.messages[key].empty?
'is-invalid' unless obj.errors.messages[key].empty?
end
helper_method :form_is_invalid?

# Default, unconfigured meeting options.
def default_meeting_options
invite_msg = "To invite someone to the meeting, send them this link:"
{
user_is_moderator: false,
meeting_logout_url: request.base_url + logout_room_path(@room),
meeting_recorded: true,
moderator_message: "To invite someone to the meeting, send them this link:\n\n
#{request.base_url + relative_root + room_path(@room)}"
moderator_message: "#{invite_msg}\n\n #{request.base_url + relative_root + room_path(@room)}",
}
end
end
5 changes: 3 additions & 2 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

class ErrorsController < ApplicationController

def not_found
render status: 404
end

def unprocessable
render status: 422
end
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/main_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class MainController < ApplicationController
# frozen_string_literal: true

#before_action :redirect_to_room
class MainController < ApplicationController
# before_action :redirect_to_room

# GET /
def index
Expand Down
26 changes: 11 additions & 15 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class RoomsController < ApplicationController
# frozen_string_literal: true

class RoomsController < ApplicationController
before_action :validate_accepted_terms, unless: -> { !Rails.configuration.terms }
before_action :find_room, except: :create
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
Expand All @@ -9,7 +10,7 @@ class RoomsController < ApplicationController
# POST /
def create
redirect_to root_path unless current_user

@room = Room.new(name: room_params[:name])
@room.owner = current_user

Expand All @@ -19,17 +20,14 @@ def create
else
redirect_to @room
end
else
# Handle room didn't save.

end
end

# GET /:room_uid
def show
if current_user && @room.owned_by?(current_user)
@recordings = @room.recordings
@is_running = @room.is_running?
@is_running = @room.running?
else
render :join
end
Expand All @@ -47,7 +45,7 @@ def join
return
end

if @room.is_running?
if @room.running?
if current_user
redirect_to @room.join_path(current_user.name, opts, current_user.uid)
else
Expand Down Expand Up @@ -92,13 +90,13 @@ def home
current_user.main_room = @room
current_user.save

redirect_to @room
redirect_to @room
end

# POST /:room_uid/:record_id
def update_recording
meta = {
"meta_#{META_LISTED}" => (params[:state] == "public")
"meta_#{META_LISTED}" => (params[:state] == "public"),
}

res = @room.update_recording(params[:record_id], meta)
Expand All @@ -124,12 +122,10 @@ def recording_length(start_time, end_time)

if len > 60
"#{len / 60} hrs"
elsif len == 0
"< 1 min"
else
if len == 0
"< 1 min"
else
"#{len} min"
end
"#{len} min"
end
end
helper_method :recording_length
Expand All @@ -147,7 +143,7 @@ def find_room

# Ensure the user is logged into the room they are accessing.
def verify_room_ownership
bring_to_room if !@room.owned_by?(current_user)
bring_to_room unless @room.owned_by?(current_user)
end

# Redirects a user to their room.
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class SessionsController < ApplicationController
# frozen_string_literal: true

class SessionsController < ApplicationController
# GET /users/login
def new
end
Expand All @@ -13,11 +14,8 @@ def destroy
# POST /users/login
def create
user = User.find_by(email: session_params[:email])
if user && user.authenticate(session_params[:password])
if user.&authenticate(session_params[:password])
login(user)
else
# Login unsuccessful, display error message.

end
end

Expand Down
18 changes: 8 additions & 10 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class UsersController < ApplicationController
# frozen_string_literal: true

class UsersController < ApplicationController
before_action :find_user, only: [:edit, :update]
before_action :ensure_unauthenticated, only: [:new, :create]

Expand All @@ -12,7 +13,7 @@ def create
@user.provider = "greenlight"

if @user.save
login(@user)
login(@user)
else
# Handle error on user creation.
render :new
Expand Down Expand Up @@ -61,16 +62,13 @@ def update
redirect_to edit_user_path(@user), notice: "Information successfully updated."
else
# Append custom errors.
errors.each do |k, v| @user.errors.add(k, v) end
errors.each { |k, v| @user.errors.add(k, v) }
render :edit
end
elsif @user.update_attributes(user_params)
redirect_to edit_user_path(@user), notice: "Information successfully updated."
else
# Update the core user attributes.
if @user.update_attributes(user_params)
redirect_to edit_user_path(@user), notice: "Information successfully updated."
else
render :edit
end
render :edit
end
end

Expand All @@ -83,7 +81,7 @@ def terms
redirect_to current_user.main_room
end
end

private

def find_user
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationHelper
include MeetingsHelper

Expand All @@ -12,7 +14,7 @@ def configured_providers
def omniauth_login_url(provider)
"#{Rails.configuration.relative_url_root}/auth/#{provider}"
end

# Determine if Greenlight is configured to allow user signups.
def allow_user_signup?
Rails.configuration.allow_user_signup
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/errors_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ErrorsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/main_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module MainHelper
end
2 changes: 2 additions & 0 deletions app/helpers/meetings_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module MeetingsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/rooms_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module RoomsHelper
end
5 changes: 3 additions & 2 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

module SessionsHelper

# Logs a user into GreenLight.
def login(user)
session[:user_id] = user.id

# If there are not terms, or the user has accepted them, go to their room.
if !Rails.configuration.terms || user.accepted_terms then
if !Rails.configuration.terms || user.accepted_terms
redirect_to user.main_room
else
redirect_to terms_path
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module UsersHelper
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
Loading

0 comments on commit 979f796

Please sign in to comment.