@@ -22,14 +22,14 class WikiController < ApplicationController | |||||
22 | before_filter :find_wiki, :authorize |
|
22 | before_filter :find_wiki, :authorize | |
23 | before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] |
|
23 | before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] | |
24 |
|
24 | |||
25 |
verify :method => :post, :only => [:destroy, :protect], :redirect_to => { :action => : |
|
25 | verify :method => :post, :only => [:destroy, :protect], :redirect_to => { :action => :show } | |
26 |
|
26 | |||
27 | helper :attachments |
|
27 | helper :attachments | |
28 | include AttachmentsHelper |
|
28 | include AttachmentsHelper | |
29 | helper :watchers |
|
29 | helper :watchers | |
30 |
|
30 | |||
31 | # display a page (in editing mode if it doesn't exist) |
|
31 | # display a page (in editing mode if it doesn't exist) | |
32 | def index |
|
32 | def show | |
33 | page_title = params[:page] |
|
33 | page_title = params[:page] | |
34 | @page = @wiki.find_or_new_page(page_title) |
|
34 | @page = @wiki.find_or_new_page(page_title) | |
35 | if @page.new_record? |
|
35 | if @page.new_record? | |
@@ -79,7 +79,7 class WikiController < ApplicationController | |||||
79 | attachments = Attachment.attach_files(@page, params[:attachments]) |
|
79 | attachments = Attachment.attach_files(@page, params[:attachments]) | |
80 | render_attachment_warning_if_needed(@page) |
|
80 | render_attachment_warning_if_needed(@page) | |
81 | # don't save if text wasn't changed |
|
81 | # don't save if text wasn't changed | |
82 |
redirect_to :action => ' |
|
82 | redirect_to :action => 'show', :project_id => @project, :page => @page.title | |
83 | return |
|
83 | return | |
84 | end |
|
84 | end | |
85 | #@content.text = params[:content][:text] |
|
85 | #@content.text = params[:content][:text] | |
@@ -91,7 +91,7 class WikiController < ApplicationController | |||||
91 | attachments = Attachment.attach_files(@page, params[:attachments]) |
|
91 | attachments = Attachment.attach_files(@page, params[:attachments]) | |
92 | render_attachment_warning_if_needed(@page) |
|
92 | render_attachment_warning_if_needed(@page) | |
93 | call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) |
|
93 | call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) | |
94 |
redirect_to :action => ' |
|
94 | redirect_to :action => 'show', :project_id => @project, :page => @page.title | |
95 | end |
|
95 | end | |
96 | end |
|
96 | end | |
97 | rescue ActiveRecord::StaleObjectError |
|
97 | rescue ActiveRecord::StaleObjectError | |
@@ -107,13 +107,13 class WikiController < ApplicationController | |||||
107 | @original_title = @page.pretty_title |
|
107 | @original_title = @page.pretty_title | |
108 | if request.post? && @page.update_attributes(params[:wiki_page]) |
|
108 | if request.post? && @page.update_attributes(params[:wiki_page]) | |
109 | flash[:notice] = l(:notice_successful_update) |
|
109 | flash[:notice] = l(:notice_successful_update) | |
110 |
redirect_to :action => ' |
|
110 | redirect_to :action => 'show', :project_id => @project, :page => @page.title | |
111 | end |
|
111 | end | |
112 | end |
|
112 | end | |
113 |
|
113 | |||
114 | def protect |
|
114 | def protect | |
115 | @page.update_attribute :protected, params[:protected] |
|
115 | @page.update_attribute :protected, params[:protected] | |
116 |
redirect_to :action => ' |
|
116 | redirect_to :action => 'show', :project_id => @project, :page => @page.title | |
117 | end |
|
117 | end | |
118 |
|
118 | |||
119 | # show page history |
|
119 | # show page history | |
@@ -176,7 +176,7 class WikiController < ApplicationController | |||||
176 | export = render_to_string :action => 'export_multiple', :layout => false |
|
176 | export = render_to_string :action => 'export_multiple', :layout => false | |
177 | send_data(export, :type => 'text/html', :filename => "wiki.html") |
|
177 | send_data(export, :type => 'text/html', :filename => "wiki.html") | |
178 | else |
|
178 | else | |
179 |
redirect_to :action => ' |
|
179 | redirect_to :action => 'show', :project_id => @project, :page => nil | |
180 | end |
|
180 | end | |
181 | end |
|
181 | end | |
182 |
|
182 | |||
@@ -204,7 +204,7 class WikiController < ApplicationController | |||||
204 | return render_403 unless editable? |
|
204 | return render_403 unless editable? | |
205 | attachments = Attachment.attach_files(@page, params[:attachments]) |
|
205 | attachments = Attachment.attach_files(@page, params[:attachments]) | |
206 | render_attachment_warning_if_needed(@page) |
|
206 | render_attachment_warning_if_needed(@page) | |
207 |
redirect_to :action => ' |
|
207 | redirect_to :action => 'show', :page => @page.title | |
208 | end |
|
208 | end | |
209 |
|
209 | |||
210 | private |
|
210 | private |
@@ -182,7 +182,7 module ApplicationHelper | |||||
182 | content << "<ul class=\"pages-hierarchy\">\n" |
|
182 | content << "<ul class=\"pages-hierarchy\">\n" | |
183 | pages[node].each do |page| |
|
183 | pages[node].each do |page| | |
184 | content << "<li>" |
|
184 | content << "<li>" | |
185 |
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => ' |
|
185 | content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :page => page.title}, | |
186 | :title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) |
|
186 | :title => (page.respond_to?(:updated_on) ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) | |
187 | content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id] |
|
187 | content << "\n" + render_page_hierarchy(pages, page.id) if pages[page.id] | |
188 | content << "</li>\n" |
|
188 | content << "</li>\n" | |
@@ -551,7 +551,7 module ApplicationHelper | |||||
551 | when :local; "#{title}.html" |
|
551 | when :local; "#{title}.html" | |
552 | when :anchor; "##{title}" # used for single-file wiki export |
|
552 | when :anchor; "##{title}" # used for single-file wiki export | |
553 | else |
|
553 | else | |
554 |
url_for(:only_path => only_path, :controller => 'wiki', :action => ' |
|
554 | url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project, :page => Wiki.titleize(page), :anchor => anchor) | |
555 | end |
|
555 | end | |
556 | link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) |
|
556 | link_to((title || page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new'))) | |
557 | else |
|
557 | else |
@@ -4,6 +4,6 | |||||
4 |
|
4 | |||
5 | <h3><%= l(:label_wiki) %></h3> |
|
5 | <h3><%= l(:label_wiki) %></h3> | |
6 |
|
6 | |||
7 |
<%= link_to l(:field_start_page), {:action => ' |
|
7 | <%= link_to l(:field_start_page), {:action => 'show', :page => nil} %><br /> | |
8 | <%= link_to l(:label_index_by_title), {:action => 'page_index'} %><br /> |
|
8 | <%= link_to l(:label_index_by_title), {:action => 'page_index'} %><br /> | |
9 | <%= link_to l(:label_index_by_date), {:action => 'date_index'} %><br /> |
|
9 | <%= link_to l(:label_index_by_date), {:action => 'date_index'} %><br /> |
@@ -6,7 +6,7 | |||||
6 | <h2><%= @page.pretty_title %></h2> |
|
6 | <h2><%= @page.pretty_title %></h2> | |
7 |
|
7 | |||
8 | <p> |
|
8 | <p> | |
9 |
<%= l(:label_version) %> <%= link_to @annotate.content.version, :action => ' |
|
9 | <%= l(:label_version) %> <%= link_to @annotate.content.version, :action => 'show', :page => @page.title, :version => @annotate.content.version %> | |
10 | <em>(<%= @annotate.content.author ? @annotate.content.author.name : "anonyme" %>, <%= format_time(@annotate.content.updated_on) %>)</em> |
|
10 | <em>(<%= @annotate.content.author ? @annotate.content.author.name : "anonyme" %>, <%= format_time(@annotate.content.updated_on) %>)</em> | |
11 | </p> |
|
11 | </p> | |
12 |
|
12 | |||
@@ -18,7 +18,7 | |||||
18 | <% @annotate.lines.each do |line| -%> |
|
18 | <% @annotate.lines.each do |line| -%> | |
19 | <tr class="bloc-<%= colors[line[0]] %>"> |
|
19 | <tr class="bloc-<%= colors[line[0]] %>"> | |
20 | <th class="line-num"><%= line_num %></th> |
|
20 | <th class="line-num"><%= line_num %></th> | |
21 |
<td class="revision"><%= link_to line[0], :controller => 'wiki', :action => ' |
|
21 | <td class="revision"><%= link_to line[0], :controller => 'wiki', :action => 'show', :project_id => @project, :page => @page.title, :version => line[0] %></td> | |
22 | <td class="author"><%= h(line[1]) %></td> |
|
22 | <td class="author"><%= h(line[1]) %></td> | |
23 | <td class="line-code"><pre><%=h line[2] %></pre></td> |
|
23 | <td class="line-code"><pre><%=h line[2] %></pre></td> | |
24 | </tr> |
|
24 | </tr> |
@@ -12,7 +12,7 | |||||
12 | <h3><%= format_date(date) %></h3> |
|
12 | <h3><%= format_date(date) %></h3> | |
13 | <ul> |
|
13 | <ul> | |
14 | <% @pages_by_date[date].each do |page| %> |
|
14 | <% @pages_by_date[date].each do |page| %> | |
15 |
<li><%= link_to page.pretty_title, :action => ' |
|
15 | <li><%= link_to page.pretty_title, :action => 'show', :page => page.title %></li> | |
16 | <% end %> |
|
16 | <% end %> | |
17 | </ul> |
|
17 | </ul> | |
18 | <% end %> |
|
18 | <% end %> | |
@@ -23,11 +23,11 | |||||
23 |
|
23 | |||
24 | <% unless @pages.empty? %> |
|
24 | <% unless @pages.empty? %> | |
25 | <% other_formats_links do |f| %> |
|
25 | <% other_formats_links do |f| %> | |
26 |
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => ' |
|
26 | <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'show', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> | |
27 | <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> |
|
27 | <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> | |
28 | <% end %> |
|
28 | <% end %> | |
29 | <% end %> |
|
29 | <% end %> | |
30 |
|
30 | |||
31 | <% content_for :header_tags do %> |
|
31 | <% content_for :header_tags do %> | |
32 |
<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => ' |
|
32 | <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'show', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %> | |
33 | <% end %> |
|
33 | <% end %> |
@@ -15,5 +15,5 | |||||
15 | </div> |
|
15 | </div> | |
16 |
|
16 | |||
17 | <%= submit_tag l(:button_apply) %> |
|
17 | <%= submit_tag l(:button_apply) %> | |
18 |
<%= link_to l(:button_cancel), :controller => 'wiki', :action => ' |
|
18 | <%= link_to l(:button_cancel), :controller => 'wiki', :action => 'show', :project_id => @project, :page => @page.title %> | |
19 | <% end %> |
|
19 | <% end %> |
@@ -5,10 +5,10 | |||||
5 | <h2><%= @page.pretty_title %></h2> |
|
5 | <h2><%= @page.pretty_title %></h2> | |
6 |
|
6 | |||
7 | <p> |
|
7 | <p> | |
8 |
<%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => ' |
|
8 | <%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => 'show', :page => @page.title, :version => @diff.content_from.version %> | |
9 | <em>(<%= @diff.content_from.author ? @diff.content_from.author.name : "anonyme" %>, <%= format_time(@diff.content_from.updated_on) %>)</em> |
|
9 | <em>(<%= @diff.content_from.author ? @diff.content_from.author.name : "anonyme" %>, <%= format_time(@diff.content_from.updated_on) %>)</em> | |
10 | → |
|
10 | → | |
11 |
<%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => ' |
|
11 | <%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => 'show', :page => @page.title, :version => @diff.content_to.version %>/<%= @page.content.version %> | |
12 | <em>(<%= @diff.content_to.author ? @diff.content_to.author.name : "anonyme" %>, <%= format_time(@diff.content_to.updated_on) %>)</em> |
|
12 | <em>(<%= @diff.content_to.author ? @diff.content_to.author.name : "anonyme" %>, <%= format_time(@diff.content_to.updated_on) %>)</em> | |
13 | </p> |
|
13 | </p> | |
14 |
|
14 |
@@ -19,7 +19,7 | |||||
19 | <% line_num = 1 %> |
|
19 | <% line_num = 1 %> | |
20 | <% @versions.each do |ver| %> |
|
20 | <% @versions.each do |ver| %> | |
21 | <tr class="<%= cycle("odd", "even") %>"> |
|
21 | <tr class="<%= cycle("odd", "even") %>"> | |
22 |
<td class="id"><%= link_to ver.version, :action => ' |
|
22 | <td class="id"><%= link_to ver.version, :action => 'show', :page => @page.title, :version => ver.version %></td> | |
23 | <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < @versions.size) %></td> |
|
23 | <td class="checkbox"><%= radio_button_tag('version', ver.version, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < @versions.size) %></td> | |
24 | <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %></td> |
|
24 | <td class="checkbox"><%= radio_button_tag('version_from', ver.version, (line_num==2), :id => "cbto-#{line_num}") if show_diff && (line_num > 1) %></td> | |
25 | <td align="center"><%= format_time(ver.updated_on) %></td> |
|
25 | <td align="center"><%= format_time(ver.updated_on) %></td> |
@@ -16,11 +16,11 | |||||
16 |
|
16 | |||
17 | <% unless @pages.empty? %> |
|
17 | <% unless @pages.empty? %> | |
18 | <% other_formats_links do |f| %> |
|
18 | <% other_formats_links do |f| %> | |
19 |
<%= f.link_to 'Atom', :url => {:controller => 'activities', :action => ' |
|
19 | <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'show', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %> | |
20 | <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> |
|
20 | <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %> | |
21 | <% end %> |
|
21 | <% end %> | |
22 | <% end %> |
|
22 | <% end %> | |
23 |
|
23 | |||
24 | <% content_for :header_tags do %> |
|
24 | <% content_for :header_tags do %> | |
25 |
<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => ' |
|
25 | <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'show', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %> | |
26 | <% end %> |
|
26 | <% end %> |
@@ -15,11 +15,11 | |||||
15 |
|
15 | |||
16 | <% if @content.version != @page.content.version %> |
|
16 | <% if @content.version != @page.content.version %> | |
17 | <p> |
|
17 | <p> | |
18 |
<%= link_to(('« ' + l(:label_previous)), :action => ' |
|
18 | <%= link_to(('« ' + l(:label_previous)), :action => 'show', :page => @page.title, :version => (@content.version - 1)) + " - " if @content.version > 1 %> | |
19 | <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %> |
|
19 | <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %> | |
20 | <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => @page.title, :version => @content.version) + ')' if @content.version > 1 %> - |
|
20 | <%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :page => @page.title, :version => @content.version) + ')' if @content.version > 1 %> - | |
21 |
<%= link_to((l(:label_next) + ' »'), :action => ' |
|
21 | <%= link_to((l(:label_next) + ' »'), :action => 'show', :page => @page.title, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %> | |
22 |
<%= link_to(l(:label_current_version), :action => ' |
|
22 | <%= link_to(l(:label_current_version), :action => 'show', :page => @page.title) %> | |
23 | <br /> |
|
23 | <br /> | |
24 | <em><%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %> </em><br /> |
|
24 | <em><%= @content.author ? @content.author.name : "anonyme" %>, <%= format_time(@content.updated_on) %> </em><br /> | |
25 | <%=h @content.comments %> |
|
25 | <%=h @content.comments %> |
@@ -32,7 +32,7 ActionController::Routing::Routes.draw do |map| | |||||
32 | wiki_views.connect 'projects/:project_id/wiki/export', :action => 'export' |
|
32 | wiki_views.connect 'projects/:project_id/wiki/export', :action => 'export' | |
33 | wiki_views.connect 'projects/:project_id/wiki/page_index', :action => 'page_index' |
|
33 | wiki_views.connect 'projects/:project_id/wiki/page_index', :action => 'page_index' | |
34 | wiki_views.connect 'projects/:project_id/wiki/date_index', :action => 'date_index' |
|
34 | wiki_views.connect 'projects/:project_id/wiki/date_index', :action => 'date_index' | |
35 |
wiki_views.connect 'projects/:project_id/wiki/:page', :action => ' |
|
35 | wiki_views.connect 'projects/:project_id/wiki/:page', :action => 'show', :page => nil | |
36 | wiki_views.connect 'projects/:project_id/wiki/:page/edit', :action => 'edit' |
|
36 | wiki_views.connect 'projects/:project_id/wiki/:page/edit', :action => 'edit' | |
37 | wiki_views.connect 'projects/:project_id/wiki/:page/rename', :action => 'rename' |
|
37 | wiki_views.connect 'projects/:project_id/wiki/:page/rename', :action => 'rename' | |
38 | wiki_views.connect 'projects/:project_id/wiki/:page/history', :action => 'history' |
|
38 | wiki_views.connect 'projects/:project_id/wiki/:page/history', :action => 'history' |
@@ -111,7 +111,7 Redmine::AccessControl.map do |map| | |||||
111 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
111 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |
112 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
112 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |
113 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
113 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |
114 |
map.permission :view_wiki_pages, :wiki => [: |
|
114 | map.permission :view_wiki_pages, :wiki => [:show, :special, :page_index, :date_index] | |
115 | map.permission :export_wiki_pages, :wiki => [:export] |
|
115 | map.permission :export_wiki_pages, :wiki => [:export] | |
116 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
116 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] | |
117 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] |
|
117 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment] | |
@@ -195,7 +195,7 Redmine::MenuManager.map :project_menu do |menu| | |||||
195 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar |
|
195 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar | |
196 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
196 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural | |
197 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
197 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural | |
198 |
menu.push :wiki, { :controller => 'wiki', :action => ' |
|
198 | menu.push :wiki, { :controller => 'wiki', :action => 'show', :page => nil }, :param => :project_id, | |
199 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
199 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } | |
200 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
200 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, | |
201 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
201 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
@@ -32,7 +32,7 class WikiControllerTest < ActionController::TestCase | |||||
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_show_start_page |
|
34 | def test_show_start_page | |
35 |
get : |
|
35 | get :show, :project_id => 'ecookbook' | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'show' |
|
37 | assert_template 'show' | |
38 | assert_tag :tag => 'h1', :content => /CookBook documentation/ |
|
38 | assert_tag :tag => 'h1', :content => /CookBook documentation/ | |
@@ -45,7 +45,7 class WikiControllerTest < ActionController::TestCase | |||||
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def test_show_page_with_name |
|
47 | def test_show_page_with_name | |
48 |
get : |
|
48 | get :show, :project_id => 1, :page => 'Another_page' | |
49 | assert_response :success |
|
49 | assert_response :success | |
50 | assert_template 'show' |
|
50 | assert_template 'show' | |
51 | assert_tag :tag => 'h1', :content => /Another page/ |
|
51 | assert_tag :tag => 'h1', :content => /Another page/ | |
@@ -60,20 +60,20 class WikiControllerTest < ActionController::TestCase | |||||
60 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') |
|
60 | page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') | |
61 | page.save! |
|
61 | page.save! | |
62 |
|
62 | |||
63 |
get : |
|
63 | get :show, :project_id => 1, :page => 'Another_page' | |
64 | assert_response :success |
|
64 | assert_response :success | |
65 | assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, |
|
65 | assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, | |
66 | :content => /Side bar content for test_show_with_sidebar/ |
|
66 | :content => /Side bar content for test_show_with_sidebar/ | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | def test_show_unexistent_page_without_edit_right |
|
69 | def test_show_unexistent_page_without_edit_right | |
70 |
get : |
|
70 | get :show, :project_id => 1, :page => 'Unexistent page' | |
71 | assert_response 404 |
|
71 | assert_response 404 | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def test_show_unexistent_page_with_edit_right |
|
74 | def test_show_unexistent_page_with_edit_right | |
75 | @request.session[:user_id] = 2 |
|
75 | @request.session[:user_id] = 2 | |
76 |
get : |
|
76 | get :show, :project_id => 1, :page => 'Unexistent page' | |
77 | assert_response :success |
|
77 | assert_response :success | |
78 | assert_template 'edit' |
|
78 | assert_template 'edit' | |
79 | end |
|
79 | end | |
@@ -85,7 +85,7 class WikiControllerTest < ActionController::TestCase | |||||
85 | :content => {:comments => 'Created the page', |
|
85 | :content => {:comments => 'Created the page', | |
86 | :text => "h1. New page\n\nThis is a new page", |
|
86 | :text => "h1. New page\n\nThis is a new page", | |
87 | :version => 0} |
|
87 | :version => 0} | |
88 |
assert_redirected_to :action => ' |
|
88 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'New_page' | |
89 | page = Project.find(1).wiki.find_page('New page') |
|
89 | page = Project.find(1).wiki.find_page('New page') | |
90 | assert !page.new_record? |
|
90 | assert !page.new_record? | |
91 | assert_not_nil page.content |
|
91 | assert_not_nil page.content | |
@@ -176,7 +176,7 class WikiControllerTest < ActionController::TestCase | |||||
176 | post :rename, :project_id => 1, :page => 'Another_page', |
|
176 | post :rename, :project_id => 1, :page => 'Another_page', | |
177 | :wiki_page => { :title => 'Another renamed page', |
|
177 | :wiki_page => { :title => 'Another renamed page', | |
178 | :redirect_existing_links => 1 } |
|
178 | :redirect_existing_links => 1 } | |
179 |
assert_redirected_to :action => ' |
|
179 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'Another_renamed_page' | |
180 | wiki = Project.find(1).wiki |
|
180 | wiki = Project.find(1).wiki | |
181 | # Check redirects |
|
181 | # Check redirects | |
182 | assert_not_nil wiki.find_page('Another page') |
|
182 | assert_not_nil wiki.find_page('Another page') | |
@@ -188,7 +188,7 class WikiControllerTest < ActionController::TestCase | |||||
188 | post :rename, :project_id => 1, :page => 'Another_page', |
|
188 | post :rename, :project_id => 1, :page => 'Another_page', | |
189 | :wiki_page => { :title => 'Another renamed page', |
|
189 | :wiki_page => { :title => 'Another renamed page', | |
190 | :redirect_existing_links => "0" } |
|
190 | :redirect_existing_links => "0" } | |
191 |
assert_redirected_to :action => ' |
|
191 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'Another_renamed_page' | |
192 | wiki = Project.find(1).wiki |
|
192 | wiki = Project.find(1).wiki | |
193 | # Check that there's no redirects |
|
193 | # Check that there's no redirects | |
194 | assert_nil wiki.find_page('Another page') |
|
194 | assert_nil wiki.find_page('Another page') | |
@@ -280,7 +280,7 class WikiControllerTest < ActionController::TestCase | |||||
280 | get :export, :project_id => 'ecookbook' |
|
280 | get :export, :project_id => 'ecookbook' | |
281 |
|
281 | |||
282 | should_respond_with :redirect |
|
282 | should_respond_with :redirect | |
283 |
should_redirect_to('wiki index') { {:action => ' |
|
283 | should_redirect_to('wiki index') { {:action => 'show', :project_id => @project, :page => nil} } | |
284 | end |
|
284 | end | |
285 | end |
|
285 | end | |
286 | end |
|
286 | end | |
@@ -298,7 +298,7 class WikiControllerTest < ActionController::TestCase | |||||
298 | end |
|
298 | end | |
299 |
|
299 | |||
300 | def test_not_found |
|
300 | def test_not_found | |
301 |
get : |
|
301 | get :show, :project_id => 999 | |
302 | assert_response 404 |
|
302 | assert_response 404 | |
303 | end |
|
303 | end | |
304 |
|
304 | |||
@@ -307,7 +307,7 class WikiControllerTest < ActionController::TestCase | |||||
307 | assert !page.protected? |
|
307 | assert !page.protected? | |
308 | @request.session[:user_id] = 2 |
|
308 | @request.session[:user_id] = 2 | |
309 | post :protect, :project_id => 1, :page => page.title, :protected => '1' |
|
309 | post :protect, :project_id => 1, :page => page.title, :protected => '1' | |
310 |
assert_redirected_to :action => ' |
|
310 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'Another_page' | |
311 | assert page.reload.protected? |
|
311 | assert page.reload.protected? | |
312 | end |
|
312 | end | |
313 |
|
313 | |||
@@ -316,13 +316,13 class WikiControllerTest < ActionController::TestCase | |||||
316 | assert page.protected? |
|
316 | assert page.protected? | |
317 | @request.session[:user_id] = 2 |
|
317 | @request.session[:user_id] = 2 | |
318 | post :protect, :project_id => 1, :page => page.title, :protected => '0' |
|
318 | post :protect, :project_id => 1, :page => page.title, :protected => '0' | |
319 |
assert_redirected_to :action => ' |
|
319 | assert_redirected_to :action => 'show', :project_id => 'ecookbook', :page => 'CookBook_documentation' | |
320 | assert !page.reload.protected? |
|
320 | assert !page.reload.protected? | |
321 | end |
|
321 | end | |
322 |
|
322 | |||
323 | def test_show_page_with_edit_link |
|
323 | def test_show_page_with_edit_link | |
324 | @request.session[:user_id] = 2 |
|
324 | @request.session[:user_id] = 2 | |
325 |
get : |
|
325 | get :show, :project_id => 1 | |
326 | assert_response :success |
|
326 | assert_response :success | |
327 | assert_template 'show' |
|
327 | assert_template 'show' | |
328 | assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
|
328 | assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } | |
@@ -330,7 +330,7 class WikiControllerTest < ActionController::TestCase | |||||
330 |
|
330 | |||
331 | def test_show_page_without_edit_link |
|
331 | def test_show_page_without_edit_link | |
332 | @request.session[:user_id] = 4 |
|
332 | @request.session[:user_id] = 4 | |
333 |
get : |
|
333 | get :show, :project_id => 1 | |
334 | assert_response :success |
|
334 | assert_response :success | |
335 | assert_template 'show' |
|
335 | assert_template 'show' | |
336 | assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
|
336 | assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } |
@@ -311,8 +311,8 class RoutingTest < ActionController::IntegrationTest | |||||
311 | end |
|
311 | end | |
312 |
|
312 | |||
313 | context "wiki (singular, project's pages)" do |
|
313 | context "wiki (singular, project's pages)" do | |
314 |
should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => ' |
|
314 | should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567' | |
315 |
should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => ' |
|
315 | should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :page => 'lalala' | |
316 | should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :page => 'my_page' |
|
316 | should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :page => 'my_page' | |
317 | should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :page => 'CookBook_documentation' |
|
317 | should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :page => 'CookBook_documentation' | |
318 | should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1' |
|
318 | should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1' |
General Comments 0
You need to be logged in to leave comments.
Login now