Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
Merged rails-4.1 branch (#14534).
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.redmine.org/redmine/trunk@13482 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Oct 22, 2014
1 parent a6ec78a commit 2d1866d
Show file tree
Hide file tree
Showing 331 changed files with 2,456 additions and 6,054 deletions.
3 changes: 3 additions & 0 deletions .travis.run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh

JRUBY_OPTS=-J-Xmx1024m bundle exec rake test:${TEST_SUITE}
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# You can also run tests on your environment.
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0
- 2.1
Expand Down Expand Up @@ -34,6 +32,7 @@ script:
- "bundle install"
- "RUN_ON_NOT_OFFICIAL='' RUBY_VER=1.9 BRANCH=trunk bundle exec rake config/database.yml"
- "bundle install"
- "JRUBY_OPTS=-J-Xmx1024m bundle exec rake ci"
- "bundle exec rake ci:setup"
- "sh .travis.run-test.sh"
notifications:
email: false
34 changes: 15 additions & 19 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
source 'https://rubygems.org'

gem "rails", "3.2.19"
gem "rails", "4.1.6"
gem "jquery-rails", "~> 3.1.1"
gem "coderay", "~> 1.1.0"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", ">= 3.0.4"
gem "request_store", "1.0.5"
gem "mime-types"
gem "awesome_nested_set", "3.0.0"
gem "protected_attributes"
gem "actionpack-action_caching"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
gem "rbpdf", "~> 1.18.1"

# Optional gem for LDAP authentication
Expand All @@ -23,16 +28,12 @@ end
platforms :mri, :mingw do
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
group :rmagick do
# RMagick 2 supports ruby 1.9
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# different requirements for the same gem on different platforms
gem "rmagick", ">= 2.0.0"
end

# Optional Markdown support, not for JRuby
group :markdown do
# TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped
gem "redcarpet", "~> 2.3.0"
gem "redcarpet", "~> 3.1.2"
end
end

Expand All @@ -57,7 +58,6 @@ if File.exist?(database_file)
gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when 'mysql'
gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when /postgresql/
gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
Expand Down Expand Up @@ -85,24 +85,20 @@ group :development do
end

group :test do
gem "shoulda", "~> 3.3.2"
gem "shoulda-matchers", "1.4.1"
gem "minitest"
gem "shoulda-context"
gem "mocha", "~> 1.0.0", :require => 'mocha/api'
if RUBY_VERSION >= '1.9.3'
gem "capybara", "~> 2.1.0"
gem "selenium-webdriver"
end
# For running UI tests
gem "capybara", "~> 2.1.0"
gem "selenium-webdriver"
end

local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile)
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(local_gemfile)
eval_gemfile local_gemfile
end

# Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
#TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
instance_eval File.read(file), file
eval_gemfile file
end
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def projects

scope = Project.status(@status).order('lft')
scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.all
@projects = scope.to_a

render :action => "projects", :layout => false if request.xhr?
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def use_layout
end

def render_feed(items, options={})
@items = items || []
@items = (items || []).to_a
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
@items = @items.slice(0, Setting.feeds_limit.to_i)
@title = options[:title] || Setting.app_title
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auto_completes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def issues
if q.match(/\A#?(\d+)\z/)
@issues << scope.find_by_id($1.to_i)
end
@issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE LOWER(?)", "%#{q}%").order("#{Issue.table_name}.id DESC").limit(10).all
@issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE LOWER(?)", "%#{q}%").order("#{Issue.table_name}.id DESC").limit(10).to_a
@issues.compact!
end
render :layout => false
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/boards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BoardsController < ApplicationController
helper :watchers

def index
@boards = @project.boards.includes(:project, :last_message => :author).all
@boards = @project.boards.preload(:project, :last_message => :author).to_a
# show the board if there is only one
if @boards.size == 1
@board = @boards.first
Expand All @@ -45,12 +45,13 @@ def show
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@topics = @board.topics.
reorder("#{Message.table_name}.sticky DESC").
includes(:last_reply).
joins("LEFT OUTER JOIN #{Message.table_name} last_replies_messages ON last_replies_messages.id = #{Message.table_name}.last_reply_id").
references(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
order(sort_clause).
preload(:author, {:last_reply => :author}).
all
to_a
@message = Message.new(:board => @board)
render :action => 'show', :layout => !request.xhr?
}
Expand All @@ -59,7 +60,7 @@ def show
reorder('created_on DESC').
includes(:author, :board).
limit(Setting.feeds_limit.to_i).
all
to_a
render_feed(@messages, :title => "#{@project}: #{@board}")
}
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DocumentsController < ApplicationController

def index
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
documents = @project.documents.includes(:attachments, :category).all
documents = @project.documents.includes(:attachments, :category).to_a
case @sort_by
when 'date'
@grouped = documents.group_by {|d| d.updated_on.to_date }
Expand All @@ -43,7 +43,7 @@ def index
end

def show
@attachments = @document.attachments.all
@attachments = @document.attachments.to_a
end

def new
Expand All @@ -69,7 +69,7 @@ def edit

def update
@document.safe_attributes = params[:document]
if request.put? and @document.save
if @document.save
flash[:notice] = l(:notice_successful_update)
redirect_to document_path(@document)
else
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/enumerations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def index
format.api {
@klass = Enumeration.get_subclass(params[:type])
if @klass
@enumerations = @klass.shared.sorted.all
@enumerations = @klass.shared.sorted.to_a
else
render_404
end
Expand All @@ -56,7 +56,7 @@ def edit
end

def update
if request.put? && @enumeration.update_attributes(params[:enumeration])
if @enumeration.update_attributes(params[:enumeration])
flash[:notice] = l(:notice_successful_update)
redirect_to enumerations_path
else
Expand All @@ -75,7 +75,7 @@ def destroy
redirect_to enumerations_path
return
end
@enumerations = @enumeration.class.system.all - [@enumeration]
@enumerations = @enumeration.class.system.to_a - [@enumeration]
end

private
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def index
'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads"

@containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse
@containers = [Project.includes(:attachments).
references(:attachments).reorder(sort_clause).find(@project.id)]
@containers += @project.versions.includes(:attachments).
references(:attachments).reorder(sort_clause).to_a.sort.reverse
render :layout => !request.xhr?
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class GroupsController < ApplicationController
def index
respond_to do |format|
format.html {
@groups = Group.sorted.all
@groups = Group.sorted.to_a
@user_count_by_group_id = user_count_by_group_id
}
format.api {
scope = Group.sorted
scope = scope.givable unless params[:builtin] == '1'
@groups = scope.all
@groups = scope.to_a
}
end
end
Expand Down Expand Up @@ -95,7 +95,7 @@ def destroy
end

def add_users
@users = User.where(:id => (params[:user_id] || params[:user_ids])).all
@users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a
@group.users << @users if request.post?
respond_to do |format|
format.html { redirect_to edit_group_path(@group, :tab => 'users') }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/issue_categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IssueCategoriesController < ApplicationController
def index
respond_to do |format|
format.html { redirect_to_settings_in_projects }
format.api { @categories = @project.issue_categories.all }
format.api { @categories = @project.issue_categories.to_a }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/issue_statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def index
render :action => "index", :layout => false if request.xhr?
}
format.api {
@issue_statuses = IssueStatus.order('position').all
@issue_statuses = IssueStatus.order('position').to_a
}
end
end
Expand Down
21 changes: 13 additions & 8 deletions app/controllers/issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ def index
end

def show
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
@journals = @issue.journals.includes(:user, :details).
references(:user, :details).
reorder("#{Journal.table_name}.id ASC").to_a
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
Journal.preload_journals_details_custom_fields(@journals)
# TODO: use #select! when ruby1.8 support is dropped
@journals.reject! {|journal| !journal.notes? && journal.visible_details.empty?}
@journals.select! {|journal| journal.notes? || journal.visible_details.any?}
@journals.reverse! if User.current.wants_comments_in_reverse_order?

@changesets = @issue.changesets.visible.all
@changesets = @issue.changesets.visible.to_a
@changesets.reverse! if User.current.wants_comments_in_reverse_order?

@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
Expand Down Expand Up @@ -189,7 +190,7 @@ def update
rescue ActiveRecord::StaleObjectError
@conflict = true
if params[:last_journal_id]
@conflict_journals = @issue.journals_after(params[:last_journal_id]).all
@conflict_journals = @issue.journals_after(params[:last_journal_id]).to_a
@conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
end
end
Expand Down Expand Up @@ -301,7 +302,7 @@ def bulk_update
else
@saved_issues = @issues
@unsaved_issues = unsaved_issues
@issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).all
@issues = Issue.visible.where(:id => @unsaved_issues.map(&:id)).to_a
bulk_edit
render :action => 'bulk_edit'
end
Expand Down Expand Up @@ -375,7 +376,9 @@ def retrieve_previous_and_next_issue_ids
def update_issue_from_params
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
@time_entry.attributes = params[:time_entry]
if params[:time_entry]
@time_entry.attributes = params[:time_entry]
end

@issue.init_journal(User.current)

Expand Down Expand Up @@ -422,7 +425,9 @@ def build_new_issue_from_params
@issue.project = @project
@issue.author ||= User.current
# Tracker must be set before custom field values
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
tracker_id = (params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id]
tracker = tracker_id.present? ? @project.trackers.find(tracker_id) : @project.trackers.first
@issue.tracker ||= tracker
if @issue.tracker.nil?
render_error l(:error_no_tracker_in_project)
return false
Expand Down
1 change: 0 additions & 1 deletion app/controllers/journals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def index
retrieve_query
sort_init 'id', 'desc'
sort_update(@query.sortable_columns)

if @query.valid?
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
:limit => 25)
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def index
order("#{Member.table_name}.id").
limit(@limit).
offset(@offset).
all
to_a
respond_to do |format|
format.html { head 406 }
format.api
Expand Down Expand Up @@ -63,7 +63,10 @@ def create

respond_to do |format|
format.html { redirect_to_settings_in_projects }
format.js { @members = members }
format.js {
@members = members
@member = Member.new
}
format.api {
@member = members.first
if @member.valid?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def show
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
@replies = @topic.children.
includes(:author, :attachments, {:board => :project}).
reorder("#{Message.table_name}.created_on ASC").
reorder("#{Message.table_name}.created_on ASC, #{Message.table_name}.id ASC").
limit(@reply_pages.per_page).
offset(@reply_pages.offset).
all
to_a

@reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => false if request.xhr?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/my_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def account
@user = User.current
@pref = @user.pref
if request.post?
@user.safe_attributes = params[:user]
@user.pref.attributes = params[:pref]
@user.safe_attributes = params[:user] if params[:user]
@user.pref.attributes = params[:pref] if params[:pref]
if @user.save
@user.pref.save
set_language_if_valid @user.language
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/news_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def index
order("#{News.table_name}.created_on DESC").
limit(@limit).
offset(@offset).
all
to_a
respond_to do |format|
format.html {
@news = News.new # for adding news inline
Expand Down
Loading

0 comments on commit 2d1866d

Please sign in to comment.