Skip to content

Commit

Permalink
[webui] Fix Build Reason in multibuild binary view
Browse files Browse the repository at this point in the history
We were using the `Package` object for asking for the build reason
getting the one for the container in the case of multibuild.
  • Loading branch information
Ana06 authored and bgeuken committed May 3, 2018
1 parent 26237a8 commit 40b3741
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ class BuildReasonController < WebuiController
before_action :set_architecture

def index
@details = @package.last_build_reason(@repository, @architecture.name)

@details = @package.last_build_reason(@repository, @architecture.name, @package_name)
return if @details.explain

redirect_back(fallback_location: package_binaries_path(package: @package, project: @project, repository: @repository.name),
Expand All @@ -18,6 +17,8 @@ def index
private

def set_package
# Store the package name in case of multibuilds
@package_name = params[:package_name]
@package = ::Package.get_by_project_and_name(@project.to_param, params[:package_name],
use_source: false, follow_project_links: true, follow_multibuild: true)
@is_link = @package.is_link? || @package.is_local_link?
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1439,12 +1439,12 @@ def self.what_depends_on(project, package, repository, architecture)
[]
end

def last_build_reason(repo, arch)
def last_build_reason(repo, arch, package_name = nil)
repo = repo.name if repo.is_a? Repository

xml_data = Nokogiri::XML(BuildReasonFile.new(
project_name: project.name,
package_name: name,
package_name: package_name || name,
repo: repo,
arch: arch
).to_s).xpath('reason')
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/views/webui/packages/build_reason/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:ruby
@pagetitle = "Build Reason for #{@project} / #{@package}"
@pagetitle = "Build Reason for #{@project} / #{@package_name}"
@metarobots = 'index,nofollow'
build_reason_breadcrumb(@project, @package, "Build Reason (#{@repository.name} / #{params[:arch]})")

Expand All @@ -10,7 +10,7 @@
Repository / Architecture: #{params[:repository]} / #{params[:arch]}

%p
= link_to("<= Go back to binaries", package_binaries_path(controller: '/webui/package', project: @project, package: @package, repository: @repository.name ))
= link_to("<= Go back to binaries", package_binaries_path(controller: '/webui/package', project: @project, package: @package_name, repository: @repository.name ))

%p
%strong
Expand Down
4 changes: 2 additions & 2 deletions src/api/spec/controllers/webui/package_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ def do_request(params)
context 'when backend returns statistics' do
before do
allow(Statistic).to receive(:find_hashed).
with(project: source_project, package: source_package, repository: repository.name, arch: 'i586').
with(project: source_project, package: source_package.name, repository: repository.name, arch: 'i586').
and_return(disk: { usage: 20, size: 30 })

get :statistics, params: { project: source_project, package: source_package, arch: 'i586', repository: repository.name }
Expand All @@ -1324,7 +1324,7 @@ def do_request(params)
context 'when backend raises an exception' do
before do
allow(Statistic).to receive(:find_hashed).
with(project: source_project, package: source_package, repository: repository.name, arch: 'i586').
with(project: source_project, package: source_package.name, repository: repository.name, arch: 'i586').
and_raise(ActiveXML::Transport::ForbiddenError)

get :statistics, params: { project: source_project, package: source_package, arch: 'i586', repository: repository.name }
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/features/webui/packages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

scenario 'via binaries view' do
allow(Buildresult).to receive(:find_hashed).
with(project: user.home_project, package: package, repository: repository.name, view: ['binarylist', 'status']).
with(project: user.home_project, package: package.name, repository: repository.name, view: ['binarylist', 'status']).
and_return(Xmlhash.parse(fake_buildresult))

visit package_binaries_path(project: user.home_project, package: package, repository: repository.name)
Expand Down

0 comments on commit 40b3741

Please sign in to comment.