twitter-bootstrap-rails 2.2.8 → 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 +7 -0
- data/README.md +160 -228
- data/Rakefile +4 -6
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +279 -38
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/javascripts/twitter/bootstrap/affix.js +142 -0
- data/app/assets/javascripts/twitter/bootstrap/alert.js +92 -0
- data/app/assets/javascripts/twitter/bootstrap/button.js +110 -0
- data/app/assets/javascripts/twitter/bootstrap/carousel.js +223 -0
- data/app/assets/javascripts/twitter/bootstrap/collapse.js +170 -0
- data/app/assets/javascripts/twitter/bootstrap/dropdown.js +151 -0
- data/app/assets/javascripts/twitter/bootstrap/modal.js +280 -0
- data/app/assets/javascripts/twitter/bootstrap/popover.js +113 -0
- data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +170 -0
- data/app/assets/javascripts/twitter/bootstrap/tab.js +128 -0
- data/app/assets/javascripts/twitter/bootstrap/tooltip.js +457 -0
- data/app/assets/javascripts/twitter/bootstrap/transition.js +59 -0
- data/app/assets/javascripts/twitter/bootstrap.js +12 -13
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -890
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +2026 -787
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -146
- data/app/helpers/bootstrap_flash_helper.rb +14 -7
- data/app/helpers/form_errors_helper.rb +22 -0
- data/app/helpers/glyph_helper.rb +8 -5
- data/app/helpers/modal_helper.rb +26 -22
- data/app/helpers/navbar_helper.rb +47 -32
- data/app/helpers/twitter_breadcrumbs_helper.rb +6 -2
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +8 -8
- data/lib/generators/bootstrap/install/install_generator.rb +3 -2
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +13 -11
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +5 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +27 -48
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +19 -34
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +13 -30
- data/lib/generators/bootstrap/partial/templates/_login.html.erb +2 -3
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +30 -10
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +10 -8
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -9
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/index.html.erb +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.haml +2 -2
- data/lib/generators/bootstrap/themed/templates/index.html.slim +4 -5
- data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.erb +5 -7
- data/lib/generators/bootstrap/themed/templates/show.html.haml +4 -4
- data/lib/generators/bootstrap/themed/templates/show.html.slim +6 -7
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +5 -5
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +3 -3
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +4 -4
- data/lib/generators/bootstrap/themed/themed_generator.rb +2 -2
- data/lib/twitter/bootstrap/rails/breadcrumbs.rb +69 -0
- data/lib/twitter/bootstrap/rails/engine.rb +17 -10
- data/lib/twitter/bootstrap/rails/version.rb +2 -2
- data/spec/lib/breadcrumbs_spec.rb +99 -0
- data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +12 -4
- data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +128 -0
- data/spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb +148 -0
- data/spec/lib/twitter_bootstrap_rails/glyph_helper_spec.rb +24 -0
- data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +15 -15
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +207 -173
- data/spec/lib/twitter_bootstrap_rails/uri_state_spec.rb +18 -16
- data/spec/spec_helper.rb +11 -1
- data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +5796 -1
- data/vendor/static-source/bootstrap.less +0 -1
- data/vendor/static-source/fontawesome.less +0 -1
- data/vendor/static-source/sprites.less +1 -1
- data/vendor/toolkit/fontawesome/bordered-pulled.less +16 -0
- data/vendor/toolkit/fontawesome/core.less +8 -126
- data/vendor/toolkit/fontawesome/fixed-width.less +6 -0
- data/vendor/toolkit/fontawesome/font-awesome.less +9 -25
- data/vendor/toolkit/fontawesome/icons.less +549 -378
- data/vendor/toolkit/fontawesome/larger.less +13 -0
- data/vendor/toolkit/fontawesome/list.less +19 -0
- data/vendor/toolkit/fontawesome/mixins.less +16 -39
- data/vendor/toolkit/fontawesome/path.less +5 -5
- data/vendor/toolkit/fontawesome/rotated-flipped.less +20 -0
- data/vendor/toolkit/fontawesome/spinning.less +29 -0
- data/vendor/toolkit/fontawesome/stacked.less +20 -0
- data/vendor/toolkit/fontawesome/variables.less +557 -731
- data/vendor/toolkit/twitter/bootstrap/alerts.less +47 -58
- data/vendor/toolkit/twitter/bootstrap/badges.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +26 -39
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +11 -9
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +168 -152
- data/vendor/toolkit/twitter/bootstrap/buttons.less +101 -170
- data/vendor/toolkit/twitter/bootstrap/carousel.less +150 -65
- data/vendor/toolkit/twitter/bootstrap/close.less +20 -19
- data/vendor/toolkit/twitter/bootstrap/code.less +38 -30
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +12 -3
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +115 -148
- data/vendor/toolkit/twitter/bootstrap/forms.less +401 -547
- data/vendor/toolkit/twitter/bootstrap/glyphicons.less +234 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +74 -11
- data/vendor/toolkit/twitter/bootstrap/input-groups.less +166 -0
- data/vendor/toolkit/twitter/bootstrap/jumbotron.less +48 -0
- data/vendor/toolkit/twitter/bootstrap/labels.less +64 -0
- data/vendor/toolkit/twitter/bootstrap/list-group.less +132 -0
- data/vendor/toolkit/twitter/bootstrap/media.less +8 -7
- data/vendor/toolkit/twitter/bootstrap/mixins/alerts.less +14 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/background-variant.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/border-radius.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/buttons.less +52 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/center-block.less +7 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/clearfix.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/forms.less +85 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/gradients.less +59 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid-framework.less +91 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid.less +122 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/hide-text.less +21 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/image.less +33 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/labels.less +12 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/list-group.less +29 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-divider.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-vertical-align.less +9 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/opacity.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/pagination.less +23 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/panels.less +24 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/progress-bar.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/reset-filter.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/resize.less +6 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/responsive-visibility.less +15 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/size.less +10 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/tab-focus.less +9 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/table-row.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-emphasis.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-overflow.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/vendor-prefixes.less +224 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +36 -699
- data/vendor/toolkit/twitter/bootstrap/modals.less +109 -54
- data/vendor/toolkit/twitter/bootstrap/navbar.less +542 -384
- data/vendor/toolkit/twitter/bootstrap/navs.less +192 -359
- data/vendor/toolkit/twitter/bootstrap/normalize.less +425 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +46 -34
- data/vendor/toolkit/twitter/bootstrap/pagination.less +70 -105
- data/vendor/toolkit/twitter/bootstrap/panels.less +248 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +61 -61
- data/vendor/toolkit/twitter/bootstrap/print.less +101 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +51 -73
- data/vendor/toolkit/twitter/bootstrap/responsive-embed.less +34 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +177 -42
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +120 -23
- data/vendor/toolkit/twitter/bootstrap/tables.less +171 -182
- data/vendor/toolkit/twitter/bootstrap/theme.less +260 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +26 -43
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +49 -24
- data/vendor/toolkit/twitter/bootstrap/type.less +208 -147
- data/vendor/toolkit/twitter/bootstrap/utilities.less +33 -7
- data/vendor/toolkit/twitter/bootstrap/variables.less +761 -215
- data/vendor/toolkit/twitter/bootstrap/wells.less +7 -7
- metadata +156 -130
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +0 -117
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +0 -99
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-button.js +0 -105
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +0 -207
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +0 -167
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +0 -169
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +0 -247
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +0 -114
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +0 -162
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +0 -144
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +0 -361
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +0 -60
- data/app/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +0 -335
- data/lib/twitter/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +0 -42
- data/test/lib/breadcrumbs_test.rb +0 -75
- data/test/test_helper.rb +0 -11
- data/vendor/toolkit/fontawesome/bootstrap.less +0 -84
- data/vendor/toolkit/fontawesome/extras.less +0 -93
- data/vendor/toolkit/fontawesome/font-awesome-ie7.less +0 -1953
- data/vendor/toolkit/twitter/bootstrap/accordion.less +0 -34
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +0 -25
- data/vendor/toolkit/twitter/bootstrap/labels-badges.less +0 -84
- data/vendor/toolkit/twitter/bootstrap/layouts.less +0 -16
- data/vendor/toolkit/twitter/bootstrap/reset.less +0 -216
- data/vendor/toolkit/twitter/bootstrap/responsive-1200px-min.less +0 -28
- data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +0 -193
- data/vendor/toolkit/twitter/bootstrap/responsive-768px-979px.less +0 -19
- data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +0 -189
- data/vendor/toolkit/twitter/bootstrap/responsive.less +0 -48
- data/vendor/toolkit/twitter/bootstrap/sprites.less +0 -197
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'rails'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'breadcrumbs.rb'
|
4
|
+
require_relative '../../../../app/helpers/flash_block_helper.rb'
|
5
|
+
require_relative '../../../../app/helpers/modal_helper.rb'
|
6
|
+
require_relative '../../../../app/helpers/navbar_helper.rb'
|
7
|
+
require_relative '../../../../app/helpers/bootstrap_flash_helper.rb'
|
8
|
+
require_relative '../../../../app/helpers/form_errors_helper.rb'
|
7
9
|
|
8
10
|
module Twitter
|
9
11
|
module Bootstrap
|
@@ -19,13 +21,18 @@ module Twitter
|
|
19
21
|
|
20
22
|
initializer 'twitter-bootstrap-rails.setup_helpers' do |app|
|
21
23
|
app.config.to_prepare do
|
22
|
-
ActionController::Base.send :include,
|
23
|
-
ActionController::Base.send :helper, FlashBlockHelper
|
24
|
-
ActionController::Base.send :helper, ModalHelper
|
25
|
-
ActionController::Base.send :helper, NavbarHelper
|
26
|
-
ActionController::Base.send :helper, BadgeLabelHelper
|
27
|
-
#ActionController::Base.send :helper_method, :render_breadcrumbs
|
24
|
+
ActionController::Base.send :include, Breadcrumbs
|
28
25
|
end
|
26
|
+
[FlashBlockHelper,
|
27
|
+
BootstrapFlashHelper,
|
28
|
+
ModalHelper,
|
29
|
+
NavbarHelper,
|
30
|
+
BadgeLabelHelper].each do |h|
|
31
|
+
app.config.to_prepare do
|
32
|
+
ActionController::Base.send :helper, h
|
33
|
+
end
|
34
|
+
end
|
35
|
+
ActionView::Helpers::FormBuilder.send :include, FormErrorsHelper
|
29
36
|
end
|
30
37
|
end
|
31
38
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twitter::Bootstrap::Breadcrumbs do
|
4
|
+
class TestModel
|
5
|
+
include ActiveModel::Model
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
"test_model"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class BaseTestController < AbstractController::Base
|
13
|
+
include Twitter::Bootstrap::Breadcrumbs
|
14
|
+
include AbstractController::Callbacks
|
15
|
+
include AbstractController::UrlFor
|
16
|
+
|
17
|
+
add_breadcrumb 'base', '/base'
|
18
|
+
add_breadcrumb :base_i18n, '/base_i18n'
|
19
|
+
|
20
|
+
def breadcrumbs
|
21
|
+
@__bs_breadcrumbs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class TestController < BaseTestController
|
26
|
+
add_breadcrumb 'class', '/class'
|
27
|
+
add_breadcrumb :class_i18n, '/class_i18n'
|
28
|
+
|
29
|
+
def show
|
30
|
+
add_breadcrumb 'instance', '/instance'
|
31
|
+
add_breadcrumb :instance_i18n, '/instance_i18n'
|
32
|
+
|
33
|
+
test_model = TestModel.new
|
34
|
+
add_breadcrumb test_model
|
35
|
+
|
36
|
+
add_breadcrumb :symbolized
|
37
|
+
add_breadcrumb :show
|
38
|
+
end
|
39
|
+
|
40
|
+
def symbolized_path
|
41
|
+
'/symbolized'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_models_path
|
45
|
+
'/test_model'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
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)
|
63
|
+
end
|
64
|
+
|
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
|
71
|
+
|
72
|
+
idx = @controller.breadcrumbs.index { |b| b[:name] == "show" && b[:url] == '' }
|
73
|
+
expect(idx).to be
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
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
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -10,13 +10,21 @@ include BadgeLabelHelper
|
|
10
10
|
|
11
11
|
describe BadgeLabelHelper, :type => :helper do
|
12
12
|
it "should return a basic bootstrap badge" do
|
13
|
-
badge('
|
13
|
+
expect(badge('New!').gsub(/\s/, '').downcase)
|
14
|
+
.to eql(BASIC_BADGE.gsub(/\s/, '').downcase)
|
14
15
|
end
|
15
16
|
|
16
17
|
it "should return a bootstrap badge with class" do
|
17
|
-
badge('
|
18
|
+
expect(badge('2', :warning).gsub(/\s/, '').downcase)
|
19
|
+
.to eql(BADGE_WITH_CLASS.gsub(/\s/, '').downcase)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should take a Number as its first parameter" do
|
23
|
+
expect(badge(12).gsub(/\s/, '').downcase)
|
24
|
+
.to eql(BADGE_WITH_NUMBER_PARAM.gsub(/\s/, '').downcase)
|
18
25
|
end
|
19
26
|
end
|
20
27
|
|
21
|
-
BASIC_BADGE = %{<span class="badge">
|
22
|
-
BADGE_WITH_CLASS = %{<span class="badge badge-warning">
|
28
|
+
BASIC_BADGE = %{<span class="badge">New!</span>}
|
29
|
+
BADGE_WITH_CLASS = %{<span class="badge badge-warning">2</span>}
|
30
|
+
BADGE_WITH_NUMBER_PARAM = %{<span class="badge">12</span>}
|
@@ -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
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'action_view'
|
4
|
+
require 'active_support'
|
5
|
+
require 'rspec/active_model/mocks'
|
6
|
+
|
7
|
+
require_relative '../../../app/helpers/form_errors_helper'
|
8
|
+
|
9
|
+
include ActionView::Helpers
|
10
|
+
include ActionView::Context
|
11
|
+
include FormErrorsHelper
|
12
|
+
|
13
|
+
describe FormErrorsHelper, :type => :helper do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@base_errors = ['base error message', 'nasty error']
|
17
|
+
@base_error = 'one base error'
|
18
|
+
|
19
|
+
|
20
|
+
@title_errors = ["can't be blank", 'is too short (minimum is 5 characters)']
|
21
|
+
@title_error = "can't be blank"
|
22
|
+
|
23
|
+
@errors = double('errors')
|
24
|
+
@new_post = mock_model( 'Post' )
|
25
|
+
allow(@new_post).to receive_messages(:errors => @errors)
|
26
|
+
allow(self).to receive_messages(:post_path => '/post/1')
|
27
|
+
allow(self).to receive_messages(:protect_against_forgery? => false)
|
28
|
+
allow(self).to receive_messages(:polymorphic_path => '')
|
29
|
+
|
30
|
+
@default_class = 'help-block'
|
31
|
+
@default_error_class = 'has-error'
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
describe 'error[:base] is a string' do
|
36
|
+
|
37
|
+
before do
|
38
|
+
allow(@errors).to receive(:[]).with(:base).and_return(@base_error)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should render base error on :base key' do
|
42
|
+
form_for(@new_post) do |builder|
|
43
|
+
expect(builder.error_span(:base)).to have_tag("div.#{@default_error_class}") do
|
44
|
+
with_tag("span.#{@default_class}", :text => @base_error)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
describe 'when there is only one error on base' do
|
53
|
+
|
54
|
+
before do
|
55
|
+
allow(@errors).to receive(:[]).with(:base).and_return(@base_error)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should render base error on :base key' do
|
59
|
+
form_for(@new_post) do |builder|
|
60
|
+
expect(builder.error_span(:base)).to have_tag("div.#{@default_error_class}") do
|
61
|
+
with_tag("span.#{@default_class}", :text => @base_error)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'when there is only one error on title' do
|
69
|
+
|
70
|
+
before do
|
71
|
+
allow(@errors).to receive(:[]).with(:title).and_return(@title_error)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should render base errors join with comma' do
|
75
|
+
form_for(@new_post) do |builder|
|
76
|
+
expect(builder.error_span(:title)).to have_tag("div.#{@default_error_class}") do
|
77
|
+
with_tag("span.#{@default_class}", :text => @title_error)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
describe 'when there is more than one error on title' do
|
86
|
+
|
87
|
+
before do
|
88
|
+
allow(@errors).to receive(:[]).with(:title).and_return(@title_errors)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should render base errors join with comma' do
|
92
|
+
form_for(@new_post) do |builder|
|
93
|
+
expect(builder.error_span(:title)).to have_tag("div.#{@default_error_class}") do
|
94
|
+
with_tag("span.#{@default_class}", :text => @title_errors.join(', '))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
describe 'when there are no errors' do
|
102
|
+
before do
|
103
|
+
allow(@errors).to receive(:[]).with(:title).and_return(nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should return nil' do
|
107
|
+
form_for(@new_post) do |builder|
|
108
|
+
expect(builder.error_span(:title)).to be_nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'when :error_class option is passed' do
|
114
|
+
let(:error_class) { 'has_warning' }
|
115
|
+
|
116
|
+
before do
|
117
|
+
allow(@errors).to receive(:[]).with(:title).and_return(@title_error)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should render with passed error class " do
|
121
|
+
form_for(@new_post) do |builder|
|
122
|
+
expect(builder.error_span(:title, :error_class => error_class))
|
123
|
+
.to have_tag("div.#{error_class}") do
|
124
|
+
with_tag("span.#{@default_class}", :text => @title_error)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe 'when :error_class option is passed' do
|
131
|
+
let(:span_class) { 'help-inline' }
|
132
|
+
|
133
|
+
before do
|
134
|
+
allow(@errors).to receive(:[]).with(:title).and_return(@title_error)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should render with passed error class " do
|
138
|
+
form_for(@new_post) do |builder|
|
139
|
+
expect(builder.error_span(:title, :span_class => span_class))
|
140
|
+
.to have_tag("div.#{@default_error_class}") do
|
141
|
+
with_tag("span.#{span_class}", :text => @title_error)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'action_view'
|
4
|
+
require 'active_support'
|
5
|
+
require_relative '../../../app/helpers/glyph_helper'
|
6
|
+
|
7
|
+
include ActionView::Helpers
|
8
|
+
include ActionView::Context
|
9
|
+
include GlyphHelper
|
10
|
+
|
11
|
+
describe GlyphHelper, :type => :helper do
|
12
|
+
it "should return a basic bootstrap glyph" do
|
13
|
+
expect(glyph(:thumbs_up).gsub(/\s/, '').downcase)
|
14
|
+
.to eql(BASIC_GLYPH.gsub(/\s/, '').downcase)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return a bootstrap glyph with span" do
|
18
|
+
expect(glyph(:thumbs_up, {:tag => :span}).gsub(/\s/, '').downcase)
|
19
|
+
.to eql(GLYPH_WITH_SPAN.gsub(/\s/, '').downcase)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
BASIC_GLYPH = %{<iclass=\"glyphiconglyphicon-thumbs-up\"></i>}
|
24
|
+
GLYPH_WITH_SPAN = %{<spanclass=\"glyphiconglyphicon-thumbs-up\"></span>}
|
@@ -11,49 +11,49 @@ describe ModalHelper, :type => :helper do
|
|
11
11
|
header_without_close = { :show_close => false, :title => 'Modal header' }
|
12
12
|
options = { :id => "modal",
|
13
13
|
:header => header_with_close,
|
14
|
-
:body => 'This is the body',
|
15
|
-
:footer => content_tag(:button, 'Save', :class => 'btn')
|
14
|
+
:body => { content: 'This is the body' },
|
15
|
+
:footer => { content: content_tag(:button, 'Save', :class => 'btn') }
|
16
16
|
}
|
17
17
|
|
18
18
|
it 'returns a complete modal' do
|
19
|
-
modal_dialog(options).gsub(/\n/, "").
|
19
|
+
expect(modal_dialog(options).gsub(/\n/, "")).to eql BASIC_MODAL.gsub(/\n/, "")
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'returns a modal header with a close button if show_close is true' do
|
23
|
-
modal_header(header_with_close).gsub(/\n/, "").
|
23
|
+
expect(modal_header(header_with_close).gsub(/\n/, "")).to eql MODAL_HEADER_WITH_CLOSE.gsub(/\n/, "")
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'renders a modal header without a close button' do
|
27
|
-
|
27
|
+
expect(modal_header(header_without_close).gsub(/\n/, "")).to eql MODAL_HEADER_WITHOUT_CLOSE.gsub(/\n/, "")
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'renders a close button' do
|
31
|
-
close_button('modal').
|
31
|
+
expect(close_button('modal')).to eql "<button class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>"
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'renders a modal toggle button' do
|
35
|
-
|
35
|
+
expect(modal_toggle('Save', :href => "#modal").gsub(/\n/, "")).to eql MODAL_TOGGLE.gsub(/\n/, "")
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
it 'renders a cancel button' do
|
39
|
+
expect(modal_cancel_button("Cancel", :data => {:dismiss => 'modal'}, :href => "#modal").gsub(/\n/, "")).to eql MODAL_CANCEL_BUTTON.gsub(/\n/, "")
|
40
|
+
end
|
42
41
|
end
|
42
|
+
|
43
43
|
BASIC_MODAL = <<-HTML
|
44
|
-
<div class=\"bootstrap-modal modal
|
44
|
+
<div class=\"bootstrap-modal modal fade\" id=\"modal\"><div class=\"modal-dialog \"><div class=\"modal-content\"><div class=\"modal-header\"><button class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button><h4 class=\"modal-title\">Modal header</h4></div><div class=\"modal-body\">This is the body</div><div class=\"modal-footer\"><button class="btn">Save</button></div></div></div></div>
|
45
45
|
HTML
|
46
46
|
|
47
47
|
MODAL_HEADER_WITHOUT_CLOSE = <<-HTML
|
48
|
-
<div class="modal-header"><
|
48
|
+
<div class="modal-header"><h4 class=\"modal-title\">Modal header</h4></div>
|
49
49
|
HTML
|
50
50
|
|
51
51
|
MODAL_HEADER_WITH_CLOSE = <<-HTML
|
52
|
-
<div class="modal-header"><button class="close" data-dismiss="modal">×</button><
|
52
|
+
<div class="modal-header"><button class="close" data-dismiss="modal" aria-hidden=\"true\">×</button><h4 class=\"modal-title\">Modal header</h4></div>
|
53
53
|
HTML
|
54
54
|
|
55
55
|
MODAL_TOGGLE = <<-HTML
|
56
|
-
<a class="btn" data-toggle="modal" href="#modal">Save</a>
|
56
|
+
<a class="btn btn-default" data-toggle="modal" href="#modal">Save</a>
|
57
57
|
HTML
|
58
58
|
|
59
59
|
MODAL_CANCEL_BUTTON = <<-HTML
|