From 0c47d088fc71a1732209e68f86314fc0c855f8ad Mon Sep 17 00:00:00 2001 From: Haruyuki Iida Date: Sat, 23 Feb 2019 16:59:10 +0900 Subject: [PATCH] Remove auto preview --- app/models/wiki_extensions_setting.rb | 10 +- .../wiki_extensions/_body_bottom.html.erb | 7 +- .../_issues_edit_notes_bottom.html.erb | 33 ------ .../_issues_form_details_bottom.html.erb | 39 ------- .../wiki_extensions_settings/_show.html.erb | 5 - assets/javascripts/wiki_extensions.js | 33 +----- init.rb | 33 +++--- lib/wiki_extensions_application_hooks.rb | 50 +-------- lib/wiki_extensions_issue_hooks.rb | 21 ---- test/functional/wiki_controller_test.rb | 106 +++++++++--------- .../wiki_extensions_controller_test.rb | 36 +++--- ...iki_extensions_settings_controller_test.rb | 2 +- test/test_helper.rb | 1 + 13 files changed, 104 insertions(+), 272 deletions(-) delete mode 100644 app/views/wiki_extensions/_issues_edit_notes_bottom.html.erb delete mode 100644 app/views/wiki_extensions/_issues_form_details_bottom.html.erb delete mode 100644 lib/wiki_extensions_issue_hooks.rb diff --git a/app/models/wiki_extensions_setting.rb b/app/models/wiki_extensions_setting.rb index 91a3c9a..61bd49d 100644 --- a/app/models/wiki_extensions_setting.rb +++ b/app/models/wiki_extensions_setting.rb @@ -1,5 +1,5 @@ # Wiki Extensions plugin for Redmine -# Copyright (C) 2011-2015 Haruyuki Iida +# Copyright (C) 2011-2019 Haruyuki Iida # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -24,7 +24,7 @@ def self.find_or_create(pj_id) unless setting setting = WikiExtensionsSetting.new setting.project_id = pj_id - setting.save! + setting.save! end 5.times do |i| WikiExtensionsMenu.find_or_create(pj_id, i + 1) @@ -32,7 +32,11 @@ def self.find_or_create(pj_id) return setting end + def auto_preview_enabled + false + end + def menus - WikiExtensionsMenu.where(:project_id => project_id).order('menu_no') + WikiExtensionsMenu.where(:project_id => project_id).order("menu_no") end end diff --git a/app/views/wiki_extensions/_body_bottom.html.erb b/app/views/wiki_extensions/_body_bottom.html.erb index dd033e4..12ca923 100644 --- a/app/views/wiki_extensions/_body_bottom.html.erb +++ b/app/views/wiki_extensions/_body_bottom.html.erb @@ -1,5 +1,5 @@ <% # Wiki Extensions plugin for Redmine - # Copyright (C) 2012-2013 Haruyuki Iida + # Copyright (C) 2012-2019 Haruyuki Iida # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,9 +22,6 @@ context = {:project => project, :controller => controller, :request => request} - return add_messages_auto_preview(context) if controller.class.name == 'MessagesController' - return add_boards_auto_preview(context) if controller.class.name == 'BoardsController' - return unless controller.class.name == 'WikiController' action_name = controller.action_name @@ -39,7 +36,7 @@ <% if action_name == 'edit' or (action_name == 'show' and page_name and page == nil) %> <%= render :partial => 'wiki_extensions/tags_form', :locals => context %> - <%= raw add_wiki_auto_preview(context) %> + <% else %> diff --git a/app/views/wiki_extensions/_issues_edit_notes_bottom.html.erb b/app/views/wiki_extensions/_issues_edit_notes_bottom.html.erb deleted file mode 100644 index d21866c..0000000 --- a/app/views/wiki_extensions/_issues_edit_notes_bottom.html.erb +++ /dev/null @@ -1,33 +0,0 @@ -<%# -# Wiki Extensions plugin for Redmine -# Copyright (C) 2012 Haruyuki Iida -# -# 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. --%> -<% if WikiExtensionsUtil.is_enabled?(project) -%> - <% - setting = WikiExtensionsSetting.find_or_create(project.id) - if setting.auto_preview_enabled - url = preview_issue_path(:project_id => @project, :id => issue) - -%> - - - - <% end %> -<% end %> \ No newline at end of file diff --git a/app/views/wiki_extensions/_issues_form_details_bottom.html.erb b/app/views/wiki_extensions/_issues_form_details_bottom.html.erb deleted file mode 100644 index a6a9fe7..0000000 --- a/app/views/wiki_extensions/_issues_form_details_bottom.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%# -# Wiki Extensions plugin for Redmine -# Copyright (C) 2012 Haruyuki Iida -# -# 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. --%> - -<% if WikiExtensionsUtil.is_enabled?(project) -%> - <% - setting = WikiExtensionsSetting.find_or_create(project.id) - if setting.auto_preview_enabled - if @issue.id.blank? - url = preview_issue_path(:project_id => @project, :id => @issue) - else - url = preview_issue_path(:project_id => @project, :id => @issue) - end - -%> - - - - <% end -%> - -<% end -%> \ No newline at end of file diff --git a/app/views/wiki_extensions_settings/_show.html.erb b/app/views/wiki_extensions_settings/_show.html.erb index c61d479..a73c6dd 100644 --- a/app/views/wiki_extensions_settings/_show.html.erb +++ b/app/views/wiki_extensions_settings/_show.html.erb @@ -45,12 +45,7 @@ function click_wiki_menu_tab(num) {

- <%= f.check_box 'auto_preview_enabled' %> -

-

- <%= f.check_box 'tag_disabled' %> -


<%=h l(:wiki_extensions_add_tab)%> diff --git a/assets/javascripts/wiki_extensions.js b/assets/javascripts/wiki_extensions.js index 8326a97..ea6a4e5 100644 --- a/assets/javascripts/wiki_extensions.js +++ b/assets/javascripts/wiki_extensions.js @@ -1,6 +1,6 @@ /* # Wiki Extensions plugin for Redmine -# Copyright (C) 2009-2017 Haruyuki Iida +# Copyright (C) 2009-2019 Haruyuki Iida # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,7 +17,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -var auto_preview_interval = 2000; function add_wiki_extensions_tags_form() { var tags_form = $('#wiki_extensions_tag_form'); @@ -34,37 +33,7 @@ function set_tag_atuto_complete(taglist) { }) } -function setAutPreviewCallback(url, preview_id, form_id, content_id) { - var content_org = $(content_id).val(); - setInterval(function(){ - var content_new = $(content_id).val(); - if (content_new != content_org) { - $(preview_id).load(url, $(form_id).we_serialize2json()); - content_org = content_new; - } - },auto_preview_interval); -} - -function setWikiAutoPreview(url) { - setAutPreviewCallback(url, '#preview', '#wiki_form', '#content_text'); -} - -function setMessagesAutoPreview(url) { - setAutPreviewCallback(url, '#preview', '#message-form', '#message_content'); -} - -function setBoardsAutoPreview(url) { - setAutPreviewCallback(url, '#preview', '#message-form', '#message_content'); -} - -function setIssueAutoPreview(url) { - setAutPreviewCallback(url, '#preview', '#issue-form', '#issue_description'); -} - -function setIssueNotesAutoPreview(url) { - setAutPreviewCallback(url, '#preview', '#issue-form', '#notes'); -} function is_table_for_sort(tbody) { var trs = tbody.getElementsByTagName('tr'); diff --git a/init.rb b/init.rb index 20a858d..96ebfd4 100644 --- a/init.rb +++ b/init.rb @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require 'redmine' begin -require 'config/initializers/session_store.rb' + require 'config/initializers/session_store.rb' rescue LoadError end require 'redmine/wiki_formatting/textile/redcloth3' @@ -30,39 +30,38 @@ include ActionView::Helpers::WikiExtensionsHelper end - Redmine::Plugin.register :redmine_wiki_extensions do name 'Redmine Wiki Extensions plugin' author 'Haruyuki Iida' author_url 'http://twitter.com/haru_iida' description 'This is a Wiki Extensions plugin for Redmine' - url "http://www.r-labs.org/projects/r-labs/wiki/Wiki_Extensions_en" + url 'http://www.r-labs.org/projects/r-labs/wiki/Wiki_Extensions_en' version '0.9.0' requires_redmine :version_or_higher => '4.0.0' project_module :wiki_extensions do - permission :wiki_extensions_vote, {:wiki_extensions => [:vote, :show_vote]}, :public => true - permission :add_wiki_comment, {:wiki_extensions => [:add_comment, :reply_comment]} - permission :delete_wiki_comments, {:wiki_extensions => [:destroy_comment]} - permission :edit_wiki_comments, {:wiki_extensions => [:update_comment]} - permission :show_wiki_extension_tabs, {:wiki_extensions => [:forward_wiki_page]}, :public => true - permission :view_wiki_comment, {:wiki_extensions => [:show_comments]}, :public => true - permission :show_wiki_tags, {:wiki_extensions => [:tag]}, :public => true - permission :wiki_extensions_settings, {:wiki_extensions_settings => [:show, :update]} + permission :wiki_extensions_vote, { :wiki_extensions => [:vote, :show_vote] }, :public => true + permission :add_wiki_comment, { :wiki_extensions => [:add_comment, :reply_comment] } + permission :delete_wiki_comments, { :wiki_extensions => [:destroy_comment] } + permission :edit_wiki_comments, { :wiki_extensions => [:update_comment] } + permission :show_wiki_extension_tabs, { :wiki_extensions => [:forward_wiki_page] }, :public => true + permission :view_wiki_comment, { :wiki_extensions => [:show_comments] }, :public => true + permission :show_wiki_tags, { :wiki_extensions => [:tag] }, :public => true + permission :wiki_extensions_settings, { :wiki_extensions_settings => [:show, :update] } end - menulist = [:wiki_extensions1,:wiki_extensions2,:wiki_extensions3,:wiki_extensions4,:wiki_extensions5] - menulist.length.times{|i| + menulist = [:wiki_extensions1, :wiki_extensions2, :wiki_extensions3, :wiki_extensions4, :wiki_extensions5] + menulist.length.times { |i| no = i + 1 before = :wiki before = menulist[i - 1] if i > 0 - menu :project_menu, menulist[i], { :controller => 'wiki_extensions', :action => 'forward_wiki_page', :menu_id => no },:after => before, - :caption => Proc.new{|proj| WikiExtensionsMenu.title(proj.id, no)}, - :if => Proc.new{|proj| WikiExtensionsMenu.enabled?(proj.id, no)} + menu :project_menu, menulist[i], { :controller => 'wiki_extensions', :action => 'forward_wiki_page', :menu_id => no }, :after => before, + :caption => Proc.new { |proj| WikiExtensionsMenu.title(proj.id, no) }, + :if => Proc.new { |proj| WikiExtensionsMenu.enabled?(proj.id, no) } } - RedCloth3::ALLOWED_TAGS << "div" + RedCloth3::ALLOWED_TAGS << 'div' activity_provider :wiki_comment, :class_name => 'WikiExtensionsComment', :default => false end diff --git a/lib/wiki_extensions_application_hooks.rb b/lib/wiki_extensions_application_hooks.rb index 2865a12..4749236 100644 --- a/lib/wiki_extensions_application_hooks.rb +++ b/lib/wiki_extensions_application_hooks.rb @@ -1,5 +1,5 @@ # Wiki Extensions plugin for Redmine -# Copyright (C) 2009-2013 Haruyuki Iida +# Copyright (C) 2009-2019 Haruyuki Iida # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -14,50 +14,12 @@ # 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. -require 'redmine' -require 'application_helper' +require "redmine" +require "application_helper" + class WikiExtensionsApplicationHooks < Redmine::Hook::ViewListener include ApplicationHelper - render_on :view_layouts_base_html_head, :partial => 'wiki_extensions/html_header' - render_on :view_layouts_base_body_bottom, :partial => 'wiki_extensions/body_bottom' - -end - -def add_wiki_auto_preview(context) - project = context[:project] - setting = WikiExtensionsSetting.find_or_create(project.id) - return '' unless setting.auto_preview_enabled - request = context[:request] - params = request.parameters if request - page_name = params[:id] if params - url = url_for(:controller => 'wiki', :action => 'preview', :id => page_name, :project_id => project) - o = '' - o << javascript_tag("setWikiAutoPreview('#{url}');") - return o + render_on :view_layouts_base_html_head, :partial => "wiki_extensions/html_header" + render_on :view_layouts_base_body_bottom, :partial => "wiki_extensions/body_bottom" end - -def add_messages_auto_preview(context) - project = context[:project] - setting = WikiExtensionsSetting.find_or_create(project.id) - return '' unless setting.auto_preview_enabled - request = context[:request] - params = request.parameters if request - board = params[:board_id] if params - url = url_for :controller => 'messages', :action => 'preview', :board_id => board - o = '' - o << javascript_tag("setMessagesAutoPreview('#{url}');") - return o -end - -def add_boards_auto_preview(context) - project = context[:project] - setting = WikiExtensionsSetting.find_or_create(project.id) - return '' unless setting.auto_preview_enabled - return '' unless @board - return '' unless @board.id - url = url_for :controller => 'messages', :action => 'preview', :board_id => @board - o = '' - o << javascript_tag("setBoardsAutoPreview('#{url}');") - return o -end \ No newline at end of file diff --git a/lib/wiki_extensions_issue_hooks.rb b/lib/wiki_extensions_issue_hooks.rb deleted file mode 100644 index cd16329..0000000 --- a/lib/wiki_extensions_issue_hooks.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Wiki Extensions plugin for Redmine -# Copyright (C) 2010-2012 Haruyuki Iida -# -# 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. - -class WikiExtensionsIssueHooks < Redmine::Hook::ViewListener - render_on :view_issues_form_details_bottom, :partial => 'wiki_extensions/issues_form_details_bottom' - render_on :view_issues_edit_notes_bottom, :partial => 'wiki_extensions/issues_edit_notes_bottom' -end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 46b2af2..0101f3a 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -17,15 +17,15 @@ require File.dirname(__FILE__) + '/../test_helper' class WikiControllerTest < ActionController::TestCase - fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, + fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments, :wiki_extensions_comments, :wiki_extensions_tags def setup @controller = WikiController.new - @request = ActionController::TestRequest.create(self.class.controller_class) + @request = ActionController::TestRequest.create(self.class.controller_class) #@response = ActionController::TestResponse.new - @request.env["HTTP_REFERER"] = '/' + @request.env['HTTP_REFERER'] = '/' @project = Project.find(1) @wiki = @project.wiki @page_name = 'macro_test' @@ -41,7 +41,7 @@ def setup header.content = WikiContent.new header.content.text = 'test' header.save! - footer = @wiki.find_or_new_page('Footer') + footer = @wiki.find_or_new_page('Footer') footer.content = WikiContent.new footer.content.text = 'test' footer.save! @@ -53,43 +53,41 @@ def setup enabled_module.project_id = 1 enabled_module.name = 'wiki_extensions' enabled_module.save - end def test_comment_form text = '{{comment_form}}' text << "\n" - text << "{{comments}}" + text << '{{comments}}' setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success - end def test_comments - text = "{{comments}}" + text = '{{comments}}' setContent(text) comment = WikiExtensionsComment.new comment.wiki_page_id = @page.id comment.user_id = 1 - comment.comment = "aaa" + comment.comment = 'aaa' comment.save! @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end def test_div + @request.session[:user_id] = 1 text = "{{div_start_tag(foo)}}\n" text << "{{div_end_tag}}\n" text << "{{div_start_tag(var, hoge)}}\n" text << "{{div_end_tag}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success - end def test_footnote @@ -98,9 +96,8 @@ def test_footnote text << "{{fnlist}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success - end def test_new @@ -110,7 +107,7 @@ def test_new text << "{{new(2009-03-01, 4)}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end @@ -121,7 +118,7 @@ def test_project text << "{{project(#{@project.id}), bar}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end @@ -133,7 +130,7 @@ def test_tags text << "{{tagcloud}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end @@ -145,17 +142,17 @@ def test_wiki text << "{{wiki(#{@project.id}, #{@page_name}, bar)}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end def test_edit @request.session[:user_id] = 1 - get :edit, :params => {:project_id => 1, :id => @page_name} + get :edit, :params => { :project_id => 1, :id => @page_name } assert_response :success - post :edit, :params => {:project_id => 1, :id => @page_name, :content => {:text => 'aaa'}, - :extension => {:tags =>{"0" => "aaa", "1" => "bbb"}}} + post :edit, :params => { :project_id => 1, :id => @page_name, :content => { :text => 'aaa' }, + :extension => { :tags => { '0' => 'aaa', '1' => 'bbb' } } } assert_response :success end @@ -163,10 +160,10 @@ def test_recent text = '' text << "{{recent}}\n" text << "{{recent(10)}}\n" - + setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end @@ -176,7 +173,7 @@ def test_lastupdated_by setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end @@ -186,7 +183,7 @@ def test_lastupdated_at setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end @@ -197,118 +194,119 @@ def test_iframe setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end - context "count" do - should "success" do + context 'count' do + should 'success' do + @request.session[:user_id] = 1 text = '' text << "{{count}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "show_count" do - should "success" do + context 'show_count' do + should 'success' do text = '' text << "{{show_count}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "popularity" do - should "success if there is no count data" do + context 'popularity' do + should 'success if there is no count data' do text = '' text << "{{popularity}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end - should "success if there is count data" do + should 'success if there is count data' do text = '' text << "{{count}}\n" text << "{{popularity}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "vote" do - should "success" do + context 'vote' do + should 'success' do text = '' text << "{{vote(aaa)}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "show_vote" do - should "success" do + context 'show_vote' do + should 'success' do text = '' text << "{{show_vote(aaa)}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "twitter" do - should "success" do + context 'twitter' do + should 'success' do text = '' text << "{{twitter(haru_iida)}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "taggedpages" do - should "success" do + context 'taggedpages' do + should 'success' do text = '' text << "{{taggedpages(aaa)}}\n" setContent(text) @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } assert_response :success end end - context "page_break" do + context 'page_break' do setup do setContent("{{page_break}}\n") @request.session[:user_id] = 1 - get :show, :params => {:project_id => 1, :id => @page_name} + get :show, :params => { :project_id => 1, :id => @page_name } end - should "success" do + should 'success' do assert_response :success end - should "be rendered correctly" do + should 'be rendered correctly' do assert response.body.include?('
') end end diff --git a/test/functional/wiki_extensions_controller_test.rb b/test/functional/wiki_extensions_controller_test.rb index 190a354..106885c 100644 --- a/test/functional/wiki_extensions_controller_test.rb +++ b/test/functional/wiki_extensions_controller_test.rb @@ -1,5 +1,5 @@ -# Code Review plugin for Redmine -# Copyright (C) 2009 Haruyuki Iida +# Wiki Extensions plugin for Redmine +# Copyright (C) 2009-2019 Haruyuki Iida # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,22 +17,22 @@ require File.dirname(__FILE__) + '/../test_helper' class WikiExtensionsControllerTest < ActionController::TestCase - fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, + fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments, :wiki_extensions_comments, :wiki_extensions_tags, :wiki_extensions_menus, :wiki_extensions_votes def setup @controller = WikiExtensionsController.new - @request = ActionController::TestRequest.create(self.class.controller_class) + @request = ActionController::TestRequest.create(self.class.controller_class) #@response = ActionController::TestResponse.new - @request.env["HTTP_REFERER"] = '/' + @request.env['HTTP_REFERER'] = '/' @project = Project.find(1) @wiki = @project.wiki @page_name = 'macro_test' @page = @wiki.find_or_new_page(@page_name) @page.content = WikiContent.new - @page.content.text = "{{comments}}" + @page.content.text = '{{comments}}' @page.save! side_bar = @wiki.find_or_new_page('SideBar') side_bar.content = WikiContent.new @@ -50,13 +50,13 @@ def setup def test_add_comment @request.session[:user_id] = 1 - post :add_comment, :params => {:id => 1, :wiki_page_id => @page.id, :comment => 'aaa'} + post :add_comment, :params => { :id => 1, :wiki_page_id => @page.id, :comment => 'aaa' } assert_response :redirect end def test_tag @request.session[:user_id] = 1 - get :tag, :params => {:id => 1, :tag_id => 1} + get :tag, :params => { :id => 1, :tag_id => 1 } #assert assigns[:tag] end @@ -64,10 +64,10 @@ def test_destroy_comment comment = WikiExtensionsComment.new comment.wiki_page_id = @page.id comment.user_id = 1 - comment.comment = "aaa" + comment.comment = 'aaa' comment.save! @request.session[:user_id] = 1 - post :destroy_comment, :params => {:id => 1, :comment_id => comment.id} + post :destroy_comment, :params => { :id => 1, :comment_id => comment.id } assert_response :redirect comment = WikiExtensionsComment.where(:id => comment.id).first assert_nil(comment) @@ -77,11 +77,11 @@ def test_update_comment comment = WikiExtensionsComment.new comment.wiki_page_id = @page.id comment.user_id = 1 - comment.comment = "aaa" + comment.comment = 'aaa' comment.save! - message = "newcomment" + message = 'newcomment' @request.session[:user_id] = 1 - post :update_comment, :params => {:id => 1, :comment_id => comment.id, :comment => message} + post :update_comment, :params => { :id => 1, :comment_id => comment.id, :comment => message } assert_response :redirect comment = WikiExtensionsComment.find(comment.id) assert_equal(message, comment.comment) @@ -89,16 +89,16 @@ def test_update_comment def test_forwad_wiki_page @request.session[:user_id] = 1 - get :forward_wiki_page, :params => {:id => 1, :menu_id => 1} + get :forward_wiki_page, :params => { :id => 1, :menu_id => 1 } assert_response :redirect end - context "vote" do - should "success if new vote." do + context 'vote' do + should 'success if new vote.' do @request.session[:user_id] = 1 count = WikiExtensionsVote.all.length - post :vote, :params => {:id => 1, :target_class_name => 'Project', :target_id => 1, - :key => 'aaa', :url => 'http://localhost:3000'} + post :vote, :params => { :id => 1, :target_class_name => 'Project', :target_id => 1, + :key => 'aaa', :url => 'http://localhost:3000' } assert_equal(count + 1, WikiExtensionsVote.all.length) assert_response :success end diff --git a/test/functional/wiki_extensions_settings_controller_test.rb b/test/functional/wiki_extensions_settings_controller_test.rb index 7aac961..60691de 100644 --- a/test/functional/wiki_extensions_settings_controller_test.rb +++ b/test/functional/wiki_extensions_settings_controller_test.rb @@ -45,7 +45,7 @@ def setup :menus => menus, :id => @project} assert_response :redirect setting = WikiExtensionsSetting.find_or_create @project.id - assert_equal(true, setting.auto_preview_enabled) + assert_equal(false, setting.auto_preview_enabled) menus = setting.menus assert_equal(5, menus.length) assert(menus[0].enabled) diff --git a/test/test_helper.rb b/test/test_helper.rb index ec96792..684ea46 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,7 @@ require 'simplecov' require 'simplecov-rcov' require 'coveralls' +require 'shoulda' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::RcovFormatter,