From 318f1fe5cebbbca0ce1730970d9903bcff2b12e2 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Tue, 4 Jun 2019 11:18:36 -0300 Subject: [PATCH 01/12] Using local mysql for travis --- .simplecov | 9 +++++++-- .travis.yml | 34 +++++++++++++++----------------- config/database.yml.example | 8 ++++---- config/database.yml.test.example | 7 ------- docker-compose.test.yml | 17 ---------------- mapknitter.test.env | 4 ---- test/test_helper.rb | 4 ++-- test/unit/warpable_test.rb | 1 + 8 files changed, 30 insertions(+), 54 deletions(-) delete mode 100644 config/database.yml.test.example delete mode 100644 docker-compose.test.yml delete mode 100644 mapknitter.test.env diff --git a/.simplecov b/.simplecov index 2bd5dffa0..e72179234 100644 --- a/.simplecov +++ b/.simplecov @@ -1,5 +1,3 @@ -require 'simplecov-cobertura' - if ENV['CI'] == 'true' SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter else @@ -7,8 +5,15 @@ else end SimpleCov.start 'rails' do + add_group 'Units', 'app/models' + add_group 'Functionals', 'app/controllers' + add_group 'Services', 'app/services' + add_group 'Libraries', 'lib/' + add_filter '/test/' + add_filter '/config/' add_filter '/db/' + add_filter '/vendor/' add_filter '/log/' add_filter '/tmp/' end diff --git a/.travis.yml b/.travis.yml index e57873248..235e13907 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,32 @@ -sudo: required - -language: generic +language: ruby +rvm: + - 2.4.6 services: - - docker + - mysql install: - - cp config/database.yml.test.example config/database.yml + - cp config/database.yml.example config/database.yml - cp config/config.yml.example config/config.yml - cp db/schema.rb.example db/schema.rb - - docker-compose -f docker-compose.test.yml up -d --build - - > - while (! docker logs mapknitter-test | grep "Phusion Passenger Standalone web server started") > /dev/null 2>&1; do - echo "Waiting for start script to finish..."; - sleep 20; - done; echo "Done!" - - docker-compose -f docker-compose.test.yml exec web bash -lc "rake db:setup || rake db:migrate" + - bundle install + - bundle exec rake db:setup || bundle exec rake db:migrate env: global: - RAILS_ENV=test + - CI=true + - TRAVIS=true matrix: - - TASK="CI=true TRAVIS=true rake test:unit" - - 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="rake test:unit" + - TASK="rake test:integration" + - TASK="rake test:functional" script: - - docker-compose -f docker-compose.test.yml exec web bash -lc "$TASK" - - bash <(curl -s https://codecov.io/bash) + - bundle exec $TASK + - > + bundle exec rake test > /dev/null 2>&1 && + bash <(curl -s https://codecov.io/bash) branches: only: diff --git a/config/database.yml.example b/config/database.yml.example index 277488812..1a563d99c 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -1,19 +1,19 @@ development: + encoding: utf8 adapter: mysql2 username: password: database: mapknitter production: + encoding: utf8 adapter: mysql2 - host: db username: mapknitter password: mapknitter database: mapknitter test: + encoding: utf8 adapter: mysql2 - username: mapknitter - password: mapknitter - host: db + username: root database: mapknitter diff --git a/config/database.yml.test.example b/config/database.yml.test.example deleted file mode 100644 index bf95c79f9..000000000 --- a/config/database.yml.test.example +++ /dev/null @@ -1,7 +0,0 @@ -test: - adapter: mysql2 - host: 127.0.0.1 - database: mapknitter-test - username: root - password: - diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100644 index 6de18f35f..000000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3.3' -services: - db: - container_name: mapknitter-test-db - image: mysql:5.7 - network_mode: host - env_file: - - mapknitter.test.env - - web: - container_name: mapknitter-test - build: . - network_mode: host - env_file: - - mapknitter.test.env - volumes: - - .:/app diff --git a/mapknitter.test.env b/mapknitter.test.env deleted file mode 100644 index 8d4d35254..000000000 --- a/mapknitter.test.env +++ /dev/null @@ -1,4 +0,0 @@ -MYSQL_DATABASE=mapknitter-test -MYSQL_USER=root -MYSQL_RANDOM_ROOT_PASSWORD=true -RAILS_ENV=test diff --git a/test/test_helper.rb b/test/test_helper.rb index 8b0be3ba0..ef2cc2a07 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,9 +1,9 @@ -ENV["RAILS_ENV"] = "test" require 'simplecov' - +require 'simplecov-cobertura' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +ENV["RAILS_ENV"] = "test" class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. diff --git a/test/unit/warpable_test.rb b/test/unit/warpable_test.rb index 7551878c8..9b96919cc 100644 --- a/test/unit/warpable_test.rb +++ b/test/unit/warpable_test.rb @@ -63,6 +63,7 @@ def setup system('touch public/warps/saugus-landfill-incinerator/folder') system('mkdir -p public/system/images/2/original/') system('cp test/fixtures/demo.png public/system/images/2/original/test.png') + system('cp test/fixtures/demo.png public/warps/saugus-landfill-incinerator/1-geo.tif') assert File.exist?('public/warps/saugus-landfill-incinerator/folder') origin = Exporter.distort_warpables(2, From 5dcfdaeec5965734345bc6926a1dcac980e88554 Mon Sep 17 00:00:00 2001 From: Cess Date: Wed, 5 Jun 2019 21:27:54 +0300 Subject: [PATCH 02/12] Fix codeclimate issues --- Gemfile | 2 +- Gemfile.lock | 12 +++++++----- app/controllers/maps_controller.rb | 10 ++-------- app/models/annotation.rb | 2 +- app/models/export.rb | 4 ++-- app/models/map.rb | 16 ++++++++-------- app/models/tag.rb | 6 +++--- app/models/warpable.rb | 2 +- app/models/way.rb | 2 +- 9 files changed, 26 insertions(+), 30 deletions(-) diff --git a/Gemfile b/Gemfile index d2dc1dd08..3797b36d2 100644 --- a/Gemfile +++ b/Gemfile @@ -43,7 +43,7 @@ group :dependencies do end group :test do - gem "rubocop", '~> 0.52.0' + gem "rubocop", '~> 0.64.0' gem 'ruby-prof' gem 'rails-perftest' gem 'simplecov', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 5d9e6465e..ee3e765f3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,6 +79,7 @@ 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) @@ -187,13 +188,14 @@ GEM net-http-persistent (~> 2.9) redcarpet (>= 3.0.0) ruby-hmac (>= 0.4.0) - rubocop (0.52.1) + rubocop (0.64.0) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) + parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (~> 1.4.0) ruby-hmac (0.4.0) ruby-openid (2.7.0) ruby-openid-apps-discovery (1.2.0) @@ -233,7 +235,7 @@ GEM thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.0) + unicode-display_width (1.4.1) uuidtools (2.1.5) web-console (2.3.0) activemodel (>= 4.0) @@ -274,7 +276,7 @@ DEPENDENCIES rdiscount (= 2.2.0.1) recaptcha right_aws_api - rubocop (~> 0.52.0) + rubocop (~> 0.64.0) ruby-openid (~> 2.5) ruby-prof sass diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 874b89e4b..34fbd77b2 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -77,7 +77,7 @@ def archive else flash[:error] = 'Only admins may archive maps.' end - redirect_to "/?_=#{Time.now.to_i.to_s}" + redirect_to "/?_=#{Time.now.to_i}" end def embed @@ -94,13 +94,7 @@ def annotate def edit; end def update - # @map.name = params[:map][:name] - # @map.location = params[:map][:location] - # @map.lat = params[:map][:lat] - # @map.lon = params[:map][:lon] - # @map.description = params[:map][:description] - # @map.license = params[:map][:license] if @map.user_id == current_user.id - @map.update_attributes(map_params) + @map.update_attributes(map_params) save_tags(@map) @map.save diff --git a/app/models/annotation.rb b/app/models/annotation.rb index b4bed15ee..e681cb9bc 100644 --- a/app/models/annotation.rb +++ b/app/models/annotation.rb @@ -1,5 +1,5 @@ class Annotation < ActiveRecord::Base - include ActiveModel::MassAssignmentSecurity + include ActiveModel::MassAssignmentSecurity belongs_to :map belongs_to :user diff --git a/app/models/export.rb b/app/models/export.rb index d85d62aa4..a4549301c 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -52,12 +52,12 @@ def self.histogram_cm_per_pixel_in_tens def self.export_count Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?', - (DateTime.now-24.hours).to_s(:db)).count + (DateTime.now - 24.hours).to_s(:db)).count end # 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 481333824..96c6a8f66 100755 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -7,19 +7,19 @@ class Map < ActiveRecord::Base validates_presence_of :name, :slug, :author, :lat, :lon validates_uniqueness_of :slug - validates_presence_of :location, :message => ' cannot be found. Try entering a latitude and longitude if this problem persists.' + validates_presence_of :location, message: ' cannot be found. Try entering a latitude and longitude if this problem persists.' # validates_format_of :slug, # :with => /^[\w-]*$/, # :message => " must not include spaces and must be alphanumeric, as it'll be used in the URL of your map, like: https://mapknitter.org/maps/your-map-name. You may use dashes and underscores.", # :on => :create # validates_format_of :tile_url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix validates_with NotAtOriginValidator - validates :lat, :lon, NotAtOrigin: true + validates :lat, :lon, NotAtOrigin: true - has_many :exports, :dependent => :destroy - has_many :tags, :dependent => :destroy - has_many :comments, :dependent => :destroy - has_many :annotations, :dependent => :destroy + has_many :exports, dependent: :destroy + has_many :tags, dependent: :destroy + has_many :comments, dependent: :destroy + has_many :annotations, dependent: :destroy belongs_to :user has_many :warpables @@ -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 @@ -254,7 +254,7 @@ def license_link end def has_tag(tagname) - !Tag.where(map_id: self.id, name: tagname).empty? + !Tag.where(map_id: id, name: tagname).empty? end def add_tag(tagname, user) diff --git a/app/models/tag.rb b/app/models/tag.rb index be5a179e5..8e052b8df 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -2,9 +2,9 @@ class Tag < ActiveRecord::Base belongs_to :map belongs_to :user - 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" + 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" def maps Map.where(id: Tag.where(name: name).collect(&:map_id).uniq) diff --git a/app/models/warpable.rb b/app/models/warpable.rb index 4049b49be..86dcc14c7 100755 --- a/app/models/warpable.rb +++ b/app/models/warpable.rb @@ -1,5 +1,5 @@ class Warpable < ActiveRecord::Base - include ActiveModel::MassAssignmentSecurity + include ActiveModel::MassAssignmentSecurity attr_accessible :image attr_accessor :src, :srcmedium # for json generation diff --git a/app/models/way.rb b/app/models/way.rb index 8237be702..7fb80d1ed 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -1,5 +1,5 @@ class Way < ActiveRecord::Base - has_many :nodes, :dependent => :destroy + has_many :nodes, dependent: :destroy def bbox=(bbox) # counting from left, counter-clockwise From 14132863b7fd59c2020d1ba059e70ead4ea9f23a Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Thu, 6 Jun 2019 16:52:40 -0300 Subject: [PATCH 03/12] Refactoring yamls --- .travis.yml | 2 ++ config/database.yml.cloud9.example | 10 +++++++--- config/database.yml.example | 15 ++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 235e13907..e8d684c96 100755 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ env: - TASK="rake test:unit" - TASK="rake test:integration" - TASK="rake test:functional" + - TASK="rake assets:precompile" script: - bundle exec $TASK @@ -32,4 +33,5 @@ branches: only: - main - unstable + - development diff --git a/config/database.yml.cloud9.example b/config/database.yml.cloud9.example index c46bb4759..f1a36e434 100644 --- a/config/database.yml.cloud9.example +++ b/config/database.yml.cloud9.example @@ -1,18 +1,22 @@ -development: +default: &default + encoding: utf8 adapter: mysql2 + +development: + <<: *default username: root password: database: mapknitter production: - adapter: mysql2 + <<: *default host: db username: mapknitter password: mapknitter database: mapknitter test: - adapter: mysql2 + <<: *default username: root password: database: mapknittertest diff --git a/config/database.yml.example b/config/database.yml.example index 1a563d99c..5202700ff 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -1,19 +1,20 @@ -development: +default: &default encoding: utf8 adapter: mysql2 + +development: + <<: *default username: password: - database: mapknitter + database: mapknitter-dev production: - encoding: utf8 - adapter: mysql2 + <<: *default username: mapknitter password: mapknitter database: mapknitter test: - encoding: utf8 - adapter: mysql2 + <<: *default username: root - database: mapknitter + database: mapknitter-test From d33dc357c5936c908de275701e2f528e86d75873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lax=20de=20Carvalho=20Alves?= Date: Thu, 6 Jun 2019 16:53:13 -0300 Subject: [PATCH 04/12] Autofixing rubocop offenses and Problematic test for #578 (#667) * Autofixing rubocop offenses * Adding Rubocop to Travis pipelines and development branch * Fixing maps controller test * Fixing remaining offenses --- .travis.yml | 2 + Gemfile | 2 +- Gemfile.lock | 22 +-- app/controllers/annotations_controller.rb | 6 +- app/controllers/feeds_controller.rb | 2 +- app/controllers/maps_controller.rb | 4 +- app/controllers/users_controller.rb | 2 +- app/models/comment.rb | 1 - app/models/export.rb | 4 +- app/models/map.rb | 8 +- app/models/tag.rb | 2 +- db/schema.rb | 223 +++++++++++----------- test/functional/maps_controller_test.rb | 9 +- test/reports/TEST-ExportTest.xml | 9 - test/reports/TEST-MapTest.xml | 11 -- test/reports/TEST-MapsControllerTest.xml | 66 ------- test/reports/TEST-UserTest.xml | 15 -- 17 files changed, 143 insertions(+), 245 deletions(-) delete mode 100644 test/reports/TEST-ExportTest.xml delete mode 100644 test/reports/TEST-MapTest.xml delete mode 100644 test/reports/TEST-MapsControllerTest.xml delete mode 100644 test/reports/TEST-UserTest.xml 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/controllers/annotations_controller.rb b/app/controllers/annotations_controller.rb index b27494903..88019d3f7 100644 --- a/app/controllers/annotations_controller.rb +++ b/app/controllers/annotations_controller.rb @@ -36,9 +36,9 @@ def update return if @annotation.user_id.nil? || current_user.can_edit?(@annotation) Annotation.update(@annotation.id, - coordinates: geojson[:geometry][:coordinates], - text: geojson[:properties][:textContent], - style: geojson[:properties][:style]) + coordinates: geojson[:geometry][:coordinates], + text: geojson[:properties][:textContent], + style: geojson[:properties][:style]) render file: 'annotations/update.json.erb', content_type: 'application/json' end diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index 6be25cbb9..392051d23 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -4,7 +4,7 @@ class FeedsController < ApplicationController def all # (Warpable.all + Map.all).sort_by(&:created_at) @maps = Map.where(archived: false, password: '') - .joins(%i[user warpables]) + .joins(%i(user warpables)) .group('maps.id') .order('id DESC') .limit(20) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 34fbd77b2..f2e9b6d38 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -3,8 +3,8 @@ class MapsController < ApplicationController protect_from_forgery except: :export - before_filter :require_login, only: %i[edit update destroy] - before_filter :find_map, only: %i[show annotate embed edit update images destroy archive] + before_filter :require_login, only: %i(edit update destroy) + before_filter :find_map, only: %i(show annotate embed edit update images destroy archive) layout 'knitter2' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5dc4f187f..40601a191 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,6 +30,6 @@ def sort_direction def user_params params.require(:user).permit(:login, :email, :name, - :password, :password_confirmation) + :password, :password_confirmation) end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 0021e4761..05d55677e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,4 @@ class Comment < ActiveRecord::Base - belongs_to :map belongs_to :user diff --git a/app/models/export.rb b/app/models/export.rb index a4549301c..94fbce007 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -52,12 +52,12 @@ def self.histogram_cm_per_pixel_in_tens def self.export_count Export.where('status != "failed" AND status != "complete" AND status != "none" AND updated_at > ?', - (DateTime.now - 24.hours).to_s(:db)).count + (DateTime.now - 24.hours).to_s(:db)).count end # 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 96c6a8f66..875a9acee 100755 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -12,7 +12,7 @@ class Map < ActiveRecord::Base # :with => /^[\w-]*$/, # :message => " must not include spaces and must be alphanumeric, as it'll be used in the URL of your map, like: https://mapknitter.org/maps/your-map-name. You may use dashes and underscores.", # :on => :create -# validates_format_of :tile_url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix + # validates_format_of :tile_url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix validates_with NotAtOriginValidator validates :lat, :lon, NotAtOrigin: true @@ -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) } @@ -87,7 +87,7 @@ def self.featured end def self.new_maps - Map.where( ['password = "" AND archived = "false"']) + Map.where(['password = "" AND archived = "false"']) .order('created_at DESC') .limit(12) end @@ -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 a9634e8df..3decc4afb 100644 --- a/test/functional/maps_controller_test.rb +++ b/test/functional/maps_controller_test.rb @@ -147,12 +147,13 @@ def teardown test 'should render new if map not created' do 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 @@ - - - - - - - - - - - - - - - From 12d6e8309ec5d71b4a85dbf8abb0e3520e315a6f Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Thu, 6 Jun 2019 17:17:30 -0300 Subject: [PATCH 05/12] Fixing unit tests --- .travis.yml | 3 --- test/unit/warpable_test.rb | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8087f74f9..33d4dfbbd 100755 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,6 @@ env: script: - bundle exec $TASK - - > - bundle exec rake test > /dev/null 2>&1 && - bash <(curl -s https://codecov.io/bash) branches: only: diff --git a/test/unit/warpable_test.rb b/test/unit/warpable_test.rb index 7551878c8..9b96919cc 100644 --- a/test/unit/warpable_test.rb +++ b/test/unit/warpable_test.rb @@ -63,6 +63,7 @@ def setup system('touch public/warps/saugus-landfill-incinerator/folder') system('mkdir -p public/system/images/2/original/') system('cp test/fixtures/demo.png public/system/images/2/original/test.png') + system('cp test/fixtures/demo.png public/warps/saugus-landfill-incinerator/1-geo.tif') assert File.exist?('public/warps/saugus-landfill-incinerator/folder') origin = Exporter.distort_warpables(2, From 7bb0e3c029a3dcbd9075f8d32a05eb8ce6dfe92b Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Thu, 6 Jun 2019 17:28:46 -0300 Subject: [PATCH 06/12] Adding docker build to travis pipelines --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33d4dfbbd..2e5ca0a53 100755 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ rvm: services: - mysql + - docker install: - cp config/database.yml.example config/database.yml @@ -18,14 +19,15 @@ env: - CI=true - TRAVIS=true matrix: - - TASK="rake test:unit" - - TASK="rake test:integration" - - TASK="rake test:functional" - - TASK="rake assets:precompile" - - TASK="rubocop" + - TASK="bundle exec rake test:unit" + - TASK="bundle exec rake test:integration" + - TASK="bundle exec rake test:functional" + - TASK="bundle exec rake assets:precompile" + - TASK="bundle exec rubocop" + - TASK="docker build -t mapknitter ." script: - - bundle exec $TASK + - $TASK branches: only: From f7e28fce4dbf327d2dce4bbd6e918ca4480f9518 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Thu, 6 Jun 2019 17:28:46 -0300 Subject: [PATCH 07/12] Adding docker build to travis pipelines --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33d4dfbbd..7fd1df83a 100755 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ rvm: services: - mysql + - docker install: - cp config/database.yml.example config/database.yml @@ -18,14 +19,15 @@ env: - CI=true - TRAVIS=true matrix: - - TASK="rake test:unit" - - TASK="rake test:integration" - - TASK="rake test:functional" - - TASK="rake assets:precompile" - - TASK="rubocop" + - TASK="bundle exec rake test:unit" + - TASK="bundle exec rake test:integration" + - TASK="bundle exec rake test:functional" + - TASK="RAILS_ENV=production bundle exec rake assets:precompile" + - TASK="bundle exec rubocop" + - TASK="docker build -t mapknitter ." script: - - bundle exec $TASK + - $TASK branches: only: From f5532a863e5daa3f567f9247edfc49f51e7c0b31 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Thu, 6 Jun 2019 17:58:04 -0300 Subject: [PATCH 08/12] Staging builds in travis --- .travis.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7fd1df83a..ecebeca0e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -18,16 +18,23 @@ env: - RAILS_ENV=test - CI=true - TRAVIS=true - matrix: - - TASK="bundle exec rake test:unit" - - TASK="bundle exec rake test:integration" - - TASK="bundle exec rake test:functional" - - TASK="RAILS_ENV=production bundle exec rake assets:precompile" - - TASK="bundle exec rubocop" - - TASK="docker build -t mapknitter ." -script: - - $TASK +jobs: + include: + - name: "Unit Tests" + script: bundle exec rake test:unit + - name: "Integration Tests" + script: bundle exec rake test:integration + - name: "Functional Tests" + script: bundle exec rake test:functional + - name: "Rubocop Linter" + script: bundle exec rubocop + - name: "Docker Builds" + script: docker build -t mapknitter . + - name: "Asset Precompilation" + env: + - RAILS_ENV=production + script: bundle exec rake assets:precompile branches: only: From 4ad08880542142490426174ac9589cf37a879b34 Mon Sep 17 00:00:00 2001 From: Kaustubh Nair Date: Mon, 10 Jun 2019 11:15:51 +0530 Subject: [PATCH 09/12] fix travis.yml --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 832459225..ecebeca0e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -16,12 +16,8 @@ install: env: global: - RAILS_ENV=test - matrix: - - TASK="CI=true TRAVIS=true rake test:unit" - - 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" + - CI=true + - TRAVIS=true jobs: include: From 35d3a898a98f2f68c154f5773fcc71823aa72720 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Tue, 11 Jun 2019 17:12:10 -0300 Subject: [PATCH 10/12] Upgrading sintax of assets and using required gems --- Gemfile | 2 ++ Gemfile.lock | 12 ++++++++++++ app/assets/javascripts/application.js | 3 +++ app/assets/stylesheets/annotations.css | 4 ++-- .../{application.css => application.css.scss} | 17 ++++++++--------- lib/exporter.rb | 3 +-- 6 files changed, 28 insertions(+), 13 deletions(-) rename app/assets/stylesheets/{application.css => application.css.scss} (83%) diff --git a/Gemfile b/Gemfile index d2dc1dd08..303451f93 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,8 @@ group :dependencies do gem "rdiscount", "2.2.0.1" # asset pipelining + gem 'bootstrap-sass' + gem 'jquery-rails' gem "sprockets"#, "2.12.1" gem "sass", :require => 'sass' gem "autoprefixer-rails" diff --git a/Gemfile.lock b/Gemfile.lock index d06519882..56ad229ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,9 @@ GEM uuidtools (~> 2.1) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) + bootstrap-sass (3.4.1) + autoprefixer-rails (>= 5.2.1) + sassc (>= 2.0.0) builder (3.2.3) byebug (11.0.1) climate_control (0.2.0) @@ -79,6 +82,10 @@ GEM concurrent-ruby (~> 1.0) image_science (1.3.0) RubyInline (~> 3.9) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) jshintrb (0.3.0) execjs multi_json (>= 1.3) @@ -205,6 +212,9 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) + sassc (2.0.1) + ffi (~> 1.9) + rake simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -251,12 +261,14 @@ DEPENDENCIES RubyInline autoprefixer-rails aws-sdk (~> 1.5.7) + bootstrap-sass byebug faker friendly_id geokit-rails (= 1.1.4) httparty image_science (= 1.3.0) + jquery-rails jshintrb minitest minitest-reporters diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index fa2ef6103..582bd52ce 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,6 +11,9 @@ // GO AFTER THE REQUIRES BELOW. // +//= require jquery +//= require bootstrap-sprockets + //= require popper //= require jquery/dist/jquery.js //= require jquery-ujs/src/rails.js diff --git a/app/assets/stylesheets/annotations.css b/app/assets/stylesheets/annotations.css index c85321d3f..7760f6e54 100644 --- a/app/assets/stylesheets/annotations.css +++ b/app/assets/stylesheets/annotations.css @@ -20,8 +20,8 @@ } .leaflet-draw-toolbar a { - background-image: url('/assets/leaflet-illustrate/dist/images/spritesheet.png'); !important + background-image: url('/assets/leaflet-illustrate/dist/images/spritesheet.png') !important; } .leaflet-retina .leaflet-draw-toolbar a { - background-image: url('/assets/leaflet-draw/dist/images/spritesheet-2x.png'); !important + background-image: url('/assets/leaflet-draw/dist/images/spritesheet-2x.png') !important; } diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css.scss similarity index 83% rename from app/assets/stylesheets/application.css rename to app/assets/stylesheets/application.css.scss index 9f8329d68..c1b78b0d6 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css.scss @@ -15,12 +15,11 @@ *= require leaflet-toolbar/dist/leaflet.toolbar.css *= require leaflet-distortableimage/dist/leaflet.distortableimage.css - *= require style - *= require maps - *= require header - *= require uploads - - *= require_self - *= require annotations - * require_tree . -*/ + */ + @import "bootstrap-sprockets"; + @import "bootstrap"; + @import "style"; + @import "maps"; + @import "header"; + @import "uploads"; + @import "annotations"; diff --git a/lib/exporter.rb b/lib/exporter.rb index bcae11dd1..61df28ba8 100644 --- a/lib/exporter.rb +++ b/lib/exporter.rb @@ -276,8 +276,7 @@ def self.generate_composite_tiff(coords, origin, placed_warpables, slug, ordered # generates a tileset at root/public/tms// # root is something like https://mapknitter.org def self.generate_tiles(key, slug, root) - key = "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" if key == "" # ugh, let's clean this up! - key = key || "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" + key = "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" if key.blank? gdal2tiles = 'gdal2tiles.py -k --s_srs EPSG:3857 -t "'+slug+'" -g "'+key+'" '+root+'/public/warps/'+slug+'/'+slug+'-geo.tif '+root+'/public/tms/'+slug+"/" puts gdal2tiles system(self.ulimit+gdal2tiles) From f7cdadafeeb71497b805f04ea59e8229084cfc7b Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Tue, 11 Jun 2019 17:21:41 -0300 Subject: [PATCH 11/12] Using updated version of GDAL and installing required dependencies --- .travis.yml | 12 +++++---- Gemfile | 8 +++--- Gemfile.lock | 9 +++++++ app/assets/javascripts/application.js | 5 ++-- .../{annotations.css => annotations.scss} | 0 app/assets/stylesheets/application.css.scss | 26 ------------------- app/assets/stylesheets/application.scss | 24 +++++++++++++++++ .../{header.css.scss => header.scss} | 0 .../stylesheets/{maps.css.scss => maps.scss} | 0 .../{style.css.scss => style.scss} | 0 .../stylesheets/{uploads.css => uploads.scss} | 0 lib/exporter-deps.sh | 17 +++++++++++- lib/exporter.rb | 2 +- test/unit/exporter_test.rb | 2 +- 14 files changed, 64 insertions(+), 41 deletions(-) rename app/assets/stylesheets/{annotations.css => annotations.scss} (100%) delete mode 100644 app/assets/stylesheets/application.css.scss create mode 100644 app/assets/stylesheets/application.scss rename app/assets/stylesheets/{header.css.scss => header.scss} (100%) rename app/assets/stylesheets/{maps.css.scss => maps.scss} (100%) rename app/assets/stylesheets/{style.css.scss => style.scss} (100%) rename app/assets/stylesheets/{uploads.css => uploads.scss} (100%) mode change 100644 => 100755 lib/exporter-deps.sh diff --git a/.travis.yml b/.travis.yml index ecebeca0e..17893f23e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,8 @@ 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 install + - ./lib/exporter-deps.sh > /dev/null 2>&1 + - bundle install && yarn install - bundle exec rake db:setup || bundle exec rake db:migrate env: @@ -31,10 +32,11 @@ jobs: script: bundle exec rubocop - name: "Docker Builds" script: docker build -t mapknitter . - - name: "Asset Precompilation" - env: - - RAILS_ENV=production - script: bundle exec rake assets:precompile + # Configure this option after full yarn setup + # - name: "Asset Precompilation" + # env: + # - RAILS_ENV=production + # script: bundle exec rake assets:precompile branches: only: diff --git a/Gemfile b/Gemfile index 303451f93..bf053a8db 100644 --- a/Gemfile +++ b/Gemfile @@ -30,22 +30,22 @@ group :dependencies do # gem 'right_aws' gem 'right_aws_api' - # compiling markdown to html gem "rdiscount", "2.2.0.1" # asset pipelining gem 'bootstrap-sass' + gem 'sassc-rails' gem 'jquery-rails' - gem "sprockets"#, "2.12.1" + gem "sprockets" + gem "sprockets-rails" gem "sass", :require => 'sass' gem "autoprefixer-rails" gem "uglifier" - end group :test do - gem "rubocop", '~> 0.52.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 b483f7325..554ee25f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -215,6 +215,12 @@ GEM sassc (2.0.1) ffi (~> 1.9) rake + sassc-rails (2.1.1) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -239,6 +245,7 @@ GEM ref thor (0.20.3) thread_safe (0.3.6) + tilt (2.0.9) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.20) @@ -290,10 +297,12 @@ DEPENDENCIES ruby-openid (~> 2.5) ruby-prof sass + sassc-rails simplecov simplecov-cobertura skylight sprockets + sprockets-rails sqlite3 therubyracer uglifier diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index ee9e5cef9..04ad5432d 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,10 +11,9 @@ // GO AFTER THE REQUIRES BELOW. // +//= require_tree . //= require jquery -//= require bootstrap-sprockets - -//= require popper +//= require jquery-ujs //= require jquery/dist/jquery.js //= require jquery-ujs/src/rails.js diff --git a/app/assets/stylesheets/annotations.css b/app/assets/stylesheets/annotations.scss similarity index 100% rename from app/assets/stylesheets/annotations.css rename to app/assets/stylesheets/annotations.scss diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss deleted file mode 100644 index 699de27f6..000000000 --- a/app/assets/stylesheets/application.css.scss +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. - * - - *= require bootstrap/dist/css/bootstrap.min.css - *= require leaflet-draw/dist/leaflet.draw.css - *= require leaflet-illustrate/dist/Leaflet.Illustrate.css - *= require leaflet-toolbar/dist/leaflet.toolbar.css - *= require leaflet-distortableimage/dist/leaflet.distortableimage.css - *= require fontawesome/css/font-awesome.min.css - - */ - @import "bootstrap-sprockets"; - @import "bootstrap"; - @import "style"; - @import "maps"; - @import "header"; - @import "uploads"; - @import "annotations"; diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 000000000..95c1fc950 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1,24 @@ +$icon-font-path: "bootstrap-sass/assets/fonts/bootstrap/"; +@import "style"; +@import "maps"; +@import "header"; +@import "uploads"; +@import "annotations"; +@import "bootstrap/dist/css/bootstrap.min.css"; +@import "leaflet-draw/dist/leaflet.draw.css"; +@import "leaflet-illustrate/dist/Leaflet.Illustrate.css"; +@import "leaflet-toolbar/dist/leaflet.toolbar.css"; +@import "leaflet-distortableimage/dist/leaflet.distortableimage.css"; +@import "fontawesome/css/font-awesome.min.css"; +// /* +// * This is a manifest file that'll be compiled into application.css, which will include all the files +// * listed below. +// * +// * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, +// * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. +// * +// * You're free to add application-wide styles to this file and they'll appear at the top of the +// * compiled file, but it's generally better to create a new file per style scope. +// * + +// */ diff --git a/app/assets/stylesheets/header.css.scss b/app/assets/stylesheets/header.scss similarity index 100% rename from app/assets/stylesheets/header.css.scss rename to app/assets/stylesheets/header.scss diff --git a/app/assets/stylesheets/maps.css.scss b/app/assets/stylesheets/maps.scss similarity index 100% rename from app/assets/stylesheets/maps.css.scss rename to app/assets/stylesheets/maps.scss diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.scss similarity index 100% rename from app/assets/stylesheets/style.css.scss rename to app/assets/stylesheets/style.scss diff --git a/app/assets/stylesheets/uploads.css b/app/assets/stylesheets/uploads.scss similarity index 100% rename from app/assets/stylesheets/uploads.css rename to app/assets/stylesheets/uploads.scss diff --git a/lib/exporter-deps.sh b/lib/exporter-deps.sh old mode 100644 new mode 100755 index fb262e8ae..f65bf5969 --- a/lib/exporter-deps.sh +++ b/lib/exporter-deps.sh @@ -1 +1,16 @@ -sudo apt-get install gdal-bin python-gdal curl libcurl4-openssl-dev libssl-dev zip libmysqlclient-dev imagemagick ruby-rmagick libfreeimage3 libfreeimage-dev ruby-dev libmagickcore-dev libmagickwand-dev +sudo add-apt-repository -y ppa:ubuntugis/ppa +sudo apt-get update +sudo apt-get install -y gdal-bin \ + python3-gdal \ + python-gdal \ + curl \ + libcurl4-openssl-dev \ + libssl-dev zip \ + libmysqlclient-dev \ + imagemagick \ + ruby-rmagick \ + libfreeimage3 \ + libfreeimage-dev \ + ruby-dev \ + libmagickcore-dev \ + libmagickwand-dev diff --git a/lib/exporter.rb b/lib/exporter.rb index 61df28ba8..e3967624d 100644 --- a/lib/exporter.rb +++ b/lib/exporter.rb @@ -277,7 +277,7 @@ def self.generate_composite_tiff(coords, origin, placed_warpables, slug, ordered # root is something like https://mapknitter.org def self.generate_tiles(key, slug, root) key = "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" if key.blank? - gdal2tiles = 'gdal2tiles.py -k --s_srs EPSG:3857 -t "'+slug+'" -g "'+key+'" '+root+'/public/warps/'+slug+'/'+slug+'-geo.tif '+root+'/public/tms/'+slug+"/" + gdal2tiles = 'gdal2tiles.py -k --s_srs EPSG:4326 -t "'+slug+'" -g "'+key+'" '+root+'/public/warps/'+slug+'/'+slug+'-geo.tif '+root+'/public/tms/'+slug+"/" puts gdal2tiles system(self.ulimit+gdal2tiles) end diff --git a/test/unit/exporter_test.rb b/test/unit/exporter_test.rb index b6d74f564..ffab0894c 100644 --- a/test/unit/exporter_test.rb +++ b/test/unit/exporter_test.rb @@ -19,7 +19,7 @@ class ExporterTest < ActiveSupport::TestCase assert Exporter.get_working_directory(w.map.slug) assert Exporter.warps_directory(w.map.slug) - map = Map.first + map = maps(:saugus) # get rid of existing geotiff system('rm -r public/warps/saugus-landfill-incinerator/1-geo.tif') From e9acca73ec86145fe8ae1a52c096edb84daddee6 Mon Sep 17 00:00:00 2001 From: Alax Alves Date: Wed, 12 Jun 2019 17:47:16 -0300 Subject: [PATCH 12/12] Enabling cache in between builds --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 17893f23e..f48a36eff 100755 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,11 @@ services: - mysql - docker +cache: + bundler: true + directories: + - public/lib/ + install: - cp config/database.yml.example config/database.yml - cp config/config.yml.example config/config.yml