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

[20043] Upgrade to Rails 4.1.x
pull/6827/head
ulferts 9 years ago
commit a8b2775440
  1. 2
      app/controllers/cost_types_controller.rb
  2. 8
      app/controllers/costlog_controller.rb
  3. 1
      app/models/cost_entry.rb
  4. 6
      app/models/labor_budget_item.rb
  5. 1
      app/models/material_budget_item.rb
  6. 6
      features/step_definitions/cost_steps.rb
  7. 4
      features/step_definitions/cost_type_steps.rb
  8. 2
      lib/open_project/costs/attributes_helper.rb
  9. 6
      lib/open_project/costs/patches/time_entry_patch.rb
  10. 4
      lib/open_project/costs/patches/work_package_patch.rb
  11. 2
      openproject-costs.gemspec
  12. 8
      spec/models/cost_entry_spec.rb
  13. 8
      spec/models/time_entry_spec.rb

@ -35,7 +35,7 @@ class CostTypesController < ApplicationController
'unit_plural' => "#{CostType.table_name}.unit_plural" }
sort_update sort_columns
@cost_types = CostType.find :all, order: sort_clause
@cost_types = CostType.order(sort_clause)
unless params[:clear_filter]
@fixed_date = Date.parse(params[:fixed_date]) rescue Date.today

@ -244,8 +244,12 @@ class CostlogController < ApplicationController
end
@from, @to = @to, @from if @from && @to && @from > @to
@from ||= (CostEntry.minimum(:spent_on, include: [:project, :user], conditions: Project.allowed_to_condition(User.current, :view_cost_entries)) || Date.today) - 1
@to ||= (CostEntry.maximum(:spent_on, include: [:project, :user], conditions: Project.allowed_to_condition(User.current, :view_cost_entries)) || Date.today)
@from ||= (CostEntry.includes([:project, :user])
.where(Project.allowed_to_condition(User.current, :view_cost_entries))
.minimum(:spent_on) || Date.today) - 1
@to ||= (CostEntry.includes([:project, :user])
.where(Project.allowed_to_condition(User.current, :view_cost_entries))
.maximum(:spent_on) || Date.today)
end
def new_default_cost_entry

@ -40,6 +40,7 @@ class CostEntry < ActiveRecord::Base
scope :visible, lambda { |*args|
where(CostEntry.visible_condition(args[0] || User.current, args[1]))
.includes([:project, :user])
.references(:project)
}
scope :on_work_packages, ->(work_packages) { where(work_package_id: work_packages) }

@ -40,9 +40,9 @@ class LaborBudgetItem < ActiveRecord::Base
end
scope :visible_costs, lambda{|*args|
{ include: [{ cost_object: :project }, :user],
conditions: LaborBudgetItem.visible_condition((args.first || User.current), args[1])
}
includes([{ cost_object: :project }, :user])
.where(LaborBudgetItem.visible_condition((args.first || User.current), args[1]))
.references(:projects)
}
def costs

@ -35,6 +35,7 @@ class MaterialBudgetItem < ActiveRecord::Base
scope :visible_costs, lambda { |*args|
where(MaterialBudgetItem.visible_condition((args.first || User.current), args[1]))
.includes(cost_object: :project)
.references(:projects)
}
def costs

@ -35,11 +35,9 @@ Given /^there (?:is|are) (\d+) (default )?hourly rate[s]? with the following:$/
end
send_table_to_object(hr, table, user: Proc.new do |rate, value|
unless rate.project.nil? || User.find_by_login(value).projects.include?(rate.project)
Rate.update_all({ project_id: User.find_by_login(value).projects(order: 'id ASC').last.id },
id: rate.id)
Rate.where(id: rate.id).update_all(project_id: User.find_by_login(value).projects(order: 'id ASC').last.id)
end
Rate.update_all({ user_id: User.find_by_login(value).id },
id: rate.id)
Rate.where(id: rate.id).update_all(user_id: User.find_by_login(value).id)
end,
valid_from: Proc.new do |rate, value|
# This works for definitions like "2 years ago"

@ -64,9 +64,7 @@ When /^I expect to click "([^"]*)" on a confirmation box saying "([^"]*)"$/ do |
end
When /^the confirmation box should have been displayed$/ do
assert page.evaluate_script('document.cookie').include?(@expected_message),
"Expected confirm box with message: '#{@expected_message}'" +
" got: '#{page.evaluate_script('document.cookie')}'"
expect(page.evaluate_script('document.cookie')).to include(@expected_message)
end
Then(/^the cost type "(.*?)" should not be listed on the index page$/) do |name|

@ -29,7 +29,7 @@ module OpenProject::Costs
end
def summarized_cost_entries
@summarized_cost_entries ||= cost_entries.calculate(:sum, :units, group: :cost_type)
@summarized_cost_entries ||= cost_entries.group(:cost_type).calculate(:sum, :units)
end
def time_entries

@ -32,6 +32,7 @@ module OpenProject::Costs::Patches::TimeEntryPatch
scope :visible, lambda { |*args|
where(TimeEntry.visible_condition(args[0] || User.current, args[1]))
.includes(:project, :user)
.references(:project)
}
before_save :update_costs
@ -49,9 +50,8 @@ module OpenProject::Costs::Patches::TimeEntryPatch
(#{Project.allowed_to_condition(user, :view_own_hourly_rate, project: project)} AND #{TimeEntry.table_name}.user_id = #{user.id})) }
view_time_entries = TimeEntry.visible_condition(user, project)
{ include: [:project, :user],
conditions: [view_time_entries, view_hourly_rates].join(' AND ')
}
includes(:project, :user)
.where([view_time_entries, view_hourly_rates].join(' AND '))
}
end
end

@ -66,8 +66,10 @@ module OpenProject::Costs::Patches::WorkPackagePatch
false
when 'reassign'
reassign_to = WorkPackage.includes(:project)
reassign_to = WorkPackage
.where(Project.allowed_to_condition(user, :edit_cost_entries))
.includes(:project)
.references(:projects)
.find_by_id(to_do[:reassign_to_id])
if reassign_to.nil?

@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.files = Dir['{app,config,db,lib,doc}/**/*', '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'
end

@ -99,7 +99,7 @@ describe CostEntry, type: :model do
cost_entry.save!
end
it { expect(CostEntry.visible(user2, project).all).to match_array([cost_entry]) }
it { expect(CostEntry.visible(user2, project)).to match_array([cost_entry]) }
end
describe "WHEN not having the view_cost_entries permission
@ -111,7 +111,7 @@ describe CostEntry, type: :model do
cost_entry.save!
end
it { expect(CostEntry.visible(user2, project).all).to match_array([]) }
it { expect(CostEntry.visible(user2, project)).to match_array([]) }
end
describe "WHEN having the view_own_cost_entries permission
@ -123,7 +123,7 @@ describe CostEntry, type: :model do
cost_entry.save!
end
it { expect(CostEntry.visible(user2, project).all).to match_array([]) }
it { expect(CostEntry.visible(user2, project)).to match_array([]) }
end
describe "WHEN having the view_own_cost_entries permission
@ -135,7 +135,7 @@ describe CostEntry, type: :model do
cost_entry2.save!
end
it { expect(CostEntry.visible(cost_entry2.user, project).all).to match_array([cost_entry2]) }
it { expect(CostEntry.visible(cost_entry2.user, project)).to match_array([cost_entry2]) }
end
end
end

@ -306,7 +306,7 @@ describe TimeEntry, type: :model do
time_entry.save!
end
it { expect(TimeEntry.visible(user2, project).all).to match_array([time_entry]) }
it { expect(TimeEntry.visible(user2, project)).to match_array([time_entry]) }
end
describe "WHEN not having the view_time_entries permission
@ -318,7 +318,7 @@ describe TimeEntry, type: :model do
time_entry.save!
end
it { expect(TimeEntry.visible(user2, project).all).to match_array([]) }
it { expect(TimeEntry.visible(user2, project)).to match_array([]) }
end
describe "WHEN having the view_own_time_entries permission
@ -332,7 +332,7 @@ describe TimeEntry, type: :model do
time_entry.save!
end
it { expect(TimeEntry.visible(user2, project).all).to match_array([]) }
it { expect(TimeEntry.visible(user2, project)).to match_array([]) }
end
describe "WHEN having the view_own_time_entries permission
@ -346,7 +346,7 @@ describe TimeEntry, type: :model do
time_entry2.save!
end
it { expect(TimeEntry.visible(time_entry2.user, project).all).to match_array([time_entry2]) }
it { expect(TimeEntry.visible(time_entry2.user, project)).to match_array([time_entry2]) }
end
end

Loading…
Cancel
Save