spec/unit/pretty_format_spec.rb in activeadmin-1.0.0.pre1 vs spec/unit/pretty_format_spec.rb in activeadmin-1.0.0.pre2
- old
+ new
@@ -5,11 +5,11 @@
def method_missing(*args, &block)
mock_action_view.send *args, &block
end
- {String: 'hello', Fixnum: 23, Float: 5.67, Bignum: 10**30,
+ {String: 'hello', Fixnum: 23, Float: 5.67, Bignum: 10**30, Symbol: :foo,
'Arbre::Element' => Arbre::Element.new.br(:foo)
}.each do |klass, obj|
it "should call `to_s` on #{klass}s" do
expect(obj).to be_a klass.to_s.constantize # safeguard for Bignum
expect(pretty_format(obj)).to eq obj.to_s
@@ -25,9 +25,23 @@
context "actually do the formatting" do
it "should actually do the formatting" do
t = Time.utc(1985,"feb",28,20,15,1)
expect(pretty_format(t)).to eq "February 28, 1985 20:15"
+ end
+
+ context "apply custom localize format" do
+ before do
+ ActiveAdmin.application.localize_format = :short
+ end
+ after do
+ ActiveAdmin.application = nil
+ end
+ it "should actually do the formatting" do
+ t = Time.utc(1985, "feb", 28, 20, 15, 1)
+
+ expect(pretty_format(t)).to eq "28 Feb 20:15"
+ end
end
context "with non-English locale" do
before(:all) do
@previous_locale = I18n.locale.to_s