forked from seyhunak/twitter-bootstrap-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to pass extra options to bootstrap_flash
- Loading branch information
1 parent
20984d4
commit 1007d3c
Showing
4 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ | |
<li>Christian Joudrey</li> | ||
<li>Todd Baur</li> | ||
<li>Leonid Shevtsov</li> | ||
<li>Christophe Maximin</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# encoding: utf-8 | ||
require 'spec_helper' | ||
require 'action_view' | ||
require 'active_support' | ||
require_relative '../../../app/helpers/bootstrap_flash_helper' | ||
|
||
include ActionView::Helpers | ||
include ActionView::Context | ||
include BootstrapFlashHelper | ||
|
||
describe BootstrapFlashHelper, type: :helper do | ||
before do | ||
allow(self).to receive(:uri_state) { :inactive } | ||
allow(self).to receive(:root_url) { '/' } | ||
end | ||
|
||
describe "bootstrap_flash" do | ||
it "should not return anything without flashes" do | ||
allow(self).to receive(:flash) { {} } | ||
|
||
element = bootstrap_flash | ||
|
||
expect(element).to eql("") | ||
end | ||
|
||
it "should work with a notice" do | ||
allow(self).to receive(:flash) { {notice: "Hello"} } | ||
|
||
element = bootstrap_flash | ||
|
||
expect(element).to have_tag(:div, | ||
text: "×Hello", | ||
with: {class: "alert fade in alert-success"}) { | ||
|
||
with_tag(:button, | ||
text: "×", | ||
with: { | ||
class: "close", | ||
"data-dismiss" => "alert" | ||
} | ||
) | ||
|
||
} | ||
end | ||
|
||
it "should work with a notice and an extra class" do | ||
allow(self).to receive(:flash) { {notice: "Hello"} } | ||
|
||
element = bootstrap_flash(class: "extra-class") | ||
|
||
expect(element).to have_tag(:div, | ||
text: "×Hello", | ||
with: {class: "alert fade in alert-success extra-class"}) { | ||
|
||
with_tag(:button, | ||
text: "×", | ||
with: { | ||
class: "close", | ||
"data-dismiss" => "alert" | ||
} | ||
) | ||
|
||
} | ||
end | ||
|
||
it "should work with a notice and an extra class and an extra attribute" do | ||
allow(self).to receive(:flash) { {notice: "Hello"} } | ||
|
||
element = bootstrap_flash(class: "extra-class", "data-no-transition-cache" => true) | ||
|
||
expect(element).to have_tag(:div, | ||
text: "×Hello", | ||
with: { | ||
class: "alert fade in alert-success extra-class", | ||
"data-no-transition-cache" => true | ||
}) { | ||
|
||
with_tag(:button, | ||
text: "×", | ||
with: { | ||
class: "close", | ||
"data-dismiss" => "alert" | ||
} | ||
) | ||
|
||
} | ||
end | ||
end | ||
|
||
end |