Skip to content

Commit

Permalink
Fix IssueTracker validation errors
Browse files Browse the repository at this point in the history
IssueTracker.create will always return an IssueTracker object,
even if it's not valid.
  • Loading branch information
hennevogel committed Sep 3, 2021
1 parent 12d15af commit bbc8ca5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/api/app/controllers/issue_trackers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def index
# POST /issue_trackers
def create
xml = Nokogiri::XML(request.raw_post, &:strict).root
@issue_tracker = IssueTracker.create(name: xml.xpath('name[1]/text()').to_s,
kind: xml.xpath('kind[1]/text()').to_s,
description: xml.xpath('description[1]/text()').to_s,
regex: xml.xpath('regex[1]/text()').to_s,
label: xml.xpath('label[1]/text()').to_s,
url: xml.xpath('url[1]/text()').to_s,
enable_fetch: xml.xpath('enable-fetch[1]/text()').to_s,
issues_updated: Time.now,
show_url: xml.xpath('show-url[1]/text()').to_s)
@issue_tracker = IssueTracker.new(name: xml.xpath('name[1]/text()').to_s,
kind: xml.xpath('kind[1]/text()').to_s,
description: xml.xpath('description[1]/text()').to_s,
regex: xml.xpath('regex[1]/text()').to_s,
label: xml.xpath('label[1]/text()').to_s,
url: xml.xpath('url[1]/text()').to_s,
enable_fetch: xml.xpath('enable-fetch[1]/text()').to_s,
issues_updated: Time.now,
show_url: xml.xpath('show-url[1]/text()').to_s)
respond_to do |format|
if @issue_tracker
if @issue_tracker.save
format.xml { render_ok }
else
format.xml { render xml: @issue_tracker.errors, status: :unprocessable_entity }
Expand Down

0 comments on commit bbc8ca5

Please sign in to comment.