Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
aa0c4b77
Commit
aa0c4b77
authored
Sep 26, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add current_action? helper
parent
afc4a754
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+15
-0
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+19
-0
No files found.
app/helpers/application_helper.rb
View file @
aa0c4b77
require
'digest/md5'
require
'digest/md5'
module
ApplicationHelper
module
ApplicationHelper
# Check if a particular controller is the current one
# Check if a particular controller is the current one
...
@@ -15,6 +16,20 @@ module ApplicationHelper
...
@@ -15,6 +16,20 @@ module ApplicationHelper
args
.
any?
{
|
v
|
v
.
to_s
.
downcase
==
controller
.
controller_name
}
args
.
any?
{
|
v
|
v
.
to_s
.
downcase
==
controller
.
controller_name
}
end
end
# Check if a partcular action is the current one
#
# args - One or more action names to check
#
# Examples
#
# # On Projects#new
# current_action?(:new) # => true
# current_action?(:create) # => false
# current_action?(:new, :create) # => true
def
current_action?
(
*
args
)
args
.
any?
{
|
v
|
v
.
to_s
.
downcase
==
action_name
}
end
def
gravatar_icon
(
user_email
=
''
,
size
=
40
)
def
gravatar_icon
(
user_email
=
''
,
size
=
40
)
if
Gitlab
.
config
.
disable_gravatar?
||
user_email
.
blank?
if
Gitlab
.
config
.
disable_gravatar?
||
user_email
.
blank?
'no_avatar.png'
'no_avatar.png'
...
...
spec/helpers/application_helper_spec.rb
View file @
aa0c4b77
...
@@ -20,6 +20,25 @@ describe ApplicationHelper do
...
@@ -20,6 +20,25 @@ describe ApplicationHelper do
end
end
end
end
describe
'current_action?'
do
before
do
stub!
(
:action_name
).
and_return
(
'foo'
)
end
it
"returns true when action matches argument"
do
current_action?
(
:foo
).
should
be_true
end
it
"returns false when action does not match argument"
do
current_action?
(
:bar
).
should_not
be_true
end
it
"should take any number of arguments"
do
current_action?
(
:baz
,
:bar
).
should_not
be_true
current_action?
(
:baz
,
:bar
,
:foo
).
should
be_true
end
end
describe
"gravatar_icon"
do
describe
"gravatar_icon"
do
let
(
:user_email
)
{
'user@email.com'
}
let
(
:user_email
)
{
'user@email.com'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment