twitter-bootstrap-rails 3.2.1.rc1 → 3.2.2
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.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +134 -14
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -1
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +356 -2
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -1
- data/app/helpers/bootstrap_flash_helper.rb +8 -3
- data/app/helpers/modal_helper.rb +6 -10
- data/app/helpers/navbar_helper.rb +5 -2
- data/app/helpers/twitter_breadcrumbs_helper.rb +4 -1
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +5 -5
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +1 -1
- data/lib/twitter/bootstrap/rails/breadcrumbs.rb +23 -12
- data/lib/twitter/bootstrap/rails/version.rb +1 -1
- data/spec/lib/breadcrumbs_spec.rb +42 -17
- data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +128 -0
- data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +1 -1
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +61 -11
- data/spec/spec_helper.rb +5 -1
- data/vendor/toolkit/fontawesome/path.less +7 -7
- metadata +10 -8
@@ -1 +1 @@
|
|
1
|
-
@font-face{font-family:'Glyphicons Halflings';src:url('
|
1
|
+
@font-face{font-family:'Glyphicons Halflings';src:url('<%= asset_path 'glyphicons-halflings-regular.eot' %>');src:url('<%= asset_path 'glyphicons-halflings-regular.eot?#iefix' %>') format('embedded-opentype'),url('<%= asset_path 'glyphicons-halflings-regular.woff' %>') format('woff'),url('<%= asset_path 'glyphicons-halflings-regular.ttf' %>') format('truetype'),url('<%= asset_path 'glyphicons-halflings-regular.svg#glyphicons-halflingsregular' %>') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}
|
@@ -13,10 +13,15 @@ module BootstrapFlashHelper
|
|
13
13
|
type = :danger if type == :error
|
14
14
|
next unless ALERT_TYPES.include?(type)
|
15
15
|
|
16
|
+
tag_class = options.extract!(:class)[:class]
|
17
|
+
tag_options = {
|
18
|
+
class: "alert fade in alert-#{type} #{tag_class}"
|
19
|
+
}.merge(options)
|
20
|
+
|
21
|
+
close_button = content_tag(:button, raw("×"), type: "button", class: "close", "data-dismiss" => "alert")
|
22
|
+
|
16
23
|
Array(message).each do |msg|
|
17
|
-
text = content_tag(:div,
|
18
|
-
content_tag(:button, raw("×"), :class => "close", "data-dismiss" => "alert") +
|
19
|
-
msg.html_safe, :class => "alert fade in alert-#{type} #{options[:class]}")
|
24
|
+
text = content_tag(:div, close_button + msg, tag_options)
|
20
25
|
flash_messages << text if msg
|
21
26
|
end
|
22
27
|
end
|
data/app/helpers/modal_helper.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
module ModalHelper
|
2
|
-
|
3
|
-
def default_options
|
4
|
-
return {:id => 'modal', :size => '', :show_close => true, :dismiss => true}
|
5
|
-
end
|
6
2
|
|
7
3
|
#modals have a header, a body, a footer for options.
|
8
4
|
def modal_dialog(options = {}, &block)
|
9
|
-
|
10
|
-
content_tag :div, :
|
11
|
-
content_tag :div, :class => "modal-dialog #{
|
5
|
+
options = {:id => 'modal', :size => '', :show_close => true, :dismiss => true}.merge options
|
6
|
+
content_tag :div, :class => "bootstrap-modal modal fade", :id => options[:id] do
|
7
|
+
content_tag :div, :class => "modal-dialog #{options['size']}" do
|
12
8
|
content_tag :div, :class => "modal-content" do
|
13
9
|
modal_header(options[:header], &block) +
|
14
10
|
modal_body(options[:body], &block) +
|
@@ -20,12 +16,12 @@ module ModalHelper
|
|
20
16
|
|
21
17
|
def modal_header(options, &block)
|
22
18
|
content_tag :div, :class => 'modal-header' do
|
23
|
-
if options[:show_close]
|
19
|
+
if options[:show_close]
|
24
20
|
close_button(options[:dismiss]) +
|
25
21
|
content_tag(:h4, options[:title], :class => 'modal-title', &block)
|
26
22
|
else
|
27
23
|
content_tag(:h4, options[:title], :class => 'modal-title', &block)
|
28
|
-
end
|
24
|
+
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
@@ -38,7 +34,7 @@ module ModalHelper
|
|
38
34
|
end
|
39
35
|
|
40
36
|
def close_button(dismiss)
|
41
|
-
#It doesn't seem to like content_tag, so we do this instead.
|
37
|
+
#It doesn't seem to like content_tag, so we do this instead.
|
42
38
|
raw("<button class=\"close\" data-dismiss=\"#{dismiss}\" aria-hidden=\"true\">×</button>")
|
43
39
|
end
|
44
40
|
|
@@ -17,8 +17,11 @@ module NavbarHelper
|
|
17
17
|
path = name || path if block_given?
|
18
18
|
options = args.extract_options!
|
19
19
|
content_tag :li, :class => is_active?(path, options) do
|
20
|
-
|
21
|
-
|
20
|
+
if block_given?
|
21
|
+
link_to path, options, &block
|
22
|
+
else
|
23
|
+
link_to name, path, options, &block
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module TwitterBreadcrumbsHelper
|
2
|
-
def
|
2
|
+
def render_bootstrap_breadcrumbs(divider = '/', options={}, &block)
|
3
3
|
default_options = { :class => '', :item_class => '', :divider_class => '', :active_class => 'active' }.merge(options)
|
4
4
|
content = render :partial => 'twitter-bootstrap/breadcrumbs', :layout => false, :locals => { :divider => divider, options: options }
|
5
5
|
if block_given?
|
@@ -8,4 +8,7 @@ module TwitterBreadcrumbsHelper
|
|
8
8
|
content
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
# Add backward compatible alias unless BC on rails present
|
13
|
+
alias_method :render_breadcrumbs, :render_bootstrap_breadcrumbs unless defined?(::BreadcrumbsOnRails)
|
11
14
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<% if @
|
1
|
+
<% if @__bs_breadcrumbs.present? %>
|
2
2
|
<ul class="breadcrumb <%= options[:class] %>">
|
3
|
-
<% separator = divider.html_safe %>
|
4
|
-
<% @
|
3
|
+
<% separator = divider.html_safe if divider %>
|
4
|
+
<% @__bs_breadcrumbs[0..-2].each do |crumb| %>
|
5
5
|
<li class="<%= options[:item_class] %>">
|
6
6
|
<%= link_to crumb[:name], crumb[:url], crumb[:options] %>
|
7
|
-
<span class="divider <%= options[:divider_class] %>"><%= separator %></span>
|
7
|
+
<span class="divider <%= options[:divider_class] %>"><%= separator if separator %></span>
|
8
8
|
</li>
|
9
9
|
<% end %>
|
10
10
|
<li class="<%= options[:active_class] %>">
|
11
|
-
<%= @
|
11
|
+
<%= @__bs_breadcrumbs.last[:name] %>
|
12
12
|
</li>
|
13
13
|
</ul>
|
14
14
|
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
|
2
2
|
<%- columns.each do |column| -%>
|
3
3
|
= f.input :<%= column.name %>
|
4
|
-
= error_span
|
4
|
+
= f.error_span :<%= column.name %>
|
5
5
|
<%- end -%>
|
6
6
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
7
7
|
= f.button :wrapped, :cancel => <%= controller_routing_path %>_path
|
@@ -1,23 +1,39 @@
|
|
1
1
|
module Twitter
|
2
2
|
module Bootstrap
|
3
|
+
|
4
|
+
# Keep current method calls as is using aliases
|
3
5
|
module Breadcrumbs
|
4
|
-
|
5
|
-
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
included do
|
8
|
+
# Used to provide compatibility with breadcrumbs-on-rails gem, if detected
|
9
|
+
# breadcrumbs controller methods won't be overridden.
|
10
|
+
if defined?(::BreadcrumbsOnRails)
|
11
|
+
::Rails.logger.info <<-EOT.squish
|
12
|
+
BreadcrumbsOnRails detected it won't be overridden. To use methods from this gem you need to call them
|
13
|
+
using bootstrap prefix i.e. add_bootstrap_breadcrumb and render_bootstrap_breadcrumbs.
|
14
|
+
EOT
|
15
|
+
else
|
16
|
+
# Provide backward compatibility with existing code
|
17
|
+
alias_method :add_breadcrumb, :add_bootstrap_breadcrumb
|
18
|
+
class << self
|
19
|
+
alias_method :add_breadcrumb, :add_bootstrap_breadcrumb
|
20
|
+
end
|
21
|
+
end
|
6
22
|
end
|
7
23
|
|
8
24
|
module ClassMethods
|
9
|
-
def
|
25
|
+
def add_bootstrap_breadcrumb(name, url = '', options = {})
|
10
26
|
options.merge! :klass => self.name
|
11
27
|
before_filter options do |controller|
|
12
|
-
controller.send :
|
28
|
+
controller.send :add_bootstrap_breadcrumb, name, url, options
|
13
29
|
end
|
14
30
|
end
|
15
31
|
end
|
16
32
|
|
17
33
|
protected
|
18
34
|
|
19
|
-
def
|
20
|
-
@
|
35
|
+
def add_bootstrap_breadcrumb(name, url = '', options = {})
|
36
|
+
@__bs_breadcrumbs ||= []
|
21
37
|
|
22
38
|
class_name = options.delete(:klass) || self.class.name
|
23
39
|
|
@@ -37,7 +53,7 @@ module Twitter
|
|
37
53
|
|
38
54
|
url = eval(url.to_s) if url.is_a?(Symbol) && url =~ /_path|_url|@/
|
39
55
|
|
40
|
-
@
|
56
|
+
@__bs_breadcrumbs << {:name => name, :url => url, :options => options}
|
41
57
|
end
|
42
58
|
|
43
59
|
def translate_breadcrumb(name, class_name)
|
@@ -48,11 +64,6 @@ module Twitter
|
|
48
64
|
|
49
65
|
I18n.t name, :scope => scope
|
50
66
|
end
|
51
|
-
|
52
|
-
def render_breadcrumbs(divider = '/')
|
53
|
-
s = render :partial => 'twitter-bootstrap/breadcrumbs', :locals => {:divider => divider}
|
54
|
-
s.first
|
55
|
-
end
|
56
67
|
end
|
57
68
|
end
|
58
69
|
end
|
@@ -18,7 +18,7 @@ describe Twitter::Bootstrap::Breadcrumbs do
|
|
18
18
|
add_breadcrumb :base_i18n, '/base_i18n'
|
19
19
|
|
20
20
|
def breadcrumbs
|
21
|
-
@
|
21
|
+
@__bs_breadcrumbs
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -46,29 +46,54 @@ describe Twitter::Bootstrap::Breadcrumbs do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
describe 'Breadcrumbs generation' do
|
50
|
+
|
51
|
+
before do
|
52
|
+
options = { :scope => [:breadcrumbs, 'test'] }
|
53
|
+
[:class_i18n, :instance_i18n, :show, :symbolized].each do |name|
|
54
|
+
I18n.expects(:t).with(name, options).returns(name.to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
name = :base_i18n
|
58
|
+
options = { :scope => [:breadcrumbs, 'base_test'] }
|
59
|
+
I18n.expects(:t).with(name, options).returns(name)
|
60
|
+
|
61
|
+
@controller = TestController.new
|
62
|
+
@controller.process(:show)
|
53
63
|
end
|
54
64
|
|
55
|
-
|
56
|
-
|
57
|
-
|
65
|
+
it "have breadcrumbs" do
|
66
|
+
[:base, :base_i18n, :class, :class_i18n, :instance, :instance_i18n, :test_model, :symbolized].each do |name|
|
67
|
+
path = "/#{name}"
|
68
|
+
idx = @controller.breadcrumbs.index { |b| b[:name] == name.to_s && b[:url] == path }
|
69
|
+
expect(idx).to be, -> { name }
|
70
|
+
end
|
58
71
|
|
59
|
-
|
60
|
-
|
72
|
+
idx = @controller.breadcrumbs.index { |b| b[:name] == "show" && b[:url] == '' }
|
73
|
+
expect(idx).to be
|
74
|
+
end
|
61
75
|
end
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
77
|
+
describe 'BreadcrumbsOnRails compatibility' do
|
78
|
+
class SomeController < AbstractController::Base
|
79
|
+
end
|
80
|
+
let(:logger) { double('logger').as_null_object }
|
81
|
+
before { allow(::Rails).to receive(:logger).and_return(logger) }
|
82
|
+
|
83
|
+
context 'when BreadcrumbsOnRails is defined' do
|
84
|
+
before do
|
85
|
+
stub_const('BreadcrumbsOnRails', 1)
|
86
|
+
expect(defined?(::BreadcrumbsOnRails)).to be_truthy
|
87
|
+
expect(logger).to receive(:info).with /BreadcrumbsOnRails detected/
|
88
|
+
SomeController.send(:include, Twitter::Bootstrap::Breadcrumbs)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'does not define aliases' do
|
92
|
+
expect(SomeController).to respond_to :add_bootstrap_breadcrumb
|
93
|
+
expect(SomeController).not_to respond_to :add_breadcrumb
|
94
|
+
end
|
68
95
|
end
|
69
96
|
|
70
|
-
idx = @controller.breadcrumbs.index { |b| b[:name] == "show" && b[:url] == '' }
|
71
|
-
expect(idx).to be
|
72
97
|
end
|
73
98
|
|
74
99
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'action_view'
|
4
|
+
require 'active_support'
|
5
|
+
require_relative '../../../app/helpers/bootstrap_flash_helper'
|
6
|
+
|
7
|
+
include ActionView::Helpers
|
8
|
+
include ActionView::Context
|
9
|
+
include BootstrapFlashHelper
|
10
|
+
|
11
|
+
describe BootstrapFlashHelper, type: :helper do
|
12
|
+
before do
|
13
|
+
allow(self).to receive(:uri_state) { :inactive }
|
14
|
+
allow(self).to receive(:root_url) { '/' }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "bootstrap_flash" do
|
18
|
+
it "should not return anything without flashes" do
|
19
|
+
allow(self).to receive(:flash) { {} }
|
20
|
+
|
21
|
+
element = bootstrap_flash
|
22
|
+
|
23
|
+
expect(element).to eql("")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should work with a notice" do
|
27
|
+
allow(self).to receive(:flash) { {notice: "Hello"} }
|
28
|
+
|
29
|
+
element = bootstrap_flash
|
30
|
+
|
31
|
+
expect(element).to have_tag(:div,
|
32
|
+
text: "×Hello",
|
33
|
+
with: {class: "alert fade in alert-success"}) {
|
34
|
+
|
35
|
+
with_tag(:button,
|
36
|
+
text: "×",
|
37
|
+
with: {
|
38
|
+
class: "close",
|
39
|
+
"data-dismiss" => "alert"
|
40
|
+
}
|
41
|
+
)
|
42
|
+
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should work with a notice and an extra class" do
|
47
|
+
allow(self).to receive(:flash) { {notice: "Hello"} }
|
48
|
+
|
49
|
+
element = bootstrap_flash(class: "extra-class")
|
50
|
+
|
51
|
+
expect(element).to have_tag(:div,
|
52
|
+
text: "×Hello",
|
53
|
+
with: {class: "alert fade in alert-success extra-class"}) {
|
54
|
+
|
55
|
+
with_tag(:button,
|
56
|
+
text: "×",
|
57
|
+
with: {
|
58
|
+
class: "close",
|
59
|
+
"data-dismiss" => "alert"
|
60
|
+
}
|
61
|
+
)
|
62
|
+
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should work with a notice and an extra class and an extra attribute" do
|
67
|
+
allow(self).to receive(:flash) { {notice: "Hello"} }
|
68
|
+
|
69
|
+
element = bootstrap_flash(class: "extra-class", "data-no-transition-cache" => true)
|
70
|
+
|
71
|
+
expect(element).to have_tag(:div,
|
72
|
+
text: "×Hello",
|
73
|
+
with: {
|
74
|
+
class: "alert fade in alert-success extra-class",
|
75
|
+
"data-no-transition-cache" => true
|
76
|
+
}) {
|
77
|
+
|
78
|
+
with_tag(:button,
|
79
|
+
text: "×",
|
80
|
+
with: {
|
81
|
+
class: "close",
|
82
|
+
"data-dismiss" => "alert"
|
83
|
+
}
|
84
|
+
)
|
85
|
+
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should escape javascript if not marked as safe by user" do
|
90
|
+
allow(self).to receive(:flash) { {notice: "<script>alert(1)</script>"} }
|
91
|
+
|
92
|
+
element = bootstrap_flash
|
93
|
+
|
94
|
+
expect(element).to have_tag(:div,
|
95
|
+
text: "×<script>alert(1)</script>",
|
96
|
+
with: {class: "alert fade in alert-success"}) {
|
97
|
+
with_tag(:button,
|
98
|
+
text: "×",
|
99
|
+
with: {
|
100
|
+
class: "close",
|
101
|
+
"data-dismiss" => "alert"
|
102
|
+
}
|
103
|
+
)
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should not escape a link if marked as safe by user" do
|
108
|
+
allow(self).to receive(:flash) { {notice: "<a href='example.com'>awesome link!</a>".html_safe} }
|
109
|
+
|
110
|
+
element = bootstrap_flash
|
111
|
+
|
112
|
+
expect(element).to have_tag(:div,
|
113
|
+
text: "×awesome link!",
|
114
|
+
with: {class: "alert fade in alert-success"}) { [
|
115
|
+
with_tag(:button,
|
116
|
+
text: "×",
|
117
|
+
with: {
|
118
|
+
class: "close",
|
119
|
+
"data-dismiss" => "alert"
|
120
|
+
}
|
121
|
+
),
|
122
|
+
with_tag(:a,
|
123
|
+
text: 'awesome link!')
|
124
|
+
]
|
125
|
+
}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -36,7 +36,7 @@ describe ModalHelper, :type => :helper do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'renders a cancel button' do
|
39
|
-
expect(modal_cancel_button("Cancel", :
|
39
|
+
expect(modal_cancel_button("Cancel", :data => {:dismiss => 'modal'}, :href => "#modal").gsub(/\n/, "")).to eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -82,44 +82,94 @@ describe NavbarHelper, :type => :helper do
|
|
82
82
|
|
83
83
|
describe "menu_group" do
|
84
84
|
it "should return a ul with the class 'nav'" do
|
85
|
-
|
85
|
+
element = menu_group do
|
86
86
|
menu_item("Home", "/") + menu_item("Products", "/products")
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
|
+
expect(element).to have_tag(:ul, with: {class: "nav navbar-nav"}) {
|
90
|
+
with_tag(:li) {
|
91
|
+
with_tag(:a, text: "Home", with: {href: "/"})
|
92
|
+
}
|
93
|
+
with_tag(:li) {
|
94
|
+
with_tag(:a, text: "Products", with: {href: "/products"})
|
95
|
+
}
|
96
|
+
}
|
89
97
|
end
|
90
98
|
|
91
|
-
it "should return a ul with class .navbar-left when passed the {:
|
92
|
-
|
99
|
+
it "should return a ul with class .navbar-left when passed the {pull: :left} option" do
|
100
|
+
element = menu_group(pull: :left) do
|
93
101
|
menu_item("Home", "/")
|
94
102
|
end
|
95
|
-
|
103
|
+
|
104
|
+
expect(element).to have_tag(:ul, with: {class: "nav navbar-nav navbar-left"}) {
|
105
|
+
with_tag(:li) {
|
106
|
+
with_tag(:a, text: "Home", with: {href: "/"})
|
107
|
+
}
|
108
|
+
}
|
96
109
|
end
|
97
110
|
end
|
98
111
|
|
99
112
|
describe "menu_item" do
|
100
113
|
it "should return a link within an li tag" do
|
101
114
|
allow(self).to receive(:current_page?) { false }
|
102
|
-
|
115
|
+
|
116
|
+
element = menu_item("Home", "/")
|
117
|
+
expect(element).to have_tag(:li) {
|
118
|
+
with_tag(:a, text: "Home", with: { href: "/" })
|
119
|
+
}
|
103
120
|
end
|
121
|
+
|
104
122
|
it "should return the link with class 'active' if on current page" do
|
105
123
|
allow(self).to receive(:uri_state) { :active }
|
106
|
-
|
124
|
+
|
125
|
+
element = menu_item("Home", "/")
|
126
|
+
expect(element).to have_tag(:li, with: {class: "active"}) {
|
127
|
+
with_tag(:a, text: "Home", with: { href: "/" })
|
128
|
+
}
|
107
129
|
end
|
130
|
+
|
108
131
|
it "should pass any other options through to the link_to method" do
|
109
132
|
allow(self).to receive_message_chain("uri_state").and_return(:active)
|
110
|
-
|
133
|
+
|
134
|
+
element = menu_item("Log out", "/users/sign_out", class: "home_link", method: :delete)
|
135
|
+
expect(element).to have_tag(:li, with: {class: "active"}) {
|
136
|
+
with_tag(:a, text: "Log out", with: {
|
137
|
+
href: "/users/sign_out",
|
138
|
+
class: "home_link",
|
139
|
+
rel: "nofollow",
|
140
|
+
"data-method" => "delete"
|
141
|
+
})
|
142
|
+
}
|
111
143
|
end
|
144
|
+
|
112
145
|
it "should pass a block but no name if a block is present" do
|
113
146
|
allow(self).to receive(:current_page?) { false }
|
114
|
-
|
147
|
+
|
148
|
+
element = menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }
|
149
|
+
expect(element).to have_tag(:li) {
|
150
|
+
with_tag(:i, with: { class: "icon-home"})
|
151
|
+
with_tag(:a, text: " Home", with: { href: "/"})
|
152
|
+
}
|
115
153
|
end
|
154
|
+
|
116
155
|
it "should work with just a block" do
|
117
156
|
allow(self).to receive(:current_page?) { false }
|
118
|
-
|
157
|
+
|
158
|
+
element = menu_item{ content_tag("i", "", :class => "icon-home") + " Home" }
|
159
|
+
expect(element).to have_tag(:li) {
|
160
|
+
with_tag(:i, with: { class: "icon-home"})
|
161
|
+
with_tag(:a, text: " Home", with: { href: "#"})
|
162
|
+
}
|
119
163
|
end
|
164
|
+
|
120
165
|
it "should return the link with class 'active' if on current page with a block" do
|
121
166
|
allow(self).to receive(:uri_state) { :active }
|
122
|
-
|
167
|
+
|
168
|
+
element = menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }
|
169
|
+
expect(element).to have_tag(:li, with: {class: "active"}) {
|
170
|
+
with_tag(:i, with: { class: "icon-home"})
|
171
|
+
with_tag(:a, text: " Home", with: { href: "/"})
|
172
|
+
}
|
123
173
|
end
|
124
174
|
end
|
125
175
|
|