Skip to content

Commit

Permalink
[api] render only matching products in binary search
Browse files Browse the repository at this point in the history
but include version information now
  • Loading branch information
adrianschroeter committed Sep 2, 2014
1 parent 65c674f commit afc66ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 14 additions & 9 deletions src/api/app/models/binary_release.rb
Expand Up @@ -25,16 +25,12 @@ def update_for_product
self.repository.product_update_repositories.map{ |i| i.product if i.product }
end

def on_product_medium
self.repository.product_medium
def product_medium
self.repository.product_medium.where(name: medium).first
end

# def on_product_medium
# return [] unless medium
# self.repository.product_medium.where("repository.product_medium.name" => medium).map{ |i| i.product if i.product }
# end

def render_attributes
# renders all values, which are used as identifier of a binary entry.
p = { :project => repository.project.name,
:repository => repository.name,
}
Expand Down Expand Up @@ -71,8 +67,17 @@ def render_xml
b.updatefor(project: up.package.project.name, product: up.name)
end

on_product_medium.uniq.each do |opm|
b.product(project: opm.product.package.project.name, name: opm.product.name, medium: opm.name)
if self.product_medium
product = self.product_medium.product
h = {project: product.package.project.name, name: product.name}
if product.baseversion
h[:baseversion] = product.baseversion
h[:patchlevel] = product.patchlevel
else
h[:version] = product.version
end
h[:release] = product.release if product.release
b.product(h)
end

end
Expand Down
4 changes: 2 additions & 2 deletions src/api/test/functional/binary_release_test.rb
Expand Up @@ -70,7 +70,7 @@ def test_search_binary_release_in_fixtures
assert_response :success
assert_xml_tag :tag => "binary", :attributes => { :project => "BaseDistro3", :repository => "BaseDistro3_repo", :name => "package", :version => "1.0", :release => "1", :arch => "i586", :medium => "DVD"}
assert_xml_tag :tag => "updatefor", :attributes => { project: "BaseDistro", product: "fixed" }
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", medium: "DVD" }
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", version: "1.2" }
get '/search/released/binary', match: "product/[@project = 'BaseDistro' and @name = 'fixed' and @medium = 'DVD']"
assert_response :success
assert_xml_tag :tag => "binary", :attributes => { :project => "BaseDistro3", :repository => "BaseDistro3_repo", :name => "package", :version => "1.0", :release => "1", :arch => "i586", :medium => "DVD"}
Expand All @@ -86,7 +86,7 @@ def test_search_binary_release_in_fixtures
assert_response :success
assert_xml_tag :tag => "binary", :attributes => { :project => "BaseDistro3", :repository => "BaseDistro3_repo", :name => "package", :version => "1.0", :release => "1", :arch => "i586"}
assert_xml_tag :tag => "updatefor", :attributes => { project: "BaseDistro", product: "fixed" }
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", medium: "DVD" }
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", version: "1.2" }

end

Expand Down

0 comments on commit afc66ab

Please sign in to comment.