]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/4182'
authorTom Hughes <tom@compton.nu>
Fri, 18 Aug 2023 18:25:36 +0000 (19:25 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 18 Aug 2023 18:25:36 +0000 (19:25 +0100)
app/views/api/versions/show.json.jbuilder [new file with mode: 0644]
test/controllers/api/versions_controller_test.rb

diff --git a/app/views/api/versions/show.json.jbuilder b/app/views/api/versions/show.json.jbuilder
new file mode 100644 (file)
index 0000000..7336902
--- /dev/null
@@ -0,0 +1,5 @@
+json.partial! "api/root_attributes"
+
+json.api do
+  json.versions @versions
+end
index a1a616ad19db026960016c8acaeda53b856589b2..1c70831c93c9b65293cb107ac1f04b059f4fd90c 100644 (file)
@@ -9,10 +9,18 @@ module Api
         { :path => "/api/versions", :method => :get },
         { :controller => "api/versions", :action => "show" }
       )
+      assert_routing(
+        { :path => "/api/versions.json", :method => :get },
+        { :controller => "api/versions", :action => "show", :format => "json" }
+      )
       assert_recognizes(
         { :controller => "api/versions", :action => "show" },
         { :path => "/api/versions", :method => :get }
       )
+      assert_recognizes(
+        { :controller => "api/versions", :action => "show", :format => "json" },
+        { :path => "/api/versions.json", :method => :get }
+      )
     end
 
     def test_versions
@@ -25,6 +33,14 @@ module Api
       end
     end
 
+    def test_versions_json
+      get api_versions_path, :params => { :format => "json" }
+      assert_response :success
+      js = ActiveSupport::JSON.decode(@response.body)
+      assert_not_nil js
+      assert_equal [Settings.api_version], js["api"]["versions"]
+    end
+
     def test_no_version_in_root_element
       get api_versions_path
       assert_response :success