diff --git a/.circleci/config.yml b/.circleci/config.yml index af3a39e101..61d613cecc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build: parallelism: 4 docker: - - image: circleci/ruby:2.3.8-stretch-node-browsers + - image: circleci/ruby:2.4.10-stretch-node-browsers environment: BUNDLE_JOBS: 3 BUNDLE_RETRY: 3 @@ -98,4 +98,4 @@ jobs: - store_artifacts: path: tmp/capybara - destination: capybara \ No newline at end of file + destination: capybara diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000000..cc534eb76f --- /dev/null +++ b/.env.sample @@ -0,0 +1,51 @@ +ADMIN_EMAIL: "service@localorbit.com" +API_ADMIN_USER_ID: +ASSET_HOST: "http://localhost:3000" +BI_CERT: +BI_CERT_KEY: +BI_DASHBOARD_URL: +BI_SERVER: +DEBUG: OFF +DOMAIN: "localtest.me" # localtest.me points to 127.0.0.1 and lets us use subdomains. localhost does not. see http://readme.localtest.me/ +# Use staging DRAGONFLY_HOST for dev and test +DRAGONFLY_HOST: 'https://d3jv177czn6wv2.cloudfront.net' +DW_DB_URL: +ETL_DAYS: '720' +FROALA_KEY: +GOOGLE_MAPS_KEY: +MAILTRAP_USERNAME: +MAILTRAP_PASSWORD: +MAX_POOL_SIZE: '10' +ON_HEROKU: 'false' +PDF_ASSET_HOST: "localtest.me" +QB_ACCESS_TOKEN: +QB_ACCESS_TOKEN_SECRET: +QB_APP_TOKEN: +QB_CONSUMER_KEY: +QB_CONSUMER_SECRET: +QB_REALM_ID: +RAILS_ENABLE_TEST_LOG: ~ +RECAPTCHA_SECRET_KEY: '' +RECAPTCHA_SECRET_KEY_V3: '' +RECAPTCHA_SITE_KEY: '' +RECAPTCHA_SITE_KEY_V3: '' +ROLLBAR_ACCESS_TOKEN: '' +SECRET_TOKEN: +SMTP_PASSWORD: +SMTP_USERNAME: +STRIPE_ACCOUNT_SIGNING_SECRET: +STRIPE_CLIENT_ID: +STRIPE_CONNECT_SIGNING_SECRET: +STRIPE_DEV_MARKET_ACCOUNT_ID: +STRIPE_PUBLISHABLE_KEY: +STRIPE_SECRET_KEY: +SUPPORT_PHONE_NUMBER: '(800) 598-3351' +TRANS_DB_URL: +TWITTER_WIDGET_ID: 'create-me-at-twitter-dot-com' +UPLOADS_ACCESS_KEY_ID: +UPLOADS_BUCKET: +UPLOADS_REGION: +UPLOADS_SECRET_ACCESS_KEY: +USE_DELAYED_JOB: 'true' +USE_ROLLBAR: 'false' +USE_UPLOAD_QUEUE: 'true' diff --git a/.env.test b/.env.test new file mode 100644 index 0000000000..25890fcb96 --- /dev/null +++ b/.env.test @@ -0,0 +1,2 @@ +CAPYBARA_WAIT_TIME: '180' +USE_UPLOAD_QUEUE: 'false' diff --git a/.gitignore b/.gitignore index f8944d74c9..54005d2a4c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,9 @@ dragonfly.log /tempfiles/* # Ignore application configuration +.env +.env.local +.env.*.local /config/application.yml /dragonfly public/system/dragonfly/development @@ -52,4 +55,4 @@ node_modules/ /snippets -.DS_Store \ No newline at end of file +.DS_Store diff --git a/.ruby-version b/.ruby-version index bc4abe86de..b0f6bf0cd2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.8 +2.4.10 diff --git a/Capfile b/Capfile new file mode 100644 index 0000000000..38ebb1452c --- /dev/null +++ b/Capfile @@ -0,0 +1,41 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +# require "capistrano/deploy" +require 'capistrano/git_deploy' +require 'capistrano/aws' + +# Load the SCM plugin appropriate to your project: +# +# require "capistrano/scm/hg" +# install_plugin Capistrano::SCM::Hg +# or +# require "capistrano/scm/svn" +# install_plugin Capistrano::SCM::Svn +# or +require "capistrano/scm/git" +install_plugin Capistrano::SCM::Git + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require "capistrano/rvm" +# require "capistrano/rbenv" +# require "capistrano/chruby" +require 'capistrano/bundler' +require 'capistrano/rails/assets' +require 'capistrano/rails/migrations' +require 'capistrano/passenger' +require 'capistrano/yarn' + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/Gemfile b/Gemfile index 253101fe3c..55f8ffa74b 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,12 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end -ruby '2.3.8' +ruby '2.4.10' -gem 'rails', '~> 4.1.11' +# This needs to load before other gems +gem 'dotenv-rails', require: 'dotenv/rails-now' + +gem 'rails', '~> 4.2.11.3' gem 'pg', '~> 0.21.0' @@ -28,7 +31,6 @@ gem 'wysihtml5-rails' gem 'active_model_serializers' gem 'active_record_query_trace' gem 'active_record_union' -gem 'acts_as_geocodable' gem 'audited-activerecord' gem 'awesome_nested_set' gem 'bootsnap', require: false # TODO: Remove this when we upgrade to rails 5.2 @@ -36,28 +38,27 @@ gem 'color' gem 'countries' gem 'csv_builder' gem 'delayed_job_active_record' -gem 'devise', '~> 3.5.10' +gem 'devise' gem 'devise_invitable' gem 'devise_masquerade' gem 'dragonfly-s3_data_store' gem 'draper' -gem 'figaro' -gem 'font_assets' -gem 'graticule' gem 'groupdate', :git => 'https://github.com/trestrantham/groupdate.git', :branch => 'custom-calculations' # Waiting on https://github.com/ankane/groupdate/pull/53 gem 'interactor-rails', '< 3.0' gem 'interactor', '< 3.0' # We are not ready for 3 yet gem 'jbuilder' gem 'jwt' -gem 'kaminari' # Paginator +gem 'kaminari' +gem 'mini_racer' gem 'pdfkit' gem 'periscope-activerecord' gem 'pg_search' -gem 'postgres_ext' gem 'rack-canonical-host' -gem 'ransack' +gem 'ransack', '1.6.4' gem 'recaptcha' +# RAILS42 TODO: gem 'responders', '~> 2.0' gem 'simpleidn' +gem 'skylight' gem 'stripe', '5.14.0' gem 'stripe_event', '2.3.0' gem 'font-awesome-rails' @@ -82,12 +83,15 @@ gem 'rschema', :git => 'https://github.com/tomdalling/rschema.git' gem 'turbolinks' -install_if -> { RUBY_PLATFORM =~ /darwin/ } do - gem 'wkhtmltopdf-binary', '0.12.5.1' -end -install_if -> { ENV['ON_HEROKU'] == 'true' } do - gem 'wkhtmltopdf-heroku' +install_if -> { ENV['ON_HEROKU'] != 'true' } do + # Maybe try 0.12.5.4 if run into issues + gem 'wkhtmltopdf-binary', '0.12.5.4' end +# install_if -> { ENV['ON_HEROKU'] == 'true' } do +# gem 'wkhtmltopdf-heroku' +# gem 'rails_12factor' +# gem 'platform-api' +# end # Product import/export gem 'rubyXL', require: false # XLSX @@ -99,6 +103,7 @@ gem 'grape' # API v2 gem 'grape-active_model_serializers' # API v2 gem 'rack-cors', :require => 'rack/cors' # API v2 gem 'grape-swagger' # API V2, documentation +gem 'puma' gem 'rollbar' @@ -110,7 +115,15 @@ group :doc do end group :development do + gem 'aws_config' gem 'bullet' + gem 'capistrano' + gem 'capistrano-aws', require: false + gem 'capistrano-bundler' + gem 'capistrano-git_deploy', github: 'thermistor/capistrano-git_deploy', require: false + gem 'capistrano-passenger' + gem 'capistrano-rails' + gem 'capistrano-yarn' gem 'ultrahook' gem 'spring' gem 'spring-commands-rspec' @@ -121,7 +134,6 @@ group :development do gem 'rails_view_annotator' gem 'rubycritic', require: false gem 'mailcatcher' - gem 'unicorn' # profiling, see https://github.com/MiniProfiler/rack-mini-profiler#installation gem 'rack-mini-profiler' @@ -130,7 +142,7 @@ group :development do gem 'stackprof' end -group :development, :test do +group :development, :test, :build do gem 'factory_bot_rails' gem 'rspec-rails', '~> 3.0' gem 'rspec_junit_formatter', :git => 'https://github.com/sj26/rspec_junit_formatter.git' @@ -164,19 +176,9 @@ group :test do gem 'stripe-ruby-mock', '~> 2.5.8', :require => 'stripe_mock' end -group :staging do - gem 'skylight' -end - group :production, :staging do gem 'newrelic_rpm' gem 'newrelic-dragonfly' #gem 'passenger' - gem 'rack-cache', require: 'rack/cache' - gem 'rails_12factor' - gem 'platform-api' -end - -group :production, :staging, :development do - gem 'puma' + # gem 'rack-cache', require: 'rack/cache' end diff --git a/Gemfile.lock b/Gemfile.lock index 44cbd306a2..13469c4f63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,6 +23,13 @@ GIT rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) +GIT + remote: https://github.com/thermistor/capistrano-git_deploy.git + revision: a1638230d12c007b6227dd9b839990de2bdcbd2a + specs: + capistrano-git_deploy (0.0.5) + capistrano (>= 3.11.0) + GIT remote: https://github.com/tomdalling/rschema.git revision: 867ff1524a0791aaee6a0225d3e17b39cd7092ee @@ -50,47 +57,54 @@ GIT GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.1) + CFPropertyList (2.3.6) accountingjs-rails (0.0.4) - actionmailer (4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) + actionmailer (4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.16) - actionview (= 4.1.16) - activesupport (= 4.1.16) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.11.3) + actionview (= 4.2.11.3) + activesupport (= 4.2.11.3) + rack (~> 1.6) rack-test (~> 0.6.2) - actionview (4.1.16) - activesupport (= 4.1.16) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.3) active_model_serializers (0.9.0) activemodel (>= 3.2) active_record_query_trace (1.5.4) active_record_union (1.0.1) activerecord (>= 4.0) - activemodel (4.1.16) - activesupport (= 4.1.16) + activejob (4.2.11.3) + activesupport (= 4.2.11.3) + globalid (>= 0.3.0) + activemodel (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) - activerecord (4.1.16) - activemodel (= 4.1.16) - activesupport (= 4.1.16) - arel (~> 5.0.0) + activerecord (4.2.11.3) + activemodel (= 4.2.11.3) + activesupport (= 4.2.11.3) + arel (~> 6.0) activerecord-import (0.10.0) activerecord (>= 3.0) - activesupport (4.1.16) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activesupport (4.2.11.3) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts_as_geocodable (2.1.0) - graticule (~> 2.0) - rails (>= 3, < 4.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - arel (5.0.1.20140414130214) + airbrussh (1.4.0) + sshkit (>= 1.6.1, != 1.7.0) + arel (6.0.4) ast (2.4.0) attr_encrypted (3.0.3) encryptor (~> 3.0.0) @@ -99,14 +113,27 @@ GEM audited-activerecord (4.0.0) activerecord (~> 4.0) audited (= 4.0.0) - awesome_nested_set (3.0.1) - activerecord (>= 4.0.0, < 5) + awesome_nested_set (3.2.0) + activerecord (>= 4.0.0, < 7.0) awesome_print (1.2.0) + aws-eventstream (1.0.3) + aws-partitions (1.295.0) aws-sdk (1.56.0) aws-sdk-v1 (= 1.56.0) + aws-sdk-core (3.93.0) + aws-eventstream (~> 1.0, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-ec2 (1.151.0) + aws-sdk-core (~> 3, >= 3.71.0) + aws-sigv4 (~> 1.1) aws-sdk-v1 (1.56.0) json (~> 1.4) nokogiri (>= 1.4.4) + aws-sigv4 (1.1.1) + aws-eventstream (~> 1.0, >= 1.0.2) + aws_config (0.1.0) axiom-types (0.1.1) descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) @@ -115,8 +142,8 @@ GEM babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - bcrypt (3.1.11) - bootsnap (1.4.5) + bcrypt (3.1.13) + bootsnap (1.4.6) msgpack (~> 1.0) browserify-rails (0.9.3) sprockets (~> 2.2) @@ -126,6 +153,25 @@ GEM uniform_notifier (~> 1.11.0) byebug (5.0.0) columnize (= 0.9.0) + capistrano (3.12.1) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-aws (1.2.1) + aws-sdk-ec2 (~> 1) + capistrano (~> 3.1) + colorize (~> 0.8) + terminal-table (~> 1.7) + capistrano-bundler (1.6.0) + capistrano (~> 3.1) + capistrano-passenger (0.2.0) + capistrano (~> 3.0) + capistrano-rails (1.4.0) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-yarn (2.0.2) + capistrano (~> 3.0) capybara (2.18.0) addressable mini_mime (>= 0.1.3) @@ -169,6 +215,7 @@ GEM currencies (~> 0.4.2) crack (0.4.3) safe_yaml (~> 1.0.0) + crass (1.0.6) csv_builder (2.1.1) actionpack (>= 3.0.0) currencies (0.4.2) @@ -183,23 +230,26 @@ GEM delayed_job (>= 3.0, < 5) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.10) + devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) + railties (>= 4.1.0) responders - thread_safe (~> 0.1) warden (~> 1.2.3) - devise_invitable (1.6.1) - actionmailer (>= 3.2.6) - devise (>= 3.2.0) - devise_masquerade (0.1.5) + devise_invitable (1.7.5) + actionmailer (>= 4.1.0) + devise (>= 4.0.0) + devise_masquerade (0.6.5) devise (>= 2.1.0) railties (>= 3.0) diff-lcs (1.3) docile (1.3.2) domino (0.7.0) capybara (>= 0.4.0) + dotenv (2.7.5) + dotenv-rails (2.7.5) + dotenv (= 2.7.5) + railties (>= 3.2, < 6.1) dragonfly (1.0.7) addressable (~> 2.3) multi_json (~> 1.0) @@ -212,6 +262,7 @@ GEM activemodel (>= 3.0) activesupport (>= 3.0) request_store (~> 1.0.3) + dry-inflector (0.2.0) email_spec (1.6.0) launchy (~> 2.1) mail (~> 2.2) @@ -219,7 +270,7 @@ GEM equalizer (0.0.11) erubis (2.7.0) eventmachine (1.0.5) - excon (0.72.0) + excon (0.73.0) execjs (2.7.0) factory_bot (4.8.2) activesupport (>= 3.0.0) @@ -229,8 +280,6 @@ GEM faraday (0.12.2) multipart-post (>= 1.2, < 3) ffi (1.12.2) - figaro (1.1.1) - thor (~> 0.14) fire_poll (1.2.0) fission (0.5.0) CFPropertyList (~> 2.2) @@ -244,17 +293,26 @@ GEM path_expander (~> 1.0) ruby_parser (~> 3.1, > 3.1.0) sexp_processor (~> 4.8) - fog (1.30.0) + fog (1.41.0) + fog-aliyun (>= 0.1.0) fog-atmos - fog-aws (~> 0.0) + fog-aws (>= 0.6.0) fog-brightbox (~> 0.4) - fog-core (~> 1.27, >= 1.27.4) - fog-ecloud - fog-google (>= 0.0.2) + fog-cloudatcost (~> 0.1.0) + fog-core (~> 1.45) + fog-digitalocean (>= 0.3.0) + fog-dnsimple (~> 1.0) + fog-dynect (~> 0.0.2) + fog-ecloud (~> 0.1) + fog-google (<= 0.1.0) + fog-internet-archive + fog-joyent fog-json fog-local + fog-openstack fog-powerdns (>= 0.1.1) fog-profitbricks + fog-rackspace fog-radosgw (>= 0.0.2) fog-riakcs fog-sakuracloud (>= 0.0.4) @@ -264,49 +322,86 @@ GEM fog-terremark fog-vmfusion fog-voxel + fog-vsphere (>= 0.4.0) + fog-xenserver fog-xml (~> 0.1.1) ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) + json (>= 1.8, < 2.0) + fog-aliyun (0.3.8) + fog-core + fog-json + ipaddress (~> 0.8) + xml-simple (~> 1.1) fog-atmos (0.1.0) fog-core fog-xml - fog-aws (0.7.4) - fog-core (~> 1.27) + fog-aws (2.0.1) + fog-core (~> 1.38) fog-json (~> 1.0) fog-xml (~> 0.1) ipaddress (~> 0.8) - fog-brightbox (0.7.1) - fog-core (~> 1.22) + fog-brightbox (0.16.1) + dry-inflector + fog-core fog-json - inflecto (~> 0.0.2) - fog-core (1.32.0) + mime-types + fog-cloudatcost (0.1.2) + fog-core (~> 1.36) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-core (1.45.0) builder - excon (~> 0.45) + excon (~> 0.58) formatador (~> 0.2) - mime-types - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - fog-ecloud (0.1.1) + fog-digitalocean (0.4.0) + fog-core + fog-json + fog-xml + ipaddress (>= 0.5) + fog-dnsimple (1.0.0) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-dynect (0.0.3) + fog-core + fog-json + fog-xml + fog-ecloud (0.3.0) fog-core fog-xml - fog-google (0.0.5) + fog-google (0.1.0) fog-core fog-json fog-xml - fog-json (1.0.2) - fog-core (~> 1.0) + fog-internet-archive (0.0.1) + fog-core + fog-json + fog-xml + fog-joyent (0.0.1) + fog-core (~> 1.42) + fog-json (>= 1.0) + fog-json (1.2.0) + fog-core multi_json (~> 1.10) - fog-local (0.2.1) - fog-core (~> 1.27) - fog-powerdns (0.1.1) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - fog-profitbricks (0.0.2) + fog-local (0.6.0) + fog-core (>= 1.27, < 3.0) + fog-openstack (0.3.10) + fog-core (>= 1.45, <= 2.1.0) + fog-json (>= 1.0) + ipaddress (>= 0.8) + fog-powerdns (0.2.0) fog-core + fog-json fog-xml - nokogiri - fog-radosgw (0.0.4) + fog-profitbricks (4.1.1) + fog-core (~> 1.42) + fog-json (~> 1.0) + fog-rackspace (0.1.6) + fog-core (>= 1.35) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.8) + fog-radosgw (0.0.5) fog-core (>= 1.21.0) fog-json fog-xml (>= 0.0.1) @@ -314,13 +409,13 @@ GEM fog-core fog-json fog-xml - fog-sakuracloud (1.0.1) + fog-sakuracloud (1.7.5) fog-core fog-json fog-serverlove (0.1.2) fog-core fog-json - fog-softlayer (0.4.6) + fog-softlayer (1.1.4) fog-core fog-json fog-storm_on_demand (0.1.1) @@ -335,15 +430,22 @@ GEM fog-voxel (0.1.0) fog-core fog-xml - fog-xml (0.1.2) + fog-vsphere (3.2.5) + fog-core + rbvmomi (>= 1.9, < 3) + fog-xenserver (1.0.0) + fog-core + fog-xml + xmlrpc + fog-xml (0.1.3) fog-core - nokogiri (~> 1.5, >= 1.5.11) + nokogiri (>= 1.5.11, < 2.0.0) font-awesome-rails (4.4.0.0) railties (>= 3.2, < 5.0) - font_assets (0.1.11) - rack formatador (0.2.5) fssm (0.2.10) + globalid (0.4.2) + activesupport (>= 4.2.0) grape (1.1.0) activesupport builder @@ -360,11 +462,6 @@ GEM grape-swagger (0.10.4) grape (>= 0.8.0) grape-entity (< 0.5.0) - graticule (2.5.0) - activesupport - i18n - json - nokogiri-happymapper (>= 0.5.9) guard (2.14.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -386,10 +483,6 @@ GEM rspec (>= 2.99.0, < 4.0) hashdiff (1.0.0) hashie (3.6.0) - heroics (0.0.22) - erubis (~> 2.0) - excon - multi_json (>= 1.9.2) hike (1.2.3) httparty (0.13.7) json (~> 1.8) @@ -397,15 +490,15 @@ GEM i18n (0.9.5) concurrent-ruby (~> 1.0) ice_nine (0.11.2) - inflecto (0.0.2) interactor (2.1.1) interactor-rails (1.0.1) interactor (< 3) rails (>= 3, < 5) - ipaddress (0.8.0) + ipaddress (0.8.3) jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) + jmespath (1.4.0) jquery-fileupload-rails (0.4.7) actionpack (>= 3.1) railties (>= 3.1) @@ -420,7 +513,6 @@ GEM kaminari (0.16.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - kgio (2.10.0) kiba (0.6.1) konacha (4.0.0) actionpack (>= 4.1, < 5) @@ -433,11 +525,15 @@ GEM konacha-chai-matchers (1.0.0) launchy (2.4.3) addressable (~> 2.3) + libv8 (7.3.492.27.1) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) + loofah (2.6.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) lumberjack (1.0.12) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) mailcatcher (0.6.1) activesupport (>= 4.0.0, < 5) @@ -455,8 +551,9 @@ GEM mime-types-data (3.2019.1009) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.14.0) - moneta (0.8.1) + mini_racer (0.2.9) + libv8 (>= 6.9.411) + minitest (5.14.1) msgpack (1.3.3) multi_json (1.14.1) multi_xml (0.6.0) @@ -466,17 +563,15 @@ GEM mustermann-grape (1.0.1) mustermann (>= 1.0.0) nenv (0.3.0) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.2) + net-scp (2.0.0) + net-ssh (>= 2.6.5, < 6.0.0) + net-ssh (5.2.0) newrelic-dragonfly (0.0.4) dragonfly newrelic_rpm newrelic_rpm (5.2.0.345) nokogiri (1.10.9) mini_portile2 (~> 2.4.0) - nokogiri-happymapper (0.5.9) - nokogiri (~> 1.5) notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) @@ -496,6 +591,7 @@ GEM omniauth-stripe-connect (2.10.1) omniauth (~> 1.3) omniauth-oauth2 (~> 1.4) + optimist (3.0.0) orm_adapter (0.5.0) parallel (1.19.1) parser (2.4.0.2) @@ -507,20 +603,12 @@ GEM activerecord (>= 3, < 5) periscope (~> 2.1.0) pg (0.21.0) - pg_array_parser (0.0.9) pg_search (0.7.8) activerecord (>= 3.1) activesupport (>= 3.1) arel - platform-api (2.0.0) - heroics (~> 0.0.22) - moneta (~> 0.8.1) - polyamorous (1.1.0) + polyamorous (1.3.3) activerecord (>= 3.0) - postgres_ext (2.3.0) - activerecord (>= 4.0.0) - arel (>= 4.0.1) - pg_array_parser (~> 0.0.9) powerpack (0.1.2) pry (0.11.3) coderay (~> 1.1.0) @@ -539,11 +627,9 @@ GEM activesupport (>= 3.0.0) quiet_assets (1.0.3) railties (>= 3.1, < 5.0) - rack (1.5.5) + rack (1.6.13) rack-accept (0.4.5) rack (>= 0.4) - rack-cache (1.2) - rack (>= 0.4) rack-canonical-host (0.1.0) addressable rack (~> 1.0) @@ -555,34 +641,37 @@ GEM rack-test (0.6.3) rack (>= 1.0) railroady (1.5.3) - rails (4.1.16) - actionmailer (= 4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) - activemodel (= 4.1.16) - activerecord (= 4.1.16) - activesupport (= 4.1.16) + rails (4.2.11.3) + actionmailer (= 4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) + activemodel (= 4.2.11.3) + activerecord (= 4.2.11.3) + activesupport (= 4.2.11.3) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.16) - sprockets-rails (~> 2.0) + railties (= 4.2.11.3) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) + nokogiri (~> 1.6) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rails-observers (0.1.2) activemodel (~> 4.0) - rails_12factor (0.0.2) - rails_serve_static_assets - rails_stdout_logging - rails_serve_static_assets (0.0.2) - rails_stdout_logging (0.0.3) rails_view_annotator (0.0.10) - railties (4.1.16) - actionpack (= 4.1.16) - activesupport (= 4.1.16) + railties (4.2.11.3) + actionpack (= 4.2.11.3) + activesupport (= 4.2.11.3) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) rake - raindrops (0.17.0) rake (13.0.1) - ransack (1.3.0) + ransack (1.6.4) actionpack (>= 3.0) activerecord (>= 3.0) activesupport (>= 3.0) @@ -591,6 +680,11 @@ GEM rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) + rbvmomi (2.3.1) + builder (~> 3.0) + json (>= 1.8) + nokogiri (~> 1.5) + optimist (~> 3.0) rdoc (4.1.1) json (~> 1.4) react-rails (1.4.2) @@ -607,8 +701,9 @@ GEM parser (>= 2.4.0.0, < 2.5) rainbow (~> 2.0) request_store (1.0.8) - responders (1.1.2) - railties (>= 3.2, < 4.2) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) rollbar (2.23.2) roxml (3.3.1) activesupport (>= 2.3.0) @@ -690,8 +785,10 @@ GEM skinny (0.2.3) eventmachine (~> 1.0.0) thin (~> 1.5.0) - skylight (1.5.1) - activesupport (>= 3.0.0) + skylight (4.2.3) + skylight-core (= 4.2.3) + skylight-core (4.2.3) + activesupport (>= 4.2.0) slop (3.6.0) spreadsheet (1.0.3) ruby-ole (>= 1.0) @@ -708,6 +805,9 @@ GEM activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) sqlite3 (1.3.11) + sshkit (1.21.0) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) stackprof (0.2.11) stripe (5.14.0) stripe-ruby-mock (2.5.8) @@ -717,18 +817,20 @@ GEM stripe_event (2.3.0) activesupport (>= 3.1) stripe (>= 2.8, < 6) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) thin (1.5.1) daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0) - thor (0.20.3) + thor (1.0.1) thread_safe (0.3.6) tilt (1.4.1) timecop (0.7.1) tty-which (0.3.0) turbolinks (2.5.3) coffee-rails - tzinfo (1.2.6) + tzinfo (1.2.7) thread_safe (~> 0.1) uglifier (2.7.2) execjs (>= 0.3.0) @@ -737,10 +839,6 @@ GEM json (>= 1.8.0) underscore-rails (1.7.0) unicode-display_width (1.6.1) - unicorn (4.9.0) - kgio (~> 2.6) - rack - raindrops (~> 0.7) uniform_notifier (1.11.0) vcr (4.0.0) virtus (1.0.5) @@ -758,13 +856,14 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - wkhtmltopdf-binary (0.12.5.1) - wkhtmltopdf-heroku (2.12.3.0) + wkhtmltopdf-binary (0.12.5.4) wysihtml5-rails (0.0.4) railties (>= 3.1.0) wysiwyg-rails (1.2.8) font-awesome-rails (>= 4.3.0.0) railties (>= 3.2, < 5.0) + xml-simple (1.1.5) + xmlrpc (0.3.0) xpath (3.2.0) nokogiri (~> 1.8) @@ -777,16 +876,23 @@ DEPENDENCIES active_record_query_trace active_record_union activerecord-import - acts_as_geocodable attr_encrypted (~> 3.0.0) audited-activerecord awesome_nested_set awesome_print aws-sdk + aws_config bootsnap browserify-rails bullet byebug + capistrano + capistrano-aws + capistrano-bundler + capistrano-git_deploy! + capistrano-passenger + capistrano-rails + capistrano-yarn capybara capybara-screenshot capybara-slow_finder_errors @@ -799,23 +905,21 @@ DEPENDENCIES database_cleaner dedent delayed_job_active_record - devise (~> 3.5.10) + devise devise_invitable devise_masquerade domino (< 0.8.0) + dotenv-rails dragonfly-s3_data_store draper email_spec factory_bot_rails - figaro fire_poll (= 1.2.0) flamegraph font-awesome-rails - font_assets grape grape-active_model_serializers grape-swagger - graticule groupdate! guard-konacha-rails guard-rspec @@ -834,6 +938,7 @@ DEPENDENCIES mailcatcher memory_profiler migration_data + mini_racer newrelic-dragonfly newrelic_rpm omniauth-stripe-connect @@ -841,8 +946,6 @@ DEPENDENCIES periscope-activerecord pg (~> 0.21.0) pg_search - platform-api - postgres_ext pry-byebug pry-rails pry-remote @@ -850,15 +953,13 @@ DEPENDENCIES pundit quickbooks-ruby! quiet_assets - rack-cache rack-canonical-host rack-cors rack-mini-profiler railroady - rails (~> 4.1.11) - rails_12factor + rails (~> 4.2.11.3) rails_view_annotator - ransack + ransack (= 1.6.4) react-rails recaptcha rollbar @@ -890,17 +991,15 @@ DEPENDENCIES uglifier (~> 2.7.2) ultrahook underscore-rails - unicorn vcr webdrivers webmock - wkhtmltopdf-binary (= 0.12.5.1) - wkhtmltopdf-heroku + wkhtmltopdf-binary (= 0.12.5.4) wysihtml5-rails wysiwyg-rails RUBY VERSION - ruby 2.3.8p459 + ruby 2.4.10p364 BUNDLED WITH 1.17.3 diff --git a/README.md b/README.md index e9f3e08f7b..c641480672 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,13 @@ See the `docs/` directory for more documentation. ## Developer Setup -1. Install `ruby 2.3.8` (use a ruby version manage like [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/)) +1. Install `ruby 2.4.10` (use a ruby version manage like [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/)) 1. Clone this repo `git clone git@github.com:LocalOrbit/localorbit.git`, `cd localorbit` into it 1. Install dependencies (for MacOs) via [Homebrew](https://brew.sh/) with `brew bundle`. Other platforms see requirements in [`Brewfile`](./Brewfile). 1. `bundle` 1. `cp config/application.yml{.example,}` and modify if needed, see [Environment variables](#environment_variables) below 1. `cp config/database.yml{.example,}` and modify if needed (Some modification is probably necessary. Try adding `template: template0`) +1. `cp .env.sample .env` and customize with your own api keys, etc. 1. `yarn` 1. `rake db:setup` - runs `db:create`, `db:schema:load` and `db:seed` 1. `rake db:seed:development` - See [Test Accounts](#test-accounts) section for usernames and passwords @@ -32,11 +33,12 @@ See the `docs/` directory for more documentation. 2. Configure an API key and secret 3. [Configure the AWS cli tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) (which should already be installed via `brew bundle`.) -### Environment variables +## Environment variables -`ENV` is generally accessed via [figaro](https://github.com/laserlemon/figaro) in application code. Figaro enforces presence of required `ENV` vars via [`config/initializers/figaro.rb`](./config/figaro.rb). In `development` and local `test` environments we populate/customize `ENV` via figaro with `config/application.yml` (see an [example application.yml](./config/application.yml.example)). For Heroku `staging` and `production` environments the `ENV` vars are populated with [Heroku cli](https://devcenter.heroku.com/articles/config-vars). For [CircleCI](https://circleci.com/gh/LocalOrbit), sensitive `ENV` vars like API keys and other secrets are managed via the [Circle CI web application](https://circleci.com/gh/LocalOrbit/localorbit/edit#env-vars), and non-sensitive `ENV` vars are managed via the [`.circleci/config.yml`](./.circleci/config.yml). +`ENV` is accessed via [dotenv](https://github.com/bkeepers/dotenv). For `build`, `staging` and `production` environments the `ENV` vars are populated via ansible automation, see [localorbit-ansible](https://github.com/thermistor/localorbit-ansible). For [CircleCI](https://circleci.com/gh/LocalOrbit), sensitive `ENV` vars like API keys and other secrets are managed via the [Circle CI web application](https://circleci.com/gh/LocalOrbit/localorbit/edit#env-vars), and non-sensitive `ENV` vars are managed via the [`.circleci/config.yml`](./.circleci/config.yml). -### Production Setup + +## Data Setup * At least one Market must be created before creating Organizations @@ -59,54 +61,44 @@ Password: password1 Email: admin@example.com Password: password1 -### Javascript Specs - -Specs live in spec/javascripts/\*.js.coffee - -Run suite on command line: bundle exec rake konacha:run -Run suite via browser: bundle exec rake konacha:serve (then visit http://localhost:3500) -Run suite automatically on changes to javascript sources or specs: bundle exec guard - - -### Cloning staging for local development - -Run `rake db:dump:staging` +## Testing -**WARNING: This will replace EVERYTHING in your development db with what is currently on staging** +To run rspec tests: -### Load production data into development or staging + rspec -Below is a quick overview, for more granular tasks see [production-copy.rake](lib/tasks/production-copy.rake). +or -#### Into development + rake -If no existing cleansed production dump, all-in-one go: +[CircleCI](https://circleci.com/gh/LocalOrbit/localorbit/tree/master) auatomatically runs tests on every commit. - rake production_copy:stomp_dev_db DOWNLOAD_NEW=YES REALLY=YES +### Javascript Specs -If an existing dump: +Specs live in spec/javascripts/\*.js.coffee - rake production_copy:stomp_dev_db REALLY=YES +Run suite on command line: `bundle exec rake konacha:run` +Run suite via browser: `bundle exec rake konacha:serve (then visit http://localhost:3500)` +Run suite automatically on changes to javascript sources or specs: bundle exec guard -Or two step +## Deployment - rake production_copy:bring_down - rake production_copy:stomp_dev_db REALLY=YES +We have a `build` environment that is setup via the [localorbit-ansible](https://github.com/thermistor/localorbit-ansible) project with Vagrant. -#### Into staging +As well there are `staging` and `production` environments which are hosted on AWS. You will need your ssh keys configured and pre-installed on the target environments servers by a colleague as per the `localorbit-ansible` project's instructions before you can deploy. -Load production data into staging via development, will also sync s3 from production to staging: +To deploy changes to the the `staging` environment, do the following command from the project directlry. This will deploy new code from the `staging` branch, and restart `passenger` and `delayed_job`. - rake production_copy:to[staging] + bundle exec cap staging deploy -Or if you already have a recent copy of production in development do: +The command is similar for `build` and `production`, just change the environment, eg. - rake production_copy:push_out[staging] + bundle exec cap production deploy +### Error reporting -### Heroku Notes +Errors are logged at [Rollbar](https://rollbar.com/LocalOrbit/all/items/). -There are _binstub_ helpers in `$RAILS_ROOT/bin` that allow for shortcuts when dealing with Heroku environments. See [binstubs plugin](https://github.com/tpope/heroku-binstubs) for usage & more info. ## Contributing See [development process](docs/development_process.md). diff --git a/app/assets/javascripts/fresh_sheets.js.coffee.erb b/app/assets/javascripts/fresh_sheets.js.coffee.erb index 7cff19c05e..4aaa6d090e 100644 --- a/app/assets/javascripts/fresh_sheets.js.coffee.erb +++ b/app/assets/javascripts/fresh_sheets.js.coffee.erb @@ -1,5 +1,5 @@ $ -> - $('.wysihtml5-textarea').editable({key: '<%= Figaro.env.froala_key %>', inlineMode: false, imageUpload: false, buttons: ['bold', 'italic', 'underline', 'sep', 'fontFamily', 'fontSize', 'color', 'sep', 'table', 'formatBlock', 'align', 'insertOrderedList', 'insertUnorderedList', 'outdent', 'indent', 'selectAll', 'createLink', 'insertImage', 'undo']}) + $('.wysihtml5-textarea').editable({key: '<%= ENV.fetch('FROALA_KEY') %>', inlineMode: false, imageUpload: false, buttons: ['bold', 'italic', 'underline', 'sep', 'fontFamily', 'fontSize', 'color', 'sep', 'table', 'formatBlock', 'align', 'insertOrderedList', 'insertUnorderedList', 'outdent', 'indent', 'selectAll', 'createLink', 'insertImage', 'undo']}) ### return unless $(".wysihtml5-textarea").length editor = new wysihtml5.Editor(document.querySelector('.wysihtml5-textarea'), { diff --git a/app/assets/javascripts/newsletter.js.coffee.erb b/app/assets/javascripts/newsletter.js.coffee.erb index 1add8c19bc..8cefac46f5 100644 --- a/app/assets/javascripts/newsletter.js.coffee.erb +++ b/app/assets/javascripts/newsletter.js.coffee.erb @@ -1,5 +1,5 @@ $ -> - $('.wysihtml5-textarea').editable({key: '<%= Figaro.env.froala_key %>', imageUpload: false, inlineMode: false, buttons: ['bold', 'italic', 'underline', 'sep', 'fontFamily', 'fontSize', 'color', 'sep', 'table', 'formatBlock', 'align', 'insertOrderedList', 'insertUnorderedList', 'outdent', 'indent', 'selectAll', 'createLink', 'insertImage', 'undo']}) + $('.wysihtml5-textarea').editable({key: '<%= ENV.fetch('FROALA_KEY') %>', imageUpload: false, inlineMode: false, buttons: ['bold', 'italic', 'underline', 'sep', 'fontFamily', 'fontSize', 'color', 'sep', 'table', 'formatBlock', 'align', 'insertOrderedList', 'insertUnorderedList', 'outdent', 'indent', 'selectAll', 'createLink', 'insertImage', 'undo']}) ### return unless $(".wysihtml5-textarea").length diff --git a/app/assets/stylesheets/modules-icons-icomoon.css.scss b/app/assets/stylesheets/modules-icons-icomoon.css.scss index ed3ad5ec43..ea4041e14e 100644 --- a/app/assets/stylesheets/modules-icons-icomoon.css.scss +++ b/app/assets/stylesheets/modules-icons-icomoon.css.scss @@ -1,8 +1,3 @@ -//= depend_on_asset "icomoon-ultimate.eot" -//= depend_on_asset "icomoon-ultimate.woff" -//= depend_on_asset "icomoon-ultimate.ttf" -//= depend_on_asset "icomoon-ultimate.svg" - @font-face { font-family: 'icomoon-ultimate88910'; src: asset_url('icomoon-ultimate.eot'); diff --git a/app/controllers/admin/metrics_controller.rb b/app/controllers/admin/metrics_controller.rb index 1793057f18..e795329237 100644 --- a/app/controllers/admin/metrics_controller.rb +++ b/app/controllers/admin/metrics_controller.rb @@ -16,13 +16,13 @@ def show end def map - @mapbox_map_id = Figaro.env.mapbox_api_key - markets = Market.where.not(id: Metrics::Base::TEST_MARKET_IDS).all. - joins("LEFT JOIN market_addresses ON (market_addresses.market_id = markets.id) AND (market_addresses.id = (SELECT market_addresses.id FROM market_addresses WHERE market_addresses.market_id = markets.id AND market_addresses.deleted_at IS NULL ORDER BY created_at ASC LIMIT 1))"). - joins("INNER JOIN geocodings ON geocodings.geocodable_type = 'MarketAddress' AND geocodings.geocodable_id = market_addresses.id"). - includes({organization: :plan}, addresses: [:geocoding]) - @map_data = ActiveModel::ArraySerializer.new(markets, each_serializer: MarketMapSerializer).to_json - @plans = plans_with_slugs + # @mapbox_map_id = ENV.fetch('MAPBOX_API_KEY') + # markets = Market.where.not(id: Metrics::Base::TEST_MARKET_IDS).all. + # joins("LEFT JOIN market_addresses ON (market_addresses.market_id = markets.id) AND (market_addresses.id = (SELECT market_addresses.id FROM market_addresses WHERE market_addresses.market_id = markets.id AND market_addresses.deleted_at IS NULL ORDER BY created_at ASC LIMIT 1))"). + # joins("INNER JOIN geocodings ON geocodings.geocodable_type = 'MarketAddress' AND geocodings.geocodable_id = market_addresses.id"). + # includes({organization: :plan}, addresses: [:geocoding]) + # @map_data = ActiveModel::ArraySerializer.new(markets, each_serializer: MarketMapSerializer).to_json + # @plans = plans_with_slugs end private diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb index 52f4649219..2a75310500 100644 --- a/app/controllers/admin/orders_controller.rb +++ b/app/controllers/admin/orders_controller.rb @@ -22,7 +22,7 @@ def index format.csv do @order_items = Orders::OrderItems.find_order_items(@orders.map(&:id), current_user) @abort_mission = @order_items.count > 2999 - if Figaro.env.use_upload_queue == "true" + if ENV.fetch('USE_UPLOAD_QUEUE') == "true" Delayed::Job.enqueue ::CSVExport::CSVOrderExportJob.new(current_user, @order_items.pluck(:id)), priority: 30 flash[:notice] = "Please check your email for export results." redirect_to admin_orders_path @@ -52,7 +52,7 @@ def purchase_orders format.csv do @order_items = Orders::OrderItems.find_order_items(@orders.map(&:id), current_user) @abort_mission = @order_items.count > 2999 - if Figaro.env.use_upload_queue == "true" + if ENV.fetch('USE_UPLOAD_QUEUE') == "true" Delayed::Job.enqueue ::CSVExport::CSVOrderExportJob.new(current_user, @order_items.pluck(:id)), priority: 30 flash[:notice] = "Please check your email for export results." redirect_to admin_purchase_orders_path diff --git a/app/controllers/api/v2/products.rb b/app/controllers/api/v2/products.rb index 079b581e1c..5b9c415120 100644 --- a/app/controllers/api/v2/products.rb +++ b/app/controllers/api/v2/products.rb @@ -5,37 +5,37 @@ module V2 ## API routes to mount - class Products < Grape::API + class Products < Grape::API include API::V2::Defaults - include Imports + include Imports - resource :products do + resource :products do ## get requests ## comment out until we determine auth access # desc "Return all products" - # get "", root: :products do + # get "", root: :products do # GeneralProduct.all # if you're actually looking for all products, this is what you want (TODO address issue: how should this GET deal with units?) # end # desc "Return a product" - # params do + # params do # requires :id, type: String, desc: "ID of the product" # end - # get ":id", root: "product" do + # get ":id", root: "product" do # Product.where(id: permitted_params[:id]).first! # end # desc "Return a product by name" - # params do + # params do # requires :name, type: String, desc: "Name of the product" # end - # get ":name", root: "product" do + # get ":name", root: "product" do # Product.where(name: permitted_params[:name]) # all that come up with that name search # end # desc "Return products by category" - # params do + # params do # requires :category, type: String, desc: "Name of category" # end # get ":category", root: "product" do # This one does not really work that well, eg category "carrots" gets all the cat "Vegetables", TODO examine priorities @@ -62,7 +62,7 @@ class Products < Grape::API if permitted_params[:code] product_code = permitted_params[:code] end - + gp_id_or_false = ::Imports::ProductHelpers.identify_product_uniqueness(permitted_params) if !gp_id_or_false product = Product.create!( @@ -104,20 +104,20 @@ class Products < Grape::API requires type: JSON # expects properly formatted JSON data end post '/add-products' do - + if params.class == Hashie::Mash # this should be the alternative case prod_hashes = params else - # this should be the 'normal' thing when you post a JSON /file/ as body per convention, Rails will put file in tempfile + # this should be the 'normal' thing when you post a JSON /file/ as body per convention, Rails will put file in tempfile prod_hashes = JSON.parse(File.read(params[:body][:tempfile])) end prod_hashes["products"].each do |p| - ::Imports::ProductHelpers.create_product_from_hash(p,Figaro.env.api_admin_user_id.to_i) + ::Imports::ProductHelpers.create_product_from_hash(p,ENV.fetch('API_ADMIN_USER_ID').to_i) end - {"result"=>"#{prod_hashes["products_total"]} products successfully created","errors"=>$row_errors} - end + {"result"=>"#{prod_hashes["products_total"]} products successfully created","errors"=>$row_errors} + end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8e63c402fe..04f11070ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -152,7 +152,7 @@ def ensure_user_not_suspended end def market_for_current_subdomain(scope=Market) - subdomain = request.subdomains(Figaro.env.domain.count(".")).first + subdomain = request.subdomains(ENV.fetch('DOMAIN').count(".")).first scope.find_by(subdomain: SimpleIDN.to_unicode(subdomain)) end @@ -167,7 +167,7 @@ def require_selected_market end def on_main_domain? - request.host == Figaro.env.domain || request.host == "app.#{Figaro.env.domain}" + request.host == ENV.fetch('DOMAIN') || request.host == "app.#{ENV.fetch('DOMAIN')}" end def adding_items_to_existing_order? @@ -348,8 +348,8 @@ def reset_session_ids end def configure_permitted_parameters - devise_parameter_sanitizer.for(:accept_invitation).concat [:name, :email] - devise_parameter_sanitizer.for(:account_update).concat [:name] + devise_parameter_sanitizer.permit(:accept_invitation, keys: [:name, :email]) + devise_parameter_sanitizer.permit(:account_update, keys: [:name]) end def redirect_to_url diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index ca3aa35d0b..a270054747 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -14,7 +14,7 @@ def show def create @registration = Registration.new(registration_params) - success = verify_recaptcha(action: 'registration', minimum_score: 0.2, secret_key: Figaro.env.recaptcha_secret_key_v3) + success = verify_recaptcha(action: 'registration', minimum_score: 0.2, secret_key: ENV.fetch('RECAPTCHA_SECRET_KEY_V3')) checkbox_success = verify_recaptcha(model: @registration) unless success if (success || checkbox_success) && @registration.save diff --git a/app/decorators/market_decorator.rb b/app/decorators/market_decorator.rb index 4adbd65d6a..a62ff6bf01 100644 --- a/app/decorators/market_decorator.rb +++ b/app/decorators/market_decorator.rb @@ -15,7 +15,7 @@ def first_address def default_address default_addrs = addresses.visible.select{|addr| addr if addr.default? } # this should have only one in the array if any - unless default_addrs.empty? + unless default_addrs.empty? default_addrs.first else addresses.visible.first # if an address can be properly default or billing via those attrs, it must also be visible (not soft-deleted) @@ -25,7 +25,7 @@ def default_address def billing_address billing_addrs = addresses.visible.select{|addr| addr if addr.billing? } # should be just one again unless billing_addrs.empty? - billing_addrs.first + billing_addrs.first else addresses.visible.first end @@ -39,11 +39,12 @@ def remit_to_address end def seller_locations_map(w=400, h=300) - addresses = organizations.selling.map do |seller| - seller.shipping_location.geocode if seller.shipping_location - end.compact + # addresses = organizations.selling.map do |seller| + # seller.shipping_location.geocode if seller.shipping_location + # end.compact - google_static_map(addresses, default_address.try(:geocode), w, h) + # google_static_map(addresses, default_address.try(:geocode), w, h) + "" end def has_address? diff --git a/app/decorators/order_decorator.rb b/app/decorators/order_decorator.rb index 37fbe14de7..8a6a9dca0d 100644 --- a/app/decorators/order_decorator.rb +++ b/app/decorators/order_decorator.rb @@ -30,12 +30,13 @@ def display_delivery_phone end def delivery_lat_long - address = organization.locations.default_shipping - if !address.nil? && !address.geocode.nil? - raw "#{address.geocode.latitude},#{address.geocode.longitude}" - else - "" - end + # address = organization.locations.default_shipping + # if !address.nil? && !address.geocode.nil? + # raw "#{address.geocode.latitude},#{address.geocode.longitude}" + # else + # "" + # end + "" end def display_market_street diff --git a/app/decorators/organization_decorator.rb b/app/decorators/organization_decorator.rb index 1f0a4f3128..2bff2fcfa5 100644 --- a/app/decorators/organization_decorator.rb +++ b/app/decorators/organization_decorator.rb @@ -9,11 +9,12 @@ def human_org_type end def locations_map(w=340, h=300) - addresses = locations.visible.map do |location| - location.geocode if location - end.compact + # addresses = locations.visible.map do |location| + # location.geocode if location + # end.compact - google_static_map(addresses, addresses.first, w, h, 11) + # google_static_map(addresses, addresses.first, w, h, 11) + "" end def ship_from_address @@ -25,12 +26,13 @@ def ship_from_address end def ship_from_lat_long - address = shipping_location - if !address.nil? && !address.geocode.nil? - raw "#{address.geocode.latitude},#{address.geocode.longitude}" - else - "" - end + # address = shipping_location + # if !address.nil? && !address.geocode.nil? + # raw "#{address.geocode.latitude},#{address.geocode.longitude}" + # else + # "" + # end + "" end def delivery_schedules diff --git a/app/decorators/organization_item_decorator.rb b/app/decorators/organization_item_decorator.rb index b396336f64..6afb77d0ea 100644 --- a/app/decorators/organization_item_decorator.rb +++ b/app/decorators/organization_item_decorator.rb @@ -28,11 +28,12 @@ def location end def location_map(w=300, h=200) - if location && location.geocode - google_static_map([location.geocode], location.geocode, w, h, 11) - else - "" - end + # if location && location.geocode + # google_static_map([location.geocode], location.geocode, w, h, 11) + # else + # "" + # end + "" end def location_label diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b72f852731..dde7b6beca 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,7 +15,7 @@ def organization_can_access?(organization, flag) def pdf_asset_url(asset) path = asset_path(asset) - "#{Figaro.env.pdf_asset_host}#{path}" + "#{ENV.fetch('PDF_ASSET_HOST')}#{path}" end # Used in navigation to get to the users organization(s) diff --git a/app/helpers/map_helper.rb b/app/helpers/map_helper.rb index b106b33e02..d0f23f7be1 100644 --- a/app/helpers/map_helper.rb +++ b/app/helpers/map_helper.rb @@ -8,24 +8,26 @@ def static_map(geocodes, center, width, height, zoom=9) width = width > 640 ? 640 : width height = height > 640 ? 640 : height - "//api.tiles.mapbox.com/v3/#{Figaro.env.mapbox_api_key}#{markers}/#{center.longitude},#{center.latitude},#{zoom}/#{width}x#{height}@2x.png" + "//api.tiles.mapbox.com/v3/#{ENV.fetch('MAPBOX_API_KEY')}#{markers}/#{center.longitude},#{center.latitude},#{zoom}/#{width}x#{height}@2x.png" end def google_static_map(geocodes, center, width, height, zoom=nil) - return "" unless center - markers = "?markers=" - unless geocodes.empty? - markers += geocodes.map {|g| "#{g.latitude},#{g.longitude}" }.join("|") - end - width = width > 640 ? 640 : width - height = height > 640 ? 640 : height + return "" - if zoom - zoom_str = "&zoom=#{zoom}" - else - zoom_str = "" - end + # return "" unless center + # markers = "?markers=" + # unless geocodes.empty? + # markers += geocodes.map {|g| "#{g.latitude},#{g.longitude}" }.join("|") + # end + # width = width > 640 ? 640 : width + # height = height > 640 ? 640 : height + + # if zoom + # zoom_str = "&zoom=#{zoom}" + # else + # zoom_str = "" + # end - "//maps.googleapis.com/maps/api/staticmap#{markers}&format=png&style=feature:road.highway|saturation:-100¢er=#{center.latitude},#{center.longitude}&size=#{width}x#{height}#{zoom_str}&key=#{Figaro.env.google_maps_key}" + # "//maps.googleapis.com/maps/api/staticmap#{markers}&format=png&style=feature:road.highway|saturation:-100¢er=#{center.latitude},#{center.longitude}&size=#{width}x#{height}#{zoom_str}&key=#{ENV.fetch('google_maps_key')}" end end diff --git a/app/interactors/generate_table_tents_or_posters.rb b/app/interactors/generate_table_tents_or_posters.rb index 6a86770376..657b845d3a 100644 --- a/app/interactors/generate_table_tents_or_posters.rb +++ b/app/interactors/generate_table_tents_or_posters.rb @@ -10,12 +10,12 @@ def perform GenerateTableTentsOrPosters.get_pdf_size(type: type) ) context[:pdf_result] = TemplatedPdfGenerator.generate_pdf( - request: request, - template: template, - locals: { + request: request, + template: template, + locals: { params: { # For some reason we packed all our data into a single local called 'params' - page_list: page_list, - include_product_names: include_product_names, + page_list: page_list, + include_product_names: include_product_names, market: order.market } }, @@ -38,12 +38,13 @@ def self.get_page_list(order:,include_product_names:) end def self.build_seller_map(seller) - seller_location = seller.shipping_location.geocode if seller.shipping_location - if seller_location - "http:" + google_static_map([seller_location], seller_location, 320, 200) - else - "" - end + # seller_location = seller.shipping_location.geocode if seller.shipping_location + # if seller_location + # "http:" + google_static_map([seller_location], seller_location, 320, 200) + # else + # "" + # end + "" end def self.get_template_from_type(type:) diff --git a/app/mailers/webhook_mailer.rb b/app/mailers/webhook_mailer.rb index 3a28741474..25cb61f3b4 100644 --- a/app/mailers/webhook_mailer.rb +++ b/app/mailers/webhook_mailer.rb @@ -1,6 +1,6 @@ class WebhookMailer < ActionMailer::Base default to: [ - Figaro.env.admin_email + ENV.fetch('ADMIN_EMAIL') ] def failed_payment(subscriber, event_params) @@ -8,7 +8,7 @@ def failed_payment(subscriber, event_params) @event_params = event_params mail( - from: Figaro.env.admin_email, + from: ENV.fetch('ADMIN_EMAIL'), subject: "Failed payment: #{@subscriber.name}" ) end @@ -18,7 +18,7 @@ def successful_payment(subscriber, event_params) @event_params = event_params mail( - from: Figaro.env.admin_email, + from: ENV.fetch('ADMIN_EMAIL'), subject: "Successful payment: #{@subscriber.name}" ) end @@ -27,7 +27,7 @@ def failed_event(exception, event) @event = event @exception = exception mail( - from: Figaro.env.admin_email, + from: ENV.fetch('ADMIN_EMAIL'), subject: "Failed webhook event: #{@event.type}" ) end diff --git a/app/models/location.rb b/app/models/location.rb index 340fdcf375..fec34bce66 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -11,8 +11,6 @@ class Location < ActiveRecord::Base before_save :ensure_default_address_label after_update :set_new_defaults - acts_as_geocodable address: {street: :address, locality: :city, region: :state, postal_code: :zip, country: :country} - def self.alphabetical_by_name order(name: :asc) end diff --git a/app/models/market.rb b/app/models/market.rb index debcfa3de7..16c81c55e7 100644 --- a/app/models/market.rb +++ b/app/models/market.rb @@ -157,7 +157,7 @@ def fulfillment_locations(default_name, secondary_name=nil) end def domain - "#{subdomain}.#{Figaro.env.domain!}" + "#{subdomain}.#{ENV.fetch('DOMAIN')}" end def seller_net_percent diff --git a/app/models/market_address.rb b/app/models/market_address.rb index 885b2a3206..7d7c33083c 100644 --- a/app/models/market_address.rb +++ b/app/models/market_address.rb @@ -6,8 +6,6 @@ class MarketAddress < ActiveRecord::Base validates :address, :city, :state, :zip, :market, :country, presence: true - acts_as_geocodable address: {street: :address, locality: :city, region: :state, postal_code: :zip, country: :country} - before_save :ensure_single_default before_save :ensure_single_billing before_save :ensure_single_remit_to @@ -34,7 +32,7 @@ def falsify_all_others_default(mkt_addr_id) end def falsify_all_others_billing(mkt_addr_id) - MarketAddress.where( billing:true ).where(market_id:"#{mkt_addr_id}".to_i).each do |ma| + MarketAddress.where( billing:true ).where(market_id:"#{mkt_addr_id}".to_i).each do |ma| if ma.id != self.id ma.billing = false ma.save! @@ -58,7 +56,7 @@ def ensure_single_default end def ensure_single_billing - if self.billing + if self.billing falsify_all_others_billing(self.market_id) end end diff --git a/app/models/order.rb b/app/models/order.rb index c1e8e8f0b6..23e494f164 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -279,15 +279,15 @@ def self.undelivered_orders_for_seller(user) end def self.buyer_orders_arel(user) - arel_table[:organization_id].in(UserOrganization.where(user_id: user.id).select(:organization_id).arel) + arel_table[:organization_id].in(UserOrganization.where(user_id: [user.id]).select(:organization_id).arel) end def self.seller_orders_arel(user) - Product.arel_table[:organization_id].in(UserOrganization.where(user_id: user.id).select(:organization_id).arel) + Product.arel_table[:organization_id].in(UserOrganization.where(user_id: [user.id]).select(:organization_id).arel) end def self.manager_orders_arel(user) - arel_table[:market_id].in(ManagedMarket.where(user_id: user.id).select(:market_id).arel) + arel_table[:market_id].in(ManagedMarket.where(user_id: [user.id]).select(:market_id).arel) end def self.cross_sold_products_arel(user) diff --git a/app/serializers/market_map_serializer.rb b/app/serializers/market_map_serializer.rb index 06dd301211..89054e4f1f 100644 --- a/app/serializers/market_map_serializer.rb +++ b/app/serializers/market_map_serializer.rb @@ -4,11 +4,11 @@ class MarketMapSerializer < ActiveModel::Serializer attributes :id, :name, :latitude, :longitude, :plan_name, :market_path def latitude - object.addresses.visible.first.geocode.latitude + # object.addresses.visible.first.geocode.latitude end def longitude - object.addresses.visible.first.geocode.longitude + # object.addresses.visible.first.geocode.longitude end def plan_name diff --git a/app/views/admin/batch_consignment_receipts/show.erb b/app/views/admin/batch_consignment_receipts/show.erb index a3e428c736..9074cc9643 100644 --- a/app/views/admin/batch_consignment_receipts/show.erb +++ b/app/views/admin/batch_consignment_receipts/show.erb @@ -22,7 +22,7 @@