Skip to content

Commit

Permalink
Merge pull request #4978 from adrianschroeter/attribute_blame_view
Browse files Browse the repository at this point in the history
[api] fix view=blame for attributes
  • Loading branch information
ChrisBr committed Jun 11, 2018
2 parents 368ca49 + c50d3f3 commit fc4f369
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 fc4f369

Please sign in to comment.