Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.0-stable' into ro-3-0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Mar 12, 2015
2 parents a285938 + 795bbbe commit d3aafc4
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Gemfile
@@ -1,5 +1,9 @@
source 'https://rubygems.org'

if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0')
abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'."
end

gem "rails", "4.2.0"
gem "jquery-rails", "~> 3.1.1"
gem "coderay", "~> 1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/repositories_controller.rb
Expand Up @@ -93,7 +93,7 @@ def pickup_extra_info

def committers
@committers = @repository.committers
@users = @project.users
@users = @project.users.to_a
additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
@users += User.where(:id => additional_user_ids).to_a unless additional_user_ids.empty?
@users.compact!
Expand Down
22 changes: 13 additions & 9 deletions app/helpers/issues_helper.rb
Expand Up @@ -320,15 +320,19 @@ def details_to_strings(details, no_html=false, options={})
end
strings << show_detail(detail, no_html, options)
end
values_by_field.each do |field, changes|
detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s)
detail.instance_variable_set "@custom_field", field
if changes[:added].any?
detail.value = changes[:added]
strings << show_detail(detail, no_html, options)
elsif changes[:deleted].any?
detail.old_value = changes[:deleted]
strings << show_detail(detail, no_html, options)
if values_by_field.present?
multiple_values_detail = Struct.new(:property, :prop_key, :custom_field, :old_value, :value)
values_by_field.each do |field, changes|
if changes[:added].any?
detail = multiple_values_detail.new('cf', field.id.to_s, field)
detail.value = changes[:added]
strings << show_detail(detail, no_html, options)
end
if changes[:deleted].any?
detail = multiple_values_detail.new('cf', field.id.to_s, field)
detail.old_value = changes[:deleted]
strings << show_detail(detail, no_html, options)
end
end
end
strings
Expand Down
4 changes: 2 additions & 2 deletions app/models/issue.rb
Expand Up @@ -819,12 +819,12 @@ def new_statuses_allowed_to(user=User.current, include_default=false)
end
end

# Returns the previous assignee if changed
# Returns the previous assignee (user or group) if changed
def assigned_to_was
# assigned_to_id_was is reset before after_save callbacks
user_id = @previous_assigned_to_id || assigned_to_id_was
if user_id && user_id != assigned_to_id
@assigned_to_was ||= User.find_by_id(user_id)
@assigned_to_was ||= Principal.find_by_id(user_id)
end
end

Expand Down
1 change: 0 additions & 1 deletion app/models/repository.rb
Expand Up @@ -38,7 +38,6 @@ class Repository < ActiveRecord::Base

validates_length_of :password, :maximum => 255, :allow_nil => true
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
# donwcase letters, digits, dashes, underscores but not digits only
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pt-BR.yml
Expand Up @@ -157,7 +157,7 @@ pt-BR:
general_text_Yes: 'Sim'
general_text_no: 'não'
general_text_yes: 'sim'
general_lang_name: 'Português(Brasil)'
general_lang_name: 'Portuguese/Brasil (Português/Brasil)'
general_csv_separator: ';'
general_csv_decimal_separator: ','
general_csv_encoding: ISO-8859-1
Expand Down
6 changes: 5 additions & 1 deletion db/migrate/20150113213922_remove_users_mail.rb
Expand Up @@ -4,6 +4,10 @@ def self.up
end

def self.down
raise IrreversibleMigration
add_column :users, :mail, :string, :limit => 60, :default => '', :null => false

EmailAddress.where(:is_default => true).each do |a|
User.where(:id => a.user_id).update_all(:mail => a.address)
end
end
end
2 changes: 1 addition & 1 deletion lib/redmine/imap.rb
Expand Up @@ -24,7 +24,7 @@ def check(imap_options={}, options={})
host = imap_options[:host] || '127.0.0.1'
port = imap_options[:port] || '143'
ssl = !imap_options[:ssl].nil?
starttls = !imap_options[:tls].nil?
starttls = !imap_options[:starttls].nil?
folder = imap_options[:folder] || 'INBOX'

imap = Net::IMAP.new(host, port, ssl)
Expand Down
9 changes: 9 additions & 0 deletions test/functional/repositories_controller_test.rb
Expand Up @@ -279,6 +279,15 @@ def test_get_committers
assert_select 'input[value=foo] + select option[selected=selected]', 0 # no option selected
end

def test_get_committers_without_changesets
Changeset.delete_all
@request.session[:user_id] = 2

get :committers, :id => 10
assert_response :success
assert_template 'committers'
end

def test_post_committers
@request.session[:user_id] = 2
# add a commit with an unknown user
Expand Down
37 changes: 37 additions & 0 deletions test/unit/helpers/issues_helper_test.rb
Expand Up @@ -296,6 +296,43 @@ def test_show_detail_relation_deleted_should_not_disclose_issue_that_is_not_visi
assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false)
end

def test_details_to_strings_with_multiple_values_removed_from_custom_field
field = IssueCustomField.generate!(:name => 'User', :field_format => 'user', :multiple => true)
details = []
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '1', :value => nil)
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '3', :value => nil)

assert_equal ["User deleted (Dave Lopper, Redmine Admin)"], details_to_strings(details, true)
assert_equal ["<strong>User</strong> deleted (<del><i>Dave Lopper, Redmine Admin</i></del>)"], details_to_strings(details, false)
end

def test_details_to_strings_with_multiple_values_added_to_custom_field
field = IssueCustomField.generate!(:name => 'User', :field_format => 'user', :multiple => true)
details = []
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => nil, :value => '1')
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => nil, :value => '3')

assert_equal ["User Dave Lopper, Redmine Admin added"], details_to_strings(details, true)
assert_equal ["<strong>User</strong> <i>Dave Lopper, Redmine Admin</i> added"], details_to_strings(details, false)
end

def test_details_to_strings_with_multiple_values_added_and_removed_from_custom_field
field = IssueCustomField.generate!(:name => 'User', :field_format => 'user', :multiple => true)
details = []
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => nil, :value => '1')
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '2', :value => nil)
details << JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s, :old_value => '3', :value => nil)

assert_equal [
"User Redmine Admin added",
"User deleted (Dave Lopper, John Smith)"
], details_to_strings(details, true)
assert_equal [
"<strong>User</strong> <i>Redmine Admin</i> added",
"<strong>User</strong> deleted (<del><i>Dave Lopper, John Smith</i></del>)"
], details_to_strings(details, false)
end

def test_find_name_by_reflection_should_return_nil_for_missing_record
assert_nil find_name_by_reflection('status', 99)
end
Expand Down
8 changes: 8 additions & 0 deletions test/unit/issue_test.rb
Expand Up @@ -2591,4 +2591,12 @@ def test_changing_tracker_should_keep_status_if_status_was_not_default_and_is_us
issue.tracker = Tracker.find(2)
assert_equal IssueStatus.find(3), issue.status
end

def test_assigned_to_was_with_a_group
group = Group.find(10)

issue = Issue.generate!(:assigned_to => group)
issue.reload.assigned_to = nil
assert_equal group, issue.assigned_to_was
end
end
29 changes: 29 additions & 0 deletions test/unit/repository_git_test.rb
Expand Up @@ -49,6 +49,35 @@ def setup
assert @repository
end

def test_nondefault_repo_with_blank_identifier_destruction
repo1 = Repository::Git.new(
:project => @project,
:url => REPOSITORY_PATH,
:identifier => '',
:is_default => true
)
assert repo1.save
repo1.fetch_changesets

repo2 = Repository::Git.new(
:project => @project,
:url => REPOSITORY_PATH,
:identifier => 'repo2',
:is_default => true
)
assert repo2.save
repo2.fetch_changesets

repo1.reload
repo2.reload
assert !repo1.is_default?
assert repo2.is_default?

assert_difference 'Repository.count', -1 do
repo1.destroy
end
end

def test_blank_path_to_repository_error_message
set_language_if_valid 'en'
repo = Repository::Git.new(
Expand Down

0 comments on commit d3aafc4

Please sign in to comment.