Merge pull request #1503 from opf/hotfix/9842_new_preview

[Hotfix] 9842 new preview
pull/1734/head
meeee 10 years ago
commit 292c930591
  1. 2
      app/assets/javascripts/application.js.erb
  2. 30
      app/assets/stylesheets/content/_preview.css.sass
  3. 1
      app/assets/stylesheets/default.css.sass
  4. 16
      app/controllers/messages_controller.rb
  5. 19
      app/controllers/news_controller.rb
  6. 28
      app/controllers/wiki_controller.rb
  7. 19
      app/controllers/work_packages_controller.rb
  8. 15
      app/helpers/application_helper.rb
  9. 17
      app/helpers/previews_helper.rb
  10. 5
      app/views/boards/show.html.erb
  11. 10
      app/views/common/preview.html.erb
  12. 5
      app/views/messages/edit.html.erb
  13. 5
      app/views/messages/new.html.erb
  14. 8
      app/views/messages/show.html.erb
  15. 5
      app/views/news/edit.html.erb
  16. 5
      app/views/news/new.html.erb
  17. 5
      app/views/news/show.html.erb
  18. 11
      app/views/wiki/edit.html.erb
  19. 8
      app/views/wiki/new.html.erb
  20. 50
      app/views/work_packages/preview.html.erb
  21. 2
      config/locales/de.yml
  22. 2
      config/locales/en.yml
  23. 23
      config/routes.rb
  24. 109
      lib/open_project/concerns/preview.rb
  25. 8
      lib/redmine.rb
  26. 19
      spec/controllers/messages_controller_spec.rb
  27. 13
      spec/controllers/news_controller_spec.rb
  28. 18
      spec/controllers/wiki_controller_spec.rb
  29. 76
      spec/controllers/work_packages_controller_spec.rb
  30. 36
      spec/permissions/add_messages_spec.rb
  31. 1
      spec/permissions/add_work_packages_spec.rb
  32. 36
      spec/permissions/edit_messages_spec.rb
  33. 36
      spec/permissions/edit_own_messages_spec.rb
  34. 16
      spec/permissions/edit_wiki_pages_spec.rb
  35. 2
      spec/permissions/edit_work_packages_spec.rb
  36. 36
      spec/permissions/manage_news_spec.rb
  37. 78
      spec/routing/previews_routing_spec.rb
  38. 13
      spec/routing/wiki_routing_spec.rb
  39. 41
      spec/support/shared/previews.rb
  40. 22
      test/functional/wiki_controller_test.rb
  41. 29
      test/integration/routing_test.rb

@ -1284,7 +1284,7 @@ var Preview = (function ($) {
$('html').on('click','a.preview', function() { $('html').on('click','a.preview', function() {
$.ajax({ $.ajax({
url: $(this).attr('href'), url: $(this).attr('href'),
type: 'PUT', type: 'POST',
data: $("#" + $(this).attr('id').replace(/-preview/, "")).serialize().replace('_method=put&', ''), data: $("#" + $(this).attr('id').replace(/-preview/, "")).serialize().replace('_method=put&', ''),
success: function(data) { $('#preview').html(data); success: function(data) { $('#preview').html(data);
$('html, body').animate({ $('html, body').animate({

@ -0,0 +1,30 @@
/*-- copyright
* OpenProject is a project management system.
* Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 3.
*
* OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
* Copyright (C) 2006-2013 Jean-Philippe Lang
* Copyright (C) 2010-2013 the ChiliProject Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* See doc/COPYRIGHT.rdoc for more details. ++
*/
.nothing-to-preview
color: red

@ -55,4 +55,5 @@
@import content/tabular @import content/tabular
@import content/headings @import content/headings
@import content/journal @import content/journal
@import content/preview
@import default/main @import default/main

@ -28,10 +28,11 @@
#++ #++
class MessagesController < ApplicationController class MessagesController < ApplicationController
include OpenProject::Concerns::Preview
menu_item :boards menu_item :boards
default_search_scope :messages default_search_scope :messages
model_object Message, :scope => Board model_object Message, :scope => Board
before_filter :find_object_and_scope before_filter :find_object_and_scope, except: [:preview]
before_filter :authorize, :except => [:preview, :edit, :update, :destroy] before_filter :authorize, :except => [:preview, :edit, :update, :destroy]
include AttachmentsHelper include AttachmentsHelper
@ -154,10 +155,13 @@ class MessagesController < ApplicationController
} }
end end
def preview protected
message = @board.messages.find_by_id(params[:id])
@attachements = message.attachments if message def parse_preview_data
@text = (params[:message] || params[:reply])[:content] if params[:message]
render :partial => 'common/preview' parse_preview_data_helper :message, :content
else
parse_preview_data_helper :reply, :content, Message
end
end end
end end

@ -29,15 +29,16 @@
class NewsController < ApplicationController class NewsController < ApplicationController
include PaginationHelper include PaginationHelper
include OpenProject::Concerns::Preview
default_search_scope :news default_search_scope :news
before_filter :disable_api before_filter :disable_api
before_filter :find_news_object, :except => [:new, :create, :index] before_filter :find_news_object, :except => [:new, :create, :index, :preview]
before_filter :find_project_from_association, :except => [:new, :create, :index] before_filter :find_project_from_association, :except => [:new, :create, :index, :preview]
before_filter :find_project, :only => [:new, :create] before_filter :find_project, :only => [:new, :create]
before_filter :authorize, :except => [:index] before_filter :authorize, :except => [:index, :preview]
before_filter :find_optional_project, :only => :index before_filter :find_optional_project, only: [:index]
accept_key_auth :index accept_key_auth :index
menu_item :new_news, :only => [:new, :create] menu_item :new_news, :only => [:new, :create]
@ -94,6 +95,16 @@ class NewsController < ApplicationController
redirect_to :action => 'index', :project_id => @project redirect_to :action => 'index', :project_id => @project
end end
protected
def parse_preview_data
parse_preview_data_helper :news, :description
end
def parse_preview_id
params[:id].to_i
end
private private
def find_news_object def find_news_object

@ -65,6 +65,7 @@ class WikiController < ApplicationController
include AttachmentsHelper include AttachmentsHelper
include PaginationHelper include PaginationHelper
include OpenProject::Concerns::Preview
attr_reader :page, :related_page attr_reader :page, :related_page
@ -315,18 +316,6 @@ class WikiController < ApplicationController
end end
end end
def preview
page = @wiki.find_page(params[:id])
# page is nil when previewing a new page
return render_403 unless page.nil? || editable?(page)
if page
@attachements = page.attachments
@previewed = page.content
end
@text = params[:content][:text]
render :partial => 'common/preview'
end
def add_attachment def add_attachment
return render_403 unless editable? return render_403 unless editable?
attachments = Attachment.attach_files(@page, params[:attachments]) attachments = Attachment.attach_files(@page, params[:attachments])
@ -349,6 +338,21 @@ class WikiController < ApplicationController
nil nil
end end
protected
def parse_preview_data
page = @wiki.find_page(params[:id])
# page is nil when previewing a new page
return render_403 unless page.nil? || editable?(page)
attachments = page && page.attachments
previewed = page && page.content
text = { WikiPage.human_attribute_name(:content) => params[:content][:text] }
return text, attachments, previewed
end
private private
def find_wiki def find_wiki

@ -48,15 +48,16 @@ class WorkPackagesController < ApplicationController
include QueriesHelper include QueriesHelper
include SortHelper include SortHelper
include PaginationHelper include PaginationHelper
include OpenProject::Concerns::Preview
accept_key_auth :index, :show, :create, :update accept_key_auth :index, :show, :create, :update
before_filter :disable_api before_filter :disable_api
before_filter :not_found_unless_work_package, before_filter :not_found_unless_work_package,
:project, :project,
:authorize, :except => [:index] :authorize, :except => [:index, :preview]
before_filter :find_optional_project, before_filter :find_optional_project,
:protect_from_unauthorized_export, :only => [:index, :all] :protect_from_unauthorized_export, :only => [:index, :all, :preview]
before_filter :load_query, :only => :index before_filter :load_query, :only => :index
def show def show
@ -124,16 +125,6 @@ class WorkPackagesController < ApplicationController
end end
end end
def preview
safe_params = permitted_params.update_work_package(project: project)
work_package.update_by(current_user, safe_params)
respond_to do |format|
format.any(:html, :js) { render 'preview', locals: { work_package: work_package },
layout: false }
end
end
def create def create
call_hook(:controller_work_package_new_before_save, { :params => params, :work_package => work_package }) call_hook(:controller_work_package_new_before_save, { :params => params, :work_package => work_package })
@ -453,4 +444,8 @@ class WorkPackagesController < ApplicationController
super super
end end
end end
def parse_preview_data
parse_preview_data_helper :work_package, [:notes, :description]
end
end end

@ -95,18 +95,11 @@ module ApplicationHelper
end end
def link_to_work_package_preview(context = nil, options = {}) def link_to_work_package_preview(context = nil, options = {})
url = context.is_a?(Project) ? form_id = options[:form_id] || 'work_package-form-preview'
preview_project_work_packages_path(context) : path = (context.is_a? WorkPackage) ? preview_work_package_path(context)
preview_work_package_path(context) : preview_work_packages_path
id = options[:form_id] || 'work_package-form-preview'
link_to l(:label_preview),
url,
:id => id,
:class => 'preview button',
:accesskey => accesskey(:preview)
preview_link path, form_id, { class: 'preview button' }
end end
# Show a sorted linkified (if active) comma-joined list of users # Show a sorted linkified (if active) comma-joined list of users

@ -27,19 +27,12 @@
# See doc/COPYRIGHT.rdoc for more details. # See doc/COPYRIGHT.rdoc for more details.
#++ #++
class News::PreviewsController < ApplicationController module PreviewsHelper
before_filter :find_model_object_and_project def preview_link(path, form_id, options = {})
options = { class: 'preview', accesskey: accesskey(:preview), id: form_id }.merge(options)
model_object News link_to path, options do
l(:label_preview)
def create
@text = news_params[:description]
render :partial => 'common/preview'
end end
private
def news_params
params.fetch(:news, {})
end end
end end

@ -44,10 +44,7 @@ See doc/COPYRIGHT.rdoc for more details.
:id => 'message-form'} do |f| %> :id => 'message-form'} do |f| %>
<%= render :partial => 'messages/form', :locals => {:f => f} %> <%= render :partial => 'messages/form', :locals => {:f => f} %>
<p><%= submit_tag l(:button_create) %> <p><%= submit_tag l(:button_create) %>
<%= link_to l(:label_preview), <%= preview_link preview_board_topics_path(@board), 'message-form-preview' %>
preview_board_topics_path(@board, @message),
:class => 'preview',
:id => 'message-form-preview' %>
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p> <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>

@ -27,6 +27,12 @@ See doc/COPYRIGHT.rdoc for more details.
++#%> ++#%>
<fieldset class="preview"><legend><%= l(:label_preview) %></legend> <% texts.each_pair do |caption, text| %>
<%= textilizable @text, :attachments => @attachements, :object => @previewed %> <fieldset class="preview"><legend><%= "#{l(:label_preview)} - #{caption}" %></legend>
<% if text.blank? %>
<span class="nothing-to-preview"><%= l(:nothing_to_preview) %></span>
<% else %>
<%= textilizable text, attachments: attachments, object: previewed %>
<% end %>
</fieldset> </fieldset>
<% end %>

@ -35,9 +35,6 @@ See doc/COPYRIGHT.rdoc for more details.
:html => {:multipart => true, :id => 'message-form'} do |f| %> :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %> <%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= link_to l(:label_preview), <%= preview_link preview_topic_path(@message), 'message-form-preview' %>
preview_topic_path(@message),
:class => 'preview',
:id => 'message-form-preview' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>

@ -35,10 +35,7 @@ See doc/COPYRIGHT.rdoc for more details.
:id => 'message-form'} do |f| %> :id => 'message-form'} do |f| %>
<%= render :partial => 'messages/form', :locals => {:f => f} %> <%= render :partial => 'messages/form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:label_preview), <%= preview_link preview_board_topics_path(@board), 'message-form-preview' %>
preview_board_topics_path(@board, @message),
:class => 'preview',
:id => 'message-form-preview' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>

@ -108,13 +108,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= form_for @reply, :as => :reply, :url => reply_to_topic_path(@topic), :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= form_for @reply, :as => :reply, :url => reply_to_topic_path(@topic), :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %> <%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
<%= submit_tag l(:button_submit) %> <%= submit_tag l(:button_submit) %>
<%= link_to_remote l(:label_preview), <%= preview_link preview_topic_path(@message), 'message-form' %>
{ :url => { :controller => '/messages', :action => 'preview', :board_id => @board },
:method => 'post',
:update => 'preview',
:with => "Form.serialize('message-form')",
:complete => "Element.scrollTo('preview')"
}, :accesskey => accesskey(:preview) %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>
</div> </div>

@ -34,9 +34,6 @@ See doc/COPYRIGHT.rdoc for more details.
<%= labelled_tabular_form_for @news, :html => { :id => 'news-form' } do |f| %> <%= labelled_tabular_form_for @news, :html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %> <%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= link_to l(:label_preview), <%= preview_link preview_news_path(@news), 'news-form-preview' %>
news_preview_path(@news),
:class => 'preview',
:id => 'news-form-preview' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>

@ -34,9 +34,6 @@ See doc/COPYRIGHT.rdoc for more details.
<%= labelled_tabular_form_for [@project, @news], :html => { :id => 'news-form' } do |f| %> <%= labelled_tabular_form_for [@project, @news], :html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %> <%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:label_preview), <%= preview_link preview_news_index_path, 'news-form-preview' %>
project_news_preview_path(@project, @news),
:class => 'preview',
:id => 'news-form-preview' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>

@ -51,10 +51,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= render :partial => 'form', :locals => { :f => f } %> <%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("edit-news"); return false;' %> <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("edit-news"); return false;' %>
<%= link_to l(:label_preview), <%= preview_link preview_news_path(@news), 'news-form-preview' %>
news_preview_path(@news),
:class => 'preview',
:id => 'news-form-preview' %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>
</div> </div>

@ -38,16 +38,9 @@ See doc/COPYRIGHT.rdoc for more details.
:'data-wp_autocomplete_url' => work_packages_auto_complete_path(:project_id => @project, :format => :json) %></p> :'data-wp_autocomplete_url' => work_packages_auto_complete_path(:project_id => @project, :format => :json) %></p>
<p><label><%= Version.human_attribute_name(:comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p> <p><label><%= Version.human_attribute_name(:comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p>
<p><label><%=l(:label_attachment_plural)%></label><br /><%= render :partial => 'attachments/form' %></p> <p><label><%=l(:label_attachment_plural)%></label><br /><%= render :partial => 'attachments/form' %></p>
<p><%= submit_tag l(:button_save) %> <p><%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview), <%= preview_link preview_project_wiki_path(@project, @page), 'wiki_form' %>
{ :url => { :controller => '/wiki', :action => 'preview', :project_id => @project, :id => @page }, </p>
:method => :post,
:update => 'preview',
:before => 'var form_data = Form.serialize("wiki_form", true); form_data._method="post";',
:with => "$H(form_data).toQueryString()",
:complete => "Element.scrollTo('preview')"
}, :accesskey => accesskey(:preview) %></p>
<%= wikitoolbar_for 'content_text' %> <%= wikitoolbar_for 'content_text' %>
<% end %> <% end %>

@ -71,13 +71,7 @@ See doc/COPYRIGHT.rdoc for more details.
<p> <p>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview), <%= preview_link preview_wiki_path(@project), 'wiki_form' %>
{ :url => wiki_preview_path(:project_id => @project),
:method => :post,
:update => 'preview',
:with => "Form.serialize('wiki_form')",
:complete => "Element.scrollTo('preview')"
}, :accesskey => accesskey(:preview) %>
</p> </p>
<%= wikitoolbar_for 'content_text' %> <%= wikitoolbar_for 'content_text' %>

@ -1,50 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See doc/COPYRIGHT.rdoc for more details.
++#%>
<% if work_package.journal_notes.present? %>
<fieldset class="preview">
<legend>
<%= Journal.human_attribute_name(:notes) %>
</legend>
<%= textilizable work_package.journal_notes,
:object => work_package %>
</fieldset>
<% end %>
<% if work_package.description.present? %>
<fieldset class="preview">
<legend>
<%= WorkPackage.human_attribute_name(:description) %>
</legend>
<%= textilizable work_package.description,
:object => work_package %>
</fieldset>
<% end %>

@ -1659,3 +1659,5 @@ de:
work_package: work_package:
updated_automatically_by_child_changes: | updated_automatically_by_child_changes: |
_Automatisch durch die Änderungen in %{child} aktualisert_ _Automatisch durch die Änderungen in %{child} aktualisert_
nothing_to_preview: "Keine Inhalte für Vorschau vorhanden"

@ -1646,3 +1646,5 @@ en:
work_package: work_package:
updated_automatically_by_child_changes: | updated_automatically_by_child_changes: |
_Updated automatically by changing values within child work package %{child}_ _Updated automatically by changing values within child work package %{child}_
nothing_to_preview: "Nothing to preview"

@ -146,9 +146,9 @@ OpenProject::Application.routes.draw do
get 'projects/:project_id/wiki/new' => 'wiki#new', :as => 'wiki_new' get 'projects/:project_id/wiki/new' => 'wiki#new', :as => 'wiki_new'
post 'projects/:project_id/wiki/new' => 'wiki#create', :as => 'wiki_create' post 'projects/:project_id/wiki/new' => 'wiki#create', :as => 'wiki_create'
post 'projects/:project_id/wiki/preview' => 'wiki#preview', :as => 'wiki_preview'
get 'projects/:project_id/wiki/:id/new' => 'wiki#new_child', :as => 'wiki_new_child' get 'projects/:project_id/wiki/:id/new' => 'wiki#new_child', :as => 'wiki_new_child'
get 'projects/:project_id/wiki/:id/toc' => 'wiki#index', :as => 'wiki_page_toc' get 'projects/:project_id/wiki/:id/toc' => 'wiki#index', :as => 'wiki_page_toc'
post 'projects/:project_id/wiki/preview' => 'wiki#preview', as: 'preview_wiki'
post 'projects/:id/wiki' => 'wikis#edit' post 'projects/:id/wiki' => 'wikis#edit'
match 'projects/:id/wiki/destroy' => 'wikis#destroy' match 'projects/:id/wiki/destroy' => 'wikis#destroy'
@ -206,11 +206,7 @@ OpenProject::Application.routes.draw do
# this could probably be rewritten with a resource :as => 'roadmap' # this could probably be rewritten with a resource :as => 'roadmap'
match '/roadmap' => 'versions#index', :via => :get match '/roadmap' => 'versions#index', :via => :get
resources :news, :only => [:index, :new, :create] do resources :news, :only => [:index, :new, :create]
collection do
resource :preview, :controller => "news/previews", :only => [:create], :as => "news_preview"
end
end
namespace :time_entries do namespace :time_entries do
resource :report, :controller => 'reports', :only => [:show] resource :report, :controller => 'reports', :only => [:show]
@ -232,12 +228,12 @@ OpenProject::Application.routes.draw do
get :parent_page, :action => 'edit_parent_page' get :parent_page, :action => 'edit_parent_page'
put :parent_page, :action => 'update_parent_page' put :parent_page, :action => 'update_parent_page'
get :history get :history
post :preview
post :protect post :protect
post :add_attachment post :add_attachment
get :list_attachments get :list_attachments
get :select_main_menu_item, to: 'wiki_menu_items#select_main_menu_item' get :select_main_menu_item, to: 'wiki_menu_items#select_main_menu_item'
post :replace_main_menu_item, to: 'wiki_menu_items#replace_main_menu_item' post :replace_main_menu_item, to: 'wiki_menu_items#replace_main_menu_item'
post :preview
end end
end end
# as routes for index and show are swapped # as routes for index and show are swapped
@ -252,7 +248,6 @@ OpenProject::Application.routes.draw do
resources :work_packages, :only => [:new, :create, :index] do resources :work_packages, :only => [:new, :create, :index] do
get :new_type, :on => :collection get :new_type, :on => :collection
put :preview, :on => :collection
collection do collection do
match '/report/:detail' => 'work_packages/reports#report_details', :via => :get match '/report/:detail' => 'work_packages/reports#report_details', :via => :get
@ -352,7 +347,6 @@ OpenProject::Application.routes.draw do
resources :work_packages, :only => [:show, :edit, :update, :index] do resources :work_packages, :only => [:show, :edit, :update, :index] do
get :new_type, :on => :member get :new_type, :on => :member
put :preview, :on => :member
resources :relations, :controller => 'work_package_relations', :only => [:create, :destroy] resources :relations, :controller => 'work_package_relations', :only => [:create, :destroy]
@ -367,6 +361,9 @@ OpenProject::Application.routes.draw do
resource :report, :controller => 'reports' resource :report, :controller => 'reports'
end end
resources :time_entries, :controller => 'timelog' resources :time_entries, :controller => 'timelog'
post :preview, on: :collection
post :preview, on: :member
end end
resources :versions, :only => [:show, :edit, :update, :destroy] do resources :versions, :only => [:show, :edit, :update, :destroy] do
@ -403,22 +400,22 @@ OpenProject::Application.routes.draw do
resources :boards, :only => [] do resources :boards, :only => [] do
resources :topics, :controller => 'messages', :except => [:index], :shallow => true do resources :topics, :controller => 'messages', :except => [:index], :shallow => true do
collection do
post :preview
end
member do member do
get :quote get :quote
post :reply, :as => 'reply_to' post :reply, :as => 'reply_to'
post :preview post :preview
end end
post :preview, on: :collection
end end
end end
resources :news, :only => [:index, :destroy, :update, :edit, :show] do resources :news, :only => [:index, :destroy, :update, :edit, :show] do
resources :comments, :controller => 'news/comments', :only => [:create, :destroy], :shallow => true resources :comments, :controller => 'news/comments', :only => [:create, :destroy], :shallow => true
resource :preview, :controller => 'news/previews', :only => [:create] post :preview, on: :member
post :preview, on: :collection
end end

@ -0,0 +1,109 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# See doc/COPYRIGHT.rdoc for more details.
#++
################################################################################
# This concern provides a general implementation of preview functionality #
# found in different controllers. #
# #
# Nevertheless, this concern expects the controller to implement the function #
# #parse_preview_data. #parse_preview_data must return a list of (wiki) texts, #
# attachments required to render the texts, and the object. Attachments and #
# object may be nil. #
# #
# You may use #parse_preview_data_helper to implement #parse_preview_data. #
# Then, a minimal implementation of #parse_preview_data may looks as follows: #
# #
# def parse_preview_data #
# parse_preview_data_helper :work_packages, [:description, :notes] #
# end #
# #
# The first parameter 'param_name' specifies the key in the params object that #
# contains the values. The second parameter 'attributes' speciffies the value #
# keys. Optionally, if 'param_name' is not equivallent to a class name, you #
# can pass the objects class as third parameter. #
# #
# For object identification #parse_preview_data_helper uses the params #
# object's 'id' key, if available. If 'id' needs some preprocessing or is not #
# the id to the object instance, you may override #parse_preview_id to provide #
# a different id. #
################################################################################
module OpenProject::Concerns::Preview
extend ActiveSupport::Concern
def preview
texts, attachments, obj = parse_preview_data
if obj.nil? || authorize_previewed_object(obj)
render 'common/preview',
layout: false,
locals: { texts: texts, attachments: attachments, previewed: obj }
end
end
protected
def parse_preview_data_helper(param_name, attributes, klass = nil)
klass ||= param_name.to_s.classify.constantize
texts = Array(attributes).each_with_object({}) do |attribute, list|
caption = (attribute == :notes) ? Journal.human_attribute_name(:notes)
: klass.human_attribute_name(attribute)
text = params[param_name][attribute]
list[caption] = text
end
obj = parse_previewed_object(klass)
attachments = previewed_object_attachments(obj)
return texts, attachments, obj
end
private
def parse_previewed_object(klass)
id = parse_previewed_id
id ? klass.find_by_id(id) : nil
end
def parse_previewed_id
params[:id]
end
def authorize_previewed_object(obj)
@project = obj.project
authorize
end
def previewed_object_attachments(obj)
is_attachable = obj && (obj.respond_to?('attachable') || obj.respond_to?('attachments'))
is_attachable ? obj.attachments : nil
end
end

@ -153,7 +153,7 @@ Redmine::AccessControl.map do |map|
end end
map.project_module :news do |map| map.project_module :news do |map|
map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :'news/comments' => [:destroy]}, :require => :member map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy, :preview], :'news/comments' => [:destroy]}, :require => :member
map.permission :view_news, {:news => [:index, :show]}, :public => true map.permission :view_news, {:news => [:index, :show]}, :public => true
map.permission :comment_news, {:'news/comments' => :create} map.permission :comment_news, {:'news/comments' => :create}
end end
@ -185,9 +185,9 @@ Redmine::AccessControl.map do |map|
map.project_module :boards do |map| map.project_module :boards do |map|
map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :move, :destroy]}, :require => :member map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :move, :destroy]}, :require => :member
map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
map.permission :add_messages, {:messages => [:new, :create, :reply, :quote]} map.permission :add_messages, {:messages => [:new, :create, :reply, :quote, :preview]}
map.permission :edit_messages, {:messages => [:edit, :update]}, :require => :member map.permission :edit_messages, {:messages => [:edit, :update, :preview]}, :require => :member
map.permission :edit_own_messages, {:messages => [:edit, :update]}, :require => :loggedin map.permission :edit_own_messages, {:messages => [:edit, :update, :preview]}, :require => :loggedin
map.permission :delete_messages, {:messages => :destroy}, :require => :member map.permission :delete_messages, {:messages => :destroy}, :require => :member
map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
end end

@ -180,4 +180,23 @@ describe MessagesController do
end end
end end
end end
describe 'preview' do
let(:content) { "Message content" }
it_behaves_like 'valid preview' do
let(:preview_texts) { [content] }
let(:preview_params) { { message: { content: content } } }
end
it_behaves_like 'valid preview' do
let(:preview_texts) { [content] }
let(:preview_params) { { reply: { content: content } } }
end
it_behaves_like 'authorizes object access' do
let(:message) { FactoryGirl.create :message, board: board }
let(:preview_params) { { id: message.id, message: { } } }
end
end
end end

@ -159,4 +159,17 @@ describe NewsController do
expect { news.reload }.to raise_error ActiveRecord::RecordNotFound expect { news.reload }.to raise_error ActiveRecord::RecordNotFound
end end
end end
describe 'preview' do
let(:description) { "News description" }
it_behaves_like 'valid preview' do
let(:preview_texts) { [description] }
let(:preview_params) { { news: { description: description } } }
end
it_behaves_like 'authorizes object access' do
let(:preview_params) { { id: news.id, news: { } } }
end
end
end end

@ -533,5 +533,23 @@ describe WikiController do
end end
end end
end end
describe 'preview' do
let(:project) { FactoryGirl.create(:project) }
let(:text) { "Wiki content" }
it_behaves_like 'valid preview' do
let(:preview_texts) { [text] }
let(:preview_params) { { project_id: project.id,
content: { text: text } } }
end
it_behaves_like 'authorizes object access' do
let(:wiki_page) { FactoryGirl.create(:wiki_page) }
let(:preview_params) { { project_id: wiki_page.wiki.project.id,
id: wiki_page.id,
content: { } } }
end
end
end end
end end

@ -28,6 +28,7 @@
#++ #++
require 'spec_helper' require 'spec_helper'
require 'support/shared/previews'
describe WorkPackagesController do describe WorkPackagesController do
@ -583,48 +584,6 @@ describe WorkPackagesController do
end end
end end
describe 'preview.html' do
let(:wp_params) { { :wp_attribute => double('wp_attribute') } }
let(:params) { { work_package: wp_params } }
let(:call_action) { post 'preview', params }
requires_permission_in_project do
before do
controller.stub(:work_package).and_return(stub_work_package)
controller.send(:permitted_params).should_receive(:update_work_package)
.with(:project => stub_work_package.project)
.and_return(wp_params)
end
it 'render the preview ' do
call_action
response.should render_template('work_packages/preview', :formats => ["html"], :layout => false)
end
end
end
describe 'preview.js' do
let(:wp_params) { { :wp_attribute => double('wp_attribute') } }
let(:params) { { work_package: wp_params } }
let(:call_action) { xhr :post, :preview, params }
requires_permission_in_project do
before do
controller.stub(:work_package).and_return(stub_work_package)
controller.send(:permitted_params).should_receive(:update_work_package)
.with(:project => stub_work_package.project)
.and_return(wp_params)
end
it 'render the preview ' do
call_action
response.should render_template('work_packages/preview', :formats => ["html"], :layout => false)
end
end
end
describe :work_package do describe :work_package do
describe 'when providing an id (wanting to see an existing wp)' do describe 'when providing an id (wanting to see an existing wp)' do
describe 'when beeing allowed to see the work_package' do describe 'when beeing allowed to see the work_package' do
@ -1054,4 +1013,37 @@ describe WorkPackagesController do
end end
end end
end end
describe 'preview' do
let(:project) { FactoryGirl.create(:project) }
let(:role) { FactoryGirl.create(:role,
permissions: [:add_work_packages]) }
let(:user) { FactoryGirl.create(:user,
member_in_project: project,
member_through_role: role) }
let(:description) { "Work package description" }
let(:notes) { "Work package note" }
let(:preview_params) { { work_package: { description: description,
notes: notes } } }
before { User.stub(:current).and_return(user) }
it_behaves_like 'valid preview' do
let(:preview_texts) { [description, notes] }
end
it_behaves_like 'authorizes object access' do
let(:work_package) { FactoryGirl.create(:work_package) }
let(:preview_params) { { id: work_package.id,
work_package: { } } }
end
describe 'preview.js' do
before { xhr :put, :preview, preview_params }
it { expect(response).to render_template('common/preview',
format: ["html"],
layout: false ) }
end
end
end end

@ -0,0 +1,36 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
require 'support/permission_specs'
describe MessagesController, "add_messages permission", type: :controller do
include PermissionSpecs
check_permission_required_for('messages#preview', :add_messages)
end

@ -35,4 +35,5 @@ describe WorkPackagesController, "add_work_packages permission", :type => :contr
check_permission_required_for('work_packages#new', :add_work_packages) check_permission_required_for('work_packages#new', :add_work_packages)
check_permission_required_for('work_packages#new_type', :add_work_packages) check_permission_required_for('work_packages#new_type', :add_work_packages)
check_permission_required_for('work_packages#create', :add_work_packages) check_permission_required_for('work_packages#create', :add_work_packages)
check_permission_required_for('work_packages#preview', :add_work_packages)
end end

@ -0,0 +1,36 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
require 'support/permission_specs'
describe MessagesController, "edit_messages permission", type: :controller do
include PermissionSpecs
check_permission_required_for('messages#preview', :edit_messages)
end

@ -0,0 +1,36 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
require 'support/permission_specs'
describe MessagesController, "edit_own_messages permission", type: :controller do
include PermissionSpecs
check_permission_required_for('messages#preview', :edit_own_messages)
end

@ -27,18 +27,10 @@
#++ #++
require 'spec_helper' require 'spec_helper'
require 'support/permission_specs'
describe WorkPackagesController do describe WikiController, "edit_wiki_pages permission", type: :controller do
include PermissionSpecs
it "should connect PUT /work_packages/1/preview to work_packages#preview" do check_permission_required_for('wiki#preview', :edit_wiki_pages)
put("/work_packages/1/preview").should route_to( :controller => 'work_packages',
:action => 'preview',
:id => '1' )
end
it "should connect PUT /project/1/work_packages/preview to work_packages#preview" do
put("/projects/1/work_packages/preview").should route_to( :controller => 'work_packages',
:action => 'preview',
:project_id => '1' )
end
end end

@ -37,5 +37,5 @@ describe WorkPackagesController, "edit_work_packages permission", :type => :cont
check_permission_required_for('work_packages#new_type', :edit_work_packages) check_permission_required_for('work_packages#new_type', :edit_work_packages)
check_permission_required_for('work_packages#quoted', :edit_work_packages) check_permission_required_for('work_packages#quoted', :edit_work_packages)
check_permission_required_for('journals#preview', :edit_work_packages) check_permission_required_for('work_packages#preview', :edit_work_packages)
end end

@ -0,0 +1,36 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
require 'support/permission_specs'
describe NewsController, "manage_news permission", type: :controller do
include PermissionSpecs
check_permission_required_for('news#preview', :manage_news)
end

@ -0,0 +1,78 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe 'preview' do
it "should connect POST /projects/:project_id/wiki/preview to wiki#preview" do
post("/projects/1/wiki/preview").should route_to(controller: 'wiki',
action: 'preview',
project_id: '1')
end
it "should connect POST /projects/:project_id/wiki/:id/preview to wiki#preview" do
post("/projects/1/wiki/1/preview").should route_to(controller: 'wiki',
action: 'preview',
project_id: '1',
id: '1')
end
it "should connect POST news/preview to news#preview" do
post("/news/preview").should route_to(controller: 'news',
action: 'preview')
end
it "should connect POST /news/:id/preview to news#preview" do
post("/news/1/preview").should route_to(controller: 'news',
action: 'preview',
id: '1')
end
it "should connect POST /boards/:board_id/topics/preview to messages#preview" do
post("/boards/1/topics/preview").should route_to(controller: 'messages',
action: 'preview',
board_id: '1')
end
it "should connect POST /topics/:id/preview to messages#preview" do
post("/topics/1/preview").should route_to(controller: 'messages',
action: 'preview',
id: '1')
end
it "should connect POST /work_packages/preview to work_packages#preview" do
post("/work_packages/preview").should route_to(controller: 'work_packages',
action: 'preview')
end
it "should connect POST /work_packages/:id/preview to work_packages#preview" do
post("/work_packages/1/preview").should route_to(controller: 'work_packages',
action: 'preview',
id: '1')
end
end

@ -49,19 +49,6 @@ describe WikiController do
:project_id => 'abc') :project_id => 'abc')
end end
it 'should connect POST /projects/:project_id/wiki/:id/preview to wiki/preview' do
post('/projects/abc/wiki/def/preview').should route_to(:controller => 'wiki',
:action => 'preview',
:project_id => 'abc',
:id => 'def')
end
it 'should connect POST /projects/:project_id/wiki/preview to wiki/preview' do
post('/projects/abc/wiki/preview').should route_to(:controller => 'wiki',
:action => 'preview',
:project_id => 'abc')
end
it do it do
post('/projects/abc/wiki/abc_wiki?version=3').should post('/projects/abc/wiki/abc_wiki?version=3').should
route_to(controller: 'wiki', route_to(controller: 'wiki',

@ -1,4 +1,3 @@
#-- encoding: UTF-8
#-- copyright #-- copyright
# OpenProject is a project management system. # OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF) # Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
@ -26,19 +25,31 @@
# #
# See doc/COPYRIGHT.rdoc for more details. # See doc/COPYRIGHT.rdoc for more details.
#++ #++
require File.expand_path('../../../test_helper', __FILE__)
shared_examples_for 'valid preview' do
class News::PreviewsControllerTest < ActionController::TestCase render_views
fixtures :all
before do
def test_create put :preview, preview_params
post :create, :project_id => 1, end
:news => { :title => '',
:description => 'News description', it { expect(response).to render_template('common/preview') }
:summary => '' }
assert_response :success it 'renders all texts' do
assert_template 'common/_preview' preview_texts.each do |text|
assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, expect(response.body).to have_selector('fieldset.preview', text: text)
:content => /News description/ end
end end
end end
shared_examples_for 'authorizes object access' do
let(:unauthorized_user) { FactoryGirl.create(:user) }
before do
User.stub(:current).and_return(unauthorized_user)
put :preview, preview_params
end
it { expect(response.status).to eq(403) }
end

@ -218,28 +218,6 @@ class WikiControllerTest < ActionController::TestCase
assert_equal 2, c.version assert_equal 2, c.version
end end
def test_preview
@request.session[:user_id] = 2
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
:content => { :comments => '',
:text => 'this is a *previewed text*',
:lock_version => 3 }
assert_response :success
assert_template 'common/_preview'
assert_tag :tag => 'strong', :content => /previewed text/
end
def test_preview_new_page
@request.session[:user_id] = 2
xhr :post, :preview, :project_id => 1, :id => 'New page',
:content => { :text => 'h1. New page',
:comments => '',
:lock_version => 0 }
assert_response :success
assert_template 'common/_preview'
assert_tag :tag => 'h1', :content => /New page/
end
def test_history def test_history
FactoryGirl.create :wiki_content_journal, FactoryGirl.create :wiki_content_journal,
journable_id: 1, journable_id: 1,

@ -245,11 +245,6 @@ class RoutingTest < ActionDispatch::IntegrationTest
should route(:post, "/boards/lala/topics").to( :controller => 'messages', should route(:post, "/boards/lala/topics").to( :controller => 'messages',
:action => 'create', :action => 'create',
:board_id => 'lala' ) :board_id => 'lala' )
should route(:post, "/boards/22/topics/preview").to( :controller => 'messages',
:action => 'preview',
:board_id => '22' )
end end
should route(:get, "/topics/2").to( :controller => 'messages', should route(:get, "/topics/2").to( :controller => 'messages',
@ -275,14 +270,6 @@ class RoutingTest < ActionDispatch::IntegrationTest
should route(:post, "/topics/555/reply").to( :controller => 'messages', should route(:post, "/topics/555/reply").to( :controller => 'messages',
:action => 'reply', :action => 'reply',
:id => '555' ) :id => '555' )
should route(:post, "/topics/2/preview").to( :controller => 'messages',
:action => 'preview',
:id => '2' )
end end
context "news" do context "news" do
@ -314,10 +301,6 @@ class RoutingTest < ActionDispatch::IntegrationTest
:action => 'create', :action => 'create',
:project_id => '567' ) :project_id => '567' )
should route(:post, "/projects/567/news/preview").to( :controller => 'news/previews',
:action => 'create',
:project_id => '567')
end end
should route(:get, "/news").to( :controller => 'news', should route(:get, "/news").to( :controller => 'news',
@ -371,14 +354,6 @@ class RoutingTest < ActionDispatch::IntegrationTest
:id => '15' ) :id => '15' )
end end
context "news/previews" do
context "news scoped" do
should route(:post, "/news/567/preview").to( :controller => 'news/previews',
:action => 'create',
:news_id => '567' )
end
end
context "project_enumerations" do context "project_enumerations" do
context "project_scoped" do context "project_scoped" do
should route(:put, "/projects/64/enumerations").to( :controller => 'project_enumerations', should route(:put, "/projects/64/enumerations").to( :controller => 'project_enumerations',
@ -645,10 +620,6 @@ class RoutingTest < ActionDispatch::IntegrationTest
:action => 'export', :action => 'export',
:project_id => '567' ) :project_id => '567' )
should route(:post, "/projects/567/wiki/CookBook_documentation/preview").to( :controller => 'wiki',
:action => 'preview',
:project_id => '567',
:id => 'CookBook_documentation' )
should route(:put, "/projects/22/wiki/ladida/rename").to( :controller => 'wiki', should route(:put, "/projects/22/wiki/ladida/rename").to( :controller => 'wiki',
:action => 'rename', :action => 'rename',
:project_id => '22', :project_id => '22',

Loading…
Cancel
Save