Skip to content

Commit

Permalink
[api] Fix view=blame for attributes
Browse files Browse the repository at this point in the history
by forwarding also the view parameter to the backend.

This was necessary as the API was not delivering what it was
supposed to do with a view parameter.
This was especially important for the standard blame view.
  • Loading branch information
adrianschroeter authored and ChrisBr committed Jun 11, 2018
1 parent 16ca88b commit c50d3f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/app/controllers/attribute_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def show_attribute
# init
# checks
# exec
if params[:rev] || @attribute_container.nil?
if params[:rev] || params[:meta] || params[:view] || @attribute_container.nil?
# old or remote instance entry
render xml: Backend::Api::Sources::Package.attributes(params[:project], params[:package], params[:rev])
render xml: Backend::Api::Sources::Package.attributes(params[:project], params[:package], params)
return
end

Expand Down
8 changes: 5 additions & 3 deletions src/api/lib/backend/api/sources/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ module Package
# Returns the attributes content
# @param revision [String] Revision hash/number.
# @return [String]
def self.attributes(project_name, package_name, revision)
def self.attributes(project_name, package_name, options = {})
params = { meta: 1 }
params[:rev] = revision if revision
http_get(['/source/:project/:package/_attribute', project_name, package_name || '_project'], params: params)
params[:rev] = options[:rev] if options[:rev]
params[:view] = options[:view] if options[:view]
http_get(['/source/:project/:package/_attribute', project_name, package_name || '_project'],
params: params, accepted: [:rev, :meta, :view])
end

# Writes the content in xml for attributes
Expand Down
5 changes: 5 additions & 0 deletions src/api/test/functional/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def test_create_type
assert_response :success
assert_xml_tag tag: 'value', content: 'A'
assert_xml_tag tag: 'value', content: 'B'
# blame view is working
get '/source/home:adrian/_project/_attribute?view=blame&meta=1'
assert_response :success
assert_match(/^ . \(adrian/, @response.body)

# cleanup
login_Iggy
delete '/attribute/TEST/Dummy/_meta'
Expand Down

0 comments on commit c50d3f3

Please sign in to comment.