Commit 0fad0d92 authored by jplang's avatar jplang

Merged rails-4.1 branch (#14534).

git-svn-id: https://svn.redmine.org/redmine/trunk@13482 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 8ea31275
#! /bin/sh
JRUBY_OPTS=-J-Xmx1024m bundle exec rake test:${TEST_SUITE}
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
# You can also run tests on your environment. # You can also run tests on your environment.
language: ruby language: ruby
rvm: rvm:
- 1.8.7
- 1.9.2
- 1.9.3 - 1.9.3
- 2.0 - 2.0
- 2.1 - 2.1
...@@ -34,6 +32,7 @@ script: ...@@ -34,6 +32,7 @@ script:
- "bundle install" - "bundle install"
- "RUN_ON_NOT_OFFICIAL='' RUBY_VER=1.9 BRANCH=trunk bundle exec rake config/database.yml" - "RUN_ON_NOT_OFFICIAL='' RUBY_VER=1.9 BRANCH=trunk bundle exec rake config/database.yml"
- "bundle install" - "bundle install"
- "JRUBY_OPTS=-J-Xmx1024m bundle exec rake ci" - "bundle exec rake ci:setup"
- "sh .travis.run-test.sh"
notifications: notifications:
email: false email: false
source 'https://rubygems.org' source 'https://rubygems.org'
gem "rails", "3.2.19" gem "rails", "4.1.6"
gem "jquery-rails", "~> 3.1.1" gem "jquery-rails", "~> 3.1.1"
gem "coderay", "~> 1.1.0" gem "coderay", "~> 1.1.0"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", ">= 3.0.4" gem "builder", ">= 3.0.4"
gem "request_store", "1.0.5" gem "request_store", "1.0.5"
gem "mime-types" 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" gem "rbpdf", "~> 1.18.1"
# Optional gem for LDAP authentication # Optional gem for LDAP authentication
...@@ -23,16 +28,12 @@ end ...@@ -23,16 +28,12 @@ end
platforms :mri, :mingw do platforms :mri, :mingw do
# Optional gem for exporting the gantt to a PNG file, not supported with jruby # Optional gem for exporting the gantt to a PNG file, not supported with jruby
group :rmagick do 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" gem "rmagick", ">= 2.0.0"
end end
# Optional Markdown support, not for JRuby # Optional Markdown support, not for JRuby
group :markdown do group :markdown do
# TODO: upgrade to redcarpet 3.x when ruby1.8 support is dropped gem "redcarpet", "~> 3.1.2"
gem "redcarpet", "~> 2.3.0"
end end
end end
...@@ -57,7 +58,6 @@ if File.exist?(database_file) ...@@ -57,7 +58,6 @@ if File.exist?(database_file)
gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw] gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when 'mysql' when 'mysql'
gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when /postgresql/ when /postgresql/
gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw] gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
...@@ -85,24 +85,20 @@ group :development do ...@@ -85,24 +85,20 @@ group :development do
end end
group :test do group :test do
gem "shoulda", "~> 3.3.2" gem "minitest"
gem "shoulda-matchers", "1.4.1" gem "shoulda-context"
gem "mocha", "~> 1.0.0", :require => 'mocha/api' gem "mocha", "~> 1.0.0", :require => 'mocha/api'
if RUBY_VERSION >= '1.9.3' # For running UI tests
gem "capybara", "~> 2.1.0" gem "capybara", "~> 2.1.0"
gem "selenium-webdriver" gem "selenium-webdriver"
end
end end
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile) if File.exists?(local_gemfile)
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v` eval_gemfile local_gemfile
instance_eval File.read(local_gemfile)
end end
# Load plugins' Gemfiles # Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file| Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` eval_gemfile file
#TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
instance_eval File.read(file), file
end end
...@@ -34,7 +34,7 @@ class AdminController < ApplicationController ...@@ -34,7 +34,7 @@ class AdminController < ApplicationController
scope = Project.status(@status).order('lft') scope = Project.status(@status).order('lft')
scope = scope.like(params[:name]) if params[:name].present? scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.all @projects = scope.to_a
render :action => "projects", :layout => false if request.xhr? render :action => "projects", :layout => false if request.xhr?
end end
......
...@@ -496,7 +496,7 @@ class ApplicationController < ActionController::Base ...@@ -496,7 +496,7 @@ class ApplicationController < ActionController::Base
end end
def render_feed(items, options={}) def render_feed(items, options={})
@items = items || [] @items = (items || []).to_a
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime } @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
@items = @items.slice(0, Setting.feeds_limit.to_i) @items = @items.slice(0, Setting.feeds_limit.to_i)
@title = options[:title] || Setting.app_title @title = options[:title] || Setting.app_title
......
...@@ -26,7 +26,7 @@ class AutoCompletesController < ApplicationController ...@@ -26,7 +26,7 @@ class AutoCompletesController < ApplicationController
if q.match(/\A#?(\d+)\z/) if q.match(/\A#?(\d+)\z/)
@issues << scope.find_by_id($1.to_i) @issues << scope.find_by_id($1.to_i)
end 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! @issues.compact!
end end
render :layout => false render :layout => false
......
...@@ -25,7 +25,7 @@ class BoardsController < ApplicationController ...@@ -25,7 +25,7 @@ class BoardsController < ApplicationController
helper :watchers helper :watchers
def index 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 # show the board if there is only one
if @boards.size == 1 if @boards.size == 1
@board = @boards.first @board = @boards.first
...@@ -45,12 +45,13 @@ class BoardsController < ApplicationController ...@@ -45,12 +45,13 @@ class BoardsController < ApplicationController
@topic_pages = Paginator.new @topic_count, per_page_option, params['page'] @topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@topics = @board.topics. @topics = @board.topics.
reorder("#{Message.table_name}.sticky DESC"). 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). limit(@topic_pages.per_page).
offset(@topic_pages.offset). offset(@topic_pages.offset).
order(sort_clause). order(sort_clause).
preload(:author, {:last_reply => :author}). preload(:author, {:last_reply => :author}).
all to_a
@message = Message.new(:board => @board) @message = Message.new(:board => @board)
render :action => 'show', :layout => !request.xhr? render :action => 'show', :layout => !request.xhr?
} }
...@@ -59,7 +60,7 @@ class BoardsController < ApplicationController ...@@ -59,7 +60,7 @@ class BoardsController < ApplicationController
reorder('created_on DESC'). reorder('created_on DESC').
includes(:author, :board). includes(:author, :board).
limit(Setting.feeds_limit.to_i). limit(Setting.feeds_limit.to_i).
all to_a
render_feed(@messages, :title => "#{@project}: #{@board}") render_feed(@messages, :title => "#{@project}: #{@board}")
} }
end end
......
...@@ -27,7 +27,7 @@ class DocumentsController < ApplicationController ...@@ -27,7 +27,7 @@ class DocumentsController < ApplicationController
def index def index
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' @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 case @sort_by
when 'date' when 'date'
@grouped = documents.group_by {|d| d.updated_on.to_date } @grouped = documents.group_by {|d| d.updated_on.to_date }
...@@ -43,7 +43,7 @@ class DocumentsController < ApplicationController ...@@ -43,7 +43,7 @@ class DocumentsController < ApplicationController
end end
def show def show
@attachments = @document.attachments.all @attachments = @document.attachments.to_a
end end
def new def new
...@@ -69,7 +69,7 @@ class DocumentsController < ApplicationController ...@@ -69,7 +69,7 @@ class DocumentsController < ApplicationController
def update def update
@document.safe_attributes = params[:document] @document.safe_attributes = params[:document]
if request.put? and @document.save if @document.save
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to document_path(@document) redirect_to document_path(@document)
else else
......
...@@ -32,7 +32,7 @@ class EnumerationsController < ApplicationController ...@@ -32,7 +32,7 @@ class EnumerationsController < ApplicationController
format.api { format.api {
@klass = Enumeration.get_subclass(params[:type]) @klass = Enumeration.get_subclass(params[:type])
if @klass if @klass
@enumerations = @klass.shared.sorted.all @enumerations = @klass.shared.sorted.to_a
else else
render_404 render_404
end end
...@@ -56,7 +56,7 @@ class EnumerationsController < ApplicationController ...@@ -56,7 +56,7 @@ class EnumerationsController < ApplicationController
end end
def update def update
if request.put? && @enumeration.update_attributes(params[:enumeration]) if @enumeration.update_attributes(params[:enumeration])
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to enumerations_path redirect_to enumerations_path
else else
...@@ -75,7 +75,7 @@ class EnumerationsController < ApplicationController ...@@ -75,7 +75,7 @@ class EnumerationsController < ApplicationController
redirect_to enumerations_path redirect_to enumerations_path
return return
end end
@enumerations = @enumeration.class.system.all - [@enumeration] @enumerations = @enumeration.class.system.to_a - [@enumeration]
end end
private private
......
...@@ -31,8 +31,10 @@ class FilesController < ApplicationController ...@@ -31,8 +31,10 @@ class FilesController < ApplicationController
'size' => "#{Attachment.table_name}.filesize", 'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads" 'downloads' => "#{Attachment.table_name}.downloads"
@containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)] @containers = [Project.includes(:attachments).
@containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse 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? render :layout => !request.xhr?
end end
......
...@@ -27,13 +27,13 @@ class GroupsController < ApplicationController ...@@ -27,13 +27,13 @@ class GroupsController < ApplicationController
def index def index
respond_to do |format| respond_to do |format|
format.html { format.html {
@groups = Group.sorted.all @groups = Group.sorted.to_a
@user_count_by_group_id = user_count_by_group_id @user_count_by_group_id = user_count_by_group_id
} }
format.api { format.api {
scope = Group.sorted scope = Group.sorted
scope = scope.givable unless params[:builtin] == '1' scope = scope.givable unless params[:builtin] == '1'
@groups = scope.all @groups = scope.to_a
} }
end end
end end
...@@ -95,7 +95,7 @@ class GroupsController < ApplicationController ...@@ -95,7 +95,7 @@ class GroupsController < ApplicationController
end end
def add_users 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? @group.users << @users if request.post?
respond_to do |format| respond_to do |format|
format.html { redirect_to edit_group_path(@group, :tab => 'users') } format.html { redirect_to edit_group_path(@group, :tab => 'users') }
......
...@@ -27,7 +27,7 @@ class IssueCategoriesController < ApplicationController ...@@ -27,7 +27,7 @@ class IssueCategoriesController < ApplicationController
def index def index
respond_to do |format| respond_to do |format|
format.html { redirect_to_settings_in_projects } format.html { redirect_to_settings_in_projects }
format.api { @categories = @project.issue_categories.all } format.api { @categories = @project.issue_categories.to_a }
end end
end end
......
...@@ -29,7 +29,7 @@ class IssueStatusesController < ApplicationController ...@@ -29,7 +29,7 @@ class IssueStatusesController < ApplicationController
render :action => "index", :layout => false if request.xhr? render :action => "index", :layout => false if request.xhr?
} }
format.api { format.api {
@issue_statuses = IssueStatus.order('position').all @issue_statuses = IssueStatus.order('position').to_a
} }
end end
end end
......
...@@ -104,15 +104,16 @@ class IssuesController < ApplicationController ...@@ -104,15 +104,16 @@ class IssuesController < ApplicationController
end end
def show 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.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
Journal.preload_journals_details_custom_fields(@journals) Journal.preload_journals_details_custom_fields(@journals)
# TODO: use #select! when ruby1.8 support is dropped @journals.select! {|journal| journal.notes? || journal.visible_details.any?}
@journals.reject! {|journal| !journal.notes? && journal.visible_details.empty?}
@journals.reverse! if User.current.wants_comments_in_reverse_order? @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? @changesets.reverse! if User.current.wants_comments_in_reverse_order?
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
...@@ -189,7 +190,7 @@ class IssuesController < ApplicationController ...@@ -189,7 +190,7 @@ class IssuesController < ApplicationController
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
@conflict = true @conflict = true
if params[:last_journal_id] 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) @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
end end
end end
...@@ -301,7 +302,7 @@ class IssuesController < ApplicationController ...@@ -301,7 +302,7 @@ class IssuesController < ApplicationController
else else
@saved_issues = @issues @saved_issues = @issues
@unsaved_issues = unsaved_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 bulk_edit
render :action => 'bulk_edit' render :action => 'bulk_edit'
end end
...@@ -375,7 +376,9 @@ class IssuesController < ApplicationController ...@@ -375,7 +376,9 @@ class IssuesController < ApplicationController
def update_issue_from_params def update_issue_from_params
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.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) @issue.init_journal(User.current)
...@@ -422,7 +425,9 @@ class IssuesController < ApplicationController ...@@ -422,7 +425,9 @@ class IssuesController < ApplicationController
@issue.project = @project @issue.project = @project
@issue.author ||= User.current @issue.author ||= User.current
# Tracker must be set before custom field values # 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? if @issue.tracker.nil?
render_error l(:error_no_tracker_in_project) render_error l(:error_no_tracker_in_project)
return false return false
......
...@@ -34,7 +34,6 @@ class JournalsController < ApplicationController ...@@ -34,7 +34,6 @@ class JournalsController < ApplicationController
retrieve_query retrieve_query
sort_init 'id', 'desc' sort_init 'id', 'desc'
sort_update(@query.sortable_columns) sort_update(@query.sortable_columns)
if @query.valid? if @query.valid?
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC", @journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
:limit => 25) :limit => 25)
......
...@@ -32,7 +32,7 @@ class MembersController < ApplicationController ...@@ -32,7 +32,7 @@ class MembersController < ApplicationController
order("#{Member.table_name}.id"). order("#{Member.table_name}.id").
limit(@limit). limit(@limit).
offset(@offset). offset(@offset).
all to_a
respond_to do |format| respond_to do |format|
format.html { head 406 } format.html { head 406 }
format.api format.api
...@@ -63,7 +63,10 @@ class MembersController < ApplicationController ...@@ -63,7 +63,10 @@ class MembersController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to_settings_in_projects } format.html { redirect_to_settings_in_projects }
format.js { @members = members } format.js {
@members = members
@member = Member.new
}
format.api { format.api {
@member = members.first @member = members.first
if @member.valid? if @member.valid?
......
...@@ -43,10 +43,10 @@ class MessagesController < ApplicationController ...@@ -43,10 +43,10 @@ class MessagesController < ApplicationController
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
@replies = @topic.children. @replies = @topic.children.
includes(:author, :attachments, {:board => :project}). 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). limit(@reply_pages.per_page).
offset(@reply_pages.offset). offset(@reply_pages.offset).
all to_a
@reply = Message.new(:subject => "RE: #{@message.subject}") @reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => false if request.xhr? render :action => "show", :layout => false if request.xhr?
......
...@@ -53,8 +53,8 @@ class MyController < ApplicationController ...@@ -53,8 +53,8 @@ class MyController < ApplicationController
@user = User.current @user = User.current
@pref = @user.pref @pref = @user.pref
if request.post? if request.post?
@user.safe_attributes = params[:user] @user.safe_attributes = params[:user] if params[:user]
@user.pref.attributes = params[:pref] @user.pref.attributes = params[:pref] if params[:pref]
if @user.save if @user.save
@user.pref.save @user.pref.save
set_language_if_valid @user.language set_language_if_valid @user.language
......
...@@ -46,7 +46,7 @@ class NewsController < ApplicationController ...@@ -46,7 +46,7 @@ class NewsController < ApplicationController