organized code into Smr module
[smr.git] / gui / test / functional / smr_asset_test.rb
blob4625cbed4c5bfe86550f1225b59f3f6e1ae50760
2 # This file is part of SMR.
4 # SMR is free software: you can redistribute it and/or modify it under the
5 # terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or (at your option) any later
7 # version.
9 # SMR is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # SMR.  If not, see <http://www.gnu.org/licenses/>.
16 require 'test_helper'
18 module Smr  #:nodoc:
20     class AssetTest < ActionController::TestCase
21         ##
22         # test time machine by verifying investment sums at certain dates
23         #
24         # this is using the admin user with id_user=>1
25         test 'invested' do
26             to_test = [
27                 {:at=>Time.new(2003,5,23), :invested=>225.0},
28                 {:at=>Time.new(2004,5,23), :invested=>12245.85},
29                 {:at=>Time.new(2014,5,23), :invested=>10570.05},
30                 {:at=>Time.new(2014,6,20), :invested=>12068.85},
31             ]
32     
33             to_test.each do |ta|
34                 a = Smr::Asset.new(1, ta[:at])
35                 assert_in_delta(ta[:invested], a.invested, 0.0001, 'wrong investment total on %s ' % ta[:at])
36             end
37         end
38     end
40 end # module