Skip to content

Commit

Permalink
Merge pull request #8474 from vpereira/refactor_routes_patchinfo
Browse files Browse the repository at this point in the history
Refactor routes patchinfo
  • Loading branch information
vpereira committed Oct 1, 2019
2 parents 9fe2000 + 39cebb2 commit fae8771
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/patchinfo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def destroy
if @package.check_weak_dependencies? && @package.destroy
redirect_to(project_show_path(@project), success: 'Patchinfo was successfully removed.')
else
redirect_to(patchinfo_show_path(package: @package, project: @project),
redirect_to(show_patchinfo_path(package: @package, project: @project),
notice: "Patchinfo can't be removed: #{@package.errors.full_messages.to_sentence}")
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/maintenance_incident_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def summary_cell(incident, patchinfo)

def category_cell(incident, patchinfo)
if patchinfo.present?
link_to(patchinfo[:category], patchinfo_show_path(project: incident.name, package: 'patchinfo'),
link_to(patchinfo[:category], show_patchinfo_path(project: incident.name, package: 'patchinfo'),
class: "patchinfo-category-#{patchinfo[:category]}")
else
link_to(patchinfo_path(project: incident.name, package: 'patchinfo'), method: :post, class: 'text-danger') do
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/package/_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
= tab_link('Overview', package_show_path(project, package))
- if package.name == 'patchinfo'
%li.nav-item
= tab_link('Details', patchinfo_show_path(project, package))
= tab_link('Details', show_patchinfo_path(project, package))
- unless @spider_bot
%li.nav-item
= tab_link('Repositories', repositories_path(project, package))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%li
%i.fas.fa-info-circle.text-info
Has a
= link_to 'patchinfo', patchinfo_show_path(package: package, project: project)
= link_to 'patchinfo', show_patchinfo_path(package: package, project: project)
for
= link_to 'maintenance updates', 'http://en.opensuse.org/Portal:Maintenance'
2 changes: 1 addition & 1 deletion src/api/app/views/webui/patchinfo/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.card-body
%h3= @pagetitle

= form_for(@patchinfo, url: update_patchinfo_path(project: @project, package: @package), method: :put, html: { id: 'patchinfo' }) do |form|
= form_for(@patchinfo, url: patchinfo_path(project: @project, package: @package), method: :put, html: { id: 'patchinfo' }) do |form|
= form.hidden_field(:name)
.form-group.col-md-8.col-lg-4
= render partial: 'webui/shared/autocomplete', locals: { html_id: 'patchinfo[packager]', label: 'Packager', value: @patchinfo.packager,
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/patchinfo/form/_issues.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
target: '_blank', rel: 'noopener') do
List of supported trackers.
= text_field_tag(:issue_ids, '', class: 'form-control w-auto d-inline-block')
= link_to(patchinfo_new_tracker_url, id: 'add-issues', title: 'Add Issues', remote: true, data: { dataType: 'json', project: project.name }) do
= link_to(new_tracker_patchinfo_url, id: 'add-issues', title: 'Add Issues', remote: true, data: { dataType: 'json', project: project.name }) do
%i.fas.fa-plus-circle.text-primary
%i.fas.fa-spinner.fa-spin.d-none
Add issues
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- if has_patchinfo
%li.list-inline-item
= link_to(patchinfo_show_path(project, 'patchinfo'), class: 'nav-link') do
= link_to(show_patchinfo_path(project, 'patchinfo'), class: 'nav-link') do
%span.fa-stack.half-font-size.text-secondary
%i.far.fa-file.fa-stack-2x
%i.fas.fa-search.fa-stack-1x
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%li
%i.fa.fa-check-circle.text-success
= link_to(patchinfo_show_path(project, 'patchinfo')) do
= link_to(show_patchinfo_path(project, 'patchinfo')) do
Patchinfo present
12 changes: 4 additions & 8 deletions src/api/config/routes/webui_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,10 @@
end
end

controller 'webui/patchinfo' do
post 'patchinfo' => :create
get 'patchinfo/edit' => :edit, as: 'edit_patchinfo'
put 'patchinfo/:project/:package' => :update, constraints: cons, as: 'update_patchinfo'
delete 'patchinfo' => :destroy
post 'patchinfo/update_issues/:project/:package' => :update_issues, as: 'update_issues_patchinfo'
get 'patchinfo/show/:project/:package' => :show, as: 'patchinfo_show', constraints: cons, defaults: { format: 'html' }
get 'patchinfo/new_tracker' => :new_tracker
resource :patchinfo, except: [:show], controller: 'webui/patchinfo' do
get 'new_tracker' => :new_tracker
post 'update_issues/:project/:package' => :update_issues, as: :update_issues
get 'show/:project/:package' => :show, as: :show, constraints: cons
end

controller 'webui/repositories' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def do_proper_post_save
end

it { expect(flash[:notice]).to eq("Patchinfo can't be removed: ") }
it { expect(response).to redirect_to(patchinfo_show_path(package: patchinfo_package, project: user.home_project)) }
it { expect(response).to redirect_to(show_patchinfo_path(package: patchinfo_package, project: user.home_project)) }
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/api/spec/features/webui/patchinfo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
fill_in 'patchinfo[summary]', with: 'A' * 15
fill_in 'patchinfo[description]', with: 'A' * 55
click_button 'Save'
expect(page).to have_current_path(patchinfo_show_path(project: project, package: 'patchinfo'))
expect(page).to have_current_path(show_patchinfo_path(project: project, package: 'patchinfo'))
expect(page).to have_text('Successfully edited patchinfo')
end
end
Expand All @@ -52,7 +52,7 @@
end

scenario 'delete' do
visit patchinfo_show_path(project: project, package: 'patchinfo')
visit show_patchinfo_path(project: project, package: 'patchinfo')
expect(page).to have_link('Delete patchinfo')
click_link('Delete patchinfo')
within('#delete-patchinfo-modal') do
Expand Down

0 comments on commit fae8771

Please sign in to comment.