GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

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 @@
# You can also run tests on your environment.
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0
- 2.1
......@@ -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
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
......@@ -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
......@@ -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]
......@@ -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
......@@ -34,7 +34,7 @@ class AdminController < ApplicationController
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
......
......@@ -496,7 +496,7 @@ class ApplicationController < ActionController::Base
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
......
......@@ -26,7 +26,7 @@ class AutoCompletesController < ApplicationController
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
......
......@@ -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
......@@ -45,12 +45,13 @@ class BoardsController < ApplicationController
@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?
}
......@@ -59,7 +60,7 @@ class BoardsController < ApplicationController
reorder('created_on DESC').
includes(:author, :board).
limit(Setting.feeds_limit.to_i).
all
to_a
render_feed(@messages, :title => "#{@project}: #{@board}")
}
end
......
......@@ -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 }
......@@ -43,7 +43,7 @@ class DocumentsController < ApplicationController
end
def show
@attachments = @document.attachments.all
@attachments = @document.attachments.to_a
end
def new
......@@ -69,7 +69,7 @@ class DocumentsController < ApplicationController
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
......
......@@ -32,7 +32,7 @@ class EnumerationsController < ApplicationController
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
......@@ -56,7 +56,7 @@ class EnumerationsController < ApplicationController
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
......@@ -75,7 +75,7 @@ class EnumerationsController < ApplicationController
redirect_to enumerations_path
return
end
@enumerations = @enumeration.class.system.all - [@enumeration]
@enumerations = @enumeration.class.system.to_a - [@enumeration]
end
private
......
......@@ -31,8 +31,10 @@ class FilesController < ApplicationController
'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
......
......@@ -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
......@@ -95,7 +95,7 @@ class GroupsController < ApplicationController
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') }
......
......@@ -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
......
......@@ -29,7 +29,7 @@ class IssueStatusesController < ApplicationController
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
......
......@@ -104,15 +104,16 @@ class IssuesController < ApplicationController
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? }
......@@ -189,7 +190,7 @@ class IssuesController < ApplicationController
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
......@@ -301,7 +302,7 @@ class IssuesController < ApplicationController
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
......@@ -375,7 +376,9 @@ class IssuesController < ApplicationController
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)
......@@ -422,7 +425,9 @@ class IssuesController < ApplicationController
@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
......
......@@ -34,7 +34,6 @@ class JournalsController < ApplicationController
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)
......
......@@ -32,7 +32,7 @@ class MembersController < ApplicationController
order("#{Member.table_name}.id").
limit(@limit).
offset(@offset).
all
to_a
respond_to do |format|
format.html { head 406 }
format.api
......@@ -63,7 +63,10 @@ class MembersController < ApplicationController
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?
......
......@@ -43,10 +43,10 @@ class MessagesController < ApplicationController
@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?
......
......@@ -53,8 +53,8 @@ class MyController < ApplicationController
@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
......
......@@ -46,7 +46,7 @@ class NewsController < ApplicationController
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
......
......@@ -20,7 +20,7 @@ class ProjectEnumerationsController < ApplicationController
before_filter :authorize
def update
if request.put? && params[:enumerations]
if params[:enumerations]
Project.transaction do
params[:enumerations].each do |id, activity|
@project.update_or_create_time_entry_activity(id, activity)
......
......@@ -53,30 +53,30 @@ class ProjectsController < ApplicationController
unless params[:closed]
scope = scope.active
end
@projects = scope.visible.order('lft').all
@projects = scope.visible.order('lft').to_a
}
format.api {
@offset, @limit = api_offset_and_limit
@project_count = Project.visible.count
@projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
@projects = Project.visible.offset(@offset).limit(@limit).order('lft').to_a
}
format.atom {
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).to_a
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
}
end
end
def new
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@issue_custom_fields = IssueCustomField.sorted.to_a
@trackers = Tracker.sorted.to_a
@project = Project.new
@project.safe_attributes = params[:project]
end
def create
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@issue_custom_fields = IssueCustomField.sorted.to_a
@trackers = Tracker.sorted.to_a
@project = Project.new
@project.safe_attributes = params[:project]
......@@ -109,8 +109,8 @@ class ProjectsController < ApplicationController
end
def copy
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@issue_custom_fields = IssueCustomField.sorted.to_a
@trackers = Tracker.sorted.to_a
@source_project = Project.find(params[:id])
if request.get?
@project = Project.copy_from(@source_project)
......@@ -145,8 +145,8 @@ class ProjectsController < ApplicationController
end
@users_by_role = @project.users_by_role
@subprojects = @project.children.visible.all
@news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all
@subprojects = @project.children.visible.to_a
@news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").to_a
@trackers = @project.rolled_up_trackers
cond = @project.project_condition(Setting.display_subprojects_issues?)
......@@ -167,10 +167,10 @@ class ProjectsController < ApplicationController
end
def settings
@issue_custom_fields = IssueCustomField.sorted.all
@issue_custom_fields = IssueCustomField.sorted.to_a
@issue_category ||= IssueCategory.new
@member ||= @project.members.new
@trackers = Tracker.sorted.all
@trackers = Tracker.sorted.to_a
@wiki ||= @project.wiki
end
......
......@@ -37,8 +37,9 @@ class QueriesController < ApplicationController
order("#{Query.table_name}.name").
limit(@limit).
offset(@offset).
all
to_a
respond_to do |format|
format.html {render_error :status => 406}
format.api
end
end
......
......@@ -90,6 +90,6 @@ class ReportsController < ApplicationController
private
def find_issue_statuses
@statuses = IssueStatus.sorted.all
@statuses = IssueStatus.sorted.to_a
end
end
......@@ -69,7 +69,7 @@ class RepositoriesController < ApplicationController
@repository.merge_extra_info(attrs[:attrs_extra])
end
@repository.project = @project
if request.put? && @repository.save
if @repository.save
redirect_to settings_project_path(@project, :tab => 'repositories')
else
render :action => 'edit'
......@@ -94,7 +94,7 @@ class RepositoriesController < ApplicationController
@committers = @repository.committers
@users = @project.users
additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
@users += User.where(:id => additional_user_ids).all unless additional_user_ids.empty?
@users += User.where(:id => additional_user_ids).to_a unless additional_user_ids.empty?
@users.compact!
@users.sort!
if request.post? && params[:committers].is_a?(Hash)
......@@ -145,7 +145,7 @@ class RepositoriesController < ApplicationController
limit(@changeset_pages.per_page).
offset(@changeset_pages.offset).
includes(:user, :repository, :parents).
all
to_a
respond_to do |format|
format.html { render :layout => false if request.xhr? }
......
......@@ -30,7 +30,7 @@ class RolesController < ApplicationController
render :action => "index", :layout => false if request.xhr?
}
format.api {
@roles = Role.givable.all
@roles = Role.givable.to_a
}
end
end
......@@ -47,7 +47,7 @@ class RolesController < ApplicationController
if params[:copy].present? && @copy_from = Role.find_by_id(params[:copy])
@role.copy_from(@copy_from)
end
@roles = Role.sorted.all
@roles = Role.sorted.to_a
end
def create
......@@ -60,7 +60,7 @@ class RolesController < ApplicationController
flash[:notice] = l(:notice_successful_create)
redirect_to roles_path
else
@roles = Role.sorted.all