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
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/>.
20 class WatchlistTest < ActiveSupport::TestCase
22 # verify that all securites being held in a position are *not* shown in the watchlist
23 test 'only securities not held in positions' do
25 a = Smr::Asset.new(User.find(1).id, date)
26 w = Smr::Watchlist.new(
28 :exclude_securities=>a.open_positions.collect{ |p| p.security.id }.uniq
30 assert w.is_a?(Smr::Watchlist)
31 assert a.is_a?(Smr::Asset)
35 a.open_positions.each{|ap|
36 assert (ap.id_security != i.id), 'watchlist id_security=%i found in Smr::Asset.open_positions' % i.id
42 # when the Security* type model reports #is_expired? == true, the
43 # Security should not be shown in the list.
44 test 'expired securities not shown' do
45 id_matured_bond = 110 # Country A 7.5% 1990(10)
46 id_expired_stock = 111 # Company A Common Stock - Old Shares
48 date = Time.new(2015,5,30)
49 w = Smr::Watchlist.new(User.find(2), date)
52 assert_not_equal id_matured_bond, wi.id, 'found matured bond in watchlist'
53 assert_not_equal id_expired_stock, wi.id, 'found expired stock in watchlist'