Skip to content

Commit

Permalink
Merge pull request #3933 from bgeuken/save_meta
Browse files Browse the repository at this point in the history
[webui] Remove unused exception handling
  • Loading branch information
bgeuken committed Oct 2, 2017
2 parents ca31fc6 + 066d9c5 commit 343f2ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,6 @@ def save_meta

rescue Suse::ValidationError => exception
errors << exception.message
rescue Project::UnknownObjectError => exception
errors << "Project with name '#{exception.message}' not found"
end

if errors.empty?
Expand Down
6 changes: 5 additions & 1 deletion src/api/app/models/project/update_from_xml_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def parse_develproject(xmlhash)
if devel
prj_name = devel['project']
if prj_name
develprj = Project.get_by_name(prj_name)
begin
develprj = Project.get_by_name(prj_name)
rescue UnknownObjectError => e
raise UnknownObjectError, "Project with name '#{e.message}' not found"
end
unless develprj
raise SaveError, "value of develproject has to be a existing project (project '#{prj_name}' does not exist)"
end
Expand Down
10 changes: 10 additions & 0 deletions src/api/spec/controllers/webui/project_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,16 @@
it { expect(response).to have_http_status(400) }
end

context 'with an invalid devel project' do
before do
post :save_meta, params: { project: user.home_project,
meta: '<project name="home:tom"><title/><description/><devel project="non-existant"/></project>' }, xhr: true
end

it { expect(flash.now[:error]).to eq("Project with name 'non-existant' not found") }
it { expect(response).to have_http_status(400) }
end

context 'with a valid meta' do
before do
post :save_meta, params: { project: user.home_project, meta: '<project name="home:tom"><title/><description/></project>' }, xhr: true
Expand Down

0 comments on commit 343f2ce

Please sign in to comment.