kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.2 KiB
64 lines
2.2 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
|
# ChiliProject is a project management system.
|
||
14 years ago
|
#
|
||
14 years ago
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
||
14 years ago
|
#
|
||
14 years ago
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
14 years ago
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
14 years ago
|
require File.expand_path('../../../test_helper', __FILE__)
|
||
|
|
||
|
class WatchersHelperTest < HelperTestCase
|
||
|
include WatchersHelper
|
||
|
|
||
|
# tested for backwards compatibility
|
||
|
context '#watcher_tag' do
|
||
|
setup do
|
||
|
# mocking watcher_link to make sure, that new API is properly called from
|
||
|
# the old one.
|
||
|
def self.watcher_link(*args)
|
||
|
@watcher_link_args = args
|
||
|
nil
|
||
|
end
|
||
|
|
||
|
# silencing deprecation warnings while testing the deprecated behavior
|
||
|
def self.watcher_tag(*args)
|
||
|
ActiveSupport::Deprecation.silence { super }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'without options' do
|
||
|
should "call watcher_link with object, user and {:id => 'watcher', :replace => '#watcher'}" do
|
||
|
watcher_tag(:object, :user)
|
||
|
assert_equal :object, @watcher_link_args.first
|
||
|
assert_equal :user, @watcher_link_args.second
|
||
|
assert_equal({:id => 'watcher', :replace => ['#watcher']}, @watcher_link_args.third)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'with replace, without id option' do
|
||
|
should "set id to replace value and prefix replace with a # to make it a valid css selectors" do
|
||
|
watcher_tag(:object, :user, :replace => 'abc')
|
||
|
assert_equal :object, @watcher_link_args.first
|
||
|
assert_equal :user, @watcher_link_args.second
|
||
|
assert_equal({:id => 'abc', :replace => ['#abc']}, @watcher_link_args.third)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'with all options' do
|
||
|
should "prefix all elements in replace with a # to make them valid css selectors" do
|
||
|
watcher_tag(:object, :user, :id => 'abc', :replace => ['abc', 'def'])
|
||
|
assert_equal :object, @watcher_link_args.first
|
||
|
assert_equal :user, @watcher_link_args.second
|
||
|
assert_equal({:id => 'abc', :replace => ['#abc', '#def']}, @watcher_link_args.third)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|