bootstrap-sass-extras 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile +4 -1
- data/Gemfile.lock +18 -4
- data/README.md +91 -37
- data/app/helpers/badge_helper.rb +13 -0
- data/app/helpers/bootstrap_flash_helper.rb +17 -15
- data/app/helpers/glyph_helper.rb +10 -7
- data/app/helpers/modal_helper.rb +19 -15
- data/app/helpers/twitter_breadcrumbs_helper.rb +3 -2
- data/app/views/bootstrap_sass_extras/_breadcrumbs.html.erb +6 -0
- data/bootstrap-sass-extras.gemspec +1 -0
- data/lib/bootstrap-sass-extras/breadcrumbs.rb +26 -9
- data/lib/bootstrap-sass-extras/engine.rb +1 -0
- data/lib/bootstrap-sass-extras/version.rb +1 -1
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +1 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +32 -50
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +20 -38
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +20 -39
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +10 -8
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +8 -7
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +8 -8
- data/lib/generators/bootstrap/themed/templates/index.html.erb +12 -10
- data/lib/generators/bootstrap/themed/templates/index.html.haml +8 -4
- data/lib/generators/bootstrap/themed/templates/index.html.slim +11 -9
- data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.erb +12 -10
- data/lib/generators/bootstrap/themed/templates/show.html.haml +13 -12
- data/lib/generators/bootstrap/themed/templates/show.html.slim +11 -10
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +9 -7
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +5 -4
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +5 -5
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/helpers/badge_helper_spec.rb +16 -0
- data/spec/helpers/bootstrap_flash_helper_spec.rb +54 -39
- data/spec/helpers/glyph_helper_spec.rb +15 -0
- data/spec/helpers/twitter_breadcrumbs_helper_spec.rb +153 -0
- metadata +13 -5
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +0 -14
@@ -1,11 +1,11 @@
|
|
1
1
|
= form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
|
2
2
|
<%- columns.each do |column| -%>
|
3
|
-
.
|
4
|
-
= f.label :<%= column.name %>, :class => 'control-label'
|
5
|
-
.
|
6
|
-
= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
|
3
|
+
.form-group
|
4
|
+
= f.label :<%= column.name %>, :class => 'control-label col-md-2'
|
5
|
+
.col-md-10
|
6
|
+
= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %> form-control'
|
7
7
|
<%- end -%>
|
8
|
-
.form-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
.form-group
|
9
|
+
.col-md-offset-2.col-md-10
|
10
|
+
= f.submit nil, :class => 'btn btn-primary'
|
11
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
@@ -16,19 +16,21 @@
|
|
16
16
|
<tbody>
|
17
17
|
<%% @<%= plural_resource_name %>.each do |<%= resource_name %>| %>
|
18
18
|
<tr>
|
19
|
-
<td><%%=
|
19
|
+
<td><%%= <%= resource_name %>.id %></td>
|
20
20
|
<%- columns.each do |column| -%>
|
21
|
-
|
21
|
+
<td><%%= <%= resource_name %>.<%= column.name %> %></td>
|
22
22
|
<%- end -%>
|
23
|
-
<td><%%=l <%= resource_name %>.created_at %></td>
|
23
|
+
<td><%%=l <%= resource_name %>.created_at, format: :long %></td>
|
24
24
|
<td>
|
25
|
-
<%%= link_to t('.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
<%%= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-xs', :title => "#{ t('.show', :default => t('helpers.links.show')) }" do %>
|
26
|
+
<%%= glyph 'info-sign' %>
|
27
|
+
<%%- end -%>
|
28
|
+
<%%= link_to edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-xs', :title => "#{ t('.edit', :default => t('helpers.links.edit')) }" do %>
|
29
|
+
<%%= glyph 'pencil' %>
|
30
|
+
<%%- end -%>
|
31
|
+
<%%= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs', :title => "#{ t('.destroy', :default => t('helpers.links.destroy')) }" do %>
|
32
|
+
<%%= glyph 'remove' %>
|
33
|
+
<%%- end -%>
|
32
34
|
</td>
|
33
35
|
</tr>
|
34
36
|
<%% end %>
|
@@ -13,13 +13,17 @@
|
|
13
13
|
%tbody
|
14
14
|
- @<%= plural_resource_name %>.each do |<%= resource_name %>|
|
15
15
|
%tr
|
16
|
-
%td=
|
16
|
+
%td= <%= resource_name %>.id
|
17
17
|
<%- columns.each do |column| -%>
|
18
18
|
%td= <%= resource_name %>.<%= column.name %>
|
19
19
|
<%- end -%>
|
20
|
-
%td=l <%= resource_name %>.created_at
|
20
|
+
%td=l <%= resource_name %>.created_at, format: :long
|
21
21
|
%td
|
22
|
-
= link_to
|
23
|
-
|
22
|
+
= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-xs', :title => "#{ t('.show', :default => t('helpers.links.show')) }" do
|
23
|
+
= glyph 'info-sign'
|
24
|
+
= link_to edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-xs', :title => "#{ t('.edit', :default => t('helpers.links.edit')) }" do
|
25
|
+
= glyph 'pencil'
|
26
|
+
= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs', :title => "#{ t('.destroy', :default => t('helpers.links.destroy')) }" do
|
27
|
+
= glyph 'remove'
|
24
28
|
|
25
29
|
= link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- model_class = <%= resource_name.classify %>
|
2
|
-
|
2
|
+
.page-header
|
3
3
|
h1=t '.title', :default => model_class.model_name.human.pluralize.titleize
|
4
|
-
table
|
4
|
+
table.table.table-striped
|
5
5
|
thead
|
6
6
|
tr
|
7
7
|
th= model_class.human_attribute_name(:id)
|
@@ -13,15 +13,17 @@ table class="table table-striped"
|
|
13
13
|
tbody
|
14
14
|
- @<%= plural_resource_name %>.each do |<%= resource_name %>|
|
15
15
|
tr
|
16
|
-
td=
|
16
|
+
td= <%= resource_name %>.id
|
17
17
|
<%- columns.each do |column| -%>
|
18
18
|
td= <%= resource_name %>.<%= column.name %>
|
19
19
|
<%- end -%>
|
20
|
-
td=l <%= resource_name %>.created_at
|
20
|
+
td=l <%= resource_name %>.created_at, format: :long
|
21
21
|
td
|
22
|
-
= link_to
|
23
|
-
|
24
|
-
= link_to
|
25
|
-
|
26
|
-
= link_to t('.
|
22
|
+
= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-xs', :title => "#{ t('.show', :default => t('helpers.links.show')) }" do
|
23
|
+
= glyph 'info-sign'
|
24
|
+
= link_to edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-xs', :title => "#{ t('.edit', :default => t('helpers.links.edit')) }" do
|
25
|
+
= glyph 'pencil'
|
26
|
+
= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-xs', :title => "#{ t('.destroy', :default => t('helpers.links.destroy')) }" do
|
27
|
+
= glyph 'remove'
|
27
28
|
|
29
|
+
= link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
|
@@ -3,21 +3,23 @@
|
|
3
3
|
<h1><%%=t '.title', :default => model_class.model_name.human.titleize %></h1>
|
4
4
|
</div>
|
5
5
|
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
<div class="fieldset">
|
7
|
+
<dl>
|
8
|
+
<%- columns.each do |column| -%>
|
9
|
+
<dt class="label label-default"><%%= model_class.human_attribute_name(:<%= column.name %>) %></dt>
|
10
|
+
<dd><pre class="prettyprint"><%%= @<%= resource_name %>.<%= column.name %> %></pre></dd>
|
11
|
+
<%- end -%>
|
12
|
+
</dl>
|
13
|
+
</div>
|
12
14
|
|
13
|
-
<div class="form-
|
15
|
+
<div class="form-group">
|
14
16
|
<%%= link_to t('.back', :default => t("helpers.links.back")),
|
15
|
-
<%= controller_routing_path %>_path, :class => 'btn' %>
|
17
|
+
<%= controller_routing_path %>_path, :class => 'btn btn-default' %>
|
16
18
|
<%%= link_to t('.edit', :default => t("helpers.links.edit")),
|
17
|
-
edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn' %>
|
19
|
+
edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default' %>
|
18
20
|
<%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
19
21
|
<%= singular_controller_routing_path %>_path(@<%= resource_name %>),
|
20
22
|
:method => 'delete',
|
21
23
|
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
22
24
|
:class => 'btn btn-danger' %>
|
23
|
-
</div>
|
25
|
+
</div>
|
@@ -1,15 +1,16 @@
|
|
1
1
|
- model_class = <%= resource_name.classify %>
|
2
|
-
|
3
|
-
|
2
|
+
div class="page-header"
|
3
|
+
h1=t '.title', :default => model_class.model_name.human.titleize
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
.fieldset
|
6
|
+
dl
|
7
|
+
<%- columns.each do |column| -%>
|
8
|
+
dt.label.label-default= model_class.human_attribute_name(:<%= column.name %>)
|
9
|
+
dd
|
10
|
+
pre.prettyprint= @<%= resource_name %>.<%= column.name %>
|
11
|
+
<%- end -%>
|
11
12
|
|
12
|
-
.form-
|
13
|
-
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
|
14
|
-
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
|
15
|
-
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
13
|
+
.form-group
|
14
|
+
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
15
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
|
16
|
+
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
@@ -2,16 +2,17 @@
|
|
2
2
|
div class="page-header"
|
3
3
|
h1=t '.title', :default => model_class.model_name.human.titleize
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
.fieldset
|
6
|
+
dl
|
7
|
+
<%- columns.each do |column| -%>
|
8
|
+
dt.label.label-default= model_class.human_attribute_name(:<%= column.name %>)
|
9
|
+
dd
|
10
|
+
pre.prettyprint= @<%= resource_name %>.<%= column.name %>
|
11
|
+
<%- end -%>
|
11
12
|
|
12
|
-
.form-
|
13
|
-
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
|
13
|
+
.form-group
|
14
|
+
= link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
14
15
|
'
|
15
|
-
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
|
16
|
+
= link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn btn-default'
|
16
17
|
'
|
17
|
-
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
18
|
+
= link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
|
@@ -1,14 +1,16 @@
|
|
1
|
-
<%%= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
|
1
|
+
<%%= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' }, wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input, boolean: :horizontal_boolean } do |f| %>
|
2
2
|
<%- columns.each do |column| -%>
|
3
|
-
|
3
|
+
<%%= f.input :<%= column.name %> %>
|
4
4
|
<%- end -%>
|
5
5
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
6
|
-
|
6
|
+
<%%= f.button :wrapped, :cancel => <%= controller_routing_path %>_path %>
|
7
7
|
<%- else -%>
|
8
|
-
<div class="form-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
<div class="form-group">
|
9
|
+
<div class='col-sm-offset-3 col-sm-9'>
|
10
|
+
<%%= f.button :submit, :class => 'btn-primary' %>
|
11
|
+
<%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
12
|
+
<%= controller_routing_path %>_path, :class => 'btn btn-default' %>
|
13
|
+
</div>
|
12
14
|
</div>
|
13
15
|
<%- end -%>
|
14
16
|
<%% end %>
|
@@ -1,11 +1,12 @@
|
|
1
|
-
= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
|
1
|
+
= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' }, wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input, boolean: :horizontal_boolean } do |f|
|
2
2
|
<%- columns.each do |column| -%>
|
3
3
|
= f.input :<%= column.name %>
|
4
4
|
<%- end -%>
|
5
5
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
6
6
|
= f.button :wrapped, :cancel => <%= controller_routing_path %>_path
|
7
7
|
<%- else -%>
|
8
|
-
.form-
|
9
|
-
|
10
|
-
|
8
|
+
.form-group
|
9
|
+
.col-sm-offset-3.col-sm-9
|
10
|
+
= f.submit nil, :class => 'btn btn-primary'
|
11
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
11
12
|
<%- end -%>
|
@@ -1,12 +1,12 @@
|
|
1
|
-
= simple_form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
|
1
|
+
= simple_form_for @<%= resource_name %>, :html => { :class => "form-horizontal" }, wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input, boolean: :horizontal_boolean } do |f|
|
2
2
|
<%- columns.each do |column| -%>
|
3
3
|
= f.input :<%= column.name %>
|
4
4
|
<%- end -%>
|
5
5
|
<%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
|
6
6
|
= f.button :wrapped, :cancel => <%= controller_routing_path %>_path
|
7
7
|
<%- else -%>
|
8
|
-
.form-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
.form-group
|
9
|
+
.col-sm-offset-3.col-sm-9
|
10
|
+
= f.submit nil, :class => 'btn btn-primary'
|
11
|
+
= link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn btn-default'
|
12
12
|
<%- end -%>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 0) do
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BadgeHelper do
|
4
|
+
describe "#badge" do
|
5
|
+
let(:html) { %(<span class="badge">%i</span>) }
|
6
|
+
|
7
|
+
it "returns proper output for badge count" do
|
8
|
+
badge(0).should == html % 0
|
9
|
+
badge(2).should == html % 2
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns nil for nil badge count" do
|
13
|
+
badge(nil).should be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,42 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BootstrapFlashHelper do
|
4
|
-
describe "bootstrap_flash" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
4
|
+
describe "#bootstrap_flash" do
|
5
|
+
let(:html) { %(<div class="alert alert-%s alert-dismissable"><button class="close" data-dismiss="alert" type="button">×</button>%s</div>) }
|
6
|
+
|
7
|
+
def flash_test(input, output)
|
8
|
+
stub!(:flash).and_return(input)
|
9
|
+
bootstrap_flash.should == html % output.to_a.flatten
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns alert-warning when sent a :warning message" do
|
13
|
+
message = "Update Warning!"
|
14
|
+
flash_test({ warning: message }, { warning: message })
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns alert-success when sent a :notice message" do
|
18
|
+
message = "Update Success!"
|
19
|
+
flash_test({ notice: message }, { success: message })
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns alert-danger when sent an :error message" do
|
23
|
+
message = "Update Failed!"
|
24
|
+
flash_test({ error: message }, { danger: message })
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns alert-danger when sent an :alert message" do
|
28
|
+
message = "Update Alert!"
|
29
|
+
flash_test({ alert: message }, { danger: message })
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns alert-info when sent a info message" do
|
33
|
+
message = "Update Information!"
|
34
|
+
flash_test({ info: message }, { info: message })
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns custom type when sent an unknown message" do
|
38
|
+
message = "Update Unknown!"
|
39
|
+
flash_test({ undefined: message }, { undefined: message })
|
40
|
+
end
|
41
|
+
|
42
|
+
it "properly handles string types" do
|
43
|
+
message = "String to Symbol Test."
|
44
|
+
flash_test({ "info" => message }, { info: message })
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns nil when sent a blank message" do
|
48
|
+
stub!(:flash).and_return(notice: "")
|
49
|
+
bootstrap_flash.should be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns nil when message doesn't have an implicit conversion to String" do
|
53
|
+
stub!(:flash).and_return(notice: true)
|
54
|
+
bootstrap_flash.should be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GlyphHelper do
|
4
|
+
describe "#glyph" do
|
5
|
+
let(:html) { %(<span class="glyphicon glyphicon-%s"></span>) }
|
6
|
+
|
7
|
+
it "returns proper output for one glyphicon" do
|
8
|
+
glyph(:test).should == html % "test"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns proper output for more than one glyphicon" do
|
12
|
+
glyph(:test1, :test2).should == "#{html % "test1"}#{html % "test2"}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TwitterBreadcrumbsHelper do
|
4
|
+
describe "given one breadcrumb" do
|
5
|
+
before do
|
6
|
+
controller.send(:add_breadcrumb, "Name", "URL")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#render_breadcrumbs" do
|
10
|
+
let(:html) {
|
11
|
+
<<-BREADCRUMBS.strip_heredoc
|
12
|
+
<ol class="breadcrumb">
|
13
|
+
<li class="active">Name</li>
|
14
|
+
</ol>
|
15
|
+
BREADCRUMBS
|
16
|
+
}
|
17
|
+
|
18
|
+
it "returns bootstrap-style breadcrumbs html" do
|
19
|
+
helper.render_breadcrumbs.should == html
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "given a block" do
|
23
|
+
it "returns breadcrumbs wrapped in the captured block" do
|
24
|
+
helper.render_breadcrumbs do |crumbs|
|
25
|
+
helper.content_tag(:div, crumbs)
|
26
|
+
end.should == "<div>#{html}</div>"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#breadcrumbs?" do
|
32
|
+
it "returns true" do
|
33
|
+
helper.breadcrumbs?.should be_true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#breadcrumb_names" do
|
38
|
+
it "returns an array of breadcrumb names" do
|
39
|
+
helper.breadcrumb_names.should == ["Name"]
|
40
|
+
controller.send(:breadcrumb_names).should == ["Name"]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#last_breadcrumb_name" do
|
45
|
+
it "returns a breadcrumb name" do
|
46
|
+
helper.last_breadcrumb_name.should == "Name"
|
47
|
+
controller.send(:last_breadcrumb_name).should == "Name"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#clear_breadcrumbs" do
|
52
|
+
it "empties all existing breadcrumbs" do
|
53
|
+
helper.breadcrumbs?.should be_true
|
54
|
+
controller.send(:clear_breadcrumbs)
|
55
|
+
helper.breadcrumbs?.should be_false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "given two breadcrumbs" do
|
61
|
+
before do
|
62
|
+
controller.send(:add_breadcrumb, "Name1", "URL1")
|
63
|
+
controller.send(:add_breadcrumb, "Name2", "URL2")
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#render_breadcrumbs" do
|
67
|
+
let(:html) {
|
68
|
+
<<-BREADCRUMBS.strip_heredoc
|
69
|
+
<ol class="breadcrumb">
|
70
|
+
<li><a href="URL1">Name1</a></li>
|
71
|
+
<li class="active">Name2</li>
|
72
|
+
</ol>
|
73
|
+
BREADCRUMBS
|
74
|
+
}
|
75
|
+
|
76
|
+
it "returns bootstrap-style breadcrumbs html" do
|
77
|
+
helper.render_breadcrumbs.should == html
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "given a block" do
|
81
|
+
it "returns breadcrumbs wrapped in the captured block" do
|
82
|
+
helper.render_breadcrumbs do |crumbs|
|
83
|
+
helper.content_tag(:div, crumbs)
|
84
|
+
end.should == "<div>#{html}</div>"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#breadcrumbs?" do
|
90
|
+
it "returns true" do
|
91
|
+
helper.breadcrumbs?.should be_true
|
92
|
+
controller.send(:breadcrumbs?).should be_true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#breadcrumb_names" do
|
97
|
+
it "returns an array of breadcrumb names" do
|
98
|
+
helper.breadcrumb_names.should == ["Name1", "Name2"]
|
99
|
+
controller.send(:breadcrumb_names).should == ["Name1", "Name2"]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#last_breadcrumb_name" do
|
104
|
+
it "returns a breadcrumb name" do
|
105
|
+
helper.last_breadcrumb_name.should == "Name2"
|
106
|
+
controller.send(:last_breadcrumb_name).should == "Name2"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#clear_breadcrumbs" do
|
111
|
+
it "empties all existing breadcrumbs" do
|
112
|
+
helper.breadcrumbs?.should be_true
|
113
|
+
controller.send(:clear_breadcrumbs)
|
114
|
+
helper.breadcrumbs?.should be_false
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "given no breadcrumbs" do
|
120
|
+
describe "#render_breadcrumbs" do
|
121
|
+
it "returns nil" do
|
122
|
+
helper.render_breadcrumbs.should be_nil
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "given a block" do
|
126
|
+
it "returns nil" do
|
127
|
+
helper.render_breadcrumbs { |crumbs| "No #{crumbs} here!" }.should be_nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#breadcrumbs?" do
|
133
|
+
it "returns false" do
|
134
|
+
helper.breadcrumbs?.should be_false
|
135
|
+
controller.send(:breadcrumbs?).should be_false
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#breadcrumb_names" do
|
140
|
+
it "returns an empty array" do
|
141
|
+
helper.breadcrumb_names.should == []
|
142
|
+
controller.send(:breadcrumb_names).should == []
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "#last_breadcrumb_name" do
|
147
|
+
it "returns nil" do
|
148
|
+
helper.last_breadcrumb_name.should be_nil
|
149
|
+
controller.send(:last_breadcrumb_name).should be_nil
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|