Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webui] Refactor package save_file #1313

Merged
merged 2 commits into from
Oct 30, 2015

Conversation

ChrisBr
Copy link
Member

@ChrisBr ChrisBr commented Oct 28, 2015

  • file is sometimes a UploadedFile object which is handled now
  • catches ValidationExceptions and Exception
  • some simplifications

This will fix #1253

redirect_to(:back, :error => 'Timeout when saving file. Please try again.')
elsif file_url.present?
# we have a remote file URI, so we have to download and save it
@services = Service.find(project: @project, package: @package.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the proper method for that:

services = @package.services

I don't see the need of using instance variables here... use locals. They aren't sent to any view/template here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

else
redirect_to({:action => :show, :project => @project, :package => @package}, :success => "The file #{filename} has been added.")

rescue APIException, StandardError => exception
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With APIException & StandardError we can catch all possible exceptions (Suse::ValidationError is an APIException and ActiveXML::Transport::Error and Timeout::Error are StandardError etc.)

@ChrisBr
Copy link
Member Author

ChrisBr commented Oct 29, 2015

@adrianschroeter & @mdeniz

  • fixed your suggestions
  • fixed, refactored and added tests

Please review!

* A new file is an UploadedFile object which caused an Exception in Suse::Validator.validate
because it called to_s on UploadedFile
* Catches and shows now all Excepton
* Some simplifications
* Refactoring and improving of the tests

This closes openSUSE#1253, closes openSUSE#1315
The submit button is disabled as long as not one of the fields is filled out.
@mdeniz
Copy link
Contributor

mdeniz commented Oct 30, 2015

LGTM

@hennevogel
Copy link
Member

👍

hennevogel added a commit that referenced this pull request Oct 30, 2015
[webui] Refactor package save_file
@hennevogel hennevogel merged commit cd48571 into openSUSE:master Oct 30, 2015
@ChrisBr ChrisBr deleted the refactor_save_file branch November 3, 2015 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants