Browse Source

Merge branch 'feature/poi-types' into develop

* feature/poi-types:
  Render place-type in small next to name
tags/0.3.6^2
Bèr Kessels 1 month ago
parent
commit
2405a3c1a0

+ 15
- 1
app/models/place.rb View File

@@ -24,7 +24,7 @@ module Hours

attr_accessor :id, :place_id, :name,
:distance, :website, :administrative_regions
attr_writer :opening_hours, :geometry
attr_writer :opening_hours, :geometry, :type, :poi_types

def status
return :unknown if opening_hours&.empty?
@@ -70,6 +70,20 @@ module Hours
@address = (address || {}).merge(@address || {})
end

def type
top_levels = {
'house' => 'Huis',
'zone' => 'Gebied',
'street' => 'Straat'
}

if @type == 'poi'
@poi_types.first&.fetch('name', false)
else
top_levels[@type]
end || 'Onbekend'
end

private

def get_intervals_as_week(date_ranges, date_in_week)

+ 1
- 0
app/views/aside_places_partial.erb View File

@@ -5,6 +5,7 @@
id="place-<%= place.id %>">
<div class="d-flex w-100 justify-content-between">
<h3 class="mb-1 small"><%= place.name %></h3>
<small><%= place.type %></small>
</div>
<p class="mb-1 small"><%= place.address.street %>, <%= place.address.city %></p>
<p class="mb-1 small">

+ 1
- 0
test/integration/web/view_regions_test.rb View File

@@ -22,6 +22,7 @@ describe 'web views regions' do

assert_selector page, 'h2', text: 'Openingstijden in Nijmegen'
assert_selector page, 'h3', text: 'Kattencafé Balthazar'
assert_selector page, 'small', text: 'Café'
end

describe 'with 21 items in nijmegen' do

+ 48
- 0
test/models/place_test.rb View File

@@ -38,6 +38,54 @@ describe Hours::Models::Place do
end
end

describe 'type' do
# TODO: implement translation in the view. And return symbols here.
describe 'with poi' do
before do
subject.type = 'poi'
end

it 'takes first from poi_types' do
subject.poi_types = [
{ 'id' => 'poi_type:amenity:cafe', 'name' => 'Café' }
]
assert_equal 'Café', subject.type
end

it 'is Onbekend witout poi_types' do
subject.poi_types = []
assert_equal 'Onbekend', subject.type
end
end

describe 'with house' do
before { subject.type = 'house' }
it 'is Huis' do
assert_equal 'Huis', subject.type
end
end

describe 'with zone' do
before { subject.type = 'zone' }
it 'is Gebied' do
assert_equal 'Gebied', subject.type
end
end

describe 'with street' do
before { subject.type = 'street' }
it 'is Straat' do
assert_equal 'Straat', subject.type
end
end
describe 'with anything else' do
before { subject.type = 'whatever' }
it 'is Onbekend' do
assert_equal 'Onbekend', subject.type
end
end
end

describe 'region_slug' do
describe 'with city' do
before { subject.city = "'s-Hertogenbosch" }

Loading…
Cancel
Save