⌚ OpenOpeningstijden main server application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

node_test.rb 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. describe Hours::Models::Node do
  4. let(:pk) { SecureRandom.uuid }
  5. subject do
  6. Hours::Models::Node.new
  7. end
  8. describe 'dataset' do
  9. it 'reads from :query_nodes' do
  10. assert_equal :query_nodes, subject.class.table_name
  11. end
  12. end
  13. describe 'location' do
  14. let(:lat) do
  15. 20.1
  16. end
  17. let(:lon) do
  18. 20.2
  19. end
  20. let(:point) do
  21. GeoRuby::SimpleFeatures::Point.from_x_y(lon, lat)
  22. end
  23. it 'has a lat' do
  24. assert_equal lat, Hours::Models::Node.new(location: point).lat
  25. end
  26. it 'has a lon' do
  27. assert_equal lon, Hours::Models::Node.new(location: point).lon
  28. end
  29. end
  30. describe 'opening_hours' do
  31. let(:opening_hours) { '1989 Mo-Fr 10:00-19:00' }
  32. before do
  33. subject.opening_hours = opening_hours
  34. end
  35. describe 'status' do
  36. it 'is true between 10:00 and 19:00' do
  37. at_time do
  38. assert_time_after(Time.parse('10:00'))
  39. assert_time_before(Time.parse('19:00'))
  40. assert_equal true, subject.status
  41. end
  42. end
  43. it 'is false after 19:00' do
  44. at_time(die_wende + 3600) do
  45. assert_time_after(Time.parse('19:00'))
  46. assert_equal false, subject.status
  47. end
  48. end
  49. end
  50. end
  51. end