twitter-bootstrap-rails 2.1.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of twitter-bootstrap-rails might be problematic. Click here for more details.

Files changed (117) hide show
  1. data/README.md +428 -21
  2. data/Rakefile +15 -3
  3. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  4. data/app/assets/fonts/fontawesome-webfont.svg +399 -0
  5. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  6. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  7. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +12 -1
  8. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +12 -1
  9. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-button.js +12 -1
  10. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +42 -11
  11. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +18 -7
  12. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +32 -11
  13. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +25 -12
  14. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +17 -6
  15. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +13 -2
  16. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +12 -1
  17. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +115 -30
  18. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +1 -1
  19. data/{vendor → app}/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +38 -13
  20. data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +890 -0
  21. data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +787 -0
  22. data/{vendor → app}/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +2 -2
  23. data/app/helpers/badge_label_helper.rb +16 -0
  24. data/app/helpers/bootstrap_flash_helper.rb +22 -16
  25. data/app/helpers/glyph_helper.rb +7 -2
  26. data/app/helpers/modal_helper.rb +29 -16
  27. data/app/helpers/navbar_helper.rb +194 -0
  28. data/app/helpers/twitter_breadcrumbs_helper.rb +7 -2
  29. data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +2 -2
  30. data/lib/generators/bootstrap/install/install_generator.rb +19 -6
  31. data/lib/generators/bootstrap/install/templates/bootstrap.coffee +2 -3
  32. data/lib/generators/bootstrap/install/templates/bootstrap.js +2 -3
  33. data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +8 -10
  34. data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +18 -0
  35. data/lib/generators/bootstrap/layout/templates/layout.html.erb +10 -12
  36. data/lib/generators/bootstrap/layout/templates/layout.html.haml +8 -11
  37. data/lib/generators/bootstrap/layout/templates/layout.html.slim +10 -11
  38. data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -2
  39. data/lib/generators/bootstrap/themed/templates/edit.html.haml +1 -1
  40. data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
  41. data/lib/generators/bootstrap/themed/templates/index.html.erb +1 -1
  42. data/lib/generators/bootstrap/themed/templates/index.html.haml +1 -1
  43. data/lib/generators/bootstrap/themed/templates/index.html.slim +1 -1
  44. data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -2
  45. data/lib/generators/bootstrap/themed/templates/new.html.haml +1 -1
  46. data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
  47. data/lib/generators/bootstrap/themed/templates/show.html.erb +1 -1
  48. data/lib/generators/bootstrap/themed/templates/show.html.haml +1 -1
  49. data/lib/generators/bootstrap/themed/templates/show.html.slim +1 -1
  50. data/lib/generators/bootstrap/themed/themed_generator.rb +2 -2
  51. data/lib/twitter/bootstrap/rails/engine.rb +3 -0
  52. data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +14 -2
  53. data/lib/twitter/bootstrap/rails/version.rb +2 -2
  54. data/lib/twitter-bootstrap-rails.rb +4 -4
  55. data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +22 -0
  56. data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +62 -0
  57. data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +362 -0
  58. data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +47 -0
  59. data/spec/spec_helper.rb +11 -0
  60. data/test/lib/breadcrumbs_test.rb +75 -0
  61. data/test/test_helper.rb +11 -0
  62. data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +316 -294
  63. data/vendor/static-source/fontawesome.less +8 -6
  64. data/vendor/static-source/sprites.less +3 -2
  65. data/vendor/toolkit/fontawesome/bootstrap.less +84 -0
  66. data/vendor/toolkit/fontawesome/core.less +129 -0
  67. data/vendor/toolkit/fontawesome/extras.less +93 -0
  68. data/vendor/toolkit/fontawesome/font-awesome-ie7.less +1953 -0
  69. data/vendor/toolkit/fontawesome/font-awesome.less +33 -0
  70. data/vendor/toolkit/fontawesome/icons.less +381 -0
  71. data/vendor/toolkit/fontawesome/mixins.less +48 -0
  72. data/vendor/toolkit/fontawesome/path.less +14 -0
  73. data/vendor/toolkit/fontawesome/variables.less +735 -0
  74. data/vendor/toolkit/twitter/bootstrap/alerts.less +14 -0
  75. data/vendor/toolkit/twitter/bootstrap/bootstrap.less +4 -4
  76. data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +6 -6
  77. data/vendor/toolkit/twitter/bootstrap/button-groups.less +31 -44
  78. data/vendor/toolkit/twitter/bootstrap/buttons.less +13 -17
  79. data/vendor/toolkit/twitter/bootstrap/carousel.less +48 -21
  80. data/vendor/toolkit/twitter/bootstrap/close.less +2 -1
  81. data/vendor/toolkit/twitter/bootstrap/code.less +3 -0
  82. data/vendor/toolkit/twitter/bootstrap/dropdowns.less +32 -21
  83. data/vendor/toolkit/twitter/bootstrap/forms.less +17 -10
  84. data/vendor/toolkit/twitter/bootstrap/labels-badges.less +12 -2
  85. data/vendor/toolkit/twitter/bootstrap/media.less +2 -2
  86. data/vendor/toolkit/twitter/bootstrap/mixins.less +25 -9
  87. data/vendor/toolkit/twitter/bootstrap/modals.less +4 -3
  88. data/vendor/toolkit/twitter/bootstrap/navbar.less +35 -13
  89. data/vendor/toolkit/twitter/bootstrap/navs.less +45 -21
  90. data/vendor/toolkit/twitter/bootstrap/pager.less +3 -1
  91. data/vendor/toolkit/twitter/bootstrap/pagination.less +3 -1
  92. data/vendor/toolkit/twitter/bootstrap/popovers.less +55 -39
  93. data/vendor/toolkit/twitter/bootstrap/reset.less +82 -4
  94. data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +2 -2
  95. data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +6 -2
  96. data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +16 -0
  97. data/vendor/toolkit/twitter/bootstrap/responsive.less +1 -1
  98. data/vendor/toolkit/twitter/bootstrap/scaffolding.less +2 -1
  99. data/vendor/toolkit/twitter/bootstrap/sprites.less +9 -5
  100. data/vendor/toolkit/twitter/bootstrap/tables.less +54 -46
  101. data/vendor/toolkit/twitter/bootstrap/thumbnails.less +3 -2
  102. data/vendor/toolkit/twitter/bootstrap/tooltip.less +6 -6
  103. data/vendor/toolkit/twitter/bootstrap/type.less +44 -24
  104. data/vendor/toolkit/twitter/bootstrap/variables.less +3 -3
  105. metadata +130 -44
  106. data/lib/generators/bootstrap/partial/templates/_navbar.html.erb +0 -13
  107. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  108. data/vendor/assets/fonts/fontawesome-webfont.svg +0 -255
  109. data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
  110. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  111. data/vendor/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +0 -218
  112. data/vendor/toolkit/font-awesome-ie7.less +0 -245
  113. data/vendor/toolkit/fontawesome.less +0 -327
  114. /data/{vendor → app}/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  115. /data/{vendor → app}/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  116. /data/{vendor → app}/assets/javascripts/twitter/bootstrap.js +0 -0
  117. /data/{vendor → app}/assets/javascripts/twitter/bootstrap_ujs.js +0 -0
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
3
+ %h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
3
+ h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,6 +1,6 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
4
4
  </div>
5
5
  <table class="table table-striped">
6
6
  <thead>
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => model_class.model_name.human.pluralize
3
+ %h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
4
  %table.table.table-striped
5
5
  %thead
6
6
  %tr
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => model_class.model_name.human.pluralize
3
+ h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
4
4
  table class="table table-striped"
5
5
  thead
6
6
  tr
@@ -1,6 +1,5 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human,
4
- :default => "New #{model_class.model_name.human}") %></h1>
3
+ <h1><%%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize %></h1>
5
4
  </div>
6
5
  <%%= render :partial => 'form' %>
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
3
+ %h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,4 +1,4 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
3
+ h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
4
4
  = render :partial => "form"
@@ -1,6 +1,6 @@
1
1
  <%%- model_class = <%= resource_name.classify %> -%>
2
2
  <div class="page-header">
3
- <h1><%%=t '.title', :default => model_class.model_name.human %></h1>
3
+ <h1><%%=t '.title', :default => model_class.model_name.human.titleize %></h1>
4
4
  </div>
5
5
 
6
6
  <dl class="dl-horizontal">
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  .page-header
3
- %h1=t '.title', :default => model_class.model_name.human
3
+ %h1=t '.title', :default => model_class.model_name.human.titleize
4
4
 
5
5
  <%- columns.each do |column| -%>
6
6
  %p
@@ -1,6 +1,6 @@
1
1
  - model_class = <%= resource_name.classify %>
2
2
  div class="page-header"
3
- h1=t '.title', :default => model_class.model_name.human
3
+ h1=t '.title', :default => model_class.model_name.human.titleize
4
4
 
5
5
  <%- columns.each do |column| -%>
6
6
  p
@@ -61,7 +61,7 @@ module Bootstrap
61
61
  end
62
62
 
63
63
  def excluded_columns_names
64
- %w[id created_at updated_at]
64
+ %w[_id _type id created_at updated_at]
65
65
  end
66
66
 
67
67
  def excluded_columns_pattern
@@ -82,7 +82,7 @@ module Bootstrap
82
82
  end
83
83
 
84
84
  def retrieve_columns
85
- if defined?(ActiveRecord)
85
+ if defined?(ActiveRecord) == "constant" && ActiveRecord.class == Module
86
86
  rescue_block ActiveRecord::StatementInvalid do
87
87
  @model_name.constantize.columns
88
88
  end
@@ -3,6 +3,7 @@ require 'rails'
3
3
  require File.dirname(__FILE__) + '/twitter-bootstrap-breadcrumbs.rb'
4
4
  require File.dirname(__FILE__) + '/../../../../app/helpers/flash_block_helper.rb'
5
5
  require File.dirname(__FILE__) + '/../../../../app/helpers/modal_helper.rb'
6
+ require File.dirname(__FILE__) + '/../../../../app/helpers/navbar_helper.rb'
6
7
 
7
8
  module Twitter
8
9
  module Bootstrap
@@ -21,6 +22,8 @@ module Twitter
21
22
  ActionController::Base.send :include, BreadCrumbs
22
23
  ActionController::Base.send :helper, FlashBlockHelper
23
24
  ActionController::Base.send :helper, ModalHelper
25
+ ActionController::Base.send :helper, NavbarHelper
26
+ ActionController::Base.send :helper, BadgeLabelHelper
24
27
  #ActionController::Base.send :helper_method, :render_breadcrumbs
25
28
  end
26
29
  end
@@ -6,8 +6,10 @@ module Twitter
6
6
  end
7
7
 
8
8
  module ClassMethods
9
- def add_breadcrumb name, url, options={}
9
+ def add_breadcrumb(name, url, options = {})
10
+ class_name = self.name
10
11
  before_filter options do |controller|
12
+ name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol)
11
13
  controller.send :add_breadcrumb, name, url
12
14
  end
13
15
  end
@@ -15,12 +17,22 @@ module Twitter
15
17
 
16
18
  protected
17
19
 
18
- def add_breadcrumb name, url = '', options = {}
20
+ def add_breadcrumb(name, url = '', options = {})
19
21
  @breadcrumbs ||= []
22
+ name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol)
20
23
  url = eval(url.to_s) if url =~ /_path|_url|@/
21
24
  @breadcrumbs << {:name => name, :url => url, :options => options}
22
25
  end
23
26
 
27
+ def translate_breadcrumb(name, class_name)
28
+ scope = [:breadcrumbs]
29
+ namespace = class_name.underscore.split('/')
30
+ namespace.last.sub!('_controller', '')
31
+ scope += namespace
32
+
33
+ I18n.t name, :scope => scope
34
+ end
35
+
24
36
  def render_breadcrumbs(divider = '/')
25
37
  s = render :partial => 'twitter-bootstrap/breadcrumbs', :locals => {:divider => divider}
26
38
  s.first
@@ -1,7 +1,7 @@
1
1
  module Twitter
2
2
  module Bootstrap
3
3
  module Rails
4
- VERSION = "2.1.7"
4
+ VERSION = "2.2.8"
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -1,9 +1,9 @@
1
1
  module Twitter
2
2
  module Bootstrap
3
- module Rails
4
- require 'twitter/bootstrap/rails/engine' if defined?(Rails)
5
- end
6
- end
3
+ module Rails
4
+ require 'twitter/bootstrap/rails/engine' if defined?(Rails)
5
+ end
6
+ end
7
7
  end
8
8
 
9
9
  #require 'less-rails'
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'action_view'
4
+ require 'active_support'
5
+ require_relative '../../../app/helpers/badge_label_helper'
6
+
7
+ include ActionView::Helpers
8
+ include ActionView::Context
9
+ include BadgeLabelHelper
10
+
11
+ describe BadgeLabelHelper, :type => :helper do
12
+ it "should return a basic bootstrap badge" do
13
+ badge('test').gsub(/\s/, '').downcase.should eql(BASIC_BADGE.gsub(/\s/, '').downcase)
14
+ end
15
+
16
+ it "should return a bootstrap badge with class" do
17
+ badge('waning', :warning).gsub(/\s/, '').downcase.should eql(BADGE_WITH_CLASS.gsub(/\s/, '').downcase)
18
+ end
19
+ end
20
+
21
+ BASIC_BADGE = %{<span class="badge">test</span>}
22
+ BADGE_WITH_CLASS = %{<span class="badge badge-warning">waning</span>}
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require_relative '../../../app/helpers/modal_helper'
4
+
5
+ include ActionView::Helpers
6
+ include ActionView::Context
7
+ include ModalHelper
8
+
9
+ describe ModalHelper, :type => :helper do
10
+ header_with_close = { :show_close => true, :dismiss => 'modal', :title => 'Modal header' }
11
+ header_without_close = { :show_close => false, :title => 'Modal header' }
12
+ options = { :id => "modal",
13
+ :header => header_with_close,
14
+ :body => 'This is the body',
15
+ :footer => content_tag(:button, 'Save', :class => 'btn')
16
+ }
17
+
18
+ it 'returns a complete modal' do
19
+ modal_dialog(options).gsub(/\n/, "").should eql BASIC_MODAL.gsub(/\n/, "")
20
+ end
21
+
22
+ it 'returns a modal header with a close button if show_close is true' do
23
+ modal_header(header_with_close).gsub(/\n/, "").should eql MODAL_HEADER_WITH_CLOSE.gsub(/\n/, "")
24
+ end
25
+
26
+ it 'renders a modal header without a close button' do
27
+ modal_header(header_without_close).gsub(/\n/, "").should eql MODAL_HEADER_WITHOUT_CLOSE.gsub(/\n/, "")
28
+ end
29
+
30
+ it 'renders a close button' do
31
+ close_button('modal').should eql "<button class=\"close\" data-dismiss=\"modal\">&times;</button>"
32
+ end
33
+
34
+ it 'renders a modal toggle button' do
35
+ modal_toggle('Save', :href => "#modal").gsub(/\n/, "").should eql MODAL_TOGGLE.gsub(/\n/, "")
36
+ end
37
+
38
+ it 'renders a cancel button' do
39
+ modal_cancel_button("Cancel", :href => "#modal", :data => {:dismiss => 'modal'}).gsub(/\n/, "").should eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
40
+ end
41
+
42
+ end
43
+ BASIC_MODAL = <<-HTML
44
+ <div class=\"bootstrap-modal modal hide fade\" id="modal"><div class=\"modal-header\"><button class=\"close\" data-dismiss=\"modal\">&times;</button><h3>Modal header</h3></div><div class=\"modal-body\">This is the body</div><div class=\"modal-footer\"><button class=\"btn\">Save</button></div></div>
45
+ HTML
46
+
47
+ MODAL_HEADER_WITHOUT_CLOSE = <<-HTML
48
+ <div class="modal-header"><h3>Modal header</h3></div>
49
+ HTML
50
+
51
+ MODAL_HEADER_WITH_CLOSE = <<-HTML
52
+ <div class="modal-header"><button class="close" data-dismiss="modal">&times;</button><h3>Modal header</h3></div>
53
+ HTML
54
+
55
+ MODAL_TOGGLE = <<-HTML
56
+ <a class="btn" data-toggle="modal" href="#modal">Save</a>
57
+ HTML
58
+
59
+ MODAL_CANCEL_BUTTON = <<-HTML
60
+ <a class="btn bootstrap-modal-cancel-button" data-dismiss="modal" href="#modal">Cancel</a>
61
+ HTML
62
+
@@ -0,0 +1,362 @@
1
+ # encoding: utf-8
2
+ #Credit for this goes to https://github.com/julescopeland/Rails-Bootstrap-Navbar
3
+ require 'spec_helper'
4
+ require 'action_view'
5
+ require 'active_support'
6
+ require_relative '../../../app/helpers/navbar_helper'
7
+
8
+ include ActionView::Helpers
9
+ include ActionView::Context
10
+ include NavbarHelper
11
+
12
+ describe NavbarHelper, :type => :helper do
13
+ before do
14
+ self.stub!("uri_state").and_return(:inactive)
15
+ self.stub!("root_url").and_return("/")
16
+ end
17
+ describe "nav_bar" do
18
+ it "should return a basic bootstrap navbar" do
19
+ nav_bar.gsub(/\s/, '').downcase.should eql(BASIC_NAVBAR.gsub(/\s/, '').downcase)
20
+ end
21
+
22
+ it "should set the fixed position to top" do
23
+ nav_bar(:fixed => :top).gsub(/\s/, '').downcase.should eql(FIXED_TOP_NAVBAR.gsub(/\s/, '').downcase)
24
+ end
25
+
26
+ it "should set the static position to top" do
27
+ nav_bar(:static => :top).gsub(/\s/, '').downcase.should eql(STATIC_TOP_NAVBAR.gsub(/\s/, '').downcase)
28
+ end
29
+
30
+ it "should set the fixed position to bottom" do
31
+ nav_bar(:fixed => :bottom).gsub(/\s/, '').downcase.should eql(FIXED_BOTTOM_NAVBAR.gsub(/\s/, '').downcase)
32
+ end
33
+
34
+ it "should set the style to inverse" do
35
+ nav_bar(:inverse => true).gsub(/\s/, '').downcase.should eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
36
+ end
37
+
38
+ it "should add the brand name and link it to the home page" do
39
+ nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase.should eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
40
+ end
41
+
42
+ it "should be able to set the brand link url" do
43
+ nav_bar(:brand => "Ninety Ten", :brand_link => "http://www.ninetyten.com").gsub(/\s/, '').downcase.should eql(NAVBAR_WITH_BRAND_AND_LINK.gsub(/\s/, '').downcase)
44
+ end
45
+
46
+ it "should set the container to fluid" do
47
+ nav_bar(:fluid => :true).gsub(/\s/, '').downcase.should eql(BASIC_NAVBAR_FLUID.gsub(/\s/, '').downcase)
48
+ end
49
+
50
+ it "should add the buttons etc for a responsive layout with no block passed" do
51
+ nav_bar(:responsive => true).gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR.gsub(/\s/, '').downcase)
52
+ end
53
+
54
+ it "should add the buttons etc for a responsive layout with block passed" do
55
+ nav_bar(:responsive => true) do
56
+ "<p>Passing a block</p>".html_safe
57
+ end.gsub(/\s/, '').downcase.should eql(RESPONSIVE_NAVBAR_WITH_BLOCK.gsub(/\s/, '').downcase)
58
+ end
59
+
60
+ it "should render contained items" do
61
+ nav_bar do
62
+ menu_group do
63
+ menu_item("Home", "/") + menu_item("Products", "/products")
64
+ end
65
+ end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
66
+ end
67
+
68
+ it "should still render the brand name even with other options turned on" do
69
+ nav_bar(:brand => "Something") do
70
+ menu_group do
71
+ menu_item "Home", "/"
72
+ end
73
+ end.gsub(/\s/, '').downcase.should eql(BRANDED_NAVBAR_WITH_ITEM.gsub(/\s/, '').downcase)
74
+ end
75
+ end
76
+
77
+ describe "menu_group" do
78
+ it "should return a ul with the class 'nav'" do
79
+ menu_group do
80
+ menu_item("Home", "/") + menu_item("Products", "/products")
81
+ end.should eql '<ul class="nav "><li><a href="/">Home</a></li><li><a href="/products">Products</a></li></ul>'
82
+ end
83
+
84
+ it "should return a ul with class .pull-left when passed the {:pull => :left} option" do
85
+ menu_group(:pull => :left) do
86
+ menu_item("Home", "/")
87
+ end.should eql('<ul class="nav pull-left"><li><a href="/">Home</a></li></ul>')
88
+ end
89
+ end
90
+
91
+ describe "menu_item" do
92
+ it "should return a link within an li tag" do
93
+ self.stub!("current_page?").and_return(false)
94
+ menu_item("Home", "/").should eql('<li><a href="/">Home</a></li>')
95
+ end
96
+ it "should return the link with class 'active' if on current page" do
97
+ self.stub!("uri_state").and_return(:active)
98
+ menu_item("Home", "/").should eql('<li class="active"><a href="/">Home</a></li>')
99
+ end
100
+ it "should pass any other options through to the link_to method" do
101
+ self.stub!("uri_state").and_return(:active)
102
+ menu_item("Log out", "/users/sign_out", :class => "home_link", :method => :delete).should eql('<li class="active"><a href="/users/sign_out" class="home_link" data-method="delete" rel="nofollow">Log out</a></li>')
103
+ end
104
+ it "should pass a block but no name if a block is present" do
105
+ self.stub!("current_page?").and_return(false)
106
+ menu_item("/"){content_tag("i", "", :class => "icon-home") + " Home"}.should eql('<li><a href="/"><i class="icon-home"></i> Home</a></li>')
107
+ end
108
+ it "should work with just a block" do
109
+ self.stub!("current_page?").and_return(false)
110
+ menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }.should eql('<li><a href="#"><i class="icon-home"></i> Home</a></li>')
111
+ end
112
+ it "should return the link with class 'active' if on current page with a block" do
113
+ self.stub!("uri_state").and_return(:active)
114
+ menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }.should eql('<li class="active"><a href="/"><i class="icon-home"></i> Home</a></li>')
115
+ end
116
+ end
117
+
118
+ describe "drop_down" do
119
+ it "should do render the proper drop down code" do
120
+ drop_down "Products" do
121
+ menu_item "Latest", "/"
122
+ end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU.gsub(/\s/, '').downcase)
123
+ end
124
+ end
125
+
126
+ describe "drop_down_with_submenu" do
127
+ it "should do render the proper drop down code" do
128
+ drop_down_with_submenu "Products" do
129
+ drop_down_submenu "Latest" do
130
+ menu_item "Option1", "/"
131
+ end
132
+ end.gsub(/\s/, '').downcase.should eql(DROPDOWN_MENU_WITH_SUBMENU.gsub(/\s/, '').downcase)
133
+ end
134
+ end
135
+
136
+ describe "menu_divider" do
137
+ it "should render <li class='divider-vertical'></li>" do
138
+ menu_divider.should eql '<li class="divider-vertical"></li>'
139
+ end
140
+ end
141
+
142
+ describe "menu_text" do
143
+ it "should render text within p tags with class 'navbar-text" do
144
+ menu_text("Strapline!").should eql("<p class=\"navbar-text\">Strapline!</p>")
145
+ end
146
+
147
+ it "should be able to be pulled right or left" do
148
+ menu_text("I am being pulled right", :pull => :right).should eql("<p class=\"pull-right navbar-text\">I am being pulled right</p>")
149
+ end
150
+
151
+ it "should be able to cope with arbitrary options being passed to the p tag" do
152
+ menu_text("I am classy!", :class => "classy", :id => "classy_text").should eql("<p class=\"classy navbar-text\" id=\"classy_text\">I am classy!</p>")
153
+ end
154
+
155
+ it "should be able to cope with a block too" do
156
+ menu_text do
157
+ "I have been rendered programmatically!"
158
+ end.should eql("<p class=\"navbar-text\">I have been rendered programmatically!</p>")
159
+ end
160
+ end
161
+
162
+ describe "rendering forms ok" do
163
+ it "should not escape anything unexpectedly" do
164
+ nav_bar do
165
+ form_tag "/", :method => 'get' do |f|
166
+ f.text_field :search, "stub"
167
+ end
168
+ end.gsub(/\s/, '').downcase.should eql(PLAIN_NAVBAR_WITH_FORM.gsub(/\s/, '').downcase)
169
+ end
170
+ end
171
+
172
+ end
173
+
174
+ # HTML output
175
+
176
+ BASIC_NAVBAR = <<-HTML
177
+ <div class="navbar">
178
+ <div class="navbar-inner">
179
+ <div class="container">
180
+ </div>
181
+ </div>
182
+ </div>
183
+ HTML
184
+
185
+ FIXED_TOP_NAVBAR = <<-HTML
186
+ <div class="navbar navbar-fixed-top">
187
+ <div class="navbar-inner">
188
+ <div class="container">
189
+ </div>
190
+ </div>
191
+ </div>
192
+ HTML
193
+
194
+ STATIC_TOP_NAVBAR = <<-HTML
195
+ <div class="navbar navbar-static-top">
196
+ <div class="navbar-inner">
197
+ <div class="container">
198
+ </div>
199
+ </div>
200
+ </div>
201
+ HTML
202
+
203
+ FIXED_BOTTOM_NAVBAR = <<-HTML
204
+ <div class="navbar navbar-fixed-bottom">
205
+ <div class="navbar-inner">
206
+ <div class="container">
207
+ </div>
208
+ </div>
209
+ </div>
210
+ HTML
211
+
212
+ INVERSE_NAVBAR = <<-HTML
213
+ <div class="navbar navbar-inverse">
214
+ <div class="navbar-inner">
215
+ <div class="container">
216
+ </div>
217
+ </div>
218
+ </div>
219
+ HTML
220
+
221
+ BASIC_NAVBAR_FLUID= <<-HTML
222
+ <div class="navbar">
223
+ <div class="navbar-inner">
224
+ <div class="container-fluid">
225
+ </div>
226
+ </div>
227
+ </div>
228
+ HTML
229
+
230
+ NAVBAR_WITH_BRAND = <<-HTML
231
+ <div class="navbar">
232
+ <div class="navbar-inner">
233
+ <div class="container">
234
+ <a href="/" class="brand">
235
+ Ninety Ten
236
+ </a>
237
+ </div>
238
+ </div>
239
+ </div>
240
+ HTML
241
+
242
+ NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
243
+ <div class="navbar">
244
+ <div class="navbar-inner">
245
+ <div class="container">
246
+ <a href="http://www.ninetyten.com" class="brand">
247
+ Ninety Ten
248
+ </a>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ HTML
253
+
254
+ RESPONSIVE_NAVBAR = <<-HTML
255
+ <div class="navbar">
256
+ <div class="navbar-inner">
257
+ <div class="container">
258
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
259
+ <span class="icon-bar"></span>
260
+ <span class="icon-bar"></span>
261
+ <span class="icon-bar"></span>
262
+ </a>
263
+ <div class="nav-collapse">
264
+ </div>
265
+ </div>
266
+ </div>
267
+ </div>
268
+ HTML
269
+
270
+ RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
271
+ <div class="navbar">
272
+ <div class="navbar-inner">
273
+ <div class="container">
274
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
275
+ <span class="icon-bar"></span>
276
+ <span class="icon-bar"></span>
277
+ <span class="icon-bar"></span>
278
+ </a>
279
+ <div class="nav-collapse">
280
+ <p>Passing a block</p>
281
+ </div>
282
+ </div>
283
+ </div>
284
+ </div>
285
+ HTML
286
+
287
+ PLAIN_NAVBAR_WITH_ITEM = <<-HTML
288
+ <div class="navbar">
289
+ <div class="navbar-inner">
290
+ <div class="container">
291
+ <ul class="nav">
292
+ <li>
293
+ <a href="/">Home</a>
294
+ </li>
295
+ <li>
296
+ <a href="/products">Products</a>
297
+ </li>
298
+ </ul>
299
+ </div>
300
+ </div>
301
+ </div>
302
+ HTML
303
+
304
+ BRANDED_NAVBAR_WITH_ITEM = <<-HTML
305
+ <div class="navbar">
306
+ <div class="navbar-inner">
307
+ <div class="container">
308
+ <a href="/" class="brand">
309
+ Something
310
+ </a>
311
+ <ul class="nav">
312
+ <li>
313
+ <a href="/">Home</a>
314
+ </li>
315
+ </ul>
316
+ </div>
317
+ </div>
318
+ </div>
319
+ HTML
320
+
321
+ DROPDOWN_MENU = <<-HTML
322
+ <li class="dropdown">
323
+ <a href="#"
324
+ class="dropdown-toggle"
325
+ data-toggle="dropdown">
326
+ Products
327
+ <b class="caret"></b>
328
+ </a>
329
+ <ul class="dropdown-menu">
330
+ <li><a href="/">Latest</a></li>
331
+ </ul>
332
+ </li>
333
+ HTML
334
+
335
+ DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
336
+ <li class="dropdown">
337
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
338
+ <ul class="dropdown-menu">
339
+ <li class="dropdown-submenu">
340
+ <a href="">Latest</a>
341
+ <ul class="dropdown-menu">
342
+ <li><a href="/">Option1</a></li>
343
+ </ul>
344
+ </li>
345
+ </ul>
346
+ </li>
347
+ HTML
348
+
349
+ PLAIN_NAVBAR_WITH_FORM = <<-HTML
350
+ <div class="navbar">
351
+ <div class="navbar-inner">
352
+ <div class="container">
353
+ <form accept-charset="utf-8" action="/" method="get">
354
+ <div style="margin:0;padding:0;display:inline">
355
+ <input name="utf8" type="hidden" value="&#x2713;"/>
356
+ </div>
357
+ <input id="search_stub" name="search[stub]" size="30" type="text"/>
358
+ </form>
359
+ </div>
360
+ </div>
361
+ </div>
362
+ HTML