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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
3ad931ca
Commit
3ad931ca
authored
Sep 25, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add current_controller? helper method
Simplifies some of the "active tab" checks we're doing
parent
95f0a411
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+11
-0
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+14
-0
No files found.
app/helpers/application_helper.rb
View file @
3ad931ca
require
'digest/md5'
module
ApplicationHelper
# Check if a particular controller is the current one
#
# Examples
#
# # On TreeController
# current_controller?(:tree) # => true
# current_controller?(:commits) # => false
def
current_controller?
(
name
)
controller
.
controller_name
==
name
.
to_s
.
downcase
end
def
gravatar_icon
(
user_email
=
''
,
size
=
40
)
if
Gitlab
.
config
.
disable_gravatar?
||
user_email
.
blank?
'no_avatar.png'
...
...
spec/helpers/application_helper_spec.rb
View file @
3ad931ca
require
'spec_helper'
describe
ApplicationHelper
do
describe
'current_controller?'
do
before
do
controller
.
stub!
(
:controller_name
).
and_return
(
'foo'
)
end
it
"returns true when controller matches argument"
do
current_controller?
(
:foo
).
should
be_true
end
it
"returns false when controller does not match argument"
do
current_controller?
(
:bar
).
should_not
be_true
end
end
describe
"gravatar_icon"
do
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