Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# call this from rails root: podman build -t mapforge-base -f .github/Dockerfile.base .

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.4.5
ARG RUBY_VERSION=4.0.0
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base

LABEL org.opencontainers.image.source="https://github.com/mapforge-org/mapforge"
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inherit_gem:
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 3.4
TargetRubyVersion: 4.0
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.5
4.0.0
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"
ruby "3.4.5"
ruby "4.0.0"

gem "rails"

Expand Down Expand Up @@ -58,14 +58,13 @@ gem "rszr"
gem "rgeo"
gem "rgeo-geojson"
gem "rgeo-proj4"
gem "gpx"
gem "gpx", git: "https://github.com/digitaltom/gpx" # Ruby 4.0 fork
# resolving request IP addresses to coordinates
gem "maxminddb"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "byebug"
gem "debug", platforms: %i[mri windows]
gem "debug"
gem "dotenv-rails", require: "dotenv/load"
gem "listen"
gem "mongo_logs_on_roids"
Expand Down Expand Up @@ -101,6 +100,7 @@ group :test do
gem "simplecov"
gem "database_cleaner-mongoid"
gem "mongoid-rspec"
gem "puffing-billy"
gem "cuprite"
gem "capybara_mock"
gem "table_print"
end
67 changes: 30 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/digitaltom/gpx
revision: 204842fc2a00dca66adb66d7d8148e7580e197bd
specs:
gpx (1.2.1)
csv
nokogiri (~> 1.7)
rake

GIT
remote: https://github.com/ruby/net-pop.git
revision: 30d89b359c940610d84ecd1fed0dba4003508fde
Expand Down Expand Up @@ -104,7 +113,6 @@ GEM
bundler-audit (0.9.3)
bundler (>= 1.2.0)
thor (~> 1.0)
byebug (12.0.0)
capybara (3.40.0)
addressable
matrix
Expand All @@ -117,15 +125,19 @@ GEM
capybara-screenshot (1.0.26)
capybara (>= 1.0, < 4)
launchy
capybara_mock (0.2.0)
rack (>= 2.2.0)
childprocess (5.1.0)
logger (~> 1.5)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
cookiejar (0.3.4)
crass (1.0.6)
csv (3.3.3)
csv (3.3.5)
cuprite (0.17)
capybara (~> 3.0)
ferrum (~> 0.17.0)
database_cleaner-core (2.0.1)
database_cleaner-mongoid (2.0.1)
database_cleaner-core (~> 2.0.0)
Expand Down Expand Up @@ -177,21 +189,8 @@ GEM
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
em-http-request (1.1.7)
addressable (>= 2.3.4)
cookiejar (!= 0.3.1)
em-socksify (>= 0.3)
eventmachine (>= 1.0.3)
http_parser.rb (>= 0.6.0)
em-socksify (0.3.3)
base64
eventmachine (>= 1.0.0.beta.4)
em-synchrony (1.0.6)
eventmachine (>= 1.0.0.beta.1)
erb (6.0.1)
erubi (1.13.1)
eventmachine (1.2.7)
eventmachine_httpserver (0.2.1)
factory_bot (6.5.5)
activesupport (>= 6.1.0)
factory_bot_rails (6.5.1)
Expand All @@ -203,6 +202,12 @@ GEM
logger
faraday-net_http (3.4.0)
net-http (>= 0.5.0)
ferrum (0.17.1)
addressable (~> 2.5)
base64 (~> 0.2)
concurrent-ruby (~> 1.1)
webrick (~> 1.7)
websocket-driver (~> 0.7)
ffi (1.17.0)
flay (2.13.3)
erubi (~> 1.10)
Expand All @@ -220,10 +225,6 @@ GEM
i18n (>= 0.7)
multi_json
request_store (>= 1.0)
gpx (1.2.1)
csv
nokogiri (~> 1.7)
rake
haml (7.1.0)
temple (>= 0.8.2)
thor
Expand All @@ -233,7 +234,6 @@ GEM
listen
rails (>= 7.0.0)
zeitwerk
http_parser.rb (0.8.0)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
Expand Down Expand Up @@ -319,7 +319,7 @@ GEM
net-smtp (0.5.1)
net-protocol
nio4r (2.7.5)
nokogiri (1.18.10-x86_64-linux-gnu)
nokogiri (1.19.0-x86_64-linux-gnu)
racc (~> 1.4)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -362,14 +362,6 @@ GEM
date
stringio
public_suffix (6.0.2)
puffing-billy (4.0.2)
addressable (~> 2.5)
em-http-request (~> 1.1, >= 1.1.0)
em-synchrony
eventmachine (~> 1.2)
eventmachine_httpserver
http_parser.rb (~> 0.8.0)
multi_json
puma (7.1.0)
nio4r (~> 2.0)
puppeteer-ruby (0.45.6)
Expand Down Expand Up @@ -520,7 +512,7 @@ GEM
rubocop-ast (>= 1.44.0, < 2.0)
ruby-next-core (1.1.2)
ruby-progressbar (1.13.0)
ruby_parser (3.21.1)
ruby_parser (3.22.0)
racc (~> 1.5)
sexp_processor (~> 4.16)
rubycritic (4.11.0)
Expand All @@ -543,7 +535,7 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 4.0)
websocket (~> 1.0)
sexp_processor (4.17.4)
sexp_processor (4.17.5)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -592,6 +584,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webrick (1.9.2)
websocket (1.2.11)
websocket-driver (0.8.0)
base64
Expand Down Expand Up @@ -626,16 +619,17 @@ DEPENDENCIES
bootsnap
brakeman
bundler-audit
byebug
capybara
capybara-screenshot
capybara_mock
cuprite
database_cleaner-mongoid
debug
dotenv-rails
dragonfly
factory_bot_rails
gon
gpx
gpx!
haml
hotwire-spark
importmap-rails
Expand All @@ -654,7 +648,6 @@ DEPENDENCIES
omniauth-google-oauth2
ostruct
parallel_tests
puffing-billy
puma
puppeteer-ruby
rack-cache
Expand Down Expand Up @@ -690,7 +683,7 @@ DEPENDENCIES
yabeda-rails

RUBY VERSION
ruby 3.4.5
ruby 4.0.0p0

BUNDLED WITH
2.7.1
4.0.3
4 changes: 3 additions & 1 deletion app/channels/map_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ class MapChannel < ApplicationCable::Channel
# Check auth on update methods by looking up map with private id
def subscribed
super
Map.find_by(private_id: params[:map_id]) || Map.find_by(public_id: params[:map_id])
map = Map.find_by(private_id: params[:map_id]) || Map.find_by(public_id: params[:map_id])
Rails.logger.warn "Invalid map id #{params[:map_id]} for subscribing to channel" and return unless map

stream_from "map_channel_#{params[:map_id]}"
transmit({ event: "connection", uuid: uuid })
Rails.logger.debug { "MapChannel subscribed '#{uuid}' for '#{params[:map_id]}'" }
Expand Down
26 changes: 19 additions & 7 deletions spec/features/feature_details_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,34 @@
expect_map_loaded
end

context 'with polygon on map' do
context 'mobile', :mobile do
before { create(:feature, :polygon_middle, layer: map.layers.first, title: 'Poly Title') }

context 'with selected feature' do
before do
click_coord('#maplibre-map', 50, 50)
click_center_of_screen
expect(page).to have_css('#feature-details-modal')
end

it 'can enlarge modal with pull-up button', :mobile do
height = find('#feature-details-modal').native.style('height').sub('px', '').to_i
expect(height).to be < 200
it 'can enlarge modal with pull-up button' do
height = element_offset_height('#feature-details-modal')
# initial height is half the screen height
expect(height).to be < 300
find('.modal-pull-button').click
sleep(0.3)
height = find('#feature-details-modal').native.style('height').sub('px', '').to_i
expect(height).to be > 150
height = element_offset_height('#feature-details-modal')
expect(height).to be > 300
end
end
end

context 'export' do
before { create(:feature, :polygon_middle, layer: map.layers.first, title: 'Poly Title') }

context 'with selected feature' do
before do
click_center_of_screen
expect(page).to have_css('#feature-details-modal')
end

it 'can download feature export' do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/feature_directions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
it 'can create foot track' do
find('.mapbox-gl-draw_line').click
find('.mapbox-gl-draw_foot').click
click_coord('#maplibre-map', 50, 50)
click_coord('#maplibre-map', 150, 150)
click_coord('#maplibre-map', 250, 250)
click_coord('#maplibre-map', 450, 450)
wait_for { Feature.line_string.count }.to eq(1)
end
end
Expand Down
16 changes: 10 additions & 6 deletions spec/features/feature_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

context 'with selected polygon feature' do
before do
click_coord('#maplibre-map', 50, 50)
click_coord('#maplibre-map', 512, 430)
expect(page).to have_css('#edit-button-edit')
end

Expand Down Expand Up @@ -101,7 +101,7 @@

context 'with selected point feature' do
before do
click_coord('#maplibre-map', 50, 50)
click_coord('#maplibre-map', 512, 430)
find('#edit-button-edit').click
end

Expand Down Expand Up @@ -134,8 +134,10 @@
end

it 'can update fill color' do
find('#fill-color').set('#aabbcc')
wait_for { point.reload.properties['marker-color'] }.to eq('#aabbcc')
color = '#aa00cc'
set_color_input('#fill-color', color)

wait_for { point.reload.properties['marker-color'] }.to eq(color)
end

it 'can set fill color transparent' do
Expand All @@ -151,8 +153,10 @@
end

it 'can update outline color' do
find('#stroke-color').set('#aabbcc')
wait_for { point.reload.properties['stroke'] }.to eq('#aabbcc')
color = '#aa00cc'
set_color_input('#stroke-color', color)

wait_for { point.reload.properties['stroke'] }.to eq(color)
end

it 'can upload image' do
Expand Down
15 changes: 10 additions & 5 deletions spec/features/map_layers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@

context 'overpass layer' do
before do
proxy.stub('https://overpass-api.de:443/api/interpreter', method: 'post')
.and_return(
headers: { 'Access-Control-Allow-Origin' => '*' },
text: File.read(Rails.root.join("spec", "fixtures", "files", "overpass.json")))
overpass_file = File.read(Rails.root.join("spec", "fixtures", "files", "overpass.json"))
# https://github.com/railsware/capybara_mock
CapybaraMock.stub_request(
:post, 'https://overpass-api.de/api/interpreter'
).to_return(
headers: { 'Access-Control-Allow-Origin' => '*' },
status: 200,
body: overpass_file
)

map.layers << layer
visit map.private_map_path
Expand All @@ -95,7 +100,7 @@
let(:layer) { create(:layer, :overpass, name: 'opass') }

it 'Shows overpass layer' do
expect(page).to have_text('opass')
expect(page).to have_text('opass(1)')
end

it 'can add overpass layer' do
Expand Down
Loading