Merge pull request #55 from finnlabs/feature/20043-rails-4.1

[20043] Upgrade to Rails 4.1.x
pull/6827/head
ulferts 9 years ago
commit 8bf6765f10
  1. 43
      app/controllers/my_projects_overviews_controller.rb
  2. 8
      app/views/my_projects_overviews/blocks/_spent_time.html.erb
  3. 12
      app/views/my_projects_overviews/blocks/_work_packages_assigned_to_me.html.erb
  4. 12
      app/views/my_projects_overviews/blocks/_work_packages_reported_by_me.html.erb
  5. 12
      app/views/my_projects_overviews/blocks/_work_packages_responsible_for.html.erb
  6. 2
      features/step_definitions/selected_widgets_steps.rb
  7. 2
      openproject-my_project_page.gemspec
  8. 2
      spec/models/my_projects_overview_spec.rb

@ -161,14 +161,15 @@ class MyProjectsOverviewsController < ApplicationController
:object_callback
def childprojects
@childprojects ||= project.children.visible.all
@childprojects ||= project.children.visible
end
def recent_news
@news ||= project.news.all :limit => 5,
:include => [ :author, :project ],
:order => "#{News.table_name}.created_on DESC"
@news ||= project
.news
.includes([:author, :project])
.order("#{News.table_name}.created_on DESC")
.limit(5)
end
def types
@ -176,24 +177,32 @@ class MyProjectsOverviewsController < ApplicationController
end
def open_work_packages_by_type
@open_work_packages_by_tracker ||= WorkPackage.visible.count(:group => :type,
:include => [:project, :status, :type],
:conditions => ["(#{subproject_condition}) AND #{Status.table_name}.is_closed=?", false])
@open_work_packages_by_tracker ||= work_packages_by_type
.where(statuses: { is_closed: false })
.count
end
def total_work_packages_by_type
@total_work_packages_by_tracker ||= WorkPackage.visible.count(:group => :type,
:include => [:project, :status, :type],
:conditions => subproject_condition)
@total_work_packages_by_tracker ||= work_packages_by_type.count
end
def work_packages_by_type
WorkPackage
.visible
.group(:type)
.includes([:project, :status, :type])
.where(subproject_condition)
end
def assigned_work_packages
@assigned_issues ||= WorkPackage.visible.open.find(:all,
:conditions => { :assigned_to_id => User.current.id },
:limit => 10,
:include => [ :status, :project, :type, :priority ],
:order => "#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_on DESC")
@assigned_issues ||= WorkPackage
.visible
.open
.where(assigned_to: User.current.id)
.limit(10)
.includes([:status, :project, :type, :priority])
.order("#{IssuePriority.table_name}.position DESC,
#{WorkPackage.table_name}.updated_on DESC")
end
def users_by_role(limit = 100)
@ -278,7 +287,7 @@ class MyProjectsOverviewsController < ApplicationController
end
def overview
@overview ||= MyProjectsOverview.find_or_create_by_project_id(project.id)
@overview ||= MyProjectsOverview.find_or_create_by(project_id: project.id)
end
def attachments

@ -26,10 +26,10 @@ See doc/COPYRIGHT.md for more details.
<% end %>
<%
entries = TimeEntry.find(:all,
:conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today],
:include => [:activity, :project, {:work_package => [:type, :status]}],
:order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Type.table_name}.position ASC, #{WorkPackage.table_name}.id ASC")
entries = TimeEntry
.where(["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today])
.includes([:activity, :project, {:work_package => [:type, :status]}])
.order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Type.table_name}.position ASC, #{WorkPackage.table_name}.id ASC")
entries_by_day = entries.group_by(&:spent_on)
%>

@ -19,17 +19,17 @@ See doc/COPYRIGHT.md for more details.
++#%>
<h3><%=l(:label_work_packages_assigned_to_me)%> (<%= WorkPackage.visible.open.count(:conditions => {:assigned_to_id => User.current.id, :project_id => @project.id})%>)</h3>
<h3><%=l(:label_work_packages_assigned_to_me)%> (<%= WorkPackage.visible.open.where(assigned_to_id: User.current.id, project_id: @project.id).count %>)</h3>
<% if defined? block_name_id %>
<%= content_for block_name_id %>
<% end %>
<% assigned_work_packages = WorkPackage.visible.open.find(:all,
:conditions => {:assigned_to_id => User.current.id, :project_id => @project.id},
:limit => 10,
:include => [ :status, :project, :type, :priority ],
:order => "#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %>
<% assigned_work_packages = WorkPackage.visible.open
.where(assigned_to_id: User.current.id, project_id: @project.id)
.limit(10)
.includes([:status, :project, :type, :priority])
.order("#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %>
<%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => assigned_work_packages } %>
<% if assigned_work_packages.length > 0 %>
<p class="small">

@ -19,17 +19,17 @@ See doc/COPYRIGHT.md for more details.
++#%>
<h3><%=l(:label_work_package_view_all_reported_by_me)%> (<%= WorkPackage.visible.count(:conditions => { :author_id => User.current.id, :project_id => @project.id }) %>)</h3>
<h3><%=l(:label_work_package_view_all_reported_by_me)%> (<%= WorkPackage.visible.where(author_id: User.current.id, project_id: @project.id).count %>)</h3>
<% if defined? block_name_id %>
<%= content_for block_name_id %>
<% end %>
<% reported_work_packages = WorkPackage.visible.find(:all,
:conditions => { :author_id => User.current.id, :project_id => @project.id },
:limit => 10,
:include => [ :status, :project, :type ],
:order => "#{WorkPackage.table_name}.updated_at DESC") %>
<% reported_work_packages = WorkPackage.visible
.where(author_id: User.current.id, project_id: @project.id)
.limit(10)
.includes([:status, :project, :type])
.order("#{WorkPackage.table_name}.updated_at DESC") %>
<%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => reported_work_packages } %>
<% if reported_work_packages.length > 0 %>
<p class="small">

@ -19,17 +19,17 @@ See doc/COPYRIGHT.md for more details.
++#%>
<h3><%=l(:label_work_packages_responsible_for)%> (<%= WorkPackage.visible.open.count(:conditions => {:responsible_id => User.current.id, :project_id => @project.id})%>)</h3>
<h3><%=l(:label_work_packages_responsible_for)%> (<%= WorkPackage.visible.open.where(responsible_id: User.current.id, project_id: @project.id).count %>)</h3>
<% if defined? block_name_id %>
<%= content_for block_name_id %>
<% end %>
<% responsible_work_packages = WorkPackage.visible.open.find(:all,
:conditions => {:responsible_id => User.current.id, :project_id => @project.id},
:limit => 10,
:include => [ :status, :project, :type, :priority ],
:order => "#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %>
<% responsible_work_packages = WorkPackage.visible.open
.where(responsible_id: User.current.id, project_id: @project.id)
.limit(10)
.includes([:status, :project, :type, :priority])
.order("#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %>
<%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => responsible_work_packages } %>
<% if responsible_work_packages.length > 0 %>
<p class="small">

@ -20,7 +20,7 @@
Given /^the following widgets are selected for the overview page of the "(.+)" project:$/ do |project_name, table|
project = Project.find_by_name(project_name)
page = MyProjectsOverview.find_or_create_by_project_id(project.id)
page = MyProjectsOverview.find_or_create_by(project_id: project.id)
blocks = ({ "top" => "", "left" => "", "right" => "", "hidden" => "" }).merge(table.rows_hash)

@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*", "README.md"]
s.test_files = Dir["spec/**/*"]
s.add_dependency 'rails', '~> 4.0.13'
s.add_dependency 'rails', '~> 4.1.11'
s.add_development_dependency "factory_girl_rails", "~> 4.0"

@ -24,7 +24,7 @@ describe MyProjectsOverview, :type => :model do
before do
@enabled_module_names = %w[activity work_package_tracking news wiki]
FactoryGirl.create(:project, :enabled_module_names => @enabled_module_names)
@project = Project.find(:first)
@project = Project.first
@overview = MyProjectsOverview.create(:project_id => @project.id)
end

Loading…
Cancel
Save