Skip to content

Commit

Permalink
remove test folder & rubocop clean
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Dec 23, 2019
1 parent a89926a commit 03ff72b
Show file tree
Hide file tree
Showing 393 changed files with 5,830 additions and 5,720 deletions.
120 changes: 60 additions & 60 deletions Gemfile
@@ -1,16 +1,18 @@
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
#gem 'rails', '~> 5.2.0'
gem "rails", "6.0.2" #, github: "rails/rails",
# gem 'rails', '~> 5.2.0'
gem 'pg'
gem 'rails', '6.0.2' # , github: "rails/rails",

gem 'anycable-rails'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# gem 'sqlite3'
# gem "sqlite3", "~> 1.3.6"
# Use Puma as the app server
gem 'puma', '~> 3.11'
Expand All @@ -22,55 +24,53 @@ gem 'uglifier', '>= 1.3.0'
# gem 'mini_racer', platforms: :ruby
gem 'haml'

gem 'devise', '4.7.0' #github: "plataformatec/devise"
gem 'devise', '4.7.0' # github: "plataformatec/devise"

# Use CoffeeScript for .coffee assets and views
#gem 'coffee-rails', '~> 4.2'
# gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder'
#gem 'haml'
# gem 'haml'
# Use Redis adapter to run Action Cable in production
gem 'redis', '~> 4.0'
gem "redis-objects", "~> 1.5"
gem "redis-namespace", "~> 1.6"
gem 'redis-namespace', '~> 1.6'
gem 'redis-objects', '~> 1.5'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem "nightfury", github: "michelson/nightfury" #"~> 1.0"
gem 'nightfury', github: 'michelson/nightfury' # "~> 1.0"

# gem 'tabs', github: 'michelson/tabs', branch: "upgrade"

gem "graphql", "~> 1.9"
gem 'graphiql-rails', group: :development
gem 'graphql', '~> 1.9'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'email_reply_trimmer'
# gem 'tunable'
gem 'aasm'
gem 'acts-as-taggable-on', '~> 6.0'
gem 'pg_search'
gem "groupdate"
gem "deep_cloneable"
gem "acts_as_list", "~> 0.9.19"
gem "friendly_id", "~> 5.2"
gem 'acts_as_list', '~> 0.9.19'
gem 'deep_cloneable'
gem 'friendly_id', '~> 5.2'
gem 'groupdate'
gem 'gutentag', '~> 2.4'
gem 'aasm'
gem "ransack"

gem "geocoder", "~> 1.4"
gem "browser", "~> 2.5"
gem 'pg_search'
gem 'ransack'

gem "google-cloud-dialogflow"
gem 'browser', '~> 2.5'
gem 'geocoder', '~> 1.4'

gem 'google-cloud-dialogflow'

gem "jwt"
gem "jwe"
gem 'jwe'
gem 'jwt'

gem 'devise-jwt', '~> 0.5.9'
gem "devise_invitable", "~> 2.0"

gem 'devise_invitable', '~> 2.0'

gem 'image_processing', '~> 1.2'

Expand All @@ -79,85 +79,85 @@ gem 'sidekiq-cron'
gem 'webpacker', '~> 3.5'

gem 'roadie'
gem "urlcrypt"

gem "mini_magick", "~> 4.8"
gem "aws-sdk-s3", "~> 1.15"
gem "aws-ses"
gem 'urlcrypt'

gem 'aws-sdk-s3', '~> 1.15'
gem 'aws-ses'
gem 'mini_magick', '~> 4.8'

gem "active_importer"
gem "roo"
gem "ruby-oembed"
gem "http"
gem "faraday", "~> 0.15.4"
gem 'active_importer'
gem 'faraday', '~> 0.15.4'
gem 'http'
gem 'roo'
gem 'ruby-oembed'

gem "mustache"
gem 'mustache'

gem "kaminari", "~> 1.1"
gem "chronic", "~> 0.10.2"
gem 'chronic', '~> 0.10.2'
gem 'kaminari', '~> 1.1'

gem "timezone", "~> 1.2"
gem 'timezone', '~> 1.2'

gem "rack-cors", "~> 1.0"
gem "email_reply_parser", "~> 0.5.9"
gem "bugsnag", "~> 6.11"
gem 'bugsnag', '~> 6.11'
gem 'email_reply_parser', '~> 0.5.9'
gem 'rack-cors', '~> 1.0'

gem "i18n-js", "~> 3.3"
gem "biz", "~> 1.8"
gem 'biz', '~> 1.8'
gem 'i18n-js', '~> 3.3'

gem "twitter"
gem 'twitter'

gem "globalize", github: 'globalize/globalize'
gem 'globalize', github: 'globalize/globalize'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

gem 'dotenv-rails', groups: [:development, :test]
gem 'dotenv-rails', groups: %i[development test]

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
#gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry'
# gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'cypress-on-rails', '~> 1.0'
gem 'pry'
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'

gem 'capistrano-bundle'
gem 'capistrano-rails'
gem 'capistrano3-puma'
gem 'capistrano-rvm'
gem 'capistrano-bundle'
gem 'capistrano-sidekiq'
gem 'capistrano3-puma'
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara' #, '>= 2.15', '< 4.0'
gem 'capybara' # , '>= 2.15', '< 4.0'
# gem 'selenium-webdriver'
gem 'faker', github: 'stympy/faker', group: %i[development test]
gem 'webdrivers'
gem 'faker', github: "stympy/faker", group: [:development, :test]
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
gem 'rspec-rails' #, git: 'https://github.com/rspec/rspec-rails', branch: '4-0-dev'
gem 'rspec-rails' # , git: 'https://github.com/rspec/rspec-rails', branch: '4-0-dev'
%w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
gem lib #, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
gem lib # , :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
end
gem 'factory_bot_rails'
gem 'brakeman'
gem 'database_cleaner'
gem 'shoulda'
gem 'shoulda-matchers'
gem 'factory_bot_rails'
gem 'rubocop', '~> 0.76.0', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
gem 'shoulda'
gem 'shoulda-matchers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -132,6 +132,7 @@ GEM
tzinfo
bootsnap (1.4.5)
msgpack (~> 1.0)
brakeman (4.7.2)
browser (2.6.1)
bugsnag (6.11.1)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -563,6 +564,7 @@ DEPENDENCIES
aws-ses
biz (~> 1.8)
bootsnap (>= 1.1.0)
brakeman
browser (~> 2.5)
bugsnag (~> 6.11)
capistrano-bundle
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
@@ -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
45 changes: 20 additions & 25 deletions app/channels/application_cable/channel.rb
@@ -1,38 +1,37 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base

def get_user_data

if params[:inner_app].present?
user = authorize_by_jwt
# self.connection.env['warden'].user
user.class.model_name.singular
@user_data = user.attributes.slice("email" ).symbolize_keys.merge({agent: true})
@user_data = user.attributes.slice('email').symbolize_keys.merge(agent: true)
return if @user_data.present?
end

if @app.encryption_enabled?
@user_data = authorize_by_encrypted_params
else
@user_data = get_user_from_unencrypted
end
@user_data = if @app.encryption_enabled?
authorize_by_encrypted_params
else
get_user_from_unencrypted
end
end

def authorize_by_jwt
token = params["jwt"].gsub("Bearer ", "")
token = params['jwt'].gsub('Bearer ', '')
Warden::JWTAuth::UserDecoder.new.call(
token, :agent, nil)
token, :agent, nil
)
end

def authorize_by_encrypted_params
begin
key = @app.encryption_key #"d2f5e36677eac3b5"
encrypted = params[:enc_data]
json = JWE.decrypt(encrypted, key)
JSON.parse(json).symbolize_keys
rescue
nil
end
key = @app.encryption_key # "d2f5e36677eac3b5"
encrypted = params[:enc_data]
json = JWE.decrypt(encrypted, key)
JSON.parse(json).symbolize_keys
rescue StandardError
nil
end

def get_user_by_session
Expand All @@ -41,13 +40,9 @@ def get_user_by_session

# non encrypted version
def get_user_from_unencrypted
begin
params.slice(:email, :properties)
rescue
nil
end
params.slice(:email, :properties)
rescue StandardError
nil
end


end
end
3 changes: 2 additions & 1 deletion app/channels/application_cable/connection.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base

end
end
17 changes: 8 additions & 9 deletions app/channels/events_channel.rb
@@ -1,21 +1,20 @@
# frozen_string_literal: true

class EventsChannel < ApplicationCable::Channel
def subscribed
@app = App.find_by(key: params[:app])
@app = App.find_by(key: params[:app])
stream_from "events:#{@app.key}"
#@app_user = @app.agents.find_by(email: @user_data[:email])
# @app_user = @app.agents.find_by(email: @user_data[:email])
end

def unsubscribed
# Any cleanup needed when channel is unsubscribed
end

def receive_conversation_part(data)
@app = App.find_by(key: params[:app])
@conversation = @app.conversations.find(data["conversation_id"])
message = @conversation.messages.find(data["message_id"])
if message.authorable_type == "AppUser" # read anyway #!= @app_user
message.read!
end
@app = App.find_by(key: params[:app])
@conversation = @app.conversations.find(data['conversation_id'])
message = @conversation.messages.find(data['message_id'])
message.read! if message.authorable_type == 'AppUser' # read anyway #!= @app_user
end

end

0 comments on commit 03ff72b

Please sign in to comment.