Commit 8d8325e0 authored by MARGERY David's avatar MARGERY David
Browse files

Aggree that leaving a trailing / for root is OK

root_controller_spec.rb and sites_controller_spec.rb implemented two
conflicting requirements when deciding how to present the root of the
API depending on whether the root was fictionnal through API_MOUNT_PATH or the
real root of the service.

This commit chooses to allways present a trailing / when building hrefs

The related test in root_controller_spec has also been updated to
reflect that the tested behavior (prepending sid) is acheived by using
X-Api-Version header rather that X-Api-Path-Prefix on real deployments.
parent c1927234
...@@ -60,6 +60,7 @@ module Grid5000 ...@@ -60,6 +60,7 @@ module Grid5000
mounted_path=path mounted_path=path
mounted_path.gsub!(/^#{mount_path}/,'') unless mount_path.nil? mounted_path.gsub!(/^#{mount_path}/,'') unless mount_path.nil?
mounted_path='/' if mounted_path.blank?
uri = File.join("/", *[root_path, api_version, path_prefix, mounted_path].compact) uri = File.join("/", *[root_path, api_version, path_prefix, mounted_path].compact)
uri = "/" if uri.blank? uri = "/" if uri.blank?
# abasu / dmargery - bug ref 7360 - for correct URI construction # abasu / dmargery - bug ref 7360 - for correct URI construction
......
...@@ -39,8 +39,8 @@ describe RootController do ...@@ -39,8 +39,8 @@ describe RootController do
} }
end end
it "should correcly add the api-prefix if any" do it "should correcly add the version if any" do
@request.env['HTTP_X_API_PATH_PREFIX'] = 'sid' @request.env['HTTP_X_API_VERSION'] = 'sid'
get :show, :id => "grid5000", :format => :json get :show, :id => "grid5000", :format => :json
response.status.should == 200 response.status.should == 200
json.should == { json.should == {
......
...@@ -46,7 +46,7 @@ describe SitesController do ...@@ -46,7 +46,7 @@ describe SitesController do
@request.env['HTTP_X_API_MOUNT_PATH'] = '/sites' @request.env['HTTP_X_API_MOUNT_PATH'] = '/sites'
get :index, :format => :json get :index, :format => :json
expect(response.status).to eq 200 expect(response.status).to eq 200
expect(json['links'].find{|l| l['rel'] == 'self'}['href']).to eq "/sid" expect(json['links'].find{|l| l['rel'] == 'self'}['href']).to eq "/sid/"
end end
end # describe "GET /sites" end # describe "GET /sites"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment