Skip to content

Commit f8bc1fe

Browse files
rbtgrRedmine Patch Meetup
authored andcommitted
Move route to /wikis/:wiki_page_id/redirects/:id
1 parent 8e7b0a2 commit f8bc1fe

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

app/controllers/wiki_redirects_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
class WikiRedirectsController < ApplicationController
2121
before_action :find_wiki_redirect
2222

23+
# /projects/{project_id}/wikis/redirects/{id}
24+
# /projects/project-a/wikis/redirects/222
25+
26+
# TODO?
27+
# /projects/{project_id}/wikis/{page}/redirects/{id}
2328
def destroy
2429
@wiki_redirect.destroy
2530
end

app/views/wiki/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
1717
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') %>
1818
<% @redirects_to_self.map { |redirect| %>
19-
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", project_redirect_path(@project, redirect), :class => 'icon icon-link-break') %>
19+
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", {:controller => 'wiki_redirects', :action => 'destroy', :project_id => @project.id, :wiki_page_id => @page.title, :id => redirect.id}, :method => :delete, :class => 'icon icon-link-break') %>
2020
<% } %>
2121
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del') %>
2222
<% else %>

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182

183183
match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
184184
resources :wiki, :except => [:index, :create], :as => 'wiki_page' do
185+
resources :redirects, controller: 'wiki_redirects', only: :destroy
185186
member do
186187
get 'rename'
187188
post 'rename'
@@ -197,7 +198,6 @@
197198
get 'date_index'
198199
post 'new'
199200
# TODO: Move to member
200-
resources :redirects, controller: 'wiki_redirects', only: :destroy
201201
end
202202
end
203203
match 'wiki', :controller => 'wiki', :action => 'show', :via => :get

test/functional/wiki_redirects_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_destroy
3434

3535
wiki_redirect = WikiRedirect.create!(wiki_id: 1, title: 'Test', redirects_to: wiki_page.title, redirects_to_wiki_id: 1)
3636

37-
delete :destroy, params: { id: wiki_redirect.id, project_id: wiki_page.wiki.project_id }
37+
delete :destroy, params: { id: wiki_redirect.id, project_id: wiki_page.wiki.project_id, wiki_page_id: wiki_page.id }
3838

3939
# WikiRedirectが消えていること
4040
assert_not WikiRedirect.where(id: wiki_redirect.id).exists?

0 commit comments

Comments
 (0)