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 af91eaf52..f48a36eff 100755 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,7 @@ install: - cp db/schema.rb.example db/schema.rb - ./lib/exporter-deps.sh > /dev/null 2>&1 - bundle install && yarn install - - if [ $RAILS_ENV == 'production' ]; then - bundle exec rake db:create; - else - bundle exec rake db:setup || bundle exec rake db:migrate; - fi + - bundle exec rake db:setup || bundle exec rake db:migrate env: global: @@ -41,13 +37,15 @@ 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: - main - unstable - development + diff --git a/Gemfile b/Gemfile index 3797b36d2..bf053a8db 100644 --- a/Gemfile +++ b/Gemfile @@ -30,20 +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 "sprockets"#, "2.12.1" + gem 'bootstrap-sass' + gem 'sassc-rails' + gem 'jquery-rails' + gem "sprockets" + gem "sprockets-rails" gem "sass", :require => 'sass' gem "autoprefixer-rails" gem "uglifier" - 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..554ee25f4 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,7 +82,10 @@ GEM concurrent-ruby (~> 1.0) image_science (1.3.0) RubyInline (~> 3.9) - jaro_winkler (1.5.2) + 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) @@ -188,14 +194,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) @@ -207,6 +212,15 @@ 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 + 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) @@ -231,11 +245,12 @@ 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) 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) @@ -253,12 +268,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 @@ -276,14 +293,16 @@ 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 + 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 7d40a8c44..04ad5432d 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,7 +11,9 @@ // GO AFTER THE REQUIRES BELOW. // -//= require popper +//= require_tree . +//= require jquery +//= 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 93% rename from app/assets/stylesheets/annotations.css rename to app/assets/stylesheets/annotations.scss index c85321d3f..7760f6e54 100644 --- a/app/assets/stylesheets/annotations.css +++ b/app/assets/stylesheets/annotations.scss @@ -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 deleted file mode 100644 index cd9eebaf4..000000000 --- a/app/assets/stylesheets/application.css +++ /dev/null @@ -1,27 +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 - - *= require style - *= require maps - *= require header - *= require uploads - - *= require_self - *= require annotations - * require_tree . -*/ 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/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 277488812..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: - adapter: mysql2 - host: db + <<: *default username: mapknitter password: mapknitter database: mapknitter test: - adapter: mysql2 - username: mapknitter - password: mapknitter - host: db - database: mapknitter + <<: *default + username: root + database: mapknitter-test 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/lib/exporter-deps.sh b/lib/exporter-deps.sh index fb262e8ae..f65bf5969 100755 --- 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 bcae11dd1..e3967624d 100644 --- a/lib/exporter.rb +++ b/lib/exporter.rb @@ -276,9 +276,8 @@ 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" - gdal2tiles = 'gdal2tiles.py -k --s_srs EPSG:3857 -t "'+slug+'" -g "'+key+'" '+root+'/public/warps/'+slug+'/'+slug+'-geo.tif '+root+'/public/tms/'+slug+"/" + key = "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" if key.blank? + 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/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 56d5f30b9..1f2772a72 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,12 +1,12 @@ -ENV["RAILS_ENV"] = "test" require 'simplecov' - +require 'simplecov-cobertura' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require 'minitest/reporters' MiniTest::Reporters.use! [MiniTest::Reporters::ProgressReporter.new, MiniTest::Reporters::JUnitReporter.new] +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/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') 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,