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

@ -26,10 +26,10 @@ See doc/COPYRIGHT.md for more details.
<% end %> <% end %>
<% <%
entries = TimeEntry.find(:all, entries = TimeEntry
:conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today], .where(["#{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]}], .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") .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) 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 %> <% if defined? block_name_id %>
<%= content_for block_name_id %> <%= content_for block_name_id %>
<% end %> <% end %>
<% assigned_work_packages = WorkPackage.visible.open.find(:all, <% assigned_work_packages = WorkPackage.visible.open
:conditions => {:assigned_to_id => User.current.id, :project_id => @project.id}, .where(assigned_to_id: User.current.id, project_id: @project.id)
:limit => 10, .limit(10)
:include => [ :status, :project, :type, :priority ], .includes([:status, :project, :type, :priority])
:order => "#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %> .order("#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %>
<%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => assigned_work_packages } %> <%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => assigned_work_packages } %>
<% if assigned_work_packages.length > 0 %> <% if assigned_work_packages.length > 0 %>
<p class="small"> <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 %> <% if defined? block_name_id %>
<%= content_for block_name_id %> <%= content_for block_name_id %>
<% end %> <% end %>
<% reported_work_packages = WorkPackage.visible.find(:all, <% reported_work_packages = WorkPackage.visible
:conditions => { :author_id => User.current.id, :project_id => @project.id }, .where(author_id: User.current.id, project_id: @project.id)
:limit => 10, .limit(10)
:include => [ :status, :project, :type ], .includes([:status, :project, :type])
:order => "#{WorkPackage.table_name}.updated_at DESC") %> .order("#{WorkPackage.table_name}.updated_at DESC") %>
<%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => reported_work_packages } %> <%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => reported_work_packages } %>
<% if reported_work_packages.length > 0 %> <% if reported_work_packages.length > 0 %>
<p class="small"> <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 %> <% if defined? block_name_id %>
<%= content_for block_name_id %> <%= content_for block_name_id %>
<% end %> <% end %>
<% responsible_work_packages = WorkPackage.visible.open.find(:all, <% responsible_work_packages = WorkPackage.visible.open
:conditions => {:responsible_id => User.current.id, :project_id => @project.id}, .where(responsible_id: User.current.id, project_id: @project.id)
:limit => 10, .limit(10)
:include => [ :status, :project, :type, :priority ], .includes([:status, :project, :type, :priority])
:order => "#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %> .order("#{IssuePriority.table_name}.position DESC, #{WorkPackage.table_name}.updated_at DESC") %>
<%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => responsible_work_packages } %> <%= render :partial => 'work_packages/list_simple', :locals => { :work_packages => responsible_work_packages } %>
<% if responsible_work_packages.length > 0 %> <% if responsible_work_packages.length > 0 %>
<p class="small"> <p class="small">

@ -20,7 +20,7 @@
Given /^the following widgets are selected for the overview page of the "(.+)" project:$/ do |project_name, table| Given /^the following widgets are selected for the overview page of the "(.+)" project:$/ do |project_name, table|
project = Project.find_by_name(project_name) 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) 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.files = Dir["{app,config,db,lib}/**/*", "README.md"]
s.test_files = Dir["spec/**/*"] 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" s.add_development_dependency "factory_girl_rails", "~> 4.0"

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

Loading…
Cancel
Save