Commit bcbb328c authored by Holger Just's avatar Holger Just

Merge branch 'master' of git://github.com/edavis10/redmine into journals

parents bc6805a6 bc3ad9af
......@@ -43,6 +43,7 @@ class MembersController < ApplicationController
format.js {
render(:update) {|page|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
page << 'hideOnLoad()'
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
}
}
......@@ -69,6 +70,7 @@ class MembersController < ApplicationController
format.js {
render(:update) {|page|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
page << 'hideOnLoad()'
page.visual_effect(:highlight, "member-#{@member.id}")
}
}
......@@ -82,7 +84,11 @@ class MembersController < ApplicationController
end
respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} }
format.js { render(:update) {|page|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
page << 'hideOnLoad()'
}
}
end
end
......
......@@ -27,7 +27,7 @@ class ProjectsController < ApplicationController
before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy, :activity ]
before_filter :authorize_global, :only => :add
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
accept_key_auth :activity
accept_key_auth :activity, :index
after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do |controller|
if controller.request.post?
......
......@@ -43,7 +43,7 @@ class SearchController < ApplicationController
begin; offset = params[:offset].to_time if params[:offset]; rescue; end
# quick jump to an issue
if @question.match(/^#?(\d+)$/) && Issue.visible.find_by_id($1)
if @question.match(/^#?(\d+)$/) && Issue.visible.find_by_id($1.to_i)
redirect_to :controller => "issues", :action => "show", :id => $1
return
end
......
......@@ -225,8 +225,11 @@ class TimelogController < ApplicationController
def destroy
(render_404; return) unless @time_entry
(render_403; return) unless @time_entry.editable_by?(User.current)
@time_entry.destroy
flash[:notice] = l(:notice_successful_delete)
if @time_entry.destroy && @time_entry.destroyed?
flash[:notice] = l(:notice_successful_delete)
else
flash[:error] = l(:notice_unable_delete_time_entry)
end
redirect_to :back
rescue ::ActionController::RedirectBackError
redirect_to :action => 'details', :project_id => @time_entry.project
......
......@@ -83,7 +83,7 @@ private
replace_ids = [params[:replace]]
end
else
replace_ids = 'watcher'
replace_ids = ['watcher']
end
respond_to do |format|
format.html { redirect_to :back }
......
......@@ -141,7 +141,6 @@ class Attachment < ActiveRecord::Base
# :unsaved => array of the files that could not be attached
def self.attach_files(obj, attachments)
attached = []
unsaved = []
if attachments && attachments.is_a?(Hash)
attachments.each_value do |attachment|
file = attachment['file']
......@@ -150,7 +149,13 @@ class Attachment < ActiveRecord::Base
:file => file,
:description => attachment['description'].to_s.strip,
:author => User.current)
a.new_record? ? (obj.unsaved_attachments << a) : (attached << a)
if a.new_record?
obj.unsaved_attachments ||= []
obj.unsaved_attachments << a
else
attached << a
end
end
end
{:files => attached, :unsaved => obj.unsaved_attachments}
......
......@@ -49,7 +49,7 @@ class MailHandler < ActionMailer::Base
logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" if logger && logger.info
return false
end
@user = User.find_by_mail(sender_email)
@user = User.find_by_mail(sender_email) if sender_email.present?
if @user && !@user.active?
logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]" if logger && logger.info
return false
......@@ -134,7 +134,7 @@ class MailHandler < ActionMailer::Base
if status && issue.new_statuses_allowed_to(user).include?(status)
issue.status = status
end
issue.subject = email.subject.chomp
issue.subject = email.subject.chomp[0,255]
if issue.subject.blank?
issue.subject = '(no subject)'
end
......
......@@ -53,7 +53,7 @@ class User < Principal
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password, :group_ids
validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }
validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }, :case_sensitive => false
validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false
# Login must contain lettres, numbers, underscores only
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
......@@ -96,7 +96,7 @@ class User < Principal
def self.try_to_login(login, password)
# Make sure no one can sign in with an empty password
return nil if password.to_s.empty?
user = find(:first, :conditions => ["login=?", login])
user = find_by_login(login)
if user
# user is already in local database
return nil if !user.active?
......@@ -221,7 +221,19 @@ class User < Principal
@notified_projects_ids = nil
notified_projects_ids
end
# Find a user account by matching the exact login and then a case-insensitive
# version. Exact matches will be given priority.
def self.find_by_login(login)
# force string comparison to be case sensitive on MySQL
type_cast = (ActiveRecord::Base.connection.adapter_name == 'MySQL') ? 'BINARY' : ''
# First look for an exact match
user = first(:conditions => ["#{type_cast} login = ?", login])
# Fail over to case-insensitive if none was found
user ||= first(:conditions => ["#{type_cast} LOWER(login) = ?", login.to_s.downcase])
end
def self.find_by_rss_key(key)
token = Token.find_by_value(key)
token && token.user.active? ? token.user : nil
......
......@@ -6,7 +6,7 @@
<tr>
<% day = calendar.startdt
while day <= calendar.enddt %>
<%= "<td class='week-number' title='#{ l(:label_week) }'>#{day.cweek}</td>" if day.cwday == calendar.first_wday %>
<%= "<td class='week-number' title='#{ l(:label_week) }'>#{(day+(11-day.cwday)%7).cweek}</td>" if day.cwday == calendar.first_wday %>
<td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>">
<p class="day-num"><%= day.day %></p>
<% calendar.events_on(day).each do |i| %>
......
......@@ -10,7 +10,7 @@
<% form_tag({ :controller => 'queries', :action => 'new' }, :id => 'query_form') do %>
<%= hidden_field_tag('project_id', @project.to_param) if @project %>
<div id="query_form_content">
<div id="query_form_content" class="hide-when-print">
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
<div style="<%= @query.new_record? ? "" : "display: none;" %>">
......@@ -33,7 +33,7 @@
</div>
</fieldset>
</div>
<p class="buttons">
<p class="buttons hide-when-print">
<%= link_to_remote l(:button_apply),
{ :url => { :set_filter => 1 },
......
......@@ -17,10 +17,10 @@
<% if Setting.rest_api_enabled? %>
<h4><%= l(:label_api_access_key) %></h4>
<p>
<div>
<%= link_to_function(l(:button_show), "$('api-access-key').toggle();")%>
<pre id='api-access-key' class='autoscroll'><%= @user.api_key %></pre>
</p>
</div>
<%= javascript_tag("$('api-access-key').hide();") %>
<p>
<% if @user.api_token %>
......
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
<% end %>
<div class="contextual">
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
<%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %>
<%= link_to(l(:label_overall_spent_time), { :controller => 'time_entries' }) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %>
<%= link_to l(:label_overall_activity), { :controller => 'projects', :action => 'activity' }%>
</div>
......
......@@ -13,6 +13,7 @@
<h3><%=l(:field_author)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'author' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
<br />
<%= call_hook(:view_reports_issue_report_split_content_left, :project => @project) %>
</div>
<div class="splitcontentright">
......@@ -27,5 +28,6 @@
<h3><%=l(:field_category)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'category' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
<br />
<%= call_hook(:view_reports_issue_report_split_content_right, :project => @project) %>
</div>
......@@ -24,6 +24,6 @@ config.action_controller.session = {
# Skip protect_from_forgery in requests http://m.onkey.org/2007/9/28/csrf-protection-for-your-existing-rails-application
config.action_controller.allow_forgery_protection = false
config.gem "shoulda"
config.gem "shoulda", :version => "~> 2.10.3"
config.gem "edavis10-object_daddy", :lib => "object_daddy"
config.gem "mocha"
......@@ -896,3 +896,5 @@ bg:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -920,3 +920,5 @@ bs:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -899,3 +899,5 @@ ca:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -902,3 +902,5 @@ cs:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -922,3 +922,5 @@ da:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -175,6 +175,7 @@ de:
notice_account_pending: "Ihr Konto wurde erstellt und wartet jetzt auf die Genehmigung des Administrators."
notice_default_data_loaded: Die Standard-Konfiguration wurde erfolgreich geladen.
notice_unable_delete_version: Die Version konnte nicht gelöscht werden.
notice_unable_delete_time_entry: Der Zeiterfassungseintrag konnte nicht gelöscht werden.
notice_issue_done_ratios_updated: Der Ticket-Fortschritt wurde aktualisiert.
error_can_t_load_default_data: "Die Standard-Konfiguration konnte nicht geladen werden: {{value}}"
......@@ -646,6 +647,7 @@ de:
label_changes_details: Details aller Änderungen
label_issue_tracking: Tickets
label_spent_time: Aufgewendete Zeit
label_overall_spent_time: Aufgewendete Zeit aller Projekte anzeigen
label_f_hour: "{{value}} Stunde"
label_f_hour_plural: "{{value}} Stunden"
label_time_tracking: Zeiterfassung
......
......@@ -902,3 +902,5 @@ el:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
This diff is collapsed.
......@@ -153,6 +153,7 @@ en:
notice_account_pending: "Your account was created and is now pending administrator approval."
notice_default_data_loaded: Default configuration successfully loaded.
notice_unable_delete_version: Unable to delete version.
notice_unable_delete_time_entry: Unable to delete time log entry.
notice_issue_done_ratios_updated: Issue done ratios updated.
error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}"
......@@ -638,6 +639,7 @@ en:
label_changes_details: Details of all changes
label_issue_tracking: Issue tracking
label_spent_time: Spent time
label_overall_spent_time: Overall spent time
label_f_hour: "{{value}} hour"
label_f_hour_plural: "{{value}} hours"
label_time_tracking: Time tracking
......
......@@ -946,3 +946,5 @@ es:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -906,3 +906,5 @@ eu:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -932,3 +932,5 @@ fi:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -925,3 +925,5 @@ fr:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -922,3 +922,5 @@ gl:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -906,3 +906,5 @@ he:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -909,3 +909,5 @@ hr:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -929,3 +929,5 @@
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -914,3 +914,5 @@ id:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -909,3 +909,5 @@ it:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -183,6 +183,7 @@ ja:
notice_account_pending: アカウントは作成済みで、管理者の承認待ちです。
notice_default_data_loaded: デフォルト設定をロードしました。
notice_unable_delete_version: バージョンを削除できません
notice_unable_delete_time_entry: 作業時間を削除できません
notice_issue_done_ratios_updated: チケットの進捗が更新されました。
error_can_t_load_default_data: "デフォルト設定がロードできませんでした: {{value}}"
......@@ -670,6 +671,7 @@ ja:
label_changes_details: 全変更の詳細
label_issue_tracking: チケットトラッキング
label_spent_time: 作業時間の記録
label_overall_spent_time: 全ての作業時間の記録
label_f_hour: "{{value}}時間"
label_f_hour_plural: "{{value}}時間"
label_time_tracking: 時間トラッキング
......
......@@ -962,3 +962,5 @@ ko:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -970,3 +970,5 @@ lt:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -897,3 +897,5 @@ lv:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -903,3 +903,5 @@ mn:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -884,3 +884,5 @@ nl:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -897,3 +897,5 @@
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -927,3 +927,5 @@ pl:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -930,3 +930,5 @@ pt-BR:
notice_failed_to_save_members: "Falha ao gravar membro(s): {{errors}}."
text_zoom_out: Afastar zoom
text_zoom_in: Aproximar zoom
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -914,3 +914,5 @@ pt:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -899,3 +899,5 @@ ro:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -1022,3 +1022,5 @@ ru:
field_principal: Глава
text_zoom_out: Отдалить
text_zoom_in: Приблизить
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -901,3 +901,5 @@ sk:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -901,3 +901,5 @@ sl:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -903,3 +903,5 @@ sr-CY:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -903,3 +903,5 @@ sr:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -197,7 +197,8 @@ sv:
notice_email_error: "Ett fel inträffade när mail skickades ({{value}})"
notice_feeds_access_key_reseted: Din RSS-nyckel återställdes.
notice_api_access_key_reseted: Din API-nyckel återställdes.
notice_failed_to_save_issues: "Misslyckades att spara {{count}} ärende(n) {{total}} valt: {{ids}}."
notice_failed_to_save_issues: "Misslyckades med att spara {{count}} ärende(n) {{total}} valt: {{ids}}."
notice_failed_to_save_members: "Misslyckades med att spara medlem(mar): {{errors}}."
notice_no_issue_selected: "Inget ärende är markerat! Var vänlig, markera de ärenden du vill ändra."
notice_account_pending: "Ditt konto skapades och avvaktar nu administratörens godkännande."
notice_default_data_loaded: Standardkonfiguration inläst.
......@@ -277,6 +278,7 @@ sv:
field_priority: Prioritet
field_fixed_version: Versionsmål
field_user: Användare
field_principal: Principal
field_role: Roll
field_homepage: Hemsida
field_is_public: Publik
......@@ -509,6 +511,7 @@ sv:
label_my_page: Min sida
label_my_account: Mitt konto
label_my_projects: Mina projekt
label_my_page_block: '"Min sida"-block'
label_administration: Administration
label_login: Logga in
label_logout: Logga ut
......@@ -919,6 +922,8 @@ sv:
text_wiki_page_destroy_children: Ta bort alla underliggande sidor
text_wiki_page_reassign_children: Flytta undersidor till denna föräldersida
text_own_membership_delete_confirmation: "Några av, eller alla, dina behörigheter kommer att tas bort och du kanske inte längre kommer kunna göra ändringar i det här projektet.\nVill du verkligen fortsätta?"
text_zoom_out: Zooma ut
text_zoom_in: Zooma in
default_role_manager: Projektledare
default_role_developper: Utvecklare
......@@ -946,8 +951,5 @@ sv:
enumeration_doc_categories: Dokumentkategorier
enumeration_activities: Aktiviteter (tidsuppföljning)
enumeration_system_activity: Systemaktivitet
field_principal: Principal
label_my_page_block: My page block
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -899,3 +899,5 @@ th:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -929,3 +929,5 @@ tr:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -898,3 +898,5 @@ uk:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -961,3 +961,5 @@ vi:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -991,3 +991,5 @@
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤)
enumeration_system_activity: 系統活動
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -924,3 +924,5 @@ zh:
notice_failed_to_save_members: "Failed to save member(s): {{errors}}."
text_zoom_out: Zoom out
text_zoom_in: Zoom in
notice_unable_delete_time_entry: Unable to delete time log entry.
label_overall_spent_time: Overall spent time
......@@ -8,6 +8,18 @@ http://www.redmine.org/
Adds context menu to the roadmap issue lists
== 2010-06-24 v0.9.5
Linkify folder names on revision view
"fiters" and "options" should be hidden in print view via css
Fixed: NoMethodError when no issue params are submitted
Fixed: projects.atom with required authentication
Fixed: External links not correctly displayed in Wiki TOC
Fixed: Member role forms in project settings are not hidden after member added
Fixed: pre can't be inside p
Fixed: session cookie path does not respect RAILS_RELATIVE_URL_ROOT
Fixed: mail handler fails when the from address is empty
== 2010-05-01 v0.9.4
Filters collapsed by default on issues index page for a saved query
......
......@@ -33,7 +33,7 @@ Optional:
4. Generate a session store secret
Redmine stores session data in cookies by default, which requires
a secret to be generated. Run:
rake config/initializers/session_store.rb
rake generate_session_store
5. Create the database structure. Under the application main directory:
rake db:migrate RAILS_ENV="production"
......
......@@ -12,12 +12,12 @@ http://www.redmine.org/
2. Copy your database settings (RAILS_ROOT/config/database.yml)
and SMTP settings (RAILS_ROOT/config/email.yml)
into the new config directory
DO NOT REPLACE ANY OTHERS FILES.
DO NOT REPLACE OR EDIT ANY OTHER FILES.
3. Generate a session store secret
Redmine stores session data in cookies by default, which requires
a secret to be generated. Run:
rake config/initializers/session_store.rb
rake generate_session_store
4. Migrate your database (please make a backup before doing this):
rake db:migrate RAILS_ENV="production"
......
......@@ -5,4 +5,6 @@ Redmine::Plugin.register :<%= plugin_name %> do
author 'Author name'
description 'This is a plugin for Redmine'
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
end
class <%= class_name %>Controller < ApplicationController
unloadable
<% actions.each do |action| -%>
def <%= action %>
......
class <%= class_name %> < ActiveRecord::Base
unloadable
end
......@@ -47,7 +47,7 @@ module Redmine
# Get info about the svn repository
def info
cmd = "#{SVN_BIN} info --xml #{target('')}"
cmd = "#{SVN_BIN} info --xml #{target}"
cmd << credentials_string
info = nil
shellout(cmd) do |io|
......@@ -77,7 +77,7 @@ module Redmine
path ||= ''
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
entries = Entries.new
cmd = "#{SVN_BIN} list --xml #{target(URI.escape(path))}@#{identifier}"
cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}"
cmd << credentials_string
shellout(cmd) do |io|
output = io.read
......@@ -116,7 +116,7 @@ module Redmine
return nil unless self.class.client_version_above?([1, 5, 0])
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
cmd = "#{SVN_BIN} proplist --verbose --xml #{target(URI.escape(path))}@#{identifier}"
cmd = "#{SVN_BIN} proplist --verbose --xml #{target(path)}@#{identifier}"
cmd << credentials_string
properties = {}
shellout(cmd) do |io|
......@@ -142,7 +142,7 @@ module Redmine
cmd << credentials_string
cmd << " --verbose " if options[:with_paths]
cmd << " --limit #{options[:limit].to_i}" if options[:limit]
cmd << ' ' + target(URI.escape(path))
cmd << ' ' + target(path)
shellout(cmd) do |io|
output = io.read
begin
......@@ -180,7 +180,7 @@ module Redmine
cmd = "#{SVN_BIN} diff -r "
cmd << "#{identifier_to}:"
cmd << "#{identifier_from}"
cmd << " #{target(URI.escape(path))}@#{identifier_from}"
cmd << " #{target(path)}@#{identifier_from}"
cmd << credentials_string
diff = []
shellout(cmd) do |io|
......@@ -194,7 +194,7 @@ module Redmine
def cat(path, identifier=nil)
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
cmd = "#{SVN_BIN} cat #{target(URI.escape(path))}@#{identifier}"
cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}"
cmd << credentials_string
cat = nil
shellout(cmd) do |io|
......@@ -207,7 +207,7 @@ module Redmine
def annotate(path, identifier=nil)
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
cmd = "#{SVN_BIN} blame #{target(URI.escape(path))}@#{identifier}"
cmd = "#{SVN_BIN} blame #{target(path)}@#{identifier}"
cmd << credentials_string
blame = Annotate.new
shellout(cmd) do |io|
......@@ -243,6 +243,13 @@ module Redmine
end
end
end
def target(path = '')
base = path.match(/^\//) ? root_url : url
uri = "#{base}/#{path}"
uri = URI.escape(URI.escape(uri), '[]')
shell_quote(uri.gsub(/[?<>\*]/, ''))
end
end
end
end
......
......@@ -4,7 +4,7 @@ module Redmine
module VERSION #:nodoc:
MAJOR = 0
MINOR = 9
TINY = 4
TINY = 5
# Branch values:
# * official release: nil
......
......@@ -65,6 +65,11 @@ module Redmine
def textile_p_withtoc(tag, atts, cite, content)
# removes wiki links from the item
toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
# sanitizes titles from links
# see redcloth3.rb, same as "#{pre}#{text}#{post}"
toc_item.gsub!(LINK_RE) { [$2, $4, $9].join }
# sanitizes image links from titles
toc_item.gsub!(IMAGE_RE) { [$5].join }
# removes styles
# eg. %{color:red}Triggers% => Triggers
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
......
......@@ -25,7 +25,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
super
end
(field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
(field_helpers - %w(radio_button hidden_field fields_for) + %w(date_select)).each do |selector|
src = <<-END_SRC
def #{selector}(field, options = {})
label_for_field(field, options) + super
......
......@@ -17,6 +17,13 @@ file 'config/initializers/session_store.rb' do
# you'll be exposed to dictionary attacks.
ActionController::Base.session = {
:session_key => '_redmine_session',
#
# Uncomment and edit the :session_path below if are hosting your Redmine
# at a suburi and don't want the top level path to access the cookies
#
# See: http://www.redmine.org/issues/3968
#
# :session_path => '/url_path_to/your/redmine/',
:secret => '#{secret}'
}
EOF
......
......@@ -226,8 +226,10 @@ Ajax.Responders.register({
}
});
Event.observe(window, 'load', function() {
function hideOnLoad() {
$$('.hol').each(function(el) {
el.hide();
});
});
}
Event.observe(window, 'load', hideOnLoad);
......@@ -1694,15 +1694,27 @@ Date.prototype.getDayOfYear = function() {
return Math.floor(time / Date.DAY);
};
/** Returns the number of the week in year, as defined in ISO 8601. */
/** Returns the number of the week in year, as defined in ISO 8601.
This function is only correct if `this` is the first day of the week. */
Date.prototype.getWeekNumber = function() {
var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
var DoW = d.getDay();
d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
var ms = d.valueOf(); // GMT
d.setMonth(0);
d.setDate(4); // Thu in Week 1
return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
var d = new Date(this.getFullYear(), this.getMonth(), this.getDate());
var days = 1000*60*60*24; // one day in milliseconds
// get the thursday of the current week
var this_thursday = new Date(
d.valueOf() // selected date
- (d.getDay() % 7)*days // previous sunday
+ 4*days // + 4 days
).valueOf();
// the thursday in the first week of the year
var first_thursday = new Date(
new Date(this.getFullYear(), 0, 4).valueOf() // January 4 is in the first week by definition
- (d.getDay() % 7)*days // previous sunday
+ 4*days // + 4 days
).valueOf();
return Math.round((this_thursday - first_thursday) / (7*days)) + 1;
};
/** Checks date and time equality */
......
// ** I18N
// Calendar EN language
// Author: Mihai Bazon, <mihai_bazon@yahoo.com>
// Encoding: any
// Distributed under the same terms as the calendar itself.
// For translators: please use UTF-8 if possible. We strongly believe that
// Unicode is the answer to a real internationalized world. Also please
// include your contact information in the header, as can be seen above.
// full day names
Calendar._DN = new Array
("Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday");
// Please note that the following array of short day names (and the same goes
// for short month names, _SMN) isn't absolutely necessary. We give it here
// for exemplification on how one can customize the short day names, but if
// they are simply the first N letters of the full name you can simply say:
//
// Calendar._SDN_len = N; // short day name length
// Calendar._SMN_len = N; // short month name length
//
// If N = 3 then this is not needed either since we assume a value of 3 if not
// present, to be compatible with translation files that were written before
// this feature.
// short day names
Calendar._SDN = new Array
("Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun");
// First day of the week. "0" means display Sunday first, "1" means display
// Monday first, etc.
Calendar._FD = 1;
// full month names
Calendar._MN = new Array
("January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December");
// short month names
Calendar._SMN = new Array
("Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
// tooltips
Calendar._TT = {};
Calendar._TT["INFO"] = "About the calendar";
Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";
Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
Calendar._TT["GO_TODAY"] = "Go Today";
Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
Calendar._TT["SEL_DATE"] = "Select date";
Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
Calendar._TT["PART_TODAY"] = " (today)";
// the following is to inform that "%s" is to be the first day of week
// %s will be replaced with the day name.
Calendar._TT["DAY_FIRST"] = "Display %s first";
// This may be locale-dependent. It specifies the week-end days, as an array
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
// means Monday, etc.
Calendar._TT["WEEKEND"] = "0,6";
Calendar._TT["CLOSE"] = "Close";
Calendar._TT["TODAY"] = "Today";
Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
// date formats
Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
Calendar._TT["TT_DATE_FORMAT"] = "%a, %e %b";
Calendar._TT["WK"] = "wk";
Calendar._TT["TIME"] = "Time:";
jsToolBar.strings = {};
jsToolBar.strings['Strong'] = 'Strong';
jsToolBar.strings['Italic'] = 'Italic';
jsToolBar.strings['Underline'] = 'Underline';
jsToolBar.strings['Deleted'] = 'Deleted';
jsToolBar.strings['Code'] = 'Inline Code';
jsToolBar.strings['Heading 1'] = 'Heading 1';
jsToolBar.strings['Heading 2'] = 'Heading 2';
jsToolBar.strings['Heading 3'] = 'Heading 3';
jsToolBar.strings['Unordered list'] = 'Unordered list';
jsToolBar.strings['Ordered list'] = 'Ordered list';
jsToolBar.strings['Quote'] = 'Quote';
jsToolBar.strings['Unquote'] = 'Remove Quote';
jsToolBar.strings['Preformatted text'] = 'Preformatted text';
jsToolBar.strings['Wiki link'] = 'Link to a Wiki page';
jsToolBar.strings['Image'] = 'Image';
......@@ -911,4 +911,5 @@ h2 img { vertical-align:middle; }
#main { background: #fff; }
#content { width: 99%; margin: 0; padding: 0; border: 0; background: #fff; overflow: visible !important;}
#wiki_add_attachment { display:none; }
.hide-when-print { display: none; }
}
......@@ -12,10 +12,6 @@ class Attachment < ActiveRecord::Base
end
def self.generate_file
@file = 'a_file.png'
@file.stubs(:original_filename).returns('a_file.png')
@file.stubs(:content_type).returns('image/png')
@file.stubs(:read).returns(false)
@file
@file = mock_file
end
end
Return-Path: <john.doe@somenet.foo>
Received: from osiris ([127.0.0.1])
by OSIRIS
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
To: <redmine@somenet.foo>
Subject: Ticket by unknown user
Date: Sun, 22 Jun 2008 12:28:07 +0200
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
This is a ticket submitted by an unknown user.
Return-Path: <JSmith@somenet.foo>
Received: from osiris ([127.0.0.1])
by OSIRIS
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
From: "John Smith" <JSmith@somenet.foo>
To: <redmine@somenet.foo>
Subject: New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...
Date: Sun, 22 Jun 2008 12:28:07 +0200
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
platea dictumst.
--- This line starts with a delimiter and should not be stripped
This paragraph is before delimiters.
BREAK
This paragraph is between delimiters.
---
This paragraph is after the delimiter so it shouldn't appear.
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
Project: onlinestore
Status: Resolved
due date: 2010-12-31
Start Date:2010-01-01
Assigned to: John Smith
......@@ -67,6 +67,8 @@ class AdminControllerTest < ActionController::TestCase
def test_load_default_configuration_data
delete_configuration_data
post :default_configuration, :lang => 'fr'
assert_response :redirect
assert_nil flash[:error]
assert IssueStatus.find_by_name('Nouveau')
end
......
......@@ -17,4 +17,48 @@ class CalendarsControllerTest < ActionController::TestCase
assert_not_nil assigns(:calendar)
end
def test_week_number_calculation
Setting.start_of_week = 7
get :show, :month => '1', :year => '2010'
assert_response :success
assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '53'},
:descendant => {:tag => 'td',
:attributes => {:class => 'odd'}, :content => '27'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '2'}
assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '1'},
:descendant => {:tag => 'td',
:attributes => {:class => 'odd'}, :content => '3'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '9'}
Setting.start_of_week = 1
get :show, :month => '1', :year => '2010'
assert_response :success
assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '53'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '28'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '3'}
assert_tag :tag => 'tr',
:descendant => {:tag => 'td',
:attributes => {:class => 'week-number'}, :content => '1'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '4'},
:descendant => {:tag => 'td',
:attributes => {:class => 'even'}, :content => '10'}
end
end
......@@ -47,6 +47,24 @@ class DocumentsControllerTest < ActionController::TestCase
:content => 'Technical documentation'}
end
def test_index_with_long_description
# adds a long description to the first document
doc = documents(:documents_001)
doc.update_attributes(:description => <<LOREM)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut egestas, mi vehicula varius varius, ipsum massa fermentum orci, eget tristique ante sem vel mi. Nulla facilisi. Donec enim libero, luctus ac sagittis sit amet, vehicula sagittis magna. Duis ultrices molestie ante, eget scelerisque sem iaculis vitae. Etiam fermentum mauris vitae metus pharetra condimentum fermentum est pretium. Proin sollicitudin elementum quam quis pharetra. Aenean facilisis nunc quis elit volutpat mollis. Aenean eleifend varius euismod. Ut dolor est, congue eget dapibus eget, elementum eu odio. Integer et lectus neque, nec scelerisque nisi. EndOfLineHere
Vestibulum non velit mi. Aliquam scelerisque libero ut nulla fringilla a sollicitudin magna rhoncus. Praesent a nunc lorem, ac porttitor eros. Sed ac diam nec neque interdum adipiscing quis quis justo. Donec arcu nunc, fringilla eu dictum at, venenatis ac sem. Vestibulum quis elit urna, ac mattis sapien. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LOREM
get :index, :project_id => 'ecookbook'
assert_response :success
assert_template 'index'
# should only truncate on new lines to avoid breaking wiki formatting
assert_select '.wiki p', :text => (doc.description.split("\n").first + '...')
assert_select '.wiki p', :text => Regexp.new(Regexp.escape("EndOfLineHere..."))
end
def test_new_with_one_attachment
ActionMailer::Base.deliveries.clear
Setting.notified_events << 'document_added'
......
......@@ -60,6 +60,33 @@ class ProjectsControllerTest < ActionController::TestCase
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
end
context "#index" do
context "by non-admin user with view_time_entries permission" do
setup do
@request.session[:user_id] = 3
end
should "show overall spent time link" do
get :index
assert_template 'index'
assert_tag :a, :attributes => {:href => '/time_entries'}
end
end
context "by non-admin user without view_time_entries permission" do
setup do
Role.find(2).remove_permission! :view_time_entries
Role.non_member.remove_permission! :view_time_entries
Role.anonymous.remove_permission! :view_time_entries
@request.session[:user_id] = 3
end
should "not show overall spent time link" do
get :index
assert_template 'index'
assert_no_tag :a, :attributes => {:href => '/time_entries'}
end
end
end
context "#add" do
context "by admin user" do
setup do
......
......@@ -57,7 +57,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
assert_equal ['folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name)
assert_equal ['[folder_with_brackets]', 'folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name)
entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
assert_equal 'file', entry.kind
assert_equal 'subversion_test/helloworld.c', entry.path
......
......@@ -133,6 +133,12 @@ class SearchControllerTest < ActionController::TestCase
assert_response :success
assert_template 'index'
end
def test_large_integer
get :index, :q => '4615713488'
assert_response :success
assert_template 'index'
end
def test_tokens_with_quotes
get :index, :id => 1, :q => '"good bye" hello "bye bye"'
......
......@@ -116,9 +116,27 @@ class TimelogControllerTest < ActionController::TestCase
@request.session[:user_id] = 2
post :destroy, :id => 1
assert_redirected_to :action => 'details', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
assert_nil TimeEntry.find_by_id(1)
end
def test_destroy_should_fail
# simulate that this fails (e.g. due to a plugin), see #5700
TimeEntry.class_eval do
before_destroy :stop_callback_chain
def stop_callback_chain ; return false ; end
end
@request.session[:user_id] = 2
post :destroy, :id => 1
assert_redirected_to :action => 'details', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
assert_not_nil TimeEntry.find_by_id(1)
# remove the simulation
TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain }
end
def test_report_no_criteria
get :report, :project_id => 1
assert_response :success
......
......@@ -61,6 +61,16 @@ class ActiveSupport::TestCase
def uploaded_test_file(name, mime)
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime)
end
# Mock out a file
def mock_file
file = 'a_file.png'
file.stubs(:size).returns(32)
file.stubs(:original_filename).returns('a_file.png')
file.stubs(:content_type).returns('image/png')
file.stubs(:read).returns(false)
file
end
# Use a temporary directory for attachment related tests
def set_tmp_attachments_directory
......
......@@ -63,4 +63,23 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 'f8139524ebb8f32e51976982cd20a85d', Attachment.disk_filename("test_accentué")[13..-1]
assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1]
end
context "Attachmnet#attach_files" do
should "add unsaved files to the object as unsaved attachments" do
# Max size of 0 to force Attachment creation failures
with_settings(:attachment_max_size => 0) do
@project = Project.generate!
response = Attachment.attach_files(@project, {
'1' => {'file' => mock_file, 'description' => 'test'},
'2' => {'file' => mock_file, 'description' => 'test'}
})
assert response[:unsaved].present?
assert_equal 2, response[:unsaved].length
assert response[:unsaved].first.new_record?
assert response[:unsaved].second.new_record?
assert_equal response[:unsaved], @project.unsaved_attachments
end
end
end
end
......@@ -420,6 +420,10 @@ h2. Subtitle with %{color:red}red text%
h1. Another title
h2. An "Internet link":http://www.redmine.org/ inside subtitle
h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues
RAW
expected = '<ul class="toc">' +
......@@ -428,8 +432,10 @@ RAW
'<li class="heading2"><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
'<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
'<li class="heading1"><a href="#Another-title">Another title</a></li>' +
'<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
'<li class="heading2"><a href="#Project-Name">Project Name</a></li>' +
'</ul>'
assert textilizable(raw).gsub("\n", "").include?(expected)
end
......
......@@ -169,6 +169,15 @@ class MailHandlerTest < ActiveSupport::TestCase
assert issue.author.anonymous?
end
end
def test_add_issue_by_anonymous_user_with_no_from_address
Role.anonymous.add_permission!(:add_issues)
assert_no_difference 'User.count' do
issue = submit_email('ticket_by_empty_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept')
assert issue.is_a?(Issue)
assert issue.author.anonymous?
end
end
def test_add_issue_by_anonymous_user_on_private_project
Role.anonymous.add_permission!(:add_issues)
......@@ -340,6 +349,12 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
end
def test_email_with_long_subject_line
issue = submit_email('ticket_with_long_subject.eml')
assert issue.is_a?(Issue)
assert_equal issue.subject, 'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[0,255]
end
private
......
......@@ -18,7 +18,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class RepositorySubversionTest < ActiveSupport::TestCase
fixtures :projects
fixtures :projects, :repositories
def setup
@project = Project.find(1)
......@@ -30,8 +30,8 @@ class RepositorySubversionTest < ActiveSupport::TestCase
@repository.fetch_changesets
@repository.reload
assert_equal 10, @repository.changesets.count
assert_equal 18, @repository.changes.count
assert_equal 11, @repository.changesets.count
assert_equal 20, @repository.changes.count
assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
end
......@@ -43,7 +43,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
assert_equal 5, @repository.changesets.count
@repository.fetch_changesets
assert_equal 10, @repository.changesets.count
assert_equal 11, @repository.changesets.count
end
def test_latest_changesets
......@@ -62,6 +62,32 @@ class RepositorySubversionTest < ActiveSupport::TestCase
changesets = @repository.latest_changesets('subversion_test/folder', 8)
assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
end
def test_directory_listing_with_square_brackets_in_path
@repository.fetch_changesets
@repository.reload
entries = @repository.entries('subversion_test/[folder_with_brackets]')
assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
assert_equal 'README.txt', entries.first.name
end
def test_directory_listing_with_square_brackets_in_base
@project = Project.find(1)
@repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
@repository.fetch_changesets
@repository.reload
assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add'
entries = @repository.entries('')
assert_not_nil entries, 'Expect to find entries'
assert_equal 1, entries.size, 'Expect a single entry'
assert_equal 'README.txt', entries.first.name
end
else
puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
def test_fake; assert true end
......
......@@ -55,6 +55,21 @@ class UserTest < ActiveSupport::TestCase
assert user.save
end
context "User.login" do
should "be case-insensitive." do
u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
u.login = 'newuser'
u.password, u.password_confirmation = "password", "password"
assert u.save
u = User.new(:firstname => "Similar", :lastname => "User", :mail => "similaruser@somenet.foo")
u.login = 'NewUser'
u.password, u.password_confirmation = "password", "password"
assert !u.save
assert_equal I18n.translate('activerecord.errors.messages.taken'), u.errors.on(:login)
end
end
def test_mail_uniqueness_should_not_be_case_sensitive
u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
u.login = 'newuser1'
......@@ -88,6 +103,25 @@ class UserTest < ActiveSupport::TestCase
assert_equal 1, @admin.errors.count
end
context "User#try_to_login" do
should "fall-back to case-insensitive if user login is not found as-typed." do
user = User.try_to_login("AdMin", "admin")
assert_kind_of User, user
assert_equal "admin", user.login
end
should "select the exact matching user first" do
case_sensitive_user = User.generate_with_protected!(:login => 'changed', :password => 'admin', :password_confirmation => 'admin')
# bypass validations to make it appear like existing data
case_sensitive_user.update_attribute(:login, 'ADMIN')
user = User.try_to_login("ADMIN", "admin")
assert_kind_of User, user
assert_equal "ADMIN", user.login
end
end
def test_password
user = User.try_to_login("admin", "admin")
assert_kind_of User, user
......
......@@ -57,7 +57,8 @@ module Redmine
# Returns an array of watchers' email addresses
def watcher_recipients
notified = watchers.collect(&:user).select(&:active?)
notified = watcher_users.active
if respond_to?(:visible?)
notified.reject! {|user| !visible?(user)}
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment