Cleanup to respect coding standards part1
This commit is contained in:
parent
d5d61dbb8f
commit
19f23f8c31
@ -1,13 +1,14 @@
|
||||
# Redmine Tweaks plugin for Redmine
|
||||
# Copyright (C) 2013-2015 AlphaNodes GmbH
|
||||
|
||||
# Garfield controller class
|
||||
class GarfieldController < ApplicationController
|
||||
|
||||
before_filter :require_login
|
||||
before_action :require_login
|
||||
|
||||
def show
|
||||
local_path = "#{Rails.root}/tmp/_garfield_#{params[:name]}.#{params[:type]}"
|
||||
mime_type = params[:filename] == 'jpg' ? 'image/jpeg' : 'image/gif'
|
||||
|
||||
send_file(local_path, :disposition => 'inline', :type => mime_type, :x_sendfile => true )
|
||||
send_file(local_path, disposition: 'inline', type: mime_type, x_sendfile: true)
|
||||
end
|
||||
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
# Redmine Tweaks plugin for Redmine
|
||||
# Copyright (C) 2013-2015 AlphaNodes GmbH
|
||||
|
||||
# Redmine Tweak helper functions
|
||||
module RedmineTweaksHelper
|
||||
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
Deface::Override.new :virtual_path => 'welcome/index',
|
||||
:name => 'add-welcome-bottom-content',
|
||||
:insert_after => 'div.splitcontentright',
|
||||
:original => '207dcef891d8921de528bb771526f4bbd46a1571',
|
||||
:partial => 'welcome/overview_bottom'
|
||||
Deface::Override.new virtual_path: 'welcome/index',
|
||||
name: 'add-welcome-bottom-content',
|
||||
insert_after: 'div.splitcontentright',
|
||||
original: '207dcef891d8921de528bb771526f4bbd46a1571',
|
||||
partial: 'welcome/overview_bottom'
|
||||
|
@ -1,5 +1,5 @@
|
||||
Deface::Override.new :virtual_path => 'welcome/index',
|
||||
:name => 'add-welcome-top-content',
|
||||
:insert_before => 'div.splitcontentleft',
|
||||
:original => 'de8d32383c41ab447d839090a2286dfeb0a355f2',
|
||||
:partial => 'welcome/overview_top'
|
||||
Deface::Override.new virtual_path: 'welcome/index',
|
||||
name: 'add-welcome-top-content',
|
||||
insert_before: 'div.splitcontentleft',
|
||||
original: 'de8d32383c41ab447d839090a2286dfeb0a355f2',
|
||||
partial: 'welcome/overview_top'
|
||||
|
@ -1,4 +1,4 @@
|
||||
Deface::Override.new :virtual_path => 'wiki/_sidebar',
|
||||
:name => 'addto-wiki-sidebar',
|
||||
:insert_after => 'ul',
|
||||
:partial => 'wiki/global_sidebar'
|
||||
Deface::Override.new virtual_path: 'wiki/_sidebar',
|
||||
name: 'addto-wiki-sidebar',
|
||||
insert_after: 'ul',
|
||||
partial: 'wiki/global_sidebar'
|
||||
|
@ -1,5 +1,5 @@
|
||||
Deface::Override.new :virtual_path => 'welcome/index',
|
||||
:name => 'remove-welcome-latest_projects',
|
||||
:original =>'bd5d94c8882c7f599059c917195497b10d519b64',
|
||||
:replace => 'div.projects',
|
||||
:partial => 'welcome/remove_projects'
|
||||
Deface::Override.new virtual_path: 'welcome/index',
|
||||
name: 'remove-welcome-latest_projects',
|
||||
original: 'bd5d94c8882c7f599059c917195497b10d519b64',
|
||||
replace: 'div.projects',
|
||||
partial: 'welcome/remove_projects'
|
||||
|
@ -1,5 +1,5 @@
|
||||
Deface::Override.new :virtual_path => 'welcome/index',
|
||||
:name => 'remove-welcome-news',
|
||||
:replace => 'div.news',
|
||||
:original => '163f5df8f0cb2d5009d7f57ad38174ed29201a1a',
|
||||
:partial => 'welcome/remove_news'
|
||||
Deface::Override.new virtual_path: 'welcome/index',
|
||||
name: 'remove-welcome-news',
|
||||
replace: 'div.news',
|
||||
original: '163f5df8f0cb2d5009d7f57ad38174ed29201a1a',
|
||||
partial: 'welcome/remove_news'
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
module RedmineTweaks
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
|
||||
desc <<-EOHELP
|
||||
Display current dates. Examples:
|
||||
|
||||
@ -19,38 +18,37 @@ EOHELP
|
||||
|
||||
macro :current_year do |obj, args|
|
||||
@current_date = Time.now.year
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
|
||||
macro :current_month do |obj, args|
|
||||
@current_date = Time.now.month
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
|
||||
macro :current_day do |obj, args|
|
||||
@current_date = Time.now.day
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
|
||||
macro :current_hour do |obj, args|
|
||||
@current_date = Time.now.hour
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
|
||||
macro :current_min do |obj, args|
|
||||
@current_date = Time.now.min
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
|
||||
macro :current_weekday do |obj, args|
|
||||
@current_date = day_name Time.now.wday
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
|
||||
macro :current_weeknumber do |obj, args|
|
||||
@current_date = Date.today.cweek
|
||||
render :partial => 'wiki/date_macros', :locals => { :current_date => @current_date }
|
||||
end
|
||||
|
||||
render partial: 'wiki/date_macros', locals: { current_date: @current_date }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,8 +7,6 @@ require_dependency 'redmine_tweaks_helper'
|
||||
module RedmineTweaks
|
||||
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
|
||||
|
||||
desc <<-EOHELP
|
||||
Garfield macro to include garfield strip of the day.
|
||||
|
||||
@ -29,11 +27,11 @@ EOHELP
|
||||
when 3 then file = RedmineTweaks.get_garfield(Date.parse(args[2] + '-' + args[1] + '-' + args[0]))
|
||||
when 0 then file = RedmineTweaks.get_garfield(Date.today)
|
||||
else
|
||||
out = "<pre>Error in garfield macro. The correct usage is {{garfield([<yyyy>,<mm>,<dd>])}}.</pre>"
|
||||
out = '<pre>Error in garfield macro. The correct usage is {{garfield([<yyyy>,<mm>,<dd>])}}.</pre>'
|
||||
end
|
||||
|
||||
image = url_for(:controller=>'garfield', :action=>'show', :name => file[:name], :type => file[:type])
|
||||
content_tag(:img, '', :alt=>"Garfield strip #{file[:name]}", :class=>'garfield', :src=>image)
|
||||
image = url_for(controller: 'garfield', action: 'show', name: file[:name], type: file[:type])
|
||||
content_tag(:img, '', alt: "Garfield strip #{file[:name]}", class: 'garfield', src: image)
|
||||
end
|
||||
end
|
||||
|
||||
@ -57,6 +55,6 @@ EOHELP
|
||||
end
|
||||
}
|
||||
end
|
||||
{ :name => filename, :type => type }
|
||||
{ name: filename, type: type }
|
||||
end
|
||||
end
|
||||
|
@ -5,16 +5,16 @@ module RedmineTweaks
|
||||
|
||||
class RedmineTweaksHookListener < Redmine::Hook::ViewListener
|
||||
|
||||
render_on(:view_layouts_base_html_head, :partial => 'global_header')
|
||||
render_on(:view_layouts_base_content, :partial => 'global_content')
|
||||
render_on(:view_layouts_base_body_bottom, :partial => 'global_footer')
|
||||
render_on(:view_layouts_base_html_head, partial: 'global_header')
|
||||
render_on(:view_layouts_base_content, partial: 'global_content')
|
||||
render_on(:view_layouts_base_body_bottom, partial: 'global_footer')
|
||||
|
||||
render_on(:view_account_login_bottom, :partial => 'login_text')
|
||||
render_on(:view_welcome_index_right, :partial => 'overview_right')
|
||||
render_on(:view_issues_new_top, :partial => 'new_ticket_message')
|
||||
render_on(:view_issues_sidebar_queries_bottom, :partial => 'global_sidebar')
|
||||
render_on(:view_projects_show_right, :partial => 'project_overview')
|
||||
render_on(:view_projects_show_sidebar_bottom, :partial => 'global_sidebar')
|
||||
render_on(:view_account_login_bottom, partial: 'login_text')
|
||||
render_on(:view_welcome_index_right, partial: 'overview_right')
|
||||
render_on(:view_issues_new_top, partial: 'new_ticket_message')
|
||||
render_on(:view_issues_sidebar_queries_bottom, partial: 'global_sidebar')
|
||||
render_on(:view_projects_show_right, partial: 'project_overview')
|
||||
render_on(:view_projects_show_sidebar_bottom, partial: 'global_sidebar')
|
||||
end
|
||||
|
||||
def self.settings() Setting[:plugin_redmine_tweaks] end
|
||||
|
@ -2,9 +2,7 @@
|
||||
# Copyright (C) 2013-2015 AlphaNodes GmbH
|
||||
|
||||
module RedmineTweaks
|
||||
|
||||
module IssuePatch
|
||||
|
||||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
module RedmineTweaks
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
|
||||
desc <<-EOHELP
|
||||
Display projects.
|
||||
|
||||
@ -29,16 +28,16 @@ EOHELP
|
||||
@projects = RedmineTweaks.load_projects
|
||||
return '' if @projects.nil?
|
||||
|
||||
@html_options = {:class => 'external'}
|
||||
render :partial => 'wiki/project_macros', :locals => {:projects => @projects,
|
||||
:list_title => options[:title],
|
||||
:with_create_issue => options[:with_create_issue]}
|
||||
@html_options = { class: 'external' }
|
||||
render partial: 'wiki/project_macros', locals: { projects: @projects,
|
||||
list_title: options[:title],
|
||||
with_create_issue: options[:with_create_issue] }
|
||||
end
|
||||
end
|
||||
|
||||
def self.load_projects
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
all_projects = Project.active.visible(User.current).find(:all, :order => "projects.name")
|
||||
all_projects = Project.active.visible(User.current).find(:all, order: 'projects.name')
|
||||
else
|
||||
all_projects = Project.visible.sorted
|
||||
end
|
||||
@ -50,5 +49,4 @@ EOHELP
|
||||
end
|
||||
my_projects
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
module RedmineTweaks
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
|
||||
desc <<-EOHELP
|
||||
Display users.
|
||||
|
||||
@ -51,7 +50,7 @@ EOHELP
|
||||
users = []
|
||||
raw_users.each {|user|
|
||||
user_roles[user.id] = user.roles_for_project(project)
|
||||
if !options[:role].present? or RedmineTweaks.check_role_matches(user_roles[user.id], options[:role])
|
||||
if !options[:role].present? || RedmineTweaks.check_role_matches(user_roles[user.id], options[:role])
|
||||
users << user
|
||||
end
|
||||
}
|
||||
@ -64,16 +63,16 @@ EOHELP
|
||||
return ''
|
||||
end
|
||||
end
|
||||
render :partial => 'wiki/user_macros', :locals => {:users => users,
|
||||
:user_roles => user_roles,
|
||||
:list_title => options[:title]}
|
||||
render partial: 'wiki/user_macros', locals: { users: users,
|
||||
user_roles: user_roles,
|
||||
list_title: options[:title] }
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_role_matches(roles, filters)
|
||||
filters.gsub('|', ',').split(',').each {|filter|
|
||||
roles.each {|role|
|
||||
if filter.to_s() == role.to_s()
|
||||
if filter.to_s == role.to_s
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ end
|
||||
require_dependency 'wiki_controller'
|
||||
|
||||
module RedmineTweaks
|
||||
|
||||
module WikiControllerPatch
|
||||
def self.included(base) # :nodoc:
|
||||
base.send(:include, InstanceMethodsForRedmineTweaksWikiController)
|
||||
@ -19,9 +18,8 @@ module RedmineTweaks
|
||||
end
|
||||
|
||||
module InstanceMethodsForRedmineTweaksWikiController
|
||||
|
||||
def respond_to_with_redmine_tweaks(&block)
|
||||
if @project and @content
|
||||
if @project && @content
|
||||
if (@_action_name == 'show')
|
||||
redmine_tweaks_include_header
|
||||
redmine_tweaks_include_footer
|
||||
@ -33,7 +31,6 @@ module RedmineTweaks
|
||||
private
|
||||
|
||||
def redmine_tweaks_include_header
|
||||
|
||||
wiki_header = '' + Setting.plugin_redmine_tweaks['global_wiki_header']
|
||||
|
||||
if Object.const_defined?('WikiExtensionsUtil') && WikiExtensionsUtil.is_enabled?(@project)
|
||||
@ -56,7 +53,6 @@ module RedmineTweaks
|
||||
end
|
||||
|
||||
def redmine_tweaks_include_footer
|
||||
|
||||
wiki_footer = '' + Setting.plugin_redmine_tweaks['global_wiki_footer']
|
||||
|
||||
if Object.const_defined?('WikiExtensionsUtil') && WikiExtensionsUtil.is_enabled?(@project)
|
||||
@ -76,5 +72,4 @@ module RedmineTweaks
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -8,7 +8,6 @@ end
|
||||
require_dependency 'wiki'
|
||||
|
||||
module RedmineTweaks
|
||||
|
||||
module WikiPatch
|
||||
def self.included(base) # :nodoc:
|
||||
base.send(:include, InstanceMethodsForRedmineTweaksWiki)
|
||||
@ -19,19 +18,17 @@ module RedmineTweaks
|
||||
end
|
||||
|
||||
module InstanceMethodsForRedmineTweaksWiki
|
||||
|
||||
def sidebar_with_redmine_tweaks
|
||||
@sidebar ||= find_page('Sidebar', :with_redirect => false)
|
||||
unless @sidebar && @sidebar.content
|
||||
wiki_sidebar = '' + Setting.plugin_redmine_tweaks['global_wiki_sidebar']
|
||||
@sidebar ||= find_page('Wiki', :with_redirect => false)
|
||||
if wiki_sidebar != '' && @sidebar.try(:content)
|
||||
@sidebar.content.text = wiki_sidebar;
|
||||
end
|
||||
else
|
||||
@sidebar ||= find_page('Sidebar', with_redirect: false)
|
||||
if @sidebar && @sidebar.content
|
||||
sidebar_without_redmine_tweaks
|
||||
else
|
||||
wiki_sidebar = '' + Setting.plugin_redmine_tweaks['global_wiki_sidebar']
|
||||
@sidebar ||= find_page('Wiki', with_redirect: false)
|
||||
if wiki_sidebar != '' && @sidebar.try(:content)
|
||||
@sidebar.content.text = wiki_sidebar
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Redmine Tweaks plugin for Redmine
|
||||
# Copyright (C) 2013-2015 AlphaNodes GmbH
|
||||
|
||||
# RedmineTweak Youtube macro
|
||||
module RedmineTweaks
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
|
||||
desc <<-EOHELP
|
||||
Youtube macro to include youtube video.
|
||||
|
||||
@ -20,7 +20,7 @@ Youtube macro to include youtube video.
|
||||
EOHELP
|
||||
|
||||
# Register youtube macro
|
||||
macro :youtube do |youtube_wiki_content, args|
|
||||
macro :youtube do |_youtube_wiki_content, args|
|
||||
h = 360
|
||||
w = 640
|
||||
if args.length >= 1
|
||||
@ -31,17 +31,16 @@ EOHELP
|
||||
h = args[2]
|
||||
end
|
||||
|
||||
unless args[3].nil? || args[3] == 1
|
||||
src = "//www.youtube.com/embed/" + v + "?autoplay=1"
|
||||
if args[3].nil? || args[3] == 1
|
||||
src = '//www.youtube-nocookie.com/embed/' + v
|
||||
else
|
||||
src = "//www.youtube-nocookie.com/embed/" + v
|
||||
src = '//www.youtube.com/embed/' + v + '?autoplay=1'
|
||||
end
|
||||
|
||||
content_tag(:iframe, '', :width=>w, :height=>h, :src=>src, :frameborder=>0, :allowfullscreen=>"true" )
|
||||
content_tag(:iframe, '', width: w, height: h, src: src, frameborder: 0, allowfullscreen: 'true')
|
||||
else
|
||||
out = "<pre>Error in youtube macro. The correct usage is {{youtube(<video key>,[<width>,<height>])}}.</pre>"
|
||||
end
|
||||
|
||||
'<pre>Error in youtube macro. The correct usage is {{youtube(<video key>,[<width>,<height>])}}.</pre>'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
# Redmine Tweaks integration tests
|
||||
class CommonViewsTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users, :email_addresses,
|
||||
@ -27,18 +28,18 @@ class CommonViewsTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Ba
|
||||
@request.env['HTTP_REFERER'] = '/'
|
||||
end
|
||||
|
||||
test "View user" do
|
||||
log_user("admin", "admin")
|
||||
get "/users/2"
|
||||
test 'View user' do
|
||||
log_user('admin', 'admin')
|
||||
get '/users/2'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "View issue" do
|
||||
log_user("admin", "admin")
|
||||
EnabledModule.create(:project_id => 1, :name => 'issue_tracking')
|
||||
issue = Issue.where(:id => 1).first
|
||||
test 'View issue' do
|
||||
log_user('admin', 'admin')
|
||||
EnabledModule.create(project_id: 1, name: 'issue_tracking')
|
||||
issue = Issue.where(id: 1).first
|
||||
issue.save
|
||||
get "/issues/1"
|
||||
get '/issues/1'
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
|
||||
|
||||
# Redmine Tweaks helper class for tests
|
||||
class RedmineTweaks::TestCase
|
||||
include ActionDispatch::TestProcess
|
||||
def self.plugin_fixtures(plugin, *fixture_names)
|
||||
@ -20,26 +21,26 @@ class RedmineTweaks::TestCase
|
||||
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
|
||||
end
|
||||
|
||||
def self.is_arrays_equal(a1, a2)
|
||||
def self.arrays_equal?(a1, a2)
|
||||
(a1 - a2) - (a2 - a1) == []
|
||||
end
|
||||
|
||||
def self.create_fixtures(fixtures_directory, table_names, class_names = {})
|
||||
def self.create_fixtures(fixtures_directory, table_names, _class_names = {})
|
||||
if ActiveRecord::VERSION::MAJOR >= 4
|
||||
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, class_names = {})
|
||||
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, _class_names = {})
|
||||
else
|
||||
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, class_names = {})
|
||||
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, _class_names = {})
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepare
|
||||
Role.where(:id => [1, 2]).each do |r|
|
||||
Role.where(id: [1, 2]).each do |r|
|
||||
r.permissions << :view_issues
|
||||
r.save
|
||||
end
|
||||
|
||||
Project.where(:id => [1, 2]).each do |project|
|
||||
EnabledModule.create(:project => project, :name => 'issue_tracking')
|
||||
Project.where(id: [1, 2]).each do |project|
|
||||
EnabledModule.create(project: project, name: 'issue_tracking')
|
||||
end
|
||||
end
|
||||
end
|
@ -3,15 +3,14 @@
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
# Redmine Tweaks unit tests
|
||||
class TweaksTest < ActiveSupport::TestCase
|
||||
|
||||
fixtures :users, :members, :projects, :roles, :member_roles,
|
||||
:journals, :journal_details,
|
||||
:groups_users,
|
||||
:enabled_modules
|
||||
|
||||
def setup
|
||||
|
||||
@admin = User.find(1)
|
||||
@jsmith = User.find(2)
|
||||
@dlopper = User.find(3)
|
||||
|
Loading…
x
Reference in New Issue
Block a user