From c432145b3859b174387aa262641505d7eb4f530a Mon Sep 17 00:00:00 2001 From: gr455 Date: Fri, 27 Mar 2020 20:54:36 +0530 Subject: [PATCH 01/43] Fix test fixtures --- test/fixtures/comments.yml | 3 +++ test/fixtures/tags.yml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml index 3671d2c8..eed6a518 100644 --- a/test/fixtures/comments.yml +++ b/test/fixtures/comments.yml @@ -5,6 +5,7 @@ one: email: MyString body: MyText wavelength: 1.5 + user_id: 1 x: 1 y: 1 @@ -13,5 +14,7 @@ two: email: MyString body: MyText wavelength: 1.5 + user_id: 2 x: 1 y: 1 + \ No newline at end of file diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index ae81940b..817114da 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -6,12 +6,12 @@ # one: { name: 'cfl', - spectrum_id: 1, + spectrum_id: 298486374, user_id: 2 } two: { name: 'led', - spectrum_id: 1, + spectrum_id: 298486374, user_id: 1 } From 9e81792b6f880c6b99c7cbd49e959bfafdb85a8a Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Mon, 30 Mar 2020 23:53:29 -0300 Subject: [PATCH 02/43] Upgrading ruby and rails version --- .travis.yml | 4 ++-- Dockerfile | 25 +++++++------------------ docker-compose.yml | 10 +++++++--- script/start.sh | 4 +++- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3549300..ad2e389f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,10 @@ language: ruby dist: trusty rvm: - - 2.1.2 + - 2.6.5 node_js: - - "0.10.29" + - 13 env: global: diff --git a/Dockerfile b/Dockerfile index 7764a274..b01acfee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,22 @@ # Dockerfile # Spectral Workbench # https://github.com/publiclab/spectral-workbench -FROM ruby:2.1 +FROM ruby:2.6.5-stretch LABEL maintainer="Sebastian Silva " -LABEL description="This image deploys Spectral Worbench!" +LABEL description="This image deploys Spectral Workbench!" # Set correct environment variables. ENV HOME /root # Install dependencies -RUN sed -i '/.*jessie-updates.*/d' /etc/apt/sources.list -RUN apt-get update -qq && \ +RUN sed -i '/.*jessie-updates.*/d' /etc/apt/sources.list && \ + apt-get update -qq && \ apt-get install -y --no-install-recommends \ imagemagick \ ruby-rmagick \ libmagickwand-dev \ libmagick++-dev \ - ruby-rmagick \ libfreeimage3 \ libfreeimage-dev \ gdal-bin \ @@ -26,24 +25,14 @@ RUN apt-get update -qq && \ libcurl4-openssl-dev \ libssl-dev \ zip \ - nodejs-legacy \ - npm \ netcat -RUN npm install -g bower - -# Install bundle of gems -WORKDIR /tmp -ADD Gemfile /tmp/Gemfile -ADD Gemfile.lock /tmp/Gemfile.lock -RUN bundle install +RUN curl -sL https://deb.nodesource.com/setup_13.x | bash - && \ + apt-get install -y nodejs npm && \ + npm install -g bower # Add the Rails app WORKDIR /app COPY . /app -ENV GIT_DIR=/app - -RUN apt-get remove -y zip \ - curl ENTRYPOINT ["sh", "script/start.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 6c810779..2fd97e01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ -version: '3.3' +version: '3.5' services: db: + container_name: spectral-db image: mysql:5.6 environment: - MYSQL_ROOT_PASSWORD=root @@ -11,14 +12,17 @@ services: - mysql-data:/var/lib/mysql web: + container_name: spectral-web build: . volumes: - .:/app + - bundle_cache:/usr/local/bundle ports: - - "127.0.0.1:5000:5000" - - "127.0.0.1:8888:8888" + - 5000:5000 + - 8888:8888 depends_on: - db volumes: mysql-data: + bundle_cache: diff --git a/script/start.sh b/script/start.sh index 4364cb91..372e4f57 100755 --- a/script/start.sh +++ b/script/start.sh @@ -2,6 +2,7 @@ pidfile=/app/tmp/pids/server.pid +bundle check || bundle install bower install --allow-root cp config/database.yml.docker.example config/database.yml cp config/config.yml.example config/config.yml @@ -14,8 +15,9 @@ done echo "MySQL is up and running!" -bundle exec rake db:setup +bundle exec rake db:schema:load bundle exec rake db:migrate +bundle exec rake db:seed if [ -f $pidfile ] ; then >&2 echo 'Server PID file already exists. Removing it...'; From a22780b03aec407c81e76412dba8729fc0dc8720 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Mon, 30 Mar 2020 23:57:05 -0300 Subject: [PATCH 03/43] Using newer sintax and deprecating a couple modules --- app/controllers/device_controller.rb | 3 ++- app/controllers/spectrums_controller.rb | 7 ++++--- app/models/user.rb | 4 ++-- app/views/spectrums/index.html.erb | 2 +- config/database.yml.docker.example | 4 ++-- config/routes.rb | 12 ++++++------ db/schema.rb.example | 4 ++-- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/controllers/device_controller.rb b/app/controllers/device_controller.rb index 90122413..7e5343d1 100644 --- a/app/controllers/device_controller.rb +++ b/app/controllers/device_controller.rb @@ -2,7 +2,8 @@ class DeviceController < ApplicationController def index if logged_in? - @devices = Device.find_all_by_user_id current_user.id, :order => "id DESC" + @devices = Device.where(user_id: current_user.id) + else flash[:error] = "You must be logged in to view that page." redirect_to "/login" diff --git a/app/controllers/spectrums_controller.rb b/app/controllers/spectrums_controller.rb index e9b3fa7b..cb187e5c 100755 --- a/app/controllers/spectrums_controller.rb +++ b/app/controllers/spectrums_controller.rb @@ -22,8 +22,8 @@ def index .where('user_id != 0') .paginate(:page => params[:page], :per_page => 24) - @sets = SpectraSet.find(:all,:limit => 4,:order => "created_at DESC") - @comments = Comment.all :limit => 12, :order => "id DESC" + @sets = SpectraSet.all + @comments = Comment.all respond_with(@spectrums) do |format| format.html { @@ -451,7 +451,8 @@ def all def rss if params[:author] - @spectrums = Spectrum.find_all_by_author(params[:author],:order => "created_at DESC",:limit => 12).paginate(:page => params[:page]) + Spectrum.where(author: params[:author]) + @spectrums = Spectrum.where(author: params[:author]).paginate(:page => params[:page]) else @spectrums = Spectrum.find(:all,:order => "created_at DESC",:limit => 12).paginate(:page => params[:page]) end diff --git a/app/models/user.rb b/app/models/user.rb index 95051bdf..3f64e7b1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -48,12 +48,12 @@ def set_count end def received_comments - spectrums = Spectrum.find_all_by_user_id self.id, :limit => 20 + spectrums = Spectrum.where(user_id: self.id) spectrum_ids = [] spectrums.each do |spectrum| spectrum_ids << spectrum.id end - Comment.find_all_by_spectrum_id(spectrum_ids.uniq).where("user_id != ?",self.id).limit(10).order("id DESC") + Comment.where(spectrum_id: spectrum_ids.uniq).where("user_id != ?",self.id).limit(10).order("id DESC") end # Authenticates a user by their login name and unencrypted password. Returns the user or nil. diff --git a/app/views/spectrums/index.html.erb b/app/views/spectrums/index.html.erb index 4c48cf8c..f6eefc79 100644 --- a/app/views/spectrums/index.html.erb +++ b/app/views/spectrums/index.html.erb @@ -23,7 +23,7 @@

Recent authors

diff --git a/config/database.yml.docker.example b/config/database.yml.docker.example index 936f5493..617db595 100644 --- a/config/database.yml.docker.example +++ b/config/database.yml.docker.example @@ -18,7 +18,7 @@ production: test: <<: *default - host: 127.0.0.1 + host: db username: root - password: + password: root database: swbench_test diff --git a/config/routes.rb b/config/routes.rb index 6468d987..5a3554f1 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,8 +75,8 @@ get '/capture/recent_calibrations' => 'capture#recent_calibrations' # Registered user pages: - get '/profile', to: 'users#show', :as => 'profile' - get '/profile/:id', to: 'users#show', :as => 'profile' + get '/profile', to: 'users#show' + get '/profile/:id', to: 'users#show' get '/macro/edit/:id' => 'macros#edit' get '/macro/update/:id' => 'macros#update' @@ -178,7 +178,7 @@ fallback "/" => "/offline" fallback "/dashboard" => "/offline" end - match "/index.manifest" => offline + get "/index.manifest" => offline root to: 'spectrums#index' @@ -187,8 +187,8 @@ # match ':controller(/:action(/:id))(.:format)' # See how all your routes lay out with 'rake routes' - match ':controller/:action' - match ':controller/:action/:id' - match ':controller/:action/:id.:format' + get ':controller/:action' + get ':controller/:action/:id' + get ':controller/:action/:id.:format' end diff --git a/db/schema.rb.example b/db/schema.rb.example index f300643f..e2f22f72 100644 --- a/db/schema.rb.example +++ b/db/schema.rb.example @@ -682,7 +682,7 @@ ActiveRecord::Schema.define(:version => 20190513143943) do t.string "author", :default => "", :null => false t.datetime "created_at" t.datetime "updated_at" - t.text "notes", :default => "", :null => false + t.text "notes", :null => false t.integer "user_id", :default => 0 end @@ -732,7 +732,7 @@ ActiveRecord::Schema.define(:version => 20190513143943) do add_index "spectrums", ["user_id"], :name => "index_spectrums_on_user_id" create_table "tags", :force => true do |t| - t.integer "user_id", :limit => 255 + t.integer "user_id" t.string "name" t.integer "spectrum_id" t.integer "set_id" From 74c1b31482915a473eb87f2195fe91eabda36e38 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Mon, 30 Mar 2020 23:58:15 -0300 Subject: [PATCH 04/43] Upgrading minimum gemset needed --- Gemfile | 18 ++-- Gemfile.lock | 226 +++++++++++++++++++++++++++++---------------------- 2 files changed, 137 insertions(+), 107 deletions(-) diff --git a/Gemfile b/Gemfile index c9864f97..e56f67f0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,10 @@ source 'https://rubygems.org' #source 'https://rails-assets.org' -ruby '~>2.1.2' -gem 'rails', '~>3.2' +ruby '~>2.6.5' +gem 'rails', '~>4.2.8' # Database handling -group :sqlite do - gem 'sqlite3' -end - group :mysql do gem 'mysql2', '~> 0.3.10' end @@ -22,6 +18,7 @@ group :assets do gem 'uglifier', '>= 1.0.3' end +gem 'responders', '~> 2.0' gem 'rmagick'#, :require => "RMagick" gem 'mime-types'#, '1.18' gem 'jquery-rails' @@ -29,15 +26,16 @@ gem 'passenger' gem 'recaptcha', '3.0.0', :require => "recaptcha/rails" gem 'cocaine', '~>0.5.3' gem 'redcarpet', '2.1.1' -gem "skylight" # performance tracking via skylight.io +gem 'skylight' # performance tracking via skylight.io gem 'rdiscount', '1.6.8' -gem 'will_paginate', '3.0.7' -gem 'will_paginate-bootstrap', '0.2.5' +gem 'will_paginate', '~>3.3.0' +gem 'will_paginate-bootstrap', '~>1.0.2' gem 'paperclip', '>= 4.1.1' -gem 'tzinfo', '0.3.49' +gem 'tzinfo', '~>1.1' +gem 'protected_attributes', '~>1.1.4' gem 'ruby-openid' gem 'open_id_authentication' diff --git a/Gemfile.lock b/Gemfile.lock index 1de434f6..451e6d74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,120 +1,148 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.22.2) - actionpack (= 3.2.22.2) - mail (~> 2.5.4) - actionpack (3.2.22.2) - activemodel (= 3.2.22.2) - activesupport (= 3.2.22.2) - builder (~> 3.0.0) + actionmailer (4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.11.1) + actionview (= 4.2.11.1) + activesupport (= 4.2.11.1) + rack (~> 1.6) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.11.1) + activesupport (= 4.2.11.1) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.22.2) - activesupport (= 3.2.22.2) - builder (~> 3.0.0) - activerecord (3.2.22.2) - activemodel (= 3.2.22.2) - activesupport (= 3.2.22.2) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.22.2) - activemodel (= 3.2.22.2) - activesupport (= 3.2.22.2) - activesupport (3.2.22.2) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - arel (3.0.3) - builder (3.0.4) - climate_control (0.0.3) - activesupport (>= 3.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (4.2.11.1) + activesupport (= 4.2.11.1) + globalid (>= 0.3.0) + activemodel (4.2.11.1) + activesupport (= 4.2.11.1) + builder (~> 3.1) + activerecord (4.2.11.1) + activemodel (= 4.2.11.1) + activesupport (= 4.2.11.1) + arel (~> 6.0) + activesupport (4.2.11.1) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + arel (6.0.4) + builder (3.2.4) + climate_control (0.2.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) + concurrent-ruby (1.1.6) + crass (1.0.6) erubis (2.7.0) execjs (2.7.0) - hike (1.2.3) - i18n (0.7.0) - journey (1.0.4) - jquery-rails (3.1.4) - railties (>= 3.0, < 5.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + jquery-rails (4.3.5) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.3) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) - mimemagic (0.3.0) - multi_json (1.12.1) + json (2.3.0) + loofah (2.4.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + mime-types (3.3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.1009) + mimemagic (0.3.4) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.0) mysql2 (0.3.21) - open_id_authentication (1.2.0) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + open_id_authentication (1.3.0) rack-openid (~> 1.3) - paperclip (4.3.6) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - cocaine (~> 0.5.5) + paperclip (6.1.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) mime-types - mimemagic (= 0.3.0) - passenger (6.0.1) + mimemagic (~> 0.3.0) + terrapin (~> 0.6.0) + passenger (6.0.4) rack rake (>= 0.8.1) - polyglot (0.3.5) - rack (1.4.7) - rack-cache (1.6.1) - rack (>= 0.4) + protected_attributes (1.1.4) + activemodel (>= 4.0.1, < 5.0) + rack (1.6.13) rack-offline (0.6.4) rack-openid (1.4.2) rack (>= 1.1.0) ruby-openid (>= 2.1.8) - rack-ssl (1.3.4) - rack rack-test (0.6.3) rack (>= 1.0) - rails (3.2.22.2) - actionmailer (= 3.2.22.2) - actionpack (= 3.2.22.2) - activerecord (= 3.2.22.2) - activeresource (= 3.2.22.2) - activesupport (= 3.2.22.2) - bundler (~> 1.0) - railties (= 3.2.22.2) - railties (3.2.22.2) - actionpack (= 3.2.22.2) - activesupport (= 3.2.22.2) - rack-ssl (~> 1.3.2) + rails (4.2.11.1) + actionmailer (= 4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) + activemodel (= 4.2.11.1) + activerecord (= 4.2.11.1) + activesupport (= 4.2.11.1) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.11.1) + 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) + railties (4.2.11.1) + actionpack (= 4.2.11.1) + activesupport (= 4.2.11.1) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (12.3.2) + thor (>= 0.18.1, < 2.0) + rake (13.0.1) rdiscount (1.6.8) - rdoc (3.12.2) - json (~> 1.4) recaptcha (3.0.0) json redcarpet (2.1.1) - rmagick (2.15.4) - ruby-openid (2.7.0) - skylight (1.7.2) - activesupport (>= 3.0.0) - sprockets (2.2.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.11) - thor (0.19.1) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.49) - uglifier (3.0.0) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) + rmagick (4.1.1) + ruby-openid (2.9.2) + skylight (4.2.3) + skylight-core (= 4.2.3) + skylight-core (4.2.3) + activesupport (>= 4.2.0) + sprockets (4.0.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + terrapin (0.6.0) + climate_control (>= 0.0.3, < 1.0) + thor (1.0.1) + thread_safe (0.3.6) + tzinfo (1.2.6) + thread_safe (~> 0.1) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) - will_paginate (3.0.7) - will_paginate-bootstrap (0.2.5) + will_paginate (3.3.0) + will_paginate-bootstrap (1.0.2) will_paginate (>= 3.0.3) PLATFORMS @@ -128,19 +156,23 @@ DEPENDENCIES open_id_authentication paperclip (>= 4.1.1) passenger + protected_attributes (~> 1.1.4) rack-offline (>= 0.6.4) - rails (~> 3.2) + rails (~> 4.2.8) rdiscount (= 1.6.8) recaptcha (= 3.0.0) redcarpet (= 2.1.1) + responders (~> 2.0) rmagick ruby-openid skylight - sqlite3 - tzinfo (= 0.3.49) + tzinfo (~> 1.1) uglifier (>= 1.0.3) - will_paginate (= 3.0.7) - will_paginate-bootstrap (= 0.2.5) + will_paginate (~> 3.3.0) + will_paginate-bootstrap (~> 1.0.2) + +RUBY VERSION + ruby 2.6.5p114 BUNDLED WITH - 1.11.2 + 1.17.2 From 6ef394779eea6ef577f50ea96398a65b15822945 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Mon, 30 Mar 2020 23:58:31 -0300 Subject: [PATCH 05/43] Running update task --- app/assets/config/manifest.js | 5 ++ bin/bundle | 3 + bin/rails | 4 + bin/rake | 4 + bin/setup | 29 ++++++ config/application.rb | 56 ++---------- config/boot.rb | 5 +- config/environment.rb | 6 +- config/environments/development.rb | 41 +++++---- config/environments/production.rb | 88 ++++++++++--------- config/environments/test.rb | 33 ++++--- config/initializers/assets.rb | 11 +++ config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + config/initializers/inflections.rb | 11 +-- config/initializers/mime_types.rb | 1 - config/initializers/session_store.rb | 7 +- config/initializers/wrap_parameters.rb | 12 +-- config/locales/en.yml | 22 ++++- config/secrets.yml | 22 +++++ 20 files changed, 215 insertions(+), 152 deletions(-) create mode 100644 app/assets/config/manifest.js create mode 100755 bin/bundle create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/setup create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/cookies_serializer.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/secrets.yml diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 00000000..0023457d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,5 @@ +//= link application.css +//= link application.js +//= link capture.css +//= link capture.js +//= link analyze.js \ No newline at end of file diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 00000000..5191e692 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 00000000..17240489 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..acdb2c13 --- /dev/null +++ b/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/config/application.rb b/config/application.rb index b06328d6..3247291a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,12 +2,9 @@ require 'rails/all' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module SpectralWorkbench class Application < Rails::Application @@ -15,16 +12,6 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' @@ -32,41 +19,8 @@ class Application < Rails::Application # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - config.i18n.enforce_available_locales = true - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Enable escaping HTML in JSON. - config.active_support.escape_html_entities_in_json = true - - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = true - - # Enable the asset pipeline - config.assets.enabled = true - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.1' - config.assets.paths << Rails.root.join("public", "lib") - config.assets.precompile += ['capture.js','analyze.js'] - - # pluralization options, but unneccessary due to: - # http://dictionary.reference.com/browse/spectrum - #ActiveSupport::Inflector.inflections do |inflect| - # inflect.irregular 'spectrum', 'spectra' - #end + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 4489e586..6b750f00 100755 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,3 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index e3afbdfd..ee8d90dc 100755 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application +# Load the Rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application -SpectralWorkbench::Application.initialize! +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 7a8898ac..b55e2144 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,38 +1,41 @@ -SpectralWorkbench::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. + config.eager_load = false - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Don't care if the mailer can't send + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Print deprecation notices to the Rails logger + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true - # Do not compress assets - config.assets.compress = false + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true - # Expands the lines which load the assets - config.assets.debug = true + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 288f225f..5c1b32e4 100755 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,73 +1,79 @@ -SpectralWorkbench::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. - # Code is not reloaded between requests + # Code is not reloaded between requests. config.cache_classes = true - # Full error reports are disabled and caching is turned on + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. + # config.action_dispatch.rack_cache = true - # Compress JavaScripts and CSS - config.assets.compress = true + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Don't fallback to assets pipeline if a precompiled asset is missed - # Jeff: actually, do! This allows rack-offline - # to run, and we offline-cache them anyways: - config.assets.compile = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # Generate digests for assets URLs - config.assets.digest = true + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false - # this shouldn't be necessary but may be for web fonts: - #config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/ - config.assets.precompile += ['capture.js','analyze.js'] + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true - # Defaults to nil and saved in location specified by config.assets.prefix - # config.assets.manifest = YOUR_PATH + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) - # config.log_level = :debug + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug - # Prepend all log lines with the following tags + # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] - # Use a different logger for distributed setups + # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - # Use a different cache store in production + # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 7c94e13e..1c19f08b 100755 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,5 @@ -SpectralWorkbench::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -7,31 +7,36 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Raise exceptions instead of rendering exception templates + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Randomize the order test cases are executed. + config.active_support.test_order = :random - # Print deprecation notices to the stderr + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..01ef3e66 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..ac5f8b66 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :marshal diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be2..ac033bf9 100755 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,15 +1,16 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end -# + # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e4..dc189968 100755 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index d07b7222..42e13de2 100755 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,8 +1,3 @@ # Be sure to restart your server when you modify this file. -SpectralWorkbench::Application.config.session_store :cookie_store, :key => '_spectral-workbench_session' - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# SpectralWorkbench::Application.config.session_store :active_record_store +Rails.application.config.session_store :cookie_store, key: '_spectral_workbench_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index da4fb076..33725e95 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,14 +1,14 @@ # Be sure to restart your server when you modify this file. -# + # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters :format => [:json] + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml index 179c14ca..06539571 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,23 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..aefbe5ae --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 27ffa7127c80a0ef918583dd20d493a8eb4db77855779f9007824f219b879438ba8929051b8344cd06058a45b8f5017623b0f686bac3801e112f5c607fea486c + +test: + secret_key_base: 4120ab7cc8ecbc840a2b0d99a1d51737ca37bcb98fd434ade5a56fd53eed80eab2d851272756b10ef90ea6c48994ed006be00697955211d4862d86a30fa5995d + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> From 59092d9ccda8581efe4094174d54c55d1821f0e9 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Wed, 1 Apr 2020 21:58:46 -0300 Subject: [PATCH 06/43] Installing Bower properly on Travis --- .travis.yml | 16 +- config/application.rb | 48 +- config/boot.rb | 2 +- config/database.yml.example | 4 +- config/environments/development.rb | 16 + config/environments/production.rb | 78 +- config/environments/test.rb | 11 + config/initializers/assets.rb | 18 +- .../20120202021608_create_spectra_sets.rb | 2 + db/migrate/20120202025658_add_set_comments.rb | 3 +- db/migrate/20120629103716_create_devices.rb | 3 +- ...20120918115739_add_spectrums_sample_row.rb | 2 +- db/migrate/20130205164725_create_likes.rb | 2 +- .../20130214153953_add_user_email_prefs.rb | 2 +- db/migrate/20130302223722_add_device_key.rb | 2 +- db/migrate/20130304165044_create_macros.rb | 4 +- db/migrate/20130308184651_add_video_row.rb | 2 +- db/migrate/20130820000000_closest_match.rb | 1196 ++++++++--------- .../20130921134441_add_spectrum_reversal.rb | 2 +- .../20150624185446_add_anonymous_user.rb | 6 +- .../20150715184613_add_spectrum_calibrated.rb | 2 +- ...224222_create_sets_spectrums_join_table.rb | 2 +- ...721195514_change_comment_author_to_user.rb | 1 - test/fixtures/users.yml | 10 +- test/performance/browsing_test.rb | 12 - 25 files changed, 754 insertions(+), 692 deletions(-) delete mode 100755 test/performance/browsing_test.rb diff --git a/.travis.yml b/.travis.yml index ad2e389f..4dc71804 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,22 +21,24 @@ services: - docker - mysql -install: +before_install: - cp config/database.yml.example config/database.yml - cp config/config.yml.example config/config.yml - cp db/schema.rb.example db/schema.rb - - bundle config set path './vendor/.bundle/' && bundle install + - bundle config set path 'vendor/.bundle/' + +install: + - bundle install + - npm install -g bower + - bower install --allow-root - if [ $RAILS_ENV == 'production' ]; then mysql -e "CREATE DATABASE swbench;"; mysql -e "CREATE USER 'swbench'@'%' IDENTIFIED BY 'swbench';"; mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'swbench'@'%';"; bundle exec rake db:schema:load; - npm install -g bower; - bower install --allow-root; else - bower install --allow-root; bundle exec rake db:create; - bundle exec rake db:schema:load || bundle exec rake db:migrate; + bundle exec rake db:migrate; fi jobs: @@ -49,8 +51,6 @@ jobs: script: rake test:functionals - name: "Integration Tests" script: rake test:integration - - name: "Performance Tests" - script: ruby -I test test/performance/*.rb - name: "Docker Builds" script: docker build -t swbench . - name: "Asset Precompilation" diff --git a/config/application.rb b/config/application.rb index 3247291a..052513a1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,12 +6,29 @@ # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end + module SpectralWorkbench class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' @@ -19,8 +36,37 @@ class Application < Rails::Application # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + config.i18n.enforce_available_locales = true + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + # Enable escaping HTML in JSON. + config.active_support.escape_html_entities_in_json = true + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + config.active_record.whitelist_attributes = true + + # Enable the asset pipeline + config.assets.enabled = true + config.assets.paths << Rails.root.join("public/lib") - # Do not swallow errors in after_commit/after_rollback callbacks. + # pluralization options, but unneccessary due to: + # http://dictionary.reference.com/browse/spectrum + #ActiveSupport::Inflector.inflections do |inflect| + # inflect.irregular 'spectrum', 'spectra' + #end config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 6b750f00..a7342939 100755 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml.example b/config/database.yml.example index e90a17ce..e075ab36 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -1,6 +1,6 @@ default: &default encoding: utf8 - adapter: sqlite3 + adapter: mysql2 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: @@ -9,7 +9,7 @@ development: database: swbench_development production: - adapter: sqlite3 + adapter: mysql2 database: production.db test: diff --git a/config/environments/development.rb b/config/environments/development.rb index b55e2144..82292fdb 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,6 +6,9 @@ # since you don't have to restart the web server when you make code changes. config.cache_classes = false + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + # Do not eager load code on boot. config.eager_load = false @@ -19,6 +22,9 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load @@ -36,6 +42,16 @@ # Raises helpful error messages. config.assets.raise_runtime_errors = true + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 5c1b32e4..60321d51 100755 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,76 +1,72 @@ Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. +# Settings specified here will take precedence over those in config/application.rb - # Code is not reloaded between requests. + # Code is not reloaded between requests config.cache_classes = true - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. + # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_files = false - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass + # Compress JavaScripts and CSS + config.assets.compress = true - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + # Don't fallback to assets pipeline if a precompiled asset is missed + # Jeff: actually, do! This allows rack-offline + # to run, and we offline-cache them anyways: + config.assets.compile = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. + # Generate digests for assets URLs config.assets.digest = true - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # See everything in the log (default is :info) + # config.log_level = :debug - # Prepend all log lines with the following tags. + # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] - # Use a different logger for distributed setups. + # Use a different logger for distributed setups # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - # Use a different cache store in production. + # Use a different cache store in production # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false + # Enable threaded mode + # config.threadsafe! + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). + # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. + # Send deprecation notices to registered listeners config.active_support.deprecation = :notify + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new diff --git a/config/environments/test.rb b/config/environments/test.rb index 1c19f08b..8195c664 100755 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,6 +7,17 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_files = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e66..d6d7005d 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,11 +1,17 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application do |config| + config.assets.version = '1.1' -# Add additional assets to the asset load path -# Rails.application.config.assets.paths << Emoji.images_path + # Add additional assets to the asset load path + # Rails.application.config.assets.paths << Emoji.images_path + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.1' + config.assets.paths << Rails.root.join("public/lib") + config.assets.precompile += ['capture.js','analyze.js'] -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # Rails.application.config.assets.precompile += %w( search.js ) +end \ No newline at end of file diff --git a/db/migrate/20120202021608_create_spectra_sets.rb b/db/migrate/20120202021608_create_spectra_sets.rb index ae2681ab..7fa06d36 100644 --- a/db/migrate/20120202021608_create_spectra_sets.rb +++ b/db/migrate/20120202021608_create_spectra_sets.rb @@ -4,6 +4,8 @@ def self.up t.string :title, :default => "", :null => false t.string :author, :default => "", :null => false t.string :spectra_string, :default => "", :null => false + t.string :notes, default: '', null: false + t.timestamps end end diff --git a/db/migrate/20120202025658_add_set_comments.rb b/db/migrate/20120202025658_add_set_comments.rb index 2b6505f3..c37b52f6 100644 --- a/db/migrate/20120202025658_add_set_comments.rb +++ b/db/migrate/20120202025658_add_set_comments.rb @@ -1,7 +1,6 @@ class AddSetComments < ActiveRecord::Migration def self.up - add_column :spectrums, :client_code, :string, :default => '', :null => false - add_column :spectra_sets, :notes, :text, :default => "", :null => false + add_column :spectrums, :client_code, :string, default: '', null: false add_column :comments, :spectra_set_id, :integer, :default => 0, :null => false end diff --git a/db/migrate/20120629103716_create_devices.rb b/db/migrate/20120629103716_create_devices.rb index 58d02a91..a4512ed1 100644 --- a/db/migrate/20120629103716_create_devices.rb +++ b/db/migrate/20120629103716_create_devices.rb @@ -3,7 +3,7 @@ def self.up create_table "devices" do |t| t.string :name - t.string :description, :limit => 100, :default => '', :null => false + t.string :description, default: '', limit: 100, null: false t.integer :height t.integer :width t.integer :calibration_id @@ -13,7 +13,6 @@ def self.up t.timestamps end - add_index :users, :login, :unique => true end def self.down diff --git a/db/migrate/20120918115739_add_spectrums_sample_row.rb b/db/migrate/20120918115739_add_spectrums_sample_row.rb index 95c982da..74590f58 100644 --- a/db/migrate/20120918115739_add_spectrums_sample_row.rb +++ b/db/migrate/20120918115739_add_spectrums_sample_row.rb @@ -1,6 +1,6 @@ class AddSpectrumsSampleRow < ActiveRecord::Migration def self.up - add_column :spectrums, :sample_row, :integer, :default => 1, :null => false + add_column :spectrums, :sample_row, :integer, null: false, default: 1 end def self.down diff --git a/db/migrate/20130205164725_create_likes.rb b/db/migrate/20130205164725_create_likes.rb index 4fb02bda..e9434457 100644 --- a/db/migrate/20130205164725_create_likes.rb +++ b/db/migrate/20130205164725_create_likes.rb @@ -2,7 +2,7 @@ class CreateLikes < ActiveRecord::Migration def self.up create_table "likes" do |t| t.integer :spectrum_id - t.string :like_type, :default => 'like', :null => false + t.string :like_type, null: false, default: "like" t.integer :user_id t.timestamps diff --git a/db/migrate/20130214153953_add_user_email_prefs.rb b/db/migrate/20130214153953_add_user_email_prefs.rb index 4cc43db9..2ff14a8e 100644 --- a/db/migrate/20130214153953_add_user_email_prefs.rb +++ b/db/migrate/20130214153953_add_user_email_prefs.rb @@ -1,6 +1,6 @@ class AddUserEmailPrefs < ActiveRecord::Migration def self.up - add_column :users, :email_preferences, :string, :default => "1", :null => false + add_column :users, :email_preferences, :string, null: false, default: 1 end def self.down diff --git a/db/migrate/20130302223722_add_device_key.rb b/db/migrate/20130302223722_add_device_key.rb index 664b06e4..6db29a34 100644 --- a/db/migrate/20130302223722_add_device_key.rb +++ b/db/migrate/20130302223722_add_device_key.rb @@ -1,6 +1,6 @@ class AddDeviceKey < ActiveRecord::Migration def self.up - add_column :devices, :key, :string, :default => "", :null => false + add_column :devices, :key, :string, null: false, default: '' end def self.down diff --git a/db/migrate/20130304165044_create_macros.rb b/db/migrate/20130304165044_create_macros.rb index 71e09b10..1f6b0525 100644 --- a/db/migrate/20130304165044_create_macros.rb +++ b/db/migrate/20130304165044_create_macros.rb @@ -2,12 +2,12 @@ class CreateMacros < ActiveRecord::Migration def self.up create_table "macros" do |t| t.integer :user_id - t.string :macro_type, :default => 'analyze', :null => false + t.string :macro_type, default: 'analyze', null: false t.string :title t.string :url # to gist, hopefully t.text :description t.text :code - t.string :published, :default => "published" # "published","spam","flagged" + t.string :published, default: 'published' t.timestamps end diff --git a/db/migrate/20130308184651_add_video_row.rb b/db/migrate/20130308184651_add_video_row.rb index ffc4af32..4befdb2b 100644 --- a/db/migrate/20130308184651_add_video_row.rb +++ b/db/migrate/20130308184651_add_video_row.rb @@ -1,6 +1,6 @@ class AddVideoRow < ActiveRecord::Migration def self.up - add_column :spectrums, :video_row, :integer, :default => 0 + add_column :spectrums, :video_row, :integer, default: 0 end def self.down diff --git a/db/migrate/20130820000000_closest_match.rb b/db/migrate/20130820000000_closest_match.rb index 6343d0c9..fb3e0849 100644 --- a/db/migrate/20130820000000_closest_match.rb +++ b/db/migrate/20130820000000_closest_match.rb @@ -4,608 +4,608 @@ def self.up t.integer :spectrum_id # This looks strange, but works well - t.integer :a10, :default => 0 # Each column for matching. Looks weird, haha - t.integer :r10, :default => 0 - t.integer :g10, :default => 0 - t.integer :b10, :default => 0 - t.integer :a20, :default => 0 - t.integer :r20, :default => 0 - t.integer :g20, :default => 0 - t.integer :b20, :default => 0 - t.integer :a30, :default => 0 - t.integer :r30, :default => 0 - t.integer :g30, :default => 0 - t.integer :b30, :default => 0 - t.integer :a40, :default => 0 - t.integer :r40, :default => 0 - t.integer :g40, :default => 0 - t.integer :b40, :default => 0 - t.integer :a50, :default => 0 - t.integer :r50, :default => 0 - t.integer :g50, :default => 0 - t.integer :b50, :default => 0 - t.integer :a60, :default => 0 - t.integer :r60, :default => 0 - t.integer :g60, :default => 0 - t.integer :b60, :default => 0 - t.integer :a70, :default => 0 - t.integer :r70, :default => 0 - t.integer :g70, :default => 0 - t.integer :b70, :default => 0 - t.integer :a80, :default => 0 - t.integer :r80, :default => 0 - t.integer :g80, :default => 0 - t.integer :b80, :default => 0 - t.integer :a90, :default => 0 - t.integer :r90, :default => 0 - t.integer :g90, :default => 0 - t.integer :b90, :default => 0 - t.integer :a100, :default => 0 - t.integer :r100, :default => 0 - t.integer :g100, :default => 0 - t.integer :b100, :default => 0 - t.integer :a110, :default => 0 - t.integer :r110, :default => 0 - t.integer :g110, :default => 0 - t.integer :b110, :default => 0 - t.integer :a120, :default => 0 - t.integer :r120, :default => 0 - t.integer :g120, :default => 0 - t.integer :b120, :default => 0 - t.integer :a130, :default => 0 - t.integer :r130, :default => 0 - t.integer :g130, :default => 0 - t.integer :b130, :default => 0 - t.integer :a140, :default => 0 - t.integer :r140, :default => 0 - t.integer :g140, :default => 0 - t.integer :b140, :default => 0 - t.integer :a150, :default => 0 - t.integer :r150, :default => 0 - t.integer :g150, :default => 0 - t.integer :b150, :default => 0 - t.integer :a160, :default => 0 - t.integer :r160, :default => 0 - t.integer :g160, :default => 0 - t.integer :b160, :default => 0 - t.integer :a170, :default => 0 - t.integer :r170, :default => 0 - t.integer :g170, :default => 0 - t.integer :b170, :default => 0 - t.integer :a180, :default => 0 - t.integer :r180, :default => 0 - t.integer :g180, :default => 0 - t.integer :b180, :default => 0 - t.integer :a190, :default => 0 - t.integer :r190, :default => 0 - t.integer :g190, :default => 0 - t.integer :b190, :default => 0 - t.integer :a200, :default => 0 - t.integer :r200, :default => 0 - t.integer :g200, :default => 0 - t.integer :b200, :default => 0 - t.integer :a210, :default => 0 - t.integer :r210, :default => 0 - t.integer :g210, :default => 0 - t.integer :b210, :default => 0 - t.integer :a220, :default => 0 - t.integer :r220, :default => 0 - t.integer :g220, :default => 0 - t.integer :b220, :default => 0 - t.integer :a230, :default => 0 - t.integer :r230, :default => 0 - t.integer :g230, :default => 0 - t.integer :b230, :default => 0 - t.integer :a240, :default => 0 - t.integer :r240, :default => 0 - t.integer :g240, :default => 0 - t.integer :b240, :default => 0 - t.integer :a250, :default => 0 - t.integer :r250, :default => 0 - t.integer :g250, :default => 0 - t.integer :b250, :default => 0 - t.integer :a260, :default => 0 - t.integer :r260, :default => 0 - t.integer :g260, :default => 0 - t.integer :b260, :default => 0 - t.integer :a270, :default => 0 - t.integer :r270, :default => 0 - t.integer :g270, :default => 0 - t.integer :b270, :default => 0 - t.integer :a280, :default => 0 - t.integer :r280, :default => 0 - t.integer :g280, :default => 0 - t.integer :b280, :default => 0 - t.integer :a290, :default => 0 - t.integer :r290, :default => 0 - t.integer :g290, :default => 0 - t.integer :b290, :default => 0 - t.integer :a300, :default => 0 - t.integer :r300, :default => 0 - t.integer :g300, :default => 0 - t.integer :b300, :default => 0 - t.integer :a310, :default => 0 - t.integer :r310, :default => 0 - t.integer :g310, :default => 0 - t.integer :b310, :default => 0 - t.integer :a320, :default => 0 - t.integer :r320, :default => 0 - t.integer :g320, :default => 0 - t.integer :b320, :default => 0 - t.integer :a330, :default => 0 - t.integer :r330, :default => 0 - t.integer :g330, :default => 0 - t.integer :b330, :default => 0 - t.integer :a340, :default => 0 - t.integer :r340, :default => 0 - t.integer :g340, :default => 0 - t.integer :b340, :default => 0 - t.integer :a350, :default => 0 - t.integer :r350, :default => 0 - t.integer :g350, :default => 0 - t.integer :b350, :default => 0 - t.integer :a360, :default => 0 - t.integer :r360, :default => 0 - t.integer :g360, :default => 0 - t.integer :b360, :default => 0 - t.integer :a370, :default => 0 - t.integer :r370, :default => 0 - t.integer :g370, :default => 0 - t.integer :b370, :default => 0 - t.integer :a380, :default => 0 - t.integer :r380, :default => 0 - t.integer :g380, :default => 0 - t.integer :b380, :default => 0 - t.integer :a390, :default => 0 - t.integer :r390, :default => 0 - t.integer :g390, :default => 0 - t.integer :b390, :default => 0 - t.integer :a400, :default => 0 - t.integer :r400, :default => 0 - t.integer :g400, :default => 0 - t.integer :b400, :default => 0 - t.integer :a410, :default => 0 - t.integer :r410, :default => 0 - t.integer :g410, :default => 0 - t.integer :b410, :default => 0 - t.integer :a420, :default => 0 - t.integer :r420, :default => 0 - t.integer :g420, :default => 0 - t.integer :b420, :default => 0 - t.integer :a430, :default => 0 - t.integer :r430, :default => 0 - t.integer :g430, :default => 0 - t.integer :b430, :default => 0 - t.integer :a440, :default => 0 - t.integer :r440, :default => 0 - t.integer :g440, :default => 0 - t.integer :b440, :default => 0 - t.integer :a450, :default => 0 - t.integer :r450, :default => 0 - t.integer :g450, :default => 0 - t.integer :b450, :default => 0 - t.integer :a460, :default => 0 - t.integer :r460, :default => 0 - t.integer :g460, :default => 0 - t.integer :b460, :default => 0 - t.integer :a470, :default => 0 - t.integer :r470, :default => 0 - t.integer :g470, :default => 0 - t.integer :b470, :default => 0 - t.integer :a480, :default => 0 - t.integer :r480, :default => 0 - t.integer :g480, :default => 0 - t.integer :b480, :default => 0 - t.integer :a490, :default => 0 - t.integer :r490, :default => 0 - t.integer :g490, :default => 0 - t.integer :b490, :default => 0 - t.integer :a500, :default => 0 - t.integer :r500, :default => 0 - t.integer :g500, :default => 0 - t.integer :b500, :default => 0 - t.integer :a510, :default => 0 - t.integer :r510, :default => 0 - t.integer :g510, :default => 0 - t.integer :b510, :default => 0 - t.integer :a520, :default => 0 - t.integer :r520, :default => 0 - t.integer :g520, :default => 0 - t.integer :b520, :default => 0 - t.integer :a530, :default => 0 - t.integer :r530, :default => 0 - t.integer :g530, :default => 0 - t.integer :b530, :default => 0 - t.integer :a540, :default => 0 - t.integer :r540, :default => 0 - t.integer :g540, :default => 0 - t.integer :b540, :default => 0 - t.integer :a550, :default => 0 - t.integer :r550, :default => 0 - t.integer :g550, :default => 0 - t.integer :b550, :default => 0 - t.integer :a560, :default => 0 - t.integer :r560, :default => 0 - t.integer :g560, :default => 0 - t.integer :b560, :default => 0 - t.integer :a570, :default => 0 - t.integer :r570, :default => 0 - t.integer :g570, :default => 0 - t.integer :b570, :default => 0 - t.integer :a580, :default => 0 - t.integer :r580, :default => 0 - t.integer :g580, :default => 0 - t.integer :b580, :default => 0 - t.integer :a590, :default => 0 - t.integer :r590, :default => 0 - t.integer :g590, :default => 0 - t.integer :b590, :default => 0 - t.integer :a600, :default => 0 - t.integer :r600, :default => 0 - t.integer :g600, :default => 0 - t.integer :b600, :default => 0 - t.integer :a610, :default => 0 - t.integer :r610, :default => 0 - t.integer :g610, :default => 0 - t.integer :b610, :default => 0 - t.integer :a620, :default => 0 - t.integer :r620, :default => 0 - t.integer :g620, :default => 0 - t.integer :b620, :default => 0 - t.integer :a630, :default => 0 - t.integer :r630, :default => 0 - t.integer :g630, :default => 0 - t.integer :b630, :default => 0 - t.integer :a640, :default => 0 - t.integer :r640, :default => 0 - t.integer :g640, :default => 0 - t.integer :b640, :default => 0 - t.integer :a650, :default => 0 - t.integer :r650, :default => 0 - t.integer :g650, :default => 0 - t.integer :b650, :default => 0 - t.integer :a660, :default => 0 - t.integer :r660, :default => 0 - t.integer :g660, :default => 0 - t.integer :b660, :default => 0 - t.integer :a670, :default => 0 - t.integer :r670, :default => 0 - t.integer :g670, :default => 0 - t.integer :b670, :default => 0 - t.integer :a680, :default => 0 - t.integer :r680, :default => 0 - t.integer :g680, :default => 0 - t.integer :b680, :default => 0 - t.integer :a690, :default => 0 - t.integer :r690, :default => 0 - t.integer :g690, :default => 0 - t.integer :b690, :default => 0 - t.integer :a700, :default => 0 - t.integer :r700, :default => 0 - t.integer :g700, :default => 0 - t.integer :b700, :default => 0 - t.integer :a710, :default => 0 - t.integer :r710, :default => 0 - t.integer :g710, :default => 0 - t.integer :b710, :default => 0 - t.integer :a720, :default => 0 - t.integer :r720, :default => 0 - t.integer :g720, :default => 0 - t.integer :b720, :default => 0 - t.integer :a730, :default => 0 - t.integer :r730, :default => 0 - t.integer :g730, :default => 0 - t.integer :b730, :default => 0 - t.integer :a740, :default => 0 - t.integer :r740, :default => 0 - t.integer :g740, :default => 0 - t.integer :b740, :default => 0 - t.integer :a750, :default => 0 - t.integer :r750, :default => 0 - t.integer :g750, :default => 0 - t.integer :b750, :default => 0 - t.integer :a760, :default => 0 - t.integer :r760, :default => 0 - t.integer :g760, :default => 0 - t.integer :b760, :default => 0 - t.integer :a770, :default => 0 - t.integer :r770, :default => 0 - t.integer :g770, :default => 0 - t.integer :b770, :default => 0 - t.integer :a780, :default => 0 - t.integer :r780, :default => 0 - t.integer :g780, :default => 0 - t.integer :b780, :default => 0 - t.integer :a790, :default => 0 - t.integer :r790, :default => 0 - t.integer :g790, :default => 0 - t.integer :b790, :default => 0 - t.integer :a800, :default => 0 - t.integer :r800, :default => 0 - t.integer :g800, :default => 0 - t.integer :b800, :default => 0 - t.integer :a810, :default => 0 - t.integer :r810, :default => 0 - t.integer :g810, :default => 0 - t.integer :b810, :default => 0 - t.integer :a820, :default => 0 - t.integer :r820, :default => 0 - t.integer :g820, :default => 0 - t.integer :b820, :default => 0 - t.integer :a830, :default => 0 - t.integer :r830, :default => 0 - t.integer :g830, :default => 0 - t.integer :b830, :default => 0 - t.integer :a840, :default => 0 - t.integer :r840, :default => 0 - t.integer :g840, :default => 0 - t.integer :b840, :default => 0 - t.integer :a850, :default => 0 - t.integer :r850, :default => 0 - t.integer :g850, :default => 0 - t.integer :b850, :default => 0 - t.integer :a860, :default => 0 - t.integer :r860, :default => 0 - t.integer :g860, :default => 0 - t.integer :b860, :default => 0 - t.integer :a870, :default => 0 - t.integer :r870, :default => 0 - t.integer :g870, :default => 0 - t.integer :b870, :default => 0 - t.integer :a880, :default => 0 - t.integer :r880, :default => 0 - t.integer :g880, :default => 0 - t.integer :b880, :default => 0 - t.integer :a890, :default => 0 - t.integer :r890, :default => 0 - t.integer :g890, :default => 0 - t.integer :b890, :default => 0 - t.integer :a900, :default => 0 - t.integer :r900, :default => 0 - t.integer :g900, :default => 0 - t.integer :b900, :default => 0 - t.integer :a910, :default => 0 - t.integer :r910, :default => 0 - t.integer :g910, :default => 0 - t.integer :b910, :default => 0 - t.integer :a920, :default => 0 - t.integer :r920, :default => 0 - t.integer :g920, :default => 0 - t.integer :b920, :default => 0 - t.integer :a930, :default => 0 - t.integer :r930, :default => 0 - t.integer :g930, :default => 0 - t.integer :b930, :default => 0 - t.integer :a940, :default => 0 - t.integer :r940, :default => 0 - t.integer :g940, :default => 0 - t.integer :b940, :default => 0 - t.integer :a950, :default => 0 - t.integer :r950, :default => 0 - t.integer :g950, :default => 0 - t.integer :b950, :default => 0 - t.integer :a960, :default => 0 - t.integer :r960, :default => 0 - t.integer :g960, :default => 0 - t.integer :b960, :default => 0 - t.integer :a970, :default => 0 - t.integer :r970, :default => 0 - t.integer :g970, :default => 0 - t.integer :b970, :default => 0 - t.integer :a980, :default => 0 - t.integer :r980, :default => 0 - t.integer :g980, :default => 0 - t.integer :b980, :default => 0 - t.integer :a990, :default => 0 - t.integer :r990, :default => 0 - t.integer :g990, :default => 0 - t.integer :b990, :default => 0 - t.integer :a1000, :default => 0 - t.integer :r1000, :default => 0 - t.integer :g1000, :default => 0 - t.integer :b1000, :default => 0 - t.integer :a1010, :default => 0 - t.integer :r1010, :default => 0 - t.integer :g1010, :default => 0 - t.integer :b1010, :default => 0 - t.integer :a1020, :default => 0 - t.integer :r1020, :default => 0 - t.integer :g1020, :default => 0 - t.integer :b1020, :default => 0 - t.integer :a1030, :default => 0 - t.integer :r1030, :default => 0 - t.integer :g1030, :default => 0 - t.integer :b1030, :default => 0 - t.integer :a1040, :default => 0 - t.integer :r1040, :default => 0 - t.integer :g1040, :default => 0 - t.integer :b1040, :default => 0 - t.integer :a1050, :default => 0 - t.integer :r1050, :default => 0 - t.integer :g1050, :default => 0 - t.integer :b1050, :default => 0 - t.integer :a1060, :default => 0 - t.integer :r1060, :default => 0 - t.integer :g1060, :default => 0 - t.integer :b1060, :default => 0 - t.integer :a1070, :default => 0 - t.integer :r1070, :default => 0 - t.integer :g1070, :default => 0 - t.integer :b1070, :default => 0 - t.integer :a1080, :default => 0 - t.integer :r1080, :default => 0 - t.integer :g1080, :default => 0 - t.integer :b1080, :default => 0 - t.integer :a1090, :default => 0 - t.integer :r1090, :default => 0 - t.integer :g1090, :default => 0 - t.integer :b1090, :default => 0 - t.integer :a1100, :default => 0 - t.integer :r1100, :default => 0 - t.integer :g1100, :default => 0 - t.integer :b1100, :default => 0 - t.integer :a1110, :default => 0 - t.integer :r1110, :default => 0 - t.integer :g1110, :default => 0 - t.integer :b1110, :default => 0 - t.integer :a1120, :default => 0 - t.integer :r1120, :default => 0 - t.integer :g1120, :default => 0 - t.integer :b1120, :default => 0 - t.integer :a1130, :default => 0 - t.integer :r1130, :default => 0 - t.integer :g1130, :default => 0 - t.integer :b1130, :default => 0 - t.integer :a1140, :default => 0 - t.integer :r1140, :default => 0 - t.integer :g1140, :default => 0 - t.integer :b1140, :default => 0 - t.integer :a1150, :default => 0 - t.integer :r1150, :default => 0 - t.integer :g1150, :default => 0 - t.integer :b1150, :default => 0 - t.integer :a1160, :default => 0 - t.integer :r1160, :default => 0 - t.integer :g1160, :default => 0 - t.integer :b1160, :default => 0 - t.integer :a1170, :default => 0 - t.integer :r1170, :default => 0 - t.integer :g1170, :default => 0 - t.integer :b1170, :default => 0 - t.integer :a1180, :default => 0 - t.integer :r1180, :default => 0 - t.integer :g1180, :default => 0 - t.integer :b1180, :default => 0 - t.integer :a1190, :default => 0 - t.integer :r1190, :default => 0 - t.integer :g1190, :default => 0 - t.integer :b1190, :default => 0 - t.integer :a1200, :default => 0 - t.integer :r1200, :default => 0 - t.integer :g1200, :default => 0 - t.integer :b1200, :default => 0 - t.integer :a1210, :default => 0 - t.integer :r1210, :default => 0 - t.integer :g1210, :default => 0 - t.integer :b1210, :default => 0 - t.integer :a1220, :default => 0 - t.integer :r1220, :default => 0 - t.integer :g1220, :default => 0 - t.integer :b1220, :default => 0 - t.integer :a1230, :default => 0 - t.integer :r1230, :default => 0 - t.integer :g1230, :default => 0 - t.integer :b1230, :default => 0 - t.integer :a1240, :default => 0 - t.integer :r1240, :default => 0 - t.integer :g1240, :default => 0 - t.integer :b1240, :default => 0 - t.integer :a1250, :default => 0 - t.integer :r1250, :default => 0 - t.integer :g1250, :default => 0 - t.integer :b1250, :default => 0 - t.integer :a1260, :default => 0 - t.integer :r1260, :default => 0 - t.integer :g1260, :default => 0 - t.integer :b1260, :default => 0 - t.integer :a1270, :default => 0 - t.integer :r1270, :default => 0 - t.integer :g1270, :default => 0 - t.integer :b1270, :default => 0 - t.integer :a1280, :default => 0 - t.integer :r1280, :default => 0 - t.integer :g1280, :default => 0 - t.integer :b1280, :default => 0 - t.integer :a1290, :default => 0 - t.integer :r1290, :default => 0 - t.integer :g1290, :default => 0 - t.integer :b1290, :default => 0 - t.integer :a1300, :default => 0 - t.integer :r1300, :default => 0 - t.integer :g1300, :default => 0 - t.integer :b1300, :default => 0 - t.integer :a1310, :default => 0 - t.integer :r1310, :default => 0 - t.integer :g1310, :default => 0 - t.integer :b1310, :default => 0 - t.integer :a1320, :default => 0 - t.integer :r1320, :default => 0 - t.integer :g1320, :default => 0 - t.integer :b1320, :default => 0 - t.integer :a1330, :default => 0 - t.integer :r1330, :default => 0 - t.integer :g1330, :default => 0 - t.integer :b1330, :default => 0 - t.integer :a1340, :default => 0 - t.integer :r1340, :default => 0 - t.integer :g1340, :default => 0 - t.integer :b1340, :default => 0 - t.integer :a1350, :default => 0 - t.integer :r1350, :default => 0 - t.integer :g1350, :default => 0 - t.integer :b1350, :default => 0 - t.integer :a1360, :default => 0 - t.integer :r1360, :default => 0 - t.integer :g1360, :default => 0 - t.integer :b1360, :default => 0 - t.integer :a1370, :default => 0 - t.integer :r1370, :default => 0 - t.integer :g1370, :default => 0 - t.integer :b1370, :default => 0 - t.integer :a1380, :default => 0 - t.integer :r1380, :default => 0 - t.integer :g1380, :default => 0 - t.integer :b1380, :default => 0 - t.integer :a1390, :default => 0 - t.integer :r1390, :default => 0 - t.integer :g1390, :default => 0 - t.integer :b1390, :default => 0 - t.integer :a1400, :default => 0 - t.integer :r1400, :default => 0 - t.integer :g1400, :default => 0 - t.integer :b1400, :default => 0 - t.integer :a1410, :default => 0 - t.integer :r1410, :default => 0 - t.integer :g1410, :default => 0 - t.integer :b1410, :default => 0 - t.integer :a1420, :default => 0 - t.integer :r1420, :default => 0 - t.integer :g1420, :default => 0 - t.integer :b1420, :default => 0 - t.integer :a1430, :default => 0 - t.integer :r1430, :default => 0 - t.integer :g1430, :default => 0 - t.integer :b1430, :default => 0 - t.integer :a1440, :default => 0 - t.integer :r1440, :default => 0 - t.integer :g1440, :default => 0 - t.integer :b1440, :default => 0 - t.integer :a1450, :default => 0 - t.integer :r1450, :default => 0 - t.integer :g1450, :default => 0 - t.integer :b1450, :default => 0 - t.integer :a1460, :default => 0 - t.integer :r1460, :default => 0 - t.integer :g1460, :default => 0 - t.integer :b1460, :default => 0 - t.integer :a1470, :default => 0 - t.integer :r1470, :default => 0 - t.integer :g1470, :default => 0 - t.integer :b1470, :default => 0 - t.integer :a1480, :default => 0 - t.integer :r1480, :default => 0 - t.integer :g1480, :default => 0 - t.integer :b1480, :default => 0 - t.integer :a1490, :default => 0 - t.integer :r1490, :default => 0 - t.integer :g1490, :default => 0 - t.integer :b1490, :default => 0 + t.integer :a10, default: 0 # Each column for matching. Looks weird, haha + t.integer :r10, default: 0 + t.integer :g10, default: 0 + t.integer :b10, default: 0 + t.integer :a20, default: 0 + t.integer :r20, default: 0 + t.integer :g20, default: 0 + t.integer :b20, default: 0 + t.integer :a30, default: 0 + t.integer :r30, default: 0 + t.integer :g30, default: 0 + t.integer :b30, default: 0 + t.integer :a40, default: 0 + t.integer :r40, default: 0 + t.integer :g40, default: 0 + t.integer :b40, default: 0 + t.integer :a50, default: 0 + t.integer :r50, default: 0 + t.integer :g50, default: 0 + t.integer :b50, default: 0 + t.integer :a60, default: 0 + t.integer :r60, default: 0 + t.integer :g60, default: 0 + t.integer :b60, default: 0 + t.integer :a70, default: 0 + t.integer :r70, default: 0 + t.integer :g70, default: 0 + t.integer :b70, default: 0 + t.integer :a80, default: 0 + t.integer :r80, default: 0 + t.integer :g80, default: 0 + t.integer :b80, default: 0 + t.integer :a90, default: 0 + t.integer :r90, default: 0 + t.integer :g90, default: 0 + t.integer :b90, default: 0 + t.integer :a100, default: 0 + t.integer :r100, default: 0 + t.integer :g100, default: 0 + t.integer :b100, default: 0 + t.integer :a110, default: 0 + t.integer :r110, default: 0 + t.integer :g110, default: 0 + t.integer :b110, default: 0 + t.integer :a120, default: 0 + t.integer :r120, default: 0 + t.integer :g120, default: 0 + t.integer :b120, default: 0 + t.integer :a130, default: 0 + t.integer :r130, default: 0 + t.integer :g130, default: 0 + t.integer :b130, default: 0 + t.integer :a140, default: 0 + t.integer :r140, default: 0 + t.integer :g140, default: 0 + t.integer :b140, default: 0 + t.integer :a150, default: 0 + t.integer :r150, default: 0 + t.integer :g150, default: 0 + t.integer :b150, default: 0 + t.integer :a160, default: 0 + t.integer :r160, default: 0 + t.integer :g160, default: 0 + t.integer :b160, default: 0 + t.integer :a170, default: 0 + t.integer :r170, default: 0 + t.integer :g170, default: 0 + t.integer :b170, default: 0 + t.integer :a180, default: 0 + t.integer :r180, default: 0 + t.integer :g180, default: 0 + t.integer :b180, default: 0 + t.integer :a190, default: 0 + t.integer :r190, default: 0 + t.integer :g190, default: 0 + t.integer :b190, default: 0 + t.integer :a200, default: 0 + t.integer :r200, default: 0 + t.integer :g200, default: 0 + t.integer :b200, default: 0 + t.integer :a210, default: 0 + t.integer :r210, default: 0 + t.integer :g210, default: 0 + t.integer :b210, default: 0 + t.integer :a220, default: 0 + t.integer :r220, default: 0 + t.integer :g220, default: 0 + t.integer :b220, default: 0 + t.integer :a230, default: 0 + t.integer :r230, default: 0 + t.integer :g230, default: 0 + t.integer :b230, default: 0 + t.integer :a240, default: 0 + t.integer :r240, default: 0 + t.integer :g240, default: 0 + t.integer :b240, default: 0 + t.integer :a250, default: 0 + t.integer :r250, default: 0 + t.integer :g250, default: 0 + t.integer :b250, default: 0 + t.integer :a260, default: 0 + t.integer :r260, default: 0 + t.integer :g260, default: 0 + t.integer :b260, default: 0 + t.integer :a270, default: 0 + t.integer :r270, default: 0 + t.integer :g270, default: 0 + t.integer :b270, default: 0 + t.integer :a280, default: 0 + t.integer :r280, default: 0 + t.integer :g280, default: 0 + t.integer :b280, default: 0 + t.integer :a290, default: 0 + t.integer :r290, default: 0 + t.integer :g290, default: 0 + t.integer :b290, default: 0 + t.integer :a300, default: 0 + t.integer :r300, default: 0 + t.integer :g300, default: 0 + t.integer :b300, default: 0 + t.integer :a310, default: 0 + t.integer :r310, default: 0 + t.integer :g310, default: 0 + t.integer :b310, default: 0 + t.integer :a320, default: 0 + t.integer :r320, default: 0 + t.integer :g320, default: 0 + t.integer :b320, default: 0 + t.integer :a330, default: 0 + t.integer :r330, default: 0 + t.integer :g330, default: 0 + t.integer :b330, default: 0 + t.integer :a340, default: 0 + t.integer :r340, default: 0 + t.integer :g340, default: 0 + t.integer :b340, default: 0 + t.integer :a350, default: 0 + t.integer :r350, default: 0 + t.integer :g350, default: 0 + t.integer :b350, default: 0 + t.integer :a360, default: 0 + t.integer :r360, default: 0 + t.integer :g360, default: 0 + t.integer :b360, default: 0 + t.integer :a370, default: 0 + t.integer :r370, default: 0 + t.integer :g370, default: 0 + t.integer :b370, default: 0 + t.integer :a380, default: 0 + t.integer :r380, default: 0 + t.integer :g380, default: 0 + t.integer :b380, default: 0 + t.integer :a390, default: 0 + t.integer :r390, default: 0 + t.integer :g390, default: 0 + t.integer :b390, default: 0 + t.integer :a400, default: 0 + t.integer :r400, default: 0 + t.integer :g400, default: 0 + t.integer :b400, default: 0 + t.integer :a410, default: 0 + t.integer :r410, default: 0 + t.integer :g410, default: 0 + t.integer :b410, default: 0 + t.integer :a420, default: 0 + t.integer :r420, default: 0 + t.integer :g420, default: 0 + t.integer :b420, default: 0 + t.integer :a430, default: 0 + t.integer :r430, default: 0 + t.integer :g430, default: 0 + t.integer :b430, default: 0 + t.integer :a440, default: 0 + t.integer :r440, default: 0 + t.integer :g440, default: 0 + t.integer :b440, default: 0 + t.integer :a450, default: 0 + t.integer :r450, default: 0 + t.integer :g450, default: 0 + t.integer :b450, default: 0 + t.integer :a460, default: 0 + t.integer :r460, default: 0 + t.integer :g460, default: 0 + t.integer :b460, default: 0 + t.integer :a470, default: 0 + t.integer :r470, default: 0 + t.integer :g470, default: 0 + t.integer :b470, default: 0 + t.integer :a480, default: 0 + t.integer :r480, default: 0 + t.integer :g480, default: 0 + t.integer :b480, default: 0 + t.integer :a490, default: 0 + t.integer :r490, default: 0 + t.integer :g490, default: 0 + t.integer :b490, default: 0 + t.integer :a500, default: 0 + t.integer :r500, default: 0 + t.integer :g500, default: 0 + t.integer :b500, default: 0 + t.integer :a510, default: 0 + t.integer :r510, default: 0 + t.integer :g510, default: 0 + t.integer :b510, default: 0 + t.integer :a520, default: 0 + t.integer :r520, default: 0 + t.integer :g520, default: 0 + t.integer :b520, default: 0 + t.integer :a530, default: 0 + t.integer :r530, default: 0 + t.integer :g530, default: 0 + t.integer :b530, default: 0 + t.integer :a540, default: 0 + t.integer :r540, default: 0 + t.integer :g540, default: 0 + t.integer :b540, default: 0 + t.integer :a550, default: 0 + t.integer :r550, default: 0 + t.integer :g550, default: 0 + t.integer :b550, default: 0 + t.integer :a560, default: 0 + t.integer :r560, default: 0 + t.integer :g560, default: 0 + t.integer :b560, default: 0 + t.integer :a570, default: 0 + t.integer :r570, default: 0 + t.integer :g570, default: 0 + t.integer :b570, default: 0 + t.integer :a580, default: 0 + t.integer :r580, default: 0 + t.integer :g580, default: 0 + t.integer :b580, default: 0 + t.integer :a590, default: 0 + t.integer :r590, default: 0 + t.integer :g590, default: 0 + t.integer :b590, default: 0 + t.integer :a600, default: 0 + t.integer :r600, default: 0 + t.integer :g600, default: 0 + t.integer :b600, default: 0 + t.integer :a610, default: 0 + t.integer :r610, default: 0 + t.integer :g610, default: 0 + t.integer :b610, default: 0 + t.integer :a620, default: 0 + t.integer :r620, default: 0 + t.integer :g620, default: 0 + t.integer :b620, default: 0 + t.integer :a630, default: 0 + t.integer :r630, default: 0 + t.integer :g630, default: 0 + t.integer :b630, default: 0 + t.integer :a640, default: 0 + t.integer :r640, default: 0 + t.integer :g640, default: 0 + t.integer :b640, default: 0 + t.integer :a650, default: 0 + t.integer :r650, default: 0 + t.integer :g650, default: 0 + t.integer :b650, default: 0 + t.integer :a660, default: 0 + t.integer :r660, default: 0 + t.integer :g660, default: 0 + t.integer :b660, default: 0 + t.integer :a670, default: 0 + t.integer :r670, default: 0 + t.integer :g670, default: 0 + t.integer :b670, default: 0 + t.integer :a680, default: 0 + t.integer :r680, default: 0 + t.integer :g680, default: 0 + t.integer :b680, default: 0 + t.integer :a690, default: 0 + t.integer :r690, default: 0 + t.integer :g690, default: 0 + t.integer :b690, default: 0 + t.integer :a700, default: 0 + t.integer :r700, default: 0 + t.integer :g700, default: 0 + t.integer :b700, default: 0 + t.integer :a710, default: 0 + t.integer :r710, default: 0 + t.integer :g710, default: 0 + t.integer :b710, default: 0 + t.integer :a720, default: 0 + t.integer :r720, default: 0 + t.integer :g720, default: 0 + t.integer :b720, default: 0 + t.integer :a730, default: 0 + t.integer :r730, default: 0 + t.integer :g730, default: 0 + t.integer :b730, default: 0 + t.integer :a740, default: 0 + t.integer :r740, default: 0 + t.integer :g740, default: 0 + t.integer :b740, default: 0 + t.integer :a750, default: 0 + t.integer :r750, default: 0 + t.integer :g750, default: 0 + t.integer :b750, default: 0 + t.integer :a760, default: 0 + t.integer :r760, default: 0 + t.integer :g760, default: 0 + t.integer :b760, default: 0 + t.integer :a770, default: 0 + t.integer :r770, default: 0 + t.integer :g770, default: 0 + t.integer :b770, default: 0 + t.integer :a780, default: 0 + t.integer :r780, default: 0 + t.integer :g780, default: 0 + t.integer :b780, default: 0 + t.integer :a790, default: 0 + t.integer :r790, default: 0 + t.integer :g790, default: 0 + t.integer :b790, default: 0 + t.integer :a800, default: 0 + t.integer :r800, default: 0 + t.integer :g800, default: 0 + t.integer :b800, default: 0 + t.integer :a810, default: 0 + t.integer :r810, default: 0 + t.integer :g810, default: 0 + t.integer :b810, default: 0 + t.integer :a820, default: 0 + t.integer :r820, default: 0 + t.integer :g820, default: 0 + t.integer :b820, default: 0 + t.integer :a830, default: 0 + t.integer :r830, default: 0 + t.integer :g830, default: 0 + t.integer :b830, default: 0 + t.integer :a840, default: 0 + t.integer :r840, default: 0 + t.integer :g840, default: 0 + t.integer :b840, default: 0 + t.integer :a850, default: 0 + t.integer :r850, default: 0 + t.integer :g850, default: 0 + t.integer :b850, default: 0 + t.integer :a860, default: 0 + t.integer :r860, default: 0 + t.integer :g860, default: 0 + t.integer :b860, default: 0 + t.integer :a870, default: 0 + t.integer :r870, default: 0 + t.integer :g870, default: 0 + t.integer :b870, default: 0 + t.integer :a880, default: 0 + t.integer :r880, default: 0 + t.integer :g880, default: 0 + t.integer :b880, default: 0 + t.integer :a890, default: 0 + t.integer :r890, default: 0 + t.integer :g890, default: 0 + t.integer :b890, default: 0 + t.integer :a900, default: 0 + t.integer :r900, default: 0 + t.integer :g900, default: 0 + t.integer :b900, default: 0 + t.integer :a910, default: 0 + t.integer :r910, default: 0 + t.integer :g910, default: 0 + t.integer :b910, default: 0 + t.integer :a920, default: 0 + t.integer :r920, default: 0 + t.integer :g920, default: 0 + t.integer :b920, default: 0 + t.integer :a930, default: 0 + t.integer :r930, default: 0 + t.integer :g930, default: 0 + t.integer :b930, default: 0 + t.integer :a940, default: 0 + t.integer :r940, default: 0 + t.integer :g940, default: 0 + t.integer :b940, default: 0 + t.integer :a950, default: 0 + t.integer :r950, default: 0 + t.integer :g950, default: 0 + t.integer :b950, default: 0 + t.integer :a960, default: 0 + t.integer :r960, default: 0 + t.integer :g960, default: 0 + t.integer :b960, default: 0 + t.integer :a970, default: 0 + t.integer :r970, default: 0 + t.integer :g970, default: 0 + t.integer :b970, default: 0 + t.integer :a980, default: 0 + t.integer :r980, default: 0 + t.integer :g980, default: 0 + t.integer :b980, default: 0 + t.integer :a990, default: 0 + t.integer :r990, default: 0 + t.integer :g990, default: 0 + t.integer :b990, default: 0 + t.integer :a1000, default: 0 + t.integer :r1000, default: 0 + t.integer :g1000, default: 0 + t.integer :b1000, default: 0 + t.integer :a1010, default: 0 + t.integer :r1010, default: 0 + t.integer :g1010, default: 0 + t.integer :b1010, default: 0 + t.integer :a1020, default: 0 + t.integer :r1020, default: 0 + t.integer :g1020, default: 0 + t.integer :b1020, default: 0 + t.integer :a1030, default: 0 + t.integer :r1030, default: 0 + t.integer :g1030, default: 0 + t.integer :b1030, default: 0 + t.integer :a1040, default: 0 + t.integer :r1040, default: 0 + t.integer :g1040, default: 0 + t.integer :b1040, default: 0 + t.integer :a1050, default: 0 + t.integer :r1050, default: 0 + t.integer :g1050, default: 0 + t.integer :b1050, default: 0 + t.integer :a1060, default: 0 + t.integer :r1060, default: 0 + t.integer :g1060, default: 0 + t.integer :b1060, default: 0 + t.integer :a1070, default: 0 + t.integer :r1070, default: 0 + t.integer :g1070, default: 0 + t.integer :b1070, default: 0 + t.integer :a1080, default: 0 + t.integer :r1080, default: 0 + t.integer :g1080, default: 0 + t.integer :b1080, default: 0 + t.integer :a1090, default: 0 + t.integer :r1090, default: 0 + t.integer :g1090, default: 0 + t.integer :b1090, default: 0 + t.integer :a1100, default: 0 + t.integer :r1100, default: 0 + t.integer :g1100, default: 0 + t.integer :b1100, default: 0 + t.integer :a1110, default: 0 + t.integer :r1110, default: 0 + t.integer :g1110, default: 0 + t.integer :b1110, default: 0 + t.integer :a1120, default: 0 + t.integer :r1120, default: 0 + t.integer :g1120, default: 0 + t.integer :b1120, default: 0 + t.integer :a1130, default: 0 + t.integer :r1130, default: 0 + t.integer :g1130, default: 0 + t.integer :b1130, default: 0 + t.integer :a1140, default: 0 + t.integer :r1140, default: 0 + t.integer :g1140, default: 0 + t.integer :b1140, default: 0 + t.integer :a1150, default: 0 + t.integer :r1150, default: 0 + t.integer :g1150, default: 0 + t.integer :b1150, default: 0 + t.integer :a1160, default: 0 + t.integer :r1160, default: 0 + t.integer :g1160, default: 0 + t.integer :b1160, default: 0 + t.integer :a1170, default: 0 + t.integer :r1170, default: 0 + t.integer :g1170, default: 0 + t.integer :b1170, default: 0 + t.integer :a1180, default: 0 + t.integer :r1180, default: 0 + t.integer :g1180, default: 0 + t.integer :b1180, default: 0 + t.integer :a1190, default: 0 + t.integer :r1190, default: 0 + t.integer :g1190, default: 0 + t.integer :b1190, default: 0 + t.integer :a1200, default: 0 + t.integer :r1200, default: 0 + t.integer :g1200, default: 0 + t.integer :b1200, default: 0 + t.integer :a1210, default: 0 + t.integer :r1210, default: 0 + t.integer :g1210, default: 0 + t.integer :b1210, default: 0 + t.integer :a1220, default: 0 + t.integer :r1220, default: 0 + t.integer :g1220, default: 0 + t.integer :b1220, default: 0 + t.integer :a1230, default: 0 + t.integer :r1230, default: 0 + t.integer :g1230, default: 0 + t.integer :b1230, default: 0 + t.integer :a1240, default: 0 + t.integer :r1240, default: 0 + t.integer :g1240, default: 0 + t.integer :b1240, default: 0 + t.integer :a1250, default: 0 + t.integer :r1250, default: 0 + t.integer :g1250, default: 0 + t.integer :b1250, default: 0 + t.integer :a1260, default: 0 + t.integer :r1260, default: 0 + t.integer :g1260, default: 0 + t.integer :b1260, default: 0 + t.integer :a1270, default: 0 + t.integer :r1270, default: 0 + t.integer :g1270, default: 0 + t.integer :b1270, default: 0 + t.integer :a1280, default: 0 + t.integer :r1280, default: 0 + t.integer :g1280, default: 0 + t.integer :b1280, default: 0 + t.integer :a1290, default: 0 + t.integer :r1290, default: 0 + t.integer :g1290, default: 0 + t.integer :b1290, default: 0 + t.integer :a1300, default: 0 + t.integer :r1300, default: 0 + t.integer :g1300, default: 0 + t.integer :b1300, default: 0 + t.integer :a1310, default: 0 + t.integer :r1310, default: 0 + t.integer :g1310, default: 0 + t.integer :b1310, default: 0 + t.integer :a1320, default: 0 + t.integer :r1320, default: 0 + t.integer :g1320, default: 0 + t.integer :b1320, default: 0 + t.integer :a1330, default: 0 + t.integer :r1330, default: 0 + t.integer :g1330, default: 0 + t.integer :b1330, default: 0 + t.integer :a1340, default: 0 + t.integer :r1340, default: 0 + t.integer :g1340, default: 0 + t.integer :b1340, default: 0 + t.integer :a1350, default: 0 + t.integer :r1350, default: 0 + t.integer :g1350, default: 0 + t.integer :b1350, default: 0 + t.integer :a1360, default: 0 + t.integer :r1360, default: 0 + t.integer :g1360, default: 0 + t.integer :b1360, default: 0 + t.integer :a1370, default: 0 + t.integer :r1370, default: 0 + t.integer :g1370, default: 0 + t.integer :b1370, default: 0 + t.integer :a1380, default: 0 + t.integer :r1380, default: 0 + t.integer :g1380, default: 0 + t.integer :b1380, default: 0 + t.integer :a1390, default: 0 + t.integer :r1390, default: 0 + t.integer :g1390, default: 0 + t.integer :b1390, default: 0 + t.integer :a1400, default: 0 + t.integer :r1400, default: 0 + t.integer :g1400, default: 0 + t.integer :b1400, default: 0 + t.integer :a1410, default: 0 + t.integer :r1410, default: 0 + t.integer :g1410, default: 0 + t.integer :b1410, default: 0 + t.integer :a1420, default: 0 + t.integer :r1420, default: 0 + t.integer :g1420, default: 0 + t.integer :b1420, default: 0 + t.integer :a1430, default: 0 + t.integer :r1430, default: 0 + t.integer :g1430, default: 0 + t.integer :b1430, default: 0 + t.integer :a1440, default: 0 + t.integer :r1440, default: 0 + t.integer :g1440, default: 0 + t.integer :b1440, default: 0 + t.integer :a1450, default: 0 + t.integer :r1450, default: 0 + t.integer :g1450, default: 0 + t.integer :b1450, default: 0 + t.integer :a1460, default: 0 + t.integer :r1460, default: 0 + t.integer :g1460, default: 0 + t.integer :b1460, default: 0 + t.integer :a1470, default: 0 + t.integer :r1470, default: 0 + t.integer :g1470, default: 0 + t.integer :b1470, default: 0 + t.integer :a1480, default: 0 + t.integer :r1480, default: 0 + t.integer :g1480, default: 0 + t.integer :b1480, default: 0 + t.integer :a1490, default: 0 + t.integer :r1490, default: 0 + t.integer :g1490, default: 0 + t.integer :b1490, default: 0 end add_index :processed_spectrums, :spectrum_id, :unique => true # Generate the processed spectrums for all the existing spectrums - Spectrum.find(:all).each do |spectrum| + Spectrum.all.each do |spectrum| spectrum.generate_processed_spectrum end end @@ -613,4 +613,4 @@ def self.up def self.down drop_table "processed_spectrums" end -end +end \ No newline at end of file diff --git a/db/migrate/20130921134441_add_spectrum_reversal.rb b/db/migrate/20130921134441_add_spectrum_reversal.rb index 684d25b7..c308216f 100644 --- a/db/migrate/20130921134441_add_spectrum_reversal.rb +++ b/db/migrate/20130921134441_add_spectrum_reversal.rb @@ -1,6 +1,6 @@ class AddSpectrumReversal < ActiveRecord::Migration def self.up - add_column :spectrums, :reversed, :boolean, :default => false, :null => false + add_column :spectrums, :reversed, :boolean, null: false, default: false end def self.down diff --git a/db/migrate/20150624185446_add_anonymous_user.rb b/db/migrate/20150624185446_add_anonymous_user.rb index e05ef16f..2697551c 100644 --- a/db/migrate/20150624185446_add_anonymous_user.rb +++ b/db/migrate/20150624185446_add_anonymous_user.rb @@ -2,7 +2,7 @@ class AddAnonymousUser < ActiveRecord::Migration def up # create an "anonymous" user: - User.new({ id:0, login:'anonymous', email: 'web@publiclab.org' }).save + User.create(login:'anonymous', email: 'web@publiclab.org', email_preferences: '1') # not anonymous, but has user_id = 0 because they predate user system Spectrum.where("author != 'anonymous'").where(user_id: 0).each do |spectrum| @@ -13,7 +13,7 @@ def up end end - add_column :spectra_sets, :user_id, :integer, :default => 0 + add_column :spectra_sets, :user_id, :integer, default: 0 SpectraSet.where("author != 'anonymous'").each do |set| user = User.where(login:set.author).first @@ -23,7 +23,7 @@ def up end end - add_column :comments, :user_id, :integer, :default => 0 + add_column :comments, :user_id, :integer, default: 0 Comment.where("author != 'anonymous'").each do |comment| user = User.where(login:comment.author).first diff --git a/db/migrate/20150715184613_add_spectrum_calibrated.rb b/db/migrate/20150715184613_add_spectrum_calibrated.rb index 9b34e792..6ae619d8 100644 --- a/db/migrate/20150715184613_add_spectrum_calibrated.rb +++ b/db/migrate/20150715184613_add_spectrum_calibrated.rb @@ -1,6 +1,6 @@ class AddSpectrumCalibrated < ActiveRecord::Migration def up - add_column :spectrums, :calibrated, :boolean, :default => false, :null => false + add_column :spectrums, :calibrated, :boolean, null: false, default: false count = Spectrum.count Spectrum.select('id').each do |spectrum| Spectrum.find(spectrum.id).save diff --git a/db/migrate/20150715224222_create_sets_spectrums_join_table.rb b/db/migrate/20150715224222_create_sets_spectrums_join_table.rb index 3a7ce923..6527ada5 100644 --- a/db/migrate/20150715224222_create_sets_spectrums_join_table.rb +++ b/db/migrate/20150715224222_create_sets_spectrums_join_table.rb @@ -19,7 +19,7 @@ def up end def down - add_column :spectrums, :spectra_string, :string, :default => "", :null => false + add_column :spectrums, :spectra_string, :string, null: false, default: '' remove_table :spectra_sets_spectrums end diff --git a/db/migrate/20150721195514_change_comment_author_to_user.rb b/db/migrate/20150721195514_change_comment_author_to_user.rb index aeca46ab..14f6be02 100644 --- a/db/migrate/20150721195514_change_comment_author_to_user.rb +++ b/db/migrate/20150721195514_change_comment_author_to_user.rb @@ -10,7 +10,6 @@ def up end end end - add_column :comments, :wavelength, :integer add_column :comments, :intensity, :integer end diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index f4873bc0..64f79f10 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -5,8 +5,8 @@ quentin: email: quentin@example.com salt: 356a192b7913b04c54574d18c28d46e6395428ab # SHA1('0') crypted_password: 7522e82320dd02c4ecdd4e7f947b23c9031e04f7 # 'monkey' - created_at: <%= 5.days.ago.to_s :db %> - remember_token_expires_at: <%= 1.days.from_now.to_s %> + created_at: <%= 5.days.ago.to_datetime %> + remember_token_expires_at: <%= 1.days.from_now.to_datetime %> remember_token: 77de68daecd823babbb58edb1c8e14d7106e83bb aaron: @@ -15,7 +15,7 @@ aaron: email: aaron@example.com salt: da4b9237bacccdf19c0760cab7aec4a8359010b0 # SHA1('1') crypted_password: 89f432716b010607bfaccf025dbde81d444e5766 # 'monkey' - created_at: <%= 1.days.ago.to_s :db %> + created_at: <%= 1.days.ago.to_datetime %> remember_token_expires_at: remember_token: @@ -26,7 +26,7 @@ admin: email: admin@example.com salt: da4b9237bacccdf19c0760cab7aec4a8359010b0 # SHA1('1') crypted_password: 89f432716b010607bfaccf025dbde81d444e5766 # 'monkey' - created_at: <%= 5.days.ago.to_s :db %> + created_at: <%= 5.days.ago.to_datetime %> remember_token_expires_at: remember_token: @@ -37,6 +37,6 @@ old_password_holder: email: salty_dog@example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test - created_at: <%= 1.days.ago.to_s :db %> + created_at: <%= 1.days.ago.to_datetime %> diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb deleted file mode 100755 index 3fea27b9..00000000 --- a/test/performance/browsing_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test_helper' -require 'rails/performance_test_help' - -class BrowsingTest < ActionDispatch::PerformanceTest - # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] - # :output => 'tmp/performance', :formats => [:flat] } - - def test_homepage - get '/' - end -end From e38451901811654861879f8781459fa3528bb3ca Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Thu, 2 Apr 2020 00:47:04 -0300 Subject: [PATCH 07/43] Fixing tests --- test/integration/exceptions_test.rb | 2 +- test/integration/redirects_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/exceptions_test.rb b/test/integration/exceptions_test.rb index e2e6f0b0..4b8495cd 100644 --- a/test/integration/exceptions_test.rb +++ b/test/integration/exceptions_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class ExceptionsTest < ActionController::IntegrationTest +class ExceptionsTest < ActionDispatch::IntegrationTest fixtures :all #test "POST /products" do diff --git a/test/integration/redirects_test.rb b/test/integration/redirects_test.rb index 5310c3cf..16f129d6 100644 --- a/test/integration/redirects_test.rb +++ b/test/integration/redirects_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class RedirectsTest < ActionController::IntegrationTest +class RedirectsTest < ActionDispatch::IntegrationTest fixtures :all test "GET /sets/show/#" do From 6f30bd2404394505cc972698d04eee6250a73a60 Mon Sep 17 00:00:00 2001 From: gr455 Date: Mon, 13 Apr 2020 16:03:14 +0530 Subject: [PATCH 08/43] Add SimpleCov for coverage monitoring --- .gitignore | 3 ++- Gemfile | 4 ++++ Gemfile.lock | 12 +++++++++++- test/test_helper.rb | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 96b96738..bb30f482 100755 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ Gemfile.lock public/lib public/assets vendor/ -db/schema.rb \ No newline at end of file +db/schema.rb +coverage/ \ No newline at end of file diff --git a/Gemfile b/Gemfile index c9864f97..76dab530 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,10 @@ group :assets do gem 'uglifier', '>= 1.0.3' end +group :test do + gem 'simplecov', require: false +end + gem 'rmagick'#, :require => "RMagick" gem 'mime-types'#, '1.18' gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 1de434f6..2dca608a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,6 +34,7 @@ GEM activesupport (>= 3.0) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) + docile (1.3.2) erubis (2.7.0) execjs (2.7.0) hike (1.2.3) @@ -97,6 +98,11 @@ GEM redcarpet (2.1.1) rmagick (2.15.4) ruby-openid (2.7.0) + simplecov (0.17.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) skylight (1.7.2) activesupport (>= 3.0.0) sprockets (2.2.3) @@ -135,6 +141,7 @@ DEPENDENCIES redcarpet (= 2.1.1) rmagick ruby-openid + simplecov skylight sqlite3 tzinfo (= 0.3.49) @@ -142,5 +149,8 @@ DEPENDENCIES will_paginate (= 3.0.7) will_paginate-bootstrap (= 0.2.5) +RUBY VERSION + ruby 2.1.10p492 + BUNDLED WITH - 1.11.2 + 1.15.1 diff --git a/test/test_helper.rb b/test/test_helper.rb index 8bf1192f..f24082c1 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,6 @@ +require 'simplecov' ENV["RAILS_ENV"] = "test" +SimpleCov.start require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' From eedddb72a6f2aa4493f93ef247fc2814539707aa Mon Sep 17 00:00:00 2001 From: gr455 Date: Tue, 14 Apr 2020 23:13:23 +0530 Subject: [PATCH 09/43] syntax changes and error fixes --- app/controllers/sets_controller.rb | 2 +- app/controllers/users_controller.rb | 12 ++++++------ app/models/user.rb | 6 +++--- app/views/users/contributors.html.erb | 2 +- app/views/users/dashboard.html.erb | 2 +- app/views/users/show.html.erb | 2 +- config/environments/development.rb | 1 - 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/controllers/sets_controller.rb b/app/controllers/sets_controller.rb index 855add49..77d74667 100644 --- a/app/controllers/sets_controller.rb +++ b/app/controllers/sets_controller.rb @@ -5,7 +5,7 @@ class SetsController < ApplicationController before_filter :no_cache, :only => [ :show, :calibrated, :search ] def index - @sets = SpectraSet.paginate(:order => "created_at DESC", :page => params[:page]) + @sets = SpectraSet.order(created_at: :desc).paginate(:page => params[:page]) end def show2 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 14a5f24e..591877f4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -12,10 +12,10 @@ def message def dashboard @offline = "flush" @spectrums = Spectrum.order('created_at DESC').where('user_id != 0').paginate(:page => params[:page],:per_page => 24) - @sets = SpectraSet.paginate(:page => params[:sets_page], :order => "created_at DESC", :per_page => 25) - @comments = Comment.paginate(:page => params[:comments_page], :order => "created_at DESC", :per_page => 40) - @users = User.paginate(:page => params[:users_page], :order => "created_at DESC", :per_page => 100) - @tags = Tag.paginate(:page => params[:tags_page], :order => "created_at DESC", :per_page => 100) + @sets = SpectraSet.order(created_at: :desc).paginate(:page => params[:sets_page], :per_page => 25) + @comments = Comment.order(created_at: :desc).paginate(:page => params[:comments_page], :per_page => 40) + @users = User.order(created_at: :desc).paginate(:page => params[:users_page], :per_page => 100) + @tags = Tag.order(created_at: :desc).paginate(:page => params[:tags_page], :per_page => 100) end def contributors @@ -35,8 +35,8 @@ def comments def show @user = User.find_by_login(params[:id]) - @spectrums = @user.spectrums.order("created_at DESC").paginate(:page => params[:page]) - @sets = @user.sets.order("created_at DESC").paginate(:page => params[:set_page], :per_page => 2) + @spectrums = @user.spectrums.order(created_at: :desc).paginate(:page => params[:page]) + @sets = @user.sets.order(created_at: :desc).paginate(:page => params[:set_page], :per_page => 2) end def index diff --git a/app/models/user.rb b/app/models/user.rb index 3f64e7b1..e8d29bd3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,7 @@ class User < ActiveRecord::Base # HACK HACK HACK -- how to do attr_accessible from here? # prevents a user from submitting a crafted form that bypasses activation # anything else you want your user to change should be added here. - attr_accessible :login, :email, :name, :password, :password_confirmation + attr_accessible :login, :email, :name, :password, :password_confirmation, :email_preferences def after_create UserMailer.google_groups_email(self) @@ -40,11 +40,11 @@ def self.weekly_tallies end def spectrum_count - Spectrum.count(:all, :conditions => {:user_id => self.id}) + Spectrum.where(:user_id => self.id).count end def set_count - SpectraSet.count(:all, :conditions => {:user_id => self.id}) + SpectraSet.where(:user_id => self.id).count end def received_comments diff --git a/app/views/users/contributors.html.erb b/app/views/users/contributors.html.erb index f39dac70..aa0fdf0b 100644 --- a/app/views/users/contributors.html.erb +++ b/app/views/users/contributors.html.erb @@ -23,7 +23,7 @@ <% @users.each do |user| %> <% if user.spectrum_count > 0 %><% end %> - <%= user.login %> + <%= user.login %> | Public Lab profile <%= user.spectrum_count %> spectra <%= user.comments.length %> comments diff --git a/app/views/users/dashboard.html.erb b/app/views/users/dashboard.html.erb index 62f32f34..a8b9cd38 100755 --- a/app/views/users/dashboard.html.erb +++ b/app/views/users/dashboard.html.erb @@ -78,7 +78,7 @@ Recent spectra by contributors like you | - Your spectra | + Your spectra | Popular | Recently liked diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 92f82ea1..9fcfad08 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -48,7 +48,7 @@ <%=h time_ago_in_words(@user.created_at) %> ago
Tags added: - <%=h Tag.count :all, :conditions => {:user_id => @user.id} %> + <%=h Tag.where(:user_id => @user.id).count %>
diff --git a/config/environments/development.rb b/config/environments/development.rb index 82292fdb..76f09aa7 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -47,7 +47,6 @@ # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false From 6229ef07cab5b02da158d92cc51077b5a3ed5840 Mon Sep 17 00:00:00 2001 From: gr455 Date: Thu, 16 Apr 2020 15:44:32 +0530 Subject: [PATCH 10/43] add route to create and more syntax changes to fix errors --- app/assets/config/manifest.js | 3 ++- app/controllers/capture_controller.rb | 2 +- app/models/spectrum.rb | 2 +- app/views/tags/index.html.erb | 2 +- config/routes.rb | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 0023457d..99907615 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -2,4 +2,5 @@ //= link application.js //= link capture.css //= link capture.js -//= link analyze.js \ No newline at end of file +//= link analyze.js +//= link upload.js \ No newline at end of file diff --git a/app/controllers/capture_controller.rb b/app/controllers/capture_controller.rb index 4ab3d399..193acec1 100755 --- a/app/controllers/capture_controller.rb +++ b/app/controllers/capture_controller.rb @@ -22,7 +22,7 @@ def index @calibrations.uniq! @start_wavelength, @end_wavelength = @calibration.wavelength_range if @calibration end - @spectrums = Spectrum.find(:all, :limit => 12, :order => "id DESC") + @spectrums = Spectrum.where(:limit => 12).order(id: :desc) render :template => "capture/index", :layout => "application" end diff --git a/app/models/spectrum.rb b/app/models/spectrum.rb index ddcf89ea..42809755 100755 --- a/app/models/spectrum.rb +++ b/app/models/spectrum.rb @@ -471,7 +471,7 @@ def is_flipped end def liked_by(user_id) - Like.find_by_user_id(user_id,:conditions => {:spectrum_id => self.id}) + Like.where(:spectrum_id => self.id).find_by_user_id(user_id) end # notify each commenter about a new comment diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 4b754670..72339e15 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -36,7 +36,7 @@ <% i = 0 %>
<% @tagnames.each do |name,count| %> - <% if tag = Tag.find_by_name(name, :order => "id DESC") %> + <% if tag = Tag.order(id: :desc).find_by_name(name) %> <% if tag.spectrum %>
diff --git a/config/routes.rb b/config/routes.rb index 5a3554f1..9d0f1b49 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -89,6 +89,7 @@ get '/popular/recent' => 'likes#recent' get '/upload' => 'spectrums#new' + post '/spectrums/create' => 'spectrums#create' get '/tags/change_reference/:id' => 'tags#change_reference' From 99850bb2e4dc96159955211a63d634a924774e98 Mon Sep 17 00:00:00 2001 From: gr455 Date: Wed, 22 Apr 2020 12:49:11 +0530 Subject: [PATCH 11/43] fix integration tests --- app/views/spectrums/_sets.html.erb | 3 +++ config/routes.rb | 1 + test/integration/exceptions_test.rb | 4 ++-- test/integration/redirects_test.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/spectrums/_sets.html.erb b/app/views/spectrums/_sets.html.erb index 48957bb2..6ed914a4 100644 --- a/app/views/spectrums/_sets.html.erb +++ b/app/views/spectrums/_sets.html.erb @@ -1,5 +1,6 @@ <% row = 1 if row.nil? %>
+ <% @sets.each_with_index do |set,index| %>
@@ -8,7 +9,9 @@

<%= set.author %> | <%= set.spectrums.length %> spectra | <%= set.comments.length %>

+ <% if !set.notes.blank? %>

<%= set.notes.truncate(200) %>

+ <% end %>