Revert "Fix save unit types"

pull/6827/head
Jan Sandbrink 10 years ago
parent 266c7d25c9
commit 00e897ac4c
  1. 8
      app/controllers/cost_reports_controller.rb
  2. 34
      spec/models/cost_query/chaining_spec.rb

@ -165,14 +165,10 @@ class CostReportsController < ApplicationController
@unit_id = 0 unless @cost_types.include? @unit_id
end
# Determine the active cost type and add a hidden filter to the query
# Determine the active cost type, if it is not labor or money, and add a hidden filter to the query
# sets the @cost_type -> this is used to select the proper units for display
def set_cost_type
if @query
existing_filter = @query.filters.detect { |f| f.is_a?(CostQuery::Filter::CostTypeId) }
if existing_filter
@query.remove_filter(existing_filter)
end
if @unit_id != 0 && @query
@query.filter :cost_type_id, operator: '=', value: @unit_id.to_s, display: false
@cost_type = CostType.find(@unit_id) if @unit_id > 0
end

@ -1,7 +1,7 @@
#-- copyright
# OpenProject Reporting Plugin
#
# Copyright (C) 2010 - 2015 the OpenProject Foundation (OPF)
# Copyright (C) 2010 - 2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -316,37 +316,5 @@ describe CostQuery, type: :model, reporting_query_helper: true do
Object.send(:remove_const, :TestFilter)
end
end
describe '#remove' do
before do
@chain = Report::Chainable.new
@chain = Report::Chainable.new(@chain)
end
it 'has one less element after removal' do
count_before = @chain.count
@chain = @chain.remove(@chain.bottom)
expect(@chain.count).to eq(count_before - 1)
end
it 'removes the specified element' do
@chain = @chain.remove(@chain.bottom)
expect(@chain.top).to eq(@chain.bottom)
end
it 'returns the top of the chain' do
@chain = Report::Chainable.new(@chain)
chain_top = @chain.top
@chain = @chain.remove(@chain.top.child)
expect(chain_top).to eq(@chain.top)
end
it 'properly disconnects the removed element from the chain' do
@chain = Report::Chainable.new(@chain)
@chain = @chain.remove(@chain.top.child)
expect(@chain.top.child).to eq(@chain.bottom)
expect(@chain.bottom.parent).to eq(@chain.top)
end
end
end
end

Loading…
Cancel
Save