Skip to content

Commit

Permalink
Merge pull request #7284 from DavidKang/bugfix-1125807
Browse files Browse the repository at this point in the history
Remove use_source from require_package
  • Loading branch information
hennevogel committed Mar 29, 2019
2 parents 1cf9e94 + 9ad5b2c commit face877
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/api/app/controllers/webui/webui_controller.rb
Expand Up @@ -259,8 +259,13 @@ def require_package
if params[:package].present?
begin
@package = Package.get_by_project_and_name(@project.to_param, params[:package],
use_source: false, follow_project_links: true, follow_multibuild: true)
rescue APIException # why it's not found is of no concern :)
follow_project_links: true, follow_multibuild: true)
rescue APIException => exception
flash[:error] = if exception.is_a?(Package::ReadSourceAccessError)
"You don't have access to the sources of this package: \"#{params[:package]}\""
else
"Package \"#{params[:package]}\" not found in project \"#{params[:project]}\""
end
end
end

Expand All @@ -269,7 +274,6 @@ def require_package
if request.xhr?
render nothing: true, status: :not_found
else
flash[:error] = "Package \"#{params[:package]}\" not found in project \"#{params[:project]}\""
redirect_to project_show_path(project: @project, nextstatus: 404)
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/spec/controllers/webui/package_controller_spec.rb
Expand Up @@ -627,8 +627,8 @@ def remove_file_post
get :revisions, params: { project: source_project, package: package }
end

it { expect(flash[:error]).to eq('Could not access revisions') }
it { expect(response).to redirect_to(package_show_path(project: source_project.name, package: package.name)) }
it { expect(flash[:error]).to eq("You don't have access to the sources of this package: \"#{package}\"") }
it { expect(response).to redirect_to(project_show_path(project: source_project.name, nextstatus: 404)) }
end

context 'with source access' do
Expand Down

0 comments on commit face877

Please sign in to comment.