Compare commits

...
16 Commits
Author SHA1 Message Date
Jean-Philippe Lang 924cf77a61 tagged version 2.0.1
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/tags/2.0.1@9733 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-28 07:25:08 +00:00
Jean-Philippe Lang 0512a30368 Updates for 2.0.1 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9732 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-28 07:24:38 +00:00
Jean-Philippe Lang bc945d78a6 Merged r9719, r9726, r9727 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9729 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-27 19:39:26 +00:00
Jean-Philippe Lang 8cd0626075 Merged r9701 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9728 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-27 19:25:30 +00:00
Jean-Philippe Lang 035bd65a5a Merged r9710 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9725 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-26 09:50:51 +00:00
Jean-Philippe Lang 955d2b134d Merged r9711 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9724 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-26 09:50:01 +00:00
Jean-Philippe Lang 743b55a3f9 Merged r9718 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9723 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-26 09:49:19 +00:00
Jean-Philippe Lang 881595f7f0 Merged r9712 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9722 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-26 09:48:37 +00:00
Jean-Philippe Lang 7f51bab0fc Merged r9709 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9721 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-26 09:47:48 +00:00
Jean-Philippe Lang 84d5092508 Merged r9699 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9720 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-26 09:40:31 +00:00
Jean-Philippe Lang 352d177f7e Merged r9703 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9706 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-21 19:00:26 +00:00
Jean-Philippe Lang 821ea2a757 Merged r9702 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9705 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-21 18:59:31 +00:00
Jean-Philippe Lang 7cd7b1bd8b Merged r9700 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9704 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-21 18:58:29 +00:00
Jean-Philippe Lang cf139e25a7 Merged r9696 from trunk. Updates for 2.0.0 release.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9697 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-14 22:19:13 +00:00
Jean-Philippe Lang 8b09f5d27d Set version to stable.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9695 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-14 17:02:27 +00:00
Jean-Philippe Lang d138df5241 Added 2.0-stable branch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.0-stable@9694 e93f8b46-1217-0410-a6f0-8f06a7374b81
2012-05-14 16:48:29 +00:00
28 changed files with 245 additions and 53 deletions
+1
View File
@@ -69,6 +69,7 @@ end
group :development do group :development do
gem "rdoc", ">= 2.4.2" gem "rdoc", ">= 2.4.2"
gem "yard"
end end
group :test do group :test do
+1 -1
View File
@@ -43,7 +43,7 @@ class ActivitiesController < ApplicationController
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language]) if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
respond_to do |format| respond_to do |format|
format.html { format.html {
@events_by_day = events.group_by(&:event_date) @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
render :layout => false if request.xhr? render :layout => false if request.xhr?
} }
format.atom { format.atom {
+2 -2
View File
@@ -178,7 +178,7 @@ module ApplicationHelper
end end
def format_activity_day(date) def format_activity_day(date)
date == Date.today ? l(:label_today).titleize : format_date(date) date == User.current.today ? l(:label_today).titleize : format_date(date)
end end
def format_activity_description(text) def format_activity_description(text)
@@ -352,7 +352,7 @@ module ApplicationHelper
def time_tag(time) def time_tag(time)
text = distance_of_time_in_words(Time.now, time) text = distance_of_time_in_words(Time.now, time)
if @project if @project
link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => time.to_date}, :title => format_time(time)) link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)}, :title => format_time(time))
else else
content_tag('acronym', text, :title => format_time(time)) content_tag('acronym', text, :title => format_time(time))
end end
+8 -4
View File
@@ -45,23 +45,27 @@ module WatchersHelper
# Returns a comma separated list of users watching the given object # Returns a comma separated list of users watching the given object
def watchers_list(object) def watchers_list(object)
remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
content = ''.html_safe
lis = object.watcher_users.collect do |user| lis = object.watcher_users.collect do |user|
s = avatar(user, :size => "16").to_s + link_to_user(user, :class => 'user').to_s s = ''.html_safe
s << avatar(user, :size => "16").to_s
s << link_to_user(user, :class => 'user')
if remove_allowed if remove_allowed
url = {:controller => 'watchers', url = {:controller => 'watchers',
:action => 'destroy', :action => 'destroy',
:object_type => object.class.to_s.underscore, :object_type => object.class.to_s.underscore,
:object_id => object.id, :object_id => object.id,
:user_id => user} :user_id => user}
s += ' ' + link_to_remote(image_tag('delete.png'), s << ' '
s << link_to_remote(image_tag('delete.png'),
{:url => url}, {:url => url},
:href => url_for(url), :href => url_for(url),
:style => "vertical-align: middle", :style => "vertical-align: middle",
:class => "delete") :class => "delete")
end end
content_tag :li, s.html_safe content << content_tag('li', s)
end end
(lis.empty? ? "" : "<ul>#{ lis.join("\n") }</ul>").html_safe content.present? ? content_tag('ul', content) : content
end end
def watchers_checkboxes(object, users, checked=nil) def watchers_checkboxes(object, users, checked=nil)
+8 -3
View File
@@ -75,7 +75,7 @@ class Issue < ActiveRecord::Base
:conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
before_create :default_assign before_create :default_assign
before_save :close_duplicates, :update_done_ratio_from_issue_status before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change
after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?} after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?}
after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
after_destroy :update_parent_attributes after_destroy :update_parent_attributes
@@ -432,8 +432,6 @@ class Issue < ActiveRecord::Base
@custom_values_before_change = {} @custom_values_before_change = {}
self.custom_field_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value } self.custom_field_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
end end
# Make sure updated_on is updated when adding a note.
updated_on_will_change!
@current_journal @current_journal
end end
@@ -994,6 +992,13 @@ class Issue < ActiveRecord::Base
end end
end end
# Make sure updated_on is updated when adding a note
def force_updated_on_change
if @current_journal
self.updated_on = current_time_from_proper_timezone
end
end
# Saves the changes in a Journal # Saves the changes in a Journal
# Called after_save # Called after_save
def create_journal def create_journal
+1 -1
View File
@@ -130,7 +130,7 @@ class Project < ActiveRecord::Base
end end
def identifier_frozen? def identifier_frozen?
errors[:identifier].nil? && !(new_record? || identifier.blank?) errors[:identifier].blank? && !(new_record? || identifier.blank?)
end end
# returns latest created projects # returns latest created projects
+10 -4
View File
@@ -848,12 +848,18 @@ class Query < ActiveRecord::Base
s = [] s = []
if from if from
from_yesterday = from - 1 from_yesterday = from - 1
from_yesterday_utc = Time.gm(from_yesterday.year, from_yesterday.month, from_yesterday.day) from_yesterday_time = Time.local(from_yesterday.year, from_yesterday.month, from_yesterday.day)
s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from_yesterday_utc.end_of_day)]) if self.class.default_timezone == :utc
from_yesterday_time = from_yesterday_time.utc
end
s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from_yesterday_time.end_of_day)])
end end
if to if to
to_utc = Time.gm(to.year, to.month, to.day) to_time = Time.local(to.year, to.month, to.day)
s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to_utc.end_of_day)]) if self.class.default_timezone == :utc
to_time = to_time.utc
end
s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to_time.end_of_day)])
end end
s.join(' AND ') s.join(' AND ')
end end
+9
View File
@@ -370,6 +370,15 @@ class User < Principal
end end
end end
# Returns the day of +time+ according to user's time zone
def time_to_date(time)
if time_zone.nil?
time.to_date
else
time.in_time_zone(time_zone).to_date
end
end
def logged? def logged?
true true
end end
+1 -1
View File
@@ -143,7 +143,7 @@ class WikiPage < ActiveRecord::Base
if time = read_attribute(:updated_on) if time = read_attribute(:updated_on)
# content updated_on was eager loaded with the page # content updated_on was eager loaded with the page
begin begin
@updated_on = Time.zone ? Time.zone.parse(time.to_s) : Time.parse(time.to_s) @updated_on = (self.class.default_timezone == :utc ? Time.parse(time.to_s).utc : Time.parse(time.to_s).localtime)
rescue rescue
end end
else else
+1 -1
View File
@@ -31,7 +31,7 @@ entries_by_day = entries.group_by(&:spent_on)
<% entries_by_day[day].each do |entry| -%> <% entries_by_day[day].each do |entry| -%>
<tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;"> <tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;">
<td class="activity"><%=h entry.activity %></td> <td class="activity"><%=h entry.activity %></td>
<td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td> <td class="subject"><%=h entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
<td class="comments"><%=h entry.comments %></td> <td class="comments"><%=h entry.comments %></td>
<td class="hours"><%= html_hours("%.2f" % entry.hours) %></td> <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
<td align="center"> <td align="center">
@@ -38,4 +38,4 @@
<% end %> <% end %>
</div> </div>
<p><%= link_to l(:label_version_new), new_project_version_path(@project), :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %></p> <p><%= link_to l(:label_version_new), new_project_version_path(@project, :back_url => ''), :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %></p>
+1 -1
View File
@@ -44,7 +44,7 @@
<% end %> <% end %>
</fieldset> </fieldset>
<% content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %> <%= content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %>
<legend><%= l(:field_column_names) %></legend> <legend><%= l(:field_column_names) %></legend>
<%= render :partial => 'queries/columns', :locals => {:query => query}%> <%= render :partial => 'queries/columns', :locals => {:query => query}%>
<% end %> <% end %>
+1
View File
@@ -26,6 +26,7 @@ module RedmineApp
config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer
config.active_record.store_full_sti_class = true config.active_record.store_full_sti_class = true
config.active_record.default_timezone = :local
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+1 -1
View File
@@ -43,7 +43,7 @@ module ActionView
end end
end end
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" } ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag || ''.html_safe }
require 'mail' require 'mail'
+21
View File
@@ -4,6 +4,27 @@ Redmine - project management software
Copyright (C) 2006-2012 Jean-Philippe Lang Copyright (C) 2006-2012 Jean-Philippe Lang
http://www.redmine.org/ http://www.redmine.org/
== 2012-05-28 v2.0.1
* Defect #10923: After creating a new Version Redmine jumps back to "Information"
* Defect #10932: Links to delete watchers are escaped when gravatars are enabled
* Defect #10964: Updated column doesn't get updated on issues
* Defect #10965: rake yard does not work for generating documentation.
* Defect #10972: Columns selection not displayed on the custom query form
* Defect #10991: My page > Spent time 'project' column is html-encoded
* Defect #10996: Time zones lost when upgrading from Redmine 1.4 to 2.0
* Defect #11013: Fetching Email from IMAP/POP3 - uninitialized constant RAILS_DEFAULT_LOGGER error
* Defect #11024: redmine_plugin_model generator does not create the migration
* Defect #11027: Saving new query without name causes escaping of input field
* Defect #11028: Project identifier can be updated
== 2012-05-15 v2.0.0
* Feature #4796: Rails 3 support
* Feature #7720: Limit the pagination-limit when max-results is fewer than max-pagination-limit
* Feature #9034: Add an id to the flash messages
* Patch #10782: Better translation for Estonian language
== 2012-05-13 v1.4.2 == 2012-05-13 v1.4.2
* Defect #10744: rake task redmine:email:test broken * Defect #10744: rake task redmine:email:test broken
+1 -1
View File
@@ -65,7 +65,7 @@ Optional:
8. Test the installation by running the WEBrick web server 8. Test the installation by running the WEBrick web server
Under the main application directory run: Under the main application directory run:
ruby script/server -e production ruby script/rails server -e production
Once WEBrick has started, point your browser to http://localhost:3000/ Once WEBrick has started, point your browser to http://localhost:3000/
You should now see the application welcome page. You should now see the application welcome page.
@@ -1,6 +1,12 @@
class RedminePluginModelGenerator < Rails::Generators::NamedBase class RedminePluginModelGenerator < Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__) source_root File.expand_path("../templates", __FILE__)
argument :model, :type => :string argument :model, :type => :string
argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
class_option :migration, :type => :boolean
class_option :timestamps, :type => :boolean
class_option :parent, :type => :string, :desc => "The parent class for the generated model"
class_option :indexes, :type => :boolean, :default => true, :desc => "Add indexes for references and belongs_to columns"
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
@@ -10,10 +16,26 @@ class RedminePluginModelGenerator < Rails::Generators::NamedBase
@plugin_pretty_name = plugin_name.titleize @plugin_pretty_name = plugin_name.titleize
@plugin_path = "plugins/#{plugin_name}" @plugin_path = "plugins/#{plugin_name}"
@model_class = model.camelize @model_class = model.camelize
@table_name = @model_class.tableize
@migration_filename = "create_#{@table_name}"
@migration_class_name = @migration_filename.camelize
end end
def copy_templates def copy_templates
template 'model.rb.erb', "#{plugin_path}/app/models/#{model}.rb" template 'model.rb.erb', "#{plugin_path}/app/models/#{model.underscore}.rb"
template 'unit_test.rb.erb', "#{plugin_path}/test/unit/#{model}_test.rb" template 'unit_test.rb.erb', "#{plugin_path}/test/unit/#{model.underscore}_test.rb"
migration_filename = "%03i_#{@migration_filename}.rb" % (migration_number + 1)
template "migration.rb", "#{plugin_path}/db/migrate/#{migration_filename}"
end
def attributes_with_index
attributes.select { |a| a.has_index? || (a.reference? && options[:indexes]) }
end
def migration_number
current = Dir.glob("#{plugin_path}/db/migrate/*.rb").map do |file|
File.basename(file).split("_").first.to_i
end.max.to_i
end end
end end
@@ -0,0 +1,15 @@
class <%= @migration_class_name %> < ActiveRecord::Migration
def change
create_table :<%= @table_name %> do |t|
<% attributes.each do |attribute| -%>
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
<% end -%>
<% if options[:timestamps] %>
t.timestamps
<% end -%>
end
<% attributes_with_index.each do |attribute| -%>
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
<% end -%>
end
end
+1 -1
View File
@@ -53,7 +53,7 @@ module Redmine
private private
def logger def logger
RAILS_DEFAULT_LOGGER ::Rails.logger
end end
end end
end end
+1 -1
View File
@@ -55,7 +55,7 @@ module Redmine
private private
def logger def logger
RAILS_DEFAULT_LOGGER ::Rails.logger
end end
end end
end end
+2 -2
View File
@@ -4,13 +4,13 @@ module Redmine
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 2 MAJOR = 2
MINOR = 0 MINOR = 0
TINY = 0 TINY = 1
# Branch values: # Branch values:
# * official release: nil # * official release: nil
# * stable branch: stable # * stable branch: stable
# * trunk: devel # * trunk: devel
BRANCH = 'devel' BRANCH = 'stable'
def self.revision def self.revision
revision = nil revision = nil
+24 -24
View File
@@ -1,8 +1,8 @@
--- ---
issues_001: issues_001:
created_on: <%= 3.days.ago.to_date.to_s(:db) %> created_on: <%= 3.days.ago.to_s(:db) %>
project_id: 1 project_id: 1
updated_on: <%= 1.day.ago.to_date.to_s(:db) %> updated_on: <%= 1.day.ago.to_s(:db) %>
priority_id: 4 priority_id: 4
subject: Can't print recipes subject: Can't print recipes
id: 1 id: 1
@@ -60,9 +60,9 @@ issues_003:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_004: issues_004:
created_on: <%= 5.days.ago.to_date.to_s(:db) %> created_on: <%= 5.days.ago.to_s(:db) %>
project_id: 2 project_id: 2
updated_on: <%= 2.days.ago.to_date.to_s(:db) %> updated_on: <%= 2.days.ago.to_s(:db) %>
priority_id: 4 priority_id: 4
subject: Issue on project 2 subject: Issue on project 2
id: 4 id: 4
@@ -77,9 +77,9 @@ issues_004:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_005: issues_005:
created_on: <%= 5.days.ago.to_date.to_s(:db) %> created_on: <%= 5.days.ago.to_s(:db) %>
project_id: 3 project_id: 3
updated_on: <%= 2.days.ago.to_date.to_s(:db) %> updated_on: <%= 2.days.ago.to_s(:db) %>
priority_id: 4 priority_id: 4
subject: Subproject issue subject: Subproject issue
id: 5 id: 5
@@ -94,9 +94,9 @@ issues_005:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_006: issues_006:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %> created_on: <%= 1.minute.ago.to_s(:db) %>
project_id: 5 project_id: 5
updated_on: <%= 1.minute.ago.to_date.to_s(:db) %> updated_on: <%= 1.minute.ago.to_s(:db) %>
priority_id: 4 priority_id: 4
subject: Issue of a private subproject subject: Issue of a private subproject
id: 6 id: 6
@@ -113,9 +113,9 @@ issues_006:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_007: issues_007:
created_on: <%= 10.days.ago.to_date.to_s(:db) %> created_on: <%= 10.days.ago.to_s(:db) %>
project_id: 1 project_id: 1
updated_on: <%= 10.days.ago.to_date.to_s(:db) %> updated_on: <%= 10.days.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Issue due today subject: Issue due today
id: 7 id: 7
@@ -133,9 +133,9 @@ issues_007:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_008: issues_008:
created_on: <%= 10.days.ago.to_date.to_s(:db) %> created_on: <%= 10.days.ago.to_s(:db) %>
project_id: 1 project_id: 1
updated_on: <%= 10.days.ago.to_date.to_s(:db) %> updated_on: <%= 10.days.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Closed issue subject: Closed issue
id: 8 id: 8
@@ -153,9 +153,9 @@ issues_008:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_009: issues_009:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %> created_on: <%= 1.minute.ago.to_s(:db) %>
project_id: 5 project_id: 5
updated_on: <%= 1.minute.ago.to_date.to_s(:db) %> updated_on: <%= 1.minute.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Blocked Issue subject: Blocked Issue
id: 9 id: 9
@@ -172,9 +172,9 @@ issues_009:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_010: issues_010:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %> created_on: <%= 1.minute.ago.to_s(:db) %>
project_id: 5 project_id: 5
updated_on: <%= 1.minute.ago.to_date.to_s(:db) %> updated_on: <%= 1.minute.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Issue Doing the Blocking subject: Issue Doing the Blocking
id: 10 id: 10
@@ -191,9 +191,9 @@ issues_010:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_011: issues_011:
created_on: <%= 3.days.ago.to_date.to_s(:db) %> created_on: <%= 3.days.ago.to_s(:db) %>
project_id: 1 project_id: 1
updated_on: <%= 1.day.ago.to_date.to_s(:db) %> updated_on: <%= 1.day.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Closed issue on a closed version subject: Closed issue on a closed version
id: 11 id: 11
@@ -210,9 +210,9 @@ issues_011:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_012: issues_012:
created_on: <%= 3.days.ago.to_date.to_s(:db) %> created_on: <%= 3.days.ago.to_s(:db) %>
project_id: 1 project_id: 1
updated_on: <%= 1.day.ago.to_date.to_s(:db) %> updated_on: <%= 1.day.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Closed issue on a locked version subject: Closed issue on a locked version
id: 12 id: 12
@@ -229,9 +229,9 @@ issues_012:
lft: 1 lft: 1
rgt: 2 rgt: 2
issues_013: issues_013:
created_on: <%= 5.days.ago.to_date.to_s(:db) %> created_on: <%= 5.days.ago.to_s(:db) %>
project_id: 3 project_id: 3
updated_on: <%= 2.days.ago.to_date.to_s(:db) %> updated_on: <%= 2.days.ago.to_s(:db) %>
priority_id: 4 priority_id: 4
subject: Subproject issue two subject: Subproject issue two
id: 13 id: 13
@@ -247,9 +247,9 @@ issues_013:
rgt: 2 rgt: 2
issues_014: issues_014:
id: 14 id: 14
created_on: <%= 15.days.ago.to_date.to_s(:db) %> created_on: <%= 15.days.ago.to_s(:db) %>
project_id: 3 project_id: 3
updated_on: <%= 15.days.ago.to_date.to_s(:db) %> updated_on: <%= 15.days.ago.to_s(:db) %>
priority_id: 5 priority_id: 5
subject: Private issue on public project subject: Private issue on public project
fixed_version_id: fixed_version_id:
+30
View File
@@ -1126,6 +1126,36 @@ class IssuesControllerTest < ActionController::TestCase
assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"} assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"}
end end
def test_show_should_display_watchers
@request.session[:user_id] = 2
Issue.find(1).add_watcher User.find(2)
get :show, :id => 1
assert_select 'div#watchers ul' do
assert_select 'li' do
assert_select 'a[href=/users/2]'
assert_select 'a img[alt=Delete]'
end
end
end
def test_show_should_display_watchers_with_gravatars
@request.session[:user_id] = 2
Issue.find(1).add_watcher User.find(2)
with_settings :gravatar_enabled => '1' do
get :show, :id => 1
end
assert_select 'div#watchers ul' do
assert_select 'li' do
assert_select 'img.gravatar'
assert_select 'a[href=/users/2]'
assert_select 'a img[alt=Delete]'
end
end
end
def test_show_with_multi_custom_field def test_show_with_multi_custom_field
field = CustomField.find(1) field = CustomField.find(1)
field.update_attribute :multiple, true field.update_attribute :multiple, true
+16 -1
View File
@@ -22,7 +22,8 @@ require 'my_controller'
class MyController; def rescue_action(e) raise e end; end class MyController; def rescue_action(e) raise e end; end
class MyControllerTest < ActionController::TestCase class MyControllerTest < ActionController::TestCase
fixtures :users, :user_preferences, :roles, :projects, :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources fixtures :users, :user_preferences, :roles, :projects, :members, :member_roles,
:issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources
def setup def setup
@controller = MyController.new @controller = MyController.new
@@ -43,6 +44,20 @@ class MyControllerTest < ActionController::TestCase
assert_template 'page' assert_template 'page'
end end
def test_page_with_timelog_block
preferences = User.find(2).pref
preferences[:my_page_layout] = {'top' => ['timelog']}
preferences.save!
TimeEntry.create!(:user => User.find(2), :spent_on => Date.yesterday, :issue_id => 1, :hours => 2.5, :activity_id => 10)
get :page
assert_response :success
assert_select 'tr.time-entry' do
assert_select 'td.subject a[href=/issues/1]'
assert_select 'td.hours', :text => '2.50'
end
end
def test_my_account_should_show_editable_custom_fields def test_my_account_should_show_editable_custom_fields
get :account get :account
assert_response :success assert_response :success
@@ -36,6 +36,10 @@ class QueriesControllerTest < ActionController::TestCase
:name => 'query_is_for_all', :name => 'query_is_for_all',
:checked => nil, :checked => nil,
:disabled => nil } :disabled => nil }
assert_select 'select[name=?]', 'c[]' do
assert_select 'option[value=tracker]'
assert_select 'option[value=subject]'
end
end end
def test_new_global_query def test_new_global_query
@@ -145,6 +149,7 @@ class QueriesControllerTest < ActionController::TestCase
end end
assert_response :success assert_response :success
assert_template 'new' assert_template 'new'
assert_select 'input[name=?]', 'query[name]'
end end
def test_edit_global_public_query def test_edit_global_public_query
+13
View File
@@ -445,6 +445,19 @@ class IssueTest < ActiveSupport::TestCase
issue.save! issue.save!
end end
def test_adding_journal_should_update_timestamp
issue = Issue.find(1)
updated_on_was = issue.updated_on
issue.init_journal(User.first, "Adding notes")
assert_difference 'Journal.count' do
assert issue.save
end
issue.reload
assert_not_equal updated_on_was, issue.updated_on
end
def test_should_close_duplicates def test_should_close_duplicates
# Create 3 issues # Create 3 issues
project = Project.find(1) project = Project.find(1)
+14
View File
@@ -106,6 +106,20 @@ class ProjectTest < ActiveSupport::TestCase
end end
end end
def test_identifier_should_not_be_frozen_for_a_new_project
assert_equal false, Project.new.identifier_frozen?
end
def test_identifier_should_not_be_frozen_for_a_saved_project_with_blank_identifier
Project.update_all(["identifier = ''"], "id = 1")
assert_equal false, Project.find(1).identifier_frozen?
end
def test_identifier_should_be_frozen_for_a_saved_project_with_valid_identifier
assert_equal true, Project.find(1).identifier_frozen?
end
def test_members_should_be_active_users def test_members_should_be_active_users
Project.all.each do |project| Project.all.each do |project|
assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) } assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) }
+32 -1
View File
@@ -424,7 +424,38 @@ class UserTest < ActiveSupport::TestCase
assert_equal 'jsmith', @jsmith.reload.name assert_equal 'jsmith', @jsmith.reload.name
end end
end end
def test_today_should_return_the_day_according_to_user_time_zone
preference = User.find(1).pref
date = Date.new(2012, 05, 15)
time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC
Date.stubs(:today).returns(date)
Time.stubs(:now).returns(time)
preference.update_attribute :time_zone, 'Baku' # UTC+4
assert_equal '2012-05-16', User.find(1).today.to_s
preference.update_attribute :time_zone, 'La Paz' # UTC-4
assert_equal '2012-05-15', User.find(1).today.to_s
preference.update_attribute :time_zone, ''
assert_equal '2012-05-15', User.find(1).today.to_s
end
def test_time_to_date_should_return_the_date_according_to_user_time_zone
preference = User.find(1).pref
time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC
preference.update_attribute :time_zone, 'Baku' # UTC+4
assert_equal '2012-05-16', User.find(1).time_to_date(time).to_s
preference.update_attribute :time_zone, 'La Paz' # UTC-4
assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s
preference.update_attribute :time_zone, ''
assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s
end
def test_fields_for_order_statement_should_return_fields_according_user_format_setting def test_fields_for_order_statement_should_return_fields_according_user_format_setting
with_settings :user_format => 'lastname_coma_firstname' do with_settings :user_format => 'lastname_coma_firstname' do
assert_equal ['users.lastname', 'users.firstname', 'users.id'], User.fields_for_order_statement assert_equal ['users.lastname', 'users.firstname', 'users.id'], User.fields_for_order_statement