Skip to content

Commit

Permalink
[webui] Fix build log for multibuild and local link packages
Browse files Browse the repository at this point in the history
The @Package variable was set in the check_build_log_access before filter.
However, for multibuild and local link packages this was set to the parent package (follow_mulitbuild / follow_project_links)
which does not contain a log file. This resulted that set_initial_offset returned an empty log and calculated no offset
which eventually resulted in cutting the end of the log files.
Fix #2651.
  • Loading branch information
ChrisBr committed Apr 19, 2017
1 parent aca0b0b commit 8ab4548
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -838,6 +838,7 @@ def update_build_log

check_ajax

@package = params[:package]
# Make sure objects don't contain invalid chars (eg. '../')
@repo = @project.repositories.find_by(name: params[:repository]).try(:name)
unless @repo
Expand Down Expand Up @@ -869,7 +870,6 @@ def update_build_log
return
end

@package = params[:package]
begin
chunk = get_log_chunk(@project, @package, @repo, @arch, @offset, @offset + @maxsize)

Expand Down
29 changes: 29 additions & 0 deletions src/api/spec/controllers/webui/package_controller_spec.rb
Expand Up @@ -819,4 +819,33 @@ def do_request(params)
end
end
end

describe 'GET #update_build_log' do
let(:architecture) { repo_for_source_project.architectures.first }
let(:params) {
{ project: source_project,
package: "#{source_package}:multibuild-package",
repository: repo_for_source_project.name,
arch: architecture.name}
}

context 'for multibuild package' do
context 'instance variables' do
before do
get :update_build_log, params: params, xhr: true
end

# This is fine as backend does not need to run to test this. Otherwise it would be necessary to create first a multibuild package in the backend
it { expect(assigns(:log_chunk)).to match(/No live log available:/) }
it { expect(assigns(:package)).to eq("#{source_package}:multibuild-package") }
it { expect(assigns(:project)).to eq(source_project) }
end

it "should call 'get_size_of_log' with appropriate arguments" do
expect(controller).to receive(:get_size_of_log).
with(source_project, "#{source_package}:multibuild-package", repo_for_source_project.name, architecture.name)
get :update_build_log, params: params, xhr: true
end
end
end
end

0 comments on commit 8ab4548

Please sign in to comment.