Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
2c2ed958
Commit
2c2ed958
authored
13 years ago
by
Gregor Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
[#416] Re-Adding watcher_tag for backwards compatibility
adding deprecation warning
parent
508b23cf
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/helpers/watchers_helper.rb
+13
-0
13 additions, 0 deletions
app/helpers/watchers_helper.rb
test/unit/helpers/watchers_helpers_test.rb
+49
-0
49 additions, 0 deletions
test/unit/helpers/watchers_helpers_test.rb
with
62 additions
and
0 deletions
app/helpers/watchers_helper.rb
+
13
−
0
View file @
2c2ed958
...
...
@@ -17,6 +17,19 @@
module
WatchersHelper
# Deprecated method. Use watcher_link instead
#
# This method will be removed in ChiliProject 3.0 or later
def
watcher_tag
(
object
,
user
,
options
=
{
:replace
=>
'watcher'
})
ActiveSupport
::
Deprecation
.
warn
"The WatchersHelper#watcher_tag is deprecated and will be removed in ChiliProject 3.0. Please use WatchersHelper#watcher_link instead. Please also note the differences between the APIs."
,
caller
options
[
:id
]
||=
options
[
:replace
]
if
options
[
:replace
].
is_a?
String
options
[
:replace
]
=
Array
(
options
[
:replace
]).
map
{
|
id
|
"#
#{
id
}
"
}
watcher_link
(
object
,
user
,
options
)
end
# Create a link to watch/unwatch object
#
# * :replace - a string or array of strings with css selectors that will be updated, whenever the watcher status is changed
...
...
This diff is collapsed.
Click to expand it.
test/unit/helpers/watchers_helpers_test.rb
0 → 100644
+
49
−
0
View file @
2c2ed958
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
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment