diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-09-26 16:13:23 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-09-26 16:32:26 -0400 |
commit | f064c84019f7414cb9cfa9e49fb735dba7f495df (patch) | |
tree | b9ec60deb714c2b354b4c4e94c44266bc47681f6 /spec/helpers/tab_helper_spec.rb | |
parent | aa0c4b77b60acfc85d99e9eacaff25e34b136529 (diff) | |
download | gitlab-ce-f064c84019f7414cb9cfa9e49fb735dba7f495df.tar.gz |
Add nav_link helper to TabHelper
Diffstat (limited to 'spec/helpers/tab_helper_spec.rb')
-rw-r--r-- | spec/helpers/tab_helper_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb new file mode 100644 index 00000000000..ef8e4cf6375 --- /dev/null +++ b/spec/helpers/tab_helper_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe TabHelper do + include ApplicationHelper + + describe 'nav_link' do + before do + controller.stub!(:controller_name).and_return('foo') + stub!(:action_name).and_return('foo') + end + + it "captures block output" do + nav_link { "Testing Blocks" }.should match(/Testing Blocks/) + end + + it "performs checks on the current controller" do + nav_link(controller: :foo).should match(/<li class="active">/) + nav_link(controller: :bar).should_not match(/active/) + nav_link(controller: [:foo, :bar]).should match(/active/) + end + + it "performs checks on the current action" do + nav_link(action: :foo).should match(/<li class="active">/) + nav_link(action: :bar).should_not match(/active/) + nav_link(action: [:foo, :bar]).should match(/active/) + end + + it "performs checks on both controller and action when both are present" do + nav_link(controller: :bar, action: :foo).should_not match(/active/) + nav_link(controller: :foo, action: :bar).should_not match(/active/) + nav_link(controller: :foo, action: :foo).should match(/active/) + end + + it "accepts a path shorthand" do + nav_link(path: 'foo#bar').should_not match(/active/) + nav_link(path: 'foo#foo').should match(/active/) + end + + it "passes extra html options to the list element" do + nav_link(action: :foo, html_options: {class: 'home'}).should match(/<li class="home active">/) + nav_link(html_options: {class: 'active'}).should match(/<li class="active">/) + end + end +end |