diff --git a/.travis.yml b/.travis.yml index e57873248..582219317 100755 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ env: - TASK="CI=true TRAVIS=true rake test:integration" - TASK="CI=true TRAVIS=true rake test:functional" - TASK="CI=true TRAVIS=true rake assets:precompile" + - TASK="CI=true TRAVIS=true bundle exec rubocop" script: - docker-compose -f docker-compose.test.yml exec web bash -lc "$TASK" @@ -34,4 +35,5 @@ branches: only: - main - unstable + - development diff --git a/Gemfile b/Gemfile index 3797b36d2..d2dc1dd08 100644 --- a/Gemfile +++ b/Gemfile @@ -43,7 +43,7 @@ group :dependencies do end group :test do - gem "rubocop", '~> 0.64.0' + gem "rubocop", '~> 0.52.0' gem 'ruby-prof' gem 'rails-perftest' gem 'simplecov', require: false diff --git a/Gemfile.lock b/Gemfile.lock index ee3e765f3..d06519882 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,7 +41,7 @@ GEM ansi (1.5.0) arel (6.0.4) ast (2.4.0) - autoprefixer-rails (9.5.1.1) + autoprefixer-rails (9.6.0) execjs aws-sdk (1.5.8) httparty (~> 0.7) @@ -79,7 +79,6 @@ GEM concurrent-ruby (~> 1.0) image_science (1.3.0) RubyInline (~> 3.9) - jaro_winkler (1.5.2) jshintrb (0.3.0) execjs multi_json (>= 1.3) @@ -176,7 +175,7 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) rdiscount (2.2.0.1) - recaptcha (4.14.0) + recaptcha (5.0.0) json redcarpet (3.4.0) ref (2.0.0) @@ -188,14 +187,13 @@ GEM net-http-persistent (~> 2.9) redcarpet (>= 3.0.0) ruby-hmac (>= 0.4.0) - rubocop (0.64.0) - jaro_winkler (~> 1.5.1) + rubocop (0.52.1) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) + parser (>= 2.4.0.2, < 3.0) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.4.0) + unicode-display_width (~> 1.0, >= 1.0.1) ruby-hmac (0.4.0) ruby-openid (2.7.0) ruby-openid-apps-discovery (1.2.0) @@ -214,9 +212,9 @@ GEM simplecov-cobertura (1.3.1) simplecov (~> 0.8) simplecov-html (0.10.2) - skylight (4.0.2) - skylight-core (= 4.0.2) - skylight-core (4.0.2) + skylight (4.1.0) + skylight-core (= 4.1.0) + skylight-core (4.1.0) activesupport (>= 4.2.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -235,7 +233,7 @@ GEM thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.4.1) + unicode-display_width (1.6.0) uuidtools (2.1.5) web-console (2.3.0) activemodel (>= 4.0) @@ -276,7 +274,7 @@ DEPENDENCIES rdiscount (= 2.2.0.1) recaptcha right_aws_api - rubocop (~> 0.64.0) + rubocop (~> 0.52.0) ruby-openid (~> 2.5) ruby-prof sass diff --git a/app/models/export.rb b/app/models/export.rb index 59353d1c1..95d5c61db 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -58,6 +58,6 @@ def self.export_count # all exports currently running def self.exporting Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?', - (DateTime.now - 24.hours).to_s(:db)) + (DateTime.now - 24.hours).to_s(:db)) end end diff --git a/app/models/map.rb b/app/models/map.rb index 7d20a84fc..d916eb70c 100755 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -22,7 +22,7 @@ class Map < ActiveRecord::Base has_many :annotations, dependent: :destroy belongs_to :user - has_many :warpables + has_many :warpables scope :active, -> { where(archived: false) } scope :has_user, -> { where('user_id != ?', 0) } @@ -140,7 +140,7 @@ def nearby_maps(dist) return [] if lat.to_f == 0.0 || lon.to_f == 0.0 Map.where('id != ? AND lat > ? AND lat < ? AND lon > ? AND lon < ?', - id, lat - dist, lat + dist, lon - dist, lon + dist) + id, lat - dist, lat + dist, lon - dist, lon + dist) .limit(10) end diff --git a/app/models/tag.rb b/app/models/tag.rb index 8e052b8df..390df29ac 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -2,7 +2,7 @@ class Tag < ActiveRecord::Base belongs_to :map belongs_to :user - validates_presence_of :name, on: :create, message: "can't be blank" + validates_presence_of :name, on: :create, message: "can't be blank" validates_presence_of :user_id, on: :create, message: "can't be blank" validates_presence_of :map_id, on: :create, message: "can't be blank" diff --git a/db/schema.rb b/db/schema.rb index 9c3ddce87..4772d9b03 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,154 +9,153 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20190420025012) do +ActiveRecord::Schema.define(version: 20190420025012) do - create_table "annotations", :force => true do |t| - t.integer "map_id" - t.integer "user_id" - t.string "annotation_type" - t.string "text" - t.string "style" - t.string "coordinates" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "annotations", force: :cascade do |t| + t.integer "map_id", limit: 4 + t.integer "user_id", limit: 4 + t.string "annotation_type", limit: 255 + t.string "text", limit: 255 + t.string "style", limit: 255 + t.string "coordinates", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "comments", :force => true do |t| - t.string "user_id" - t.string "body" - t.integer "map_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "comments", force: :cascade do |t| + t.string "user_id", limit: 255 + t.string "body", limit: 255 + t.integer "map_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "exports", :force => true do |t| - t.integer "map_id", :default => 0 - t.integer "size", :default => 0 - t.integer "width", :default => 0 - t.integer "height", :default => 0 - t.float "cm_per_pixel", :default => 0.0 - t.string "status", :default => "none" - t.boolean "tms", :default => false - t.boolean "jpg", :default => false - t.boolean "geotiff", :default => false + create_table "exports", force: :cascade do |t| + t.integer "map_id", limit: 4, default: 0 + t.integer "size", limit: 4, default: 0 + t.integer "width", limit: 4, default: 0 + t.integer "height", limit: 4, default: 0 + t.float "cm_per_pixel", limit: 24, default: 0.0 + t.string "status", limit: 255, default: "none" + t.boolean "tms", default: false + t.boolean "jpg", default: false + t.boolean "geotiff", default: false t.datetime "created_at" t.datetime "updated_at" - t.boolean "zip", :default => false, :null => false - t.text "bands_string", :null => false - t.string "export_type", :default => "normal", :null => false - t.integer "user_id", :default => 0 - t.string "export_url" + t.boolean "zip", default: false, null: false + t.text "bands_string", limit: 65535, null: false + t.string "export_type", limit: 255, default: "normal", null: false + t.integer "user_id", limit: 4, default: 0 + t.string "export_url", limit: 255 end - create_table "maps", :force => true do |t| - t.string "name", :default => "" - t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0 - t.integer "version", :default => 1 - t.string "password", :default => "" - t.text "styles" + create_table "maps", force: :cascade do |t| + t.string "name", limit: 255, default: "" + t.decimal "lat", precision: 20, scale: 10, default: 0.0 + t.decimal "lon", precision: 20, scale: 10, default: 0.0 + t.integer "version", limit: 4, default: 1 + t.string "password", limit: 255, default: "" + t.text "styles", limit: 65535 t.datetime "created_at" t.datetime "updated_at" - t.text "description" - t.string "author", :default => "anonymous" - t.decimal "zoom", :precision => 15, :scale => 10, :default => 2.0 - t.string "location", :default => "" - t.string "static_data", :default => "" - t.boolean "vectors", :default => false, :null => false - t.string "tiles", :default => "google", :null => false - t.string "email", :default => "", :null => false - t.boolean "archived", :default => false, :null => false - t.text "tile_url" - t.text "tile_layer" - t.string "license", :default => "copyright" - t.integer "user_id", :default => 0 - t.boolean "anon_annotatable", :default => false - t.string "slug" + t.text "description", limit: 65535 + t.string "author", limit: 255, default: "anonymous" + t.decimal "zoom", precision: 15, scale: 10, default: 2.0 + t.string "location", limit: 255, default: "" + t.string "static_data", limit: 255, default: "" + t.boolean "vectors", default: false, null: false + t.string "tiles", limit: 255, default: "google", null: false + t.string "email", limit: 255, default: "", null: false + t.boolean "archived", default: false, null: false + t.text "tile_url", limit: 65535 + t.text "tile_layer", limit: 65535 + t.string "license", limit: 255, default: "copyright" + t.integer "user_id", limit: 4, default: 0 + t.boolean "anon_annotatable", default: false + t.string "slug", limit: 255 end - add_index "maps", ["slug"], :name => "index_maps_on_slug", :unique => true + add_index "maps", ["slug"], name: "index_maps_on_slug", unique: true, using: :btree - create_table "nodes", :force => true do |t| - t.string "color", :default => "red" - t.string "author", :default => "anonymous" - t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0 - t.integer "way_id", :default => 0 - t.integer "order", :default => 0 + create_table "nodes", force: :cascade do |t| + t.string "color", limit: 255, default: "red" + t.string "author", limit: 255, default: "anonymous" + t.decimal "lat", precision: 20, scale: 10, default: 0.0 + t.decimal "lon", precision: 20, scale: 10, default: 0.0 + t.integer "way_id", limit: 4, default: 0 + t.integer "order", limit: 4, default: 0 t.datetime "created_at" t.datetime "updated_at" - t.string "name", :default => "" - t.string "description", :default => "" - t.integer "map_id", :default => 0 - t.integer "way_order", :default => 0 - t.text "body" + t.string "name", limit: 255, default: "" + t.string "description", limit: 255, default: "" + t.integer "map_id", limit: 4, default: 0 + t.integer "way_order", limit: 4, default: 0 + t.text "body", limit: 65535 end - create_table "tags", :force => true do |t| - t.string "user_id" - t.string "name" - t.integer "map_id" - t.integer "warpable_id" + create_table "tags", force: :cascade do |t| + t.string "user_id", limit: 255 + t.string "name", limit: 255 + t.integer "map_id", limit: 4 + t.integer "warpable_id", limit: 4 t.datetime "created_at" t.datetime "updated_at" end - add_index "tags", ["map_id"], :name => "index_tags_on_map_id" - add_index "tags", ["user_id"], :name => "index_tags_on_user_id" - add_index "tags", ["warpable_id"], :name => "index_tags_on_warpable_id" + add_index "tags", ["map_id"], name: "index_tags_on_map_id", using: :btree + add_index "tags", ["user_id"], name: "index_tags_on_user_id", using: :btree + add_index "tags", ["warpable_id"], name: "index_tags_on_warpable_id", using: :btree - create_table "users", :force => true do |t| - t.string "login", :limit => 40 - t.string "name", :limit => 100, :default => "" - t.string "email", :limit => 100 - t.string "crypted_password", :limit => 40 - t.string "salt", :limit => 40 - t.string "identity_url" - t.string "role", :limit => 40, :default => "basic" + create_table "users", force: :cascade do |t| + t.string "login", limit: 40 + t.string "name", limit: 100, default: "" + t.string "email", limit: 100 + t.string "crypted_password", limit: 40 + t.string "salt", limit: 40 + t.string "identity_url", limit: 255 + t.string "role", limit: 40, default: "basic" t.datetime "created_at" t.datetime "updated_at" - t.string "remember_token", :limit => 40 + t.string "remember_token", limit: 40 t.datetime "remember_token_expires_at" end - add_index "users", ["login"], :name => "index_users_on_login", :unique => true + add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree - create_table "warpables", :force => true do |t| - t.integer "parent_id" - t.string "image_content_type" - t.string "image_file_name" - t.string "thumbnail" - t.integer "image_file_size" - t.integer "width" - t.integer "height" + create_table "warpables", force: :cascade do |t| + t.integer "parent_id", limit: 4 + t.string "image_content_type", limit: 255 + t.string "image_file_name", limit: 255 + t.string "thumbnail", limit: 255 + t.integer "image_file_size", limit: 4 + t.integer "width", limit: 4 + t.integer "height", limit: 4 t.datetime "created_at" t.datetime "updated_at" - t.integer "map_id", :default => 0 - t.string "nodes", :default => "" - t.boolean "locked", :default => false, :null => false - t.boolean "deleted", :default => false, :null => false - t.text "history", :null => false - t.float "cm_per_pixel", :default => 0.0, :null => false + t.integer "map_id", limit: 4, default: 0 + t.string "nodes", limit: 255, default: "" + t.boolean "locked", default: false, null: false + t.boolean "deleted", default: false, null: false + t.text "history", limit: 65535, null: false + t.float "cm_per_pixel", limit: 24, default: 0.0, null: false end - create_table "ways", :force => true do |t| - t.string "color", :default => "red" - t.string "author", :default => "anonymous" - t.decimal "lat1", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lat2", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon1", :precision => 20, :scale => 10, :default => 0.0 - t.decimal "lon2", :precision => 20, :scale => 10, :default => 0.0 + create_table "ways", force: :cascade do |t| + t.string "color", limit: 255, default: "red" + t.string "author", limit: 255, default: "anonymous" + t.decimal "lat1", precision: 20, scale: 10, default: 0.0 + t.decimal "lat2", precision: 20, scale: 10, default: 0.0 + t.decimal "lon1", precision: 20, scale: 10, default: 0.0 + t.decimal "lon2", precision: 20, scale: 10, default: 0.0 t.datetime "created_at" t.datetime "updated_at" - t.string "name", :default => "" - t.string "description", :default => "" - t.boolean "complete", :default => true - t.integer "map_id", :default => 0 - t.text "body" + t.string "name", limit: 255, default: "" + t.string "description", limit: 255, default: "" + t.boolean "complete", default: true + t.integer "map_id", limit: 4, default: 0 + t.text "body", limit: 65535 end end - diff --git a/test/functional/maps_controller_test.rb b/test/functional/maps_controller_test.rb index ceb8bb6a3..5b1b6ca07 100644 --- a/test/functional/maps_controller_test.rb +++ b/test/functional/maps_controller_test.rb @@ -148,12 +148,13 @@ def teardown skip 'images and warpable naming contradicts with rails naming convention' session[:user_id] = 1 before_count = Map.count - post(:create, map: { - name: 'Coal terminal map', - slug: 'coal-terminal' - }) + post(:new, map: { + name: 'Coal terminal map', + slug: 'coal-terminal' + }) @map = assigns(:map) + assert_not @map.save assert_response :success assert_template :new assert_equal before_count, Map.count diff --git a/test/reports/TEST-ExportTest.xml b/test/reports/TEST-ExportTest.xml deleted file mode 100644 index 6c6d2d3a3..000000000 --- a/test/reports/TEST-ExportTest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/test/reports/TEST-MapTest.xml b/test/reports/TEST-MapTest.xml deleted file mode 100644 index 9a15a2d15..000000000 --- a/test/reports/TEST-MapTest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/reports/TEST-MapsControllerTest.xml b/test/reports/TEST-MapsControllerTest.xml deleted file mode 100644 index b67e87d3b..000000000 --- a/test/reports/TEST-MapsControllerTest.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Failure: -test_should_render_new_if_map_not_created(Minitest::Result) [/home/k/.rvm/gems/ruby-2.4.6/gems/actionpack-4.2.11.1/lib/action_dispatch/routing/route_set.rb:234]: -ActionView::Template::Error: No route matches {:action=>"index", :controller=>"warpables", :map_id=>nil} missing required keys: [:map_id] - app/views/images/_new.html.erb:13:in `_app_views_images__new_html_erb___582794143336601479_47432368697160' - app/views/layouts/knitter2.html.erb:195:in `_app_views_layouts_knitter__html_erb__1554220659803257588_47432335059940' - app/controllers/maps_controller.rb:41:in `create' - test/functional/maps_controller_test.rb:151:in `block in <class:MapsControllerTest>' - - - - - - - - - - - - - - - - - - - - diff --git a/test/reports/TEST-UserTest.xml b/test/reports/TEST-UserTest.xml deleted file mode 100644 index 4aea8b0da..000000000 --- a/test/reports/TEST-UserTest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - -